3

I'm trying to make a macro program with python 3.7 on Windows10

I want to send keyboard/mouse inputs to any specific target window while the target window keep inactivated(minimized or background)

pyautogui seems to not be able to do that (If I miss something let me know plz)

pywinauto can send inputs to specific target window but it always make the target window activate.

Is there any way keeping target window inactivated????


import pywinauto

app = pywinauto.application.Application().connect(best_match='123 - Notepad', top_level_only=False, visible_only=False)

form = app.window(title_re='123 - Notepad')

for i in range(1, 10):
    form.type_keys("12e12e21e")
tzrm
  • 513
  • 1
  • 8
  • 14
kroos8
  • 63
  • 1
  • 7
  • There is no specific way to utilize the mouse inputs while the keyboard is minimized however, the link that @VisalyRyabov has provided should give you enough information on how to navigate the minimized window via sending key commands. Make sure you're using `send_keys()` or `set_edit_text()` *without* using `set_focus()`. – jkwhite Oct 22 '19 at 22:59

2 Answers2

3

I found the answer!!!!

app = Application(backend="win32").connect(process=12345)
form = app.window(title_re="windowtitle")
form.send_keystrokes("1234567")
kroos8
  • 63
  • 1
  • 7
1

Remote Execution Guide -> Tricks to run automation on a locked machine

Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78