Reputation: 223
I am doing GUI automation(winmerge) in python using win32api
.I have to select the winmerge window so that i can send some keyboard strokes to it using sendkeys function.However my keyboard strokes are going to python active shell and not to the desired window.I do not know the window handle so cant use findwindow function.Can you suggest a way to select the winmerge window.
P.S-i saw a function called Enumwindow(which requires a local callback function arguement.Could you also tell me what to pass as the local call function arguement)
Thanking you in advance.
My code till now-
import win32api
import win32com.client
import subprocess
import win32gui
subprocess.Popen(r'winmergeu {0} {1}'.format('file1','file2') )
shell=win32com.client.Dispatch("WScript.Shell")
shell.Sendkeys("""
%t
r
""")
Upvotes: 0
Views: 1658
Reputation: 43096
Here is a link to an answer that should help you for activating the right window : https://stackoverflow.com/a/2091530/117092 It runs a regex on the title of every opened windows and return an handle on the 1st matching window. Developped for Python 2.x, it should also work in Python 3.x
Then you can send keys to this window. The following module may help : http://www.rutherfurd.net/python/sendkeys/#sendkeys
I hope it helps
luc
Upvotes: 1