0

i want to simulate the pressing of the enter key using py-appscript

i already found this, but it seems to only output the newline Translate Applescrip [key code 125 using command down] to appscript

right now i want to press the enter key after the value has been set.

Example, after entering the IP hit enter key.

or send a keycode to the field itself.

Community
  • 1
  • 1

1 Answers1

1

app('System Events').key_code(76). (Or key_code(36) or keystroke('\r') if you meant ↩ instead of ⌤.)

keystroke and key_code don't ignore keys actually held down by the user, so you might need to add a delay if you're using a shortcut with modifier keys used to run the script.

Lri
  • 26,768
  • 8
  • 84
  • 82
  • i already did this but this did not work. lets say an application needs you to press enter to trigger an event, so i want to send a keystroke or key_code but what happened instead of simulating the enter key, it printed a newline in the command line. There is another way though, if the program ask you to press tab to loss focus on the component, just locate another component and set the focus there. and the out of focus trigger will now be triggered. – cristopher cutas Jul 12 '11 at 05:46