How to program keystrokes on a single app in Windows after minimizing?

时间:2017-04-10 02:04:58

标签: autohotkey minimize minimized

I'm able to program certain automated tasks using AutoHotKey but it requires that I have the app window open. In other words, I can't Alt+Tab away from the app or else the AutoHotKey script won't work.

Is there a way I can program certain keystrokes and mouse movements to an app on Windows so that those keystrokes continue to function even after I minimize (or Alt+Tab away) the app?

From similar questions I've found here, creating a bot seems to be the best way to do this, but would a bot work on a minimized program (running in the background)?

1 个答案:

答案 0 :(得分:0)

您可以使用 ControlSend ControlClick 向特定应用发送命令。

  

ControlSend

     

将模拟击键发送到窗口或控件。

     

实施例

ControlSend, Edit1, This is a line of text in the notepad window., Untitled
SetTitleMatchMode, 2
ControlSend, , abc, cmd.exe  ; Send directly to a command prompt window.

  

ControlClick

     

向控件发送鼠标按钮或鼠标滚轮事件。

     

实施例

ControlClick, OK, Some Window Title  ; Clicks the OK button
ControlClick, x55 y77, WinTitle  ; Clicks at a set of coordinates. Note the lack of a comma between X and Y.

; The following method may improve reliability and reduce side effects:
SetControlDelay -1
ControlClick, Toolbar321, WinTitle,,,, NA x192 y10  ; Clicks in NA mode at coordinates that are relative to a named control.