1

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)?

Stevoisiak
  • 23,794
  • 27
  • 122
  • 225

1 Answers1

1

You can send commands to a specific application with ControlSend and ControlClick.

ControlSend

Sends simulated keystrokes to a window or control.

Examples

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

Sends a mouse button or mouse wheel event to a control.

Examples

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. 
Stevoisiak
  • 23,794
  • 27
  • 122
  • 225