Page 1 of 1

Sending Keystrokes to Multiple Windows

Posted: 23 Jan 2022, 02:31
by jkpwk213
I apologize if I'm asking something super obvious, I'm very new to this scripting. I found this code that someone else posted and was hoping I could change it to where it wouldn't look for alpha character but instead look for arrow directions only? (Up, Down, Left, Right)

I'm just not sure what to put in place of the alphabetized list? Or would I need to declare those keystrokes different?


Thanks!

Code: Select all

SetTitleMatchMode, 2
WinGet, Hwnd_List, List , Notepad

Loop, Parse, % "abcdefghijklmnopqrstuvwxyz"
	Hotkey, %A_LoopField%, LoopSend
return

LoopSend:
	Loop, %Hwnd_List%
	{
		Hwnd := Hwnd_List%A_Index%
		ControlSend,, %A_ThisHotkey%, ahk_id %Hwnd%
	}
return

Esc::ExitApp

Re: Sending Keystrokes to Multiple Windows  Topic is solved

Posted: 23 Jan 2022, 03:14
by Rohwedder
Hallo,
try:

Code: Select all

SetTitleMatchMode, 2
WinGet, Hwnd_List, List, ahk_exe NOTEPAD.EXE
Loop, Parse, % "abcdefghijklmnopqrstuvwxyz" ;Test
	Hotkey, $%A_LoopField%, $Up ;Test
$Up::
$Left::
$Down::
$Right::
Key := "{" SubStr(A_ThisHotkey, 2) "}"
Loop, %Hwnd_List%
	ControlSend,, %Key%,% "ahk_id " Hwnd_List%A_Index%
return
Esc::ExitApp
if you don't need the 2 Test lines, just delete them.

Re: Sending Keystrokes to Multiple Windows

Posted: 23 Jan 2022, 09:16
by jkpwk213
This worked perfectly thank you!