2

I have a script i often use to press keys in windows, but its dependencies don't exist in mac. I found a script here - PyUserInput - but i cant install it.

I wrote this program and want to press tab twice then enter twice (to select a button on a webpage and press it, then confirm) but i cant get any scripts working so cant test it out yet...

import pykeyboard
  k = pykeyboard.PyKeyboard()
  if key == "tab": 
      k.press_key(k.tab, n=2)
  if key == "tab": 
      k.press_key(k.enter_key, n=2)

  time.sleep(.5)#hold

  if key == "tab":  
      k.release_key(k.tab)
  if key == "tab": 
      k.release_key(k.enter_key)
JDurstberger
  • 4,127
  • 8
  • 31
  • 68
tenshiism
  • 57
  • 1
  • 5
  • Is Python required? You could just use AppleScript. It's easy to learn (sort of), the syntax is simple (usually), and it's built in. You can use that to press keys, – Arc676 Nov 20 '15 at 08:52
  • 1
    actually ive already written a 25 line script in python to open list specified web pages and wait 1 second, so if i used this i would need a way to open the web pages as well... ill add the main bit to the question – tenshiism Nov 20 '15 at 08:59
  • Possible duplicate of [Is there a sendKey for Mac in Python?](http://stackoverflow.com/questions/1770312/is-there-a-sendkey-for-mac-in-python) – Rob Nov 20 '15 at 09:01
  • Note that the accepted answer at the provided link also uses AppleScript, just via Python. It would therefore be simpler to just use AppleScript and not have that Python go-between, if possible. – Arc676 Nov 20 '15 at 09:04
  • 1
    this solution is confusing and doesnt explain its answer. do i pass osascript to the shell? is osascript a program that i have to download? can i open my shell script for pressing buttons from os.system('filename.sh') or do i need to pass it commands and is one of those commands osascript and if so what is it? otherwise, what must i give it? PS yes, i must use python – tenshiism Nov 20 '15 at 09:19
  • 1
    i just found out that apple script is a program on MAC. after using windows for 20 years i bought a mac and ALL i want to do is make a keypress happen from a python script! – tenshiism Nov 20 '15 at 10:59

0 Answers0