Reputation: 1
I am trying to achieve the following behavior in a PYTHON 2.4 script, here are the steps, and after them, the question:
So, in steps 5 and 7 what I want to do is simulate the pressing of keys Alt+Tab in order to go back to the script window (in step 5), and go back again to the 'Z' program's window (in step 7). And the problem is that I have no idea how to achieve this (the simulation to press keys alt+tab), and didn't find answers to my doubts. I am using the python win32api modules to positionate mouse in a certain point and make the clicks, but I don't find the way to simulate the key pressing.
Upvotes: 0
Views: 10023
Reputation:
An Easier Way
Use this Library W32S
My Library. And If u want , just copy the source instead
Upvotes: 0
Reputation: 2091
Try This :
1) Use : https://gist.github.com/chriskiehl/2906125
2)
import win32api
import win32com.client
shell = win32com.client.Dispatch("WScript.Shell")
shell.Run("app")
win32api.Sleep(100)
shell.AppActivate("myApp")
win32api.Sleep(100)
shell.SendKeys("name")
win32api.Sleep(500)
shell.SendKeys("{ENTER}")
win32api.Sleep(2500)
shell.SendKeys("^a") # CTRL+A may "select all" depending on which window's focused
shell.SendKeys("{DELETE}") # Delete selected text? Depends on context. :P
shell.SendKeys("{TAB}") #Press tab... to change focus or whatever
Upvotes: 3
Reputation: 15385
You need the WinApi function SendInput.
See the description in the MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx
Upvotes: 0