Created
January 28, 2019 22:57
-
-
Save JonathanStreet/3c29718c1edca776e33a3ce93fbf6999 to your computer and use it in GitHub Desktop.
[AHK] Send text to multiple open windows (e.g. Notepad)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Press `Ctrl + b` to start | |
^b:: | |
InputBox, UserInput, Command, Enter a command. | |
if ErrorLevel | |
{ | |
MsgBox, CANCEL was pressed. | |
} | |
else | |
{ | |
; Find windows containing 'Notepad' anywhere. | |
SetTitleMatchMode, 2 | |
WinGet, myList, list, Notepad | |
; Loop through all windows | |
Loop, %myList% | |
{ | |
; Send the input & return to the window | |
WinGet MMX, MinMax, % "ahk_id" myList%a_index% | |
; Only run on windows that are visible | |
IfNotEqual MMX, -1 | |
{ | |
; Add a delay to the keys to prevent uppercase/lowercase issues | |
SetKeyDelay,,10 | |
; Send the keystrokes to the window | |
ControlSend,, %UserInput%{return}, % "ahk_id" myList%a_index% | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment