AppleScript Press Ok

Discussion in 'Mac Programming' started by Levi Alberta, Feb 3, 2014.

  1. Levi Alberta macrumors newbie

    Joined:
    Jan 29, 2014
    #1
    Trying to come up with an AppleScript that will press Function and Enter together...

    The script I have so far is:

    tell application "Vuze" to activate
    tell application "System Events"
    tell process "Vuze"
    keystroke "u" using {command down}
    keystroke "v" using {command down}
    key code 65535 using keystroke return
    end tell
    end tell

    I looked up the key code for the function key, and 65535 is what came back. The start of the script is grabbing some data from a text file and copying the contents. It is then pasting the contents into Vuze (which is where the Command V comes from.

    The script pastes the data correctly into the window that pops up (when you press Command U). Problem is, when I press Funtion + Return together, it selects "Ok" which is on the window and the problem is solved. When I attempt to get the script to do it it just keeps repeating itself over and over again and not once does it select Ok.

    Thoughts?
     

    Attached Files:

  2. kryten2, Feb 3, 2014
    Last edited: Feb 3, 2014

    kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #2
    From the System Events Dictionary :

    The result of pressing Funtion + Return together on my AZERTY Belgian Aluminium Apple keyboard reveals decimal 63 in the Full Key Codes application.
     

    Attached Files:

  3. Levi Alberta thread starter macrumors newbie

    Joined:
    Jan 29, 2014
    #3
    I'm reading and re-reading your response. I'm a little confused (I'm by no means an expert at this..).

    My initial thoughts is to change the script to this:

    tell application "Vuze" to activate
    tell application "System Events"
    tell process "Vuze"
    keystroke "u" using {command down}
    keystroke "v" using {command down}
    key code v
    key code integer {65535, 36}

    key code 65535 using keystroke return
    end tell
    end tell

    Is this correct? I just tried it and it fails. I'm guessing I really screwed it up.
     
  4. kryten2 macrumors 6502a

    Joined:
    Mar 17, 2012
    Location:
    Belgium
    #4
    Is the FUNCTION key we are talking about the one you see with a red square around it in the attached tumbnail of my previous post?

    What decimal key code do you see in the Full Key Codes application when you press those 2 keys on your keyboard?

    Info : https://www.macupdate.com/app/mac/38164/full-key-codes
     
  5. Levi Alberta, Feb 3, 2014
    Last edited: Feb 4, 2014

    Levi Alberta thread starter macrumors newbie

    Joined:
    Jan 29, 2014
    #5
    Yes, that is the same function key that is in your previous post. I have attached a screen shot from the "key codes" app that I downloaded.
     

    Attached Files:

Share This Page