Advertisement
Guest User

Untitled

a guest
Mar 1st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. import win32gui
  2. import win32con
  3. import win32api
  4. from time import sleep
  5.  
  6. #[hwnd] No matter what people tell you, this is the handle meaning unique ID,
  7. #["Notepad"] This is the application main/parent name, an easy way to check for examples is in Task Manager
  8. #["test - Notepad"] This is the application sub/child name, an easy way to check for examples is in Task Manager clicking dropdown arrow
  9. #hwndMain = win32gui.FindWindow("Notepad", "test - Notepad") this returns the main/parent Unique ID
  10. hwndMain = win32gui.FindWindow("Notepad", "test - Notepad")
  11.  
  12. #["hwndMain"] this is the main/parent Unique ID used to get the sub/child Unique ID
  13. #[win32con.GW_CHILD] I havent tested it full, but this DOES get a sub/child Unique ID, if there are multiple you'd have too loop through it, or look for other documention, or i may edit this at some point ;)
  14. #hwndChild = win32gui.GetWindow(hwndMain, win32con.GW_CHILD) this returns the sub/child Unique ID
  15. hwndChild = win32gui.GetWindow(hwndMain, win32con.GW_CHILD)
  16.  
  17. #print(hwndMain) #you can use this to see main/parent Unique ID
  18. #print(hwndChild) #you can use this to see sub/child Unique ID
  19.  
  20. #While(True) Will always run and continue to run indefinitely
  21. while(True):
  22. #[hwndChild] this is the Unique ID of the sub/child application/proccess
  23. #[win32con.WM_CHAR] This sets what PostMessage Expects for input theres KeyDown and KeyUp as well
  24. #[0x44] hex code for D
  25. #[0]No clue, good luck!
  26. #temp = win32api.PostMessage(hwndChild, win32con.WM_CHAR, 0x44, 0) returns key sent
  27. temp = win32api.PostMessage(hwndChild, win32con.WM_CHAR, 0x44, 0)
  28.  
  29. #print(temp) prints the returned value of temp, into the console
  30. print(temp)
  31. #sleep(1) this waits 1 second before looping through again
  32. sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement