2
votes

I am trying to write a script that duplicates a little bit of what Autohotkey does, because it doesn't work very well for me. I need the script to detect keyboard/mouse-click input to a program, and send different strings/sequence of keystrokes based on the original key pressed. For example if I press mouse middle button, I want to send the three keystrokes 8,9 and 0 in place of the click. All this while some other application is being used. i.e. Torchlight II. Can anyone tell me

  1. what to use to get the global keyboard input and
  2. How to send keystrokes to an application?

I would have used Autohotkey for this but it is acting very unreliably with random unacceptable bugs. I am using python 2.7 64bit, windows 7.

1
You can try SendKeys. - Sufian Latif
Sendkeys doesn't work for Python 2.7 - thekindlyone
Worked for me a few days ago. - Sufian Latif
sendkeys-ctypes this one works. think you meant this. thanks.Next phase is Keyboard,mouse events hooks. Any advice? - thekindlyone

1 Answers

2
votes

I found the solutions and finished the script. Here are my findings.

1.I got the global keyboard/mouse inputs from Pyhook. Installing it on Python 2.7 amdx64 might be a bit tricky.

2.To send keystrokes/input to an application I used sendkeys-ctypes which works well with python 2.7