Apple Script Help.

Discussion in 'Mac Apps and Mac App Store' started by auschase, Sep 26, 2011.

  1. auschase, Sep 26, 2011
    Last edited: Sep 27, 2011

    auschase macrumors newbie

    Joined:
    Sep 26, 2011
    #1
    Can someone help me with this applescript. I am trying to keystroke the result from the dialog.
    PHP:
    display dialog "" default answer "" buttons {"OK"} default button 1
    set STUnum to result

    tell app 
    "System Events" to keystroke "blah" STUnum
     
  2. Intell macrumors P6

    Intell

    Joined:
    Jan 24, 2010
    Location:
    Inside
    #2
    Use this:

    PHP:
    display dialog "" default answer "" buttons {"OK"} default button 1
    set STUnum to text returned of the result

    tell application 
    "System Events" to keystroke "blah" STUnum
     
  3. Jolly Jimmy macrumors 65816

    Jolly Jimmy

    Joined:
    Dec 13, 2007
    #3
    You need to use "text returned of result", so :

    Code:
    set STUnum to text returned of result
    EDIT : Dammit, beaten by seconds.
     
  4. auschase thread starter macrumors newbie

    Joined:
    Sep 26, 2011
  5. auschase thread starter macrumors newbie

    Joined:
    Sep 26, 2011
    #5
    Also, How would you tell it to click the button "add favorite server" in Finder>Go>Connect to server?
     
  6. Intell macrumors P6

    Intell

    Joined:
    Jan 24, 2010
    Location:
    Inside
    #6
    PHP:
    tell application "System Events"
        
    tell application "Finder" to activate
        keystroke 
    "k" using {command down}
    end tell
     
  7. auschase thread starter macrumors newbie

    Joined:
    Sep 26, 2011
    #7
    Sorry to keep asking questions I am new at this but, would anyone know why I can't click any of the check boxes in Language & text of application System Preferences

    PHP:
    tell application "System Preferences"
                
    activate
                set the current pane to pane 
    "com.apple.Localization"
                
    reveal anchor "InputMenu" of pane id "com.apple.Localization"
            
    end tell
            tell application 
    "System Events" to click checkbox "Keyboad & Character Viewer" of table "inputmenu" of scroll area 1 of tab group 1 of window "Language & text" of application "System Preferences"
    thakns
     
  8. Intell macrumors P6

    Intell

    Joined:
    Jan 24, 2010
    Location:
    Inside
    #8
    I'm not very good with GUI scripting, I try to avoid it. I could probably help you get your end goal though. What is it you're trying to do in System Preferences?
     
  9. auschase thread starter macrumors newbie

    Joined:
    Sep 26, 2011
    #9
    I am trying to click a check box on the left hand side of Language & Text> InputMenu.
    This is what I have so far:
    PHP:
    tell application "System Events"
                
    tell process "System Preferences"
                    
    if value of checkbox "1" of row "hebrew" of table "input menu" of scroll area 1 of tab group 1 of window "Language & Text" is 0 then
                        click checkbox 
    "Hebrew" of tab group 1 of window "Language & Text"
                    
    end if
                
    end tell
            end tell
     
  10. Intell macrumors P6

    Intell

    Joined:
    Jan 24, 2010
    Location:
    Inside
    #10
    Ok, its a bit late where I am. But I should be able to figure this out tomorrow.
     
  11. auschase thread starter macrumors newbie

    Joined:
    Sep 26, 2011
    #11
    Change: (This works)
    PHP:
    tell application "System Events"
                
                
                
    tell process "System Preferences"
                    
    set value of text field 1 of tab group 1 of window "Language & Text" to "Hebrew"
                    
    click button 1 of text field 1 of tab group 1 of window "Language & Text"
                    
    tell application "System Events" to keystroke return
                    if 
    value of checkbox 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window "Language & Text" is 0 then
                        click checkbox 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 
    "Language & Text"
                        
    click button 2 of text field 1 of tab group 1 of window "Language & Text"
                    
    else
                        
    click button 2 of text field 1 of tab group 1 of window "Language & Text"
                    
    end if
                
    end tell
                tell process 
    "System Preferences"
                    
    if value of checkbox 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window "Language & Text" is 0 then
                        click checkbox 1 of row 1 of table 1 of scroll area 1 of tab group 1 of window 
    "Language & Text"
                    
    end if
                
    end tell
                
            end tell
     
  12. Intell macrumors P6

    Intell

    Joined:
    Jan 24, 2010
    Location:
    Inside
  13. Jolly Jimmy macrumors 65816

    Jolly Jimmy

    Joined:
    Dec 13, 2007
    #13
    Just out of curiosity, how do you colour code your scripts like that? I'm especially interested in colouring conditional keyworks like "if" and "else" but the fomatting preferences in AppleScript Editor don't seem to allow that.
     
  14. Intell macrumors P6

    Intell

    Joined:
    Jan 24, 2010
    Location:
    Inside
    #14
    That's just MacRumor's php tag. To change the colours, go into AppleScript's preferences and click the formatting tab.
     
  15. Jolly Jimmy macrumors 65816

    Jolly Jimmy

    Joined:
    Dec 13, 2007
    #15
    I can't seem to colour conditional keyworks like "if" and "else" separately unfortunately.
     

Share This Page