Send Script to Multiple Windows

Get help with using AutoHotkey and its commands and hotkeys
JakeK0202
Posts: 5
Joined: 21 May 2016, 10:30

Send Script to Multiple Windows

09 Jun 2016, 19:50

So, I'm using a very simple code to repeatedly press a key for the emulator desmume. I want to know now if it is possible to use this code, and make it affect multiple open windows. Sorry, I'm sure that this type of question has come up countless numbers of times, but I can't quite find what I'm looking for.

Here's the code I've been using, I need this to affect multiple windows, if possible:

Code: Select all

x::
	While ("x", "P") {
		SendEvent, {c down}
		Sleep, 15
		SendEvent, {c up}
	}
return
User avatar
lifeweaver
Posts: 144
Joined: 10 May 2014, 05:57
GitHub: lifeweaver
Location: OH

Re: Send Script to Multiple Windows

10 Jun 2016, 06:43

Hi JakeK0202,

Check out ControlSend

Here is on example of a script I use it in, note how I use the process id to tell ControlSend where to send the keys.

Code: Select all

; Opensruby interperter
#IfWinActive
!`:: ; Opensruby interperter, sends common text
Run, %ComSpec% /K "C:\Users\lifeweaver\Desktop\test\ruby\uru 193", %A_Desktop%\blah\blah,,cmd_pid
SetKeyDelay, 0, 10
ControlSend,, {Shift up}{Alt up}, ahk_pid %cmd_pid%
ControlSend,, require 'test'{Enter}, ahk_pid %cmd_pid%
ControlSend,, require 'test1'{Enter}, ahk_pid %cmd_pid%
ControlSend,, include test{Enter}, ahk_pid %cmd_pid%
ControlSend,, include test1{Enter}, ahk_pid %cmd_pid%
return
JakeK0202
Posts: 5
Joined: 21 May 2016, 10:30

Re: Send Script to Multiple Windows

10 Jun 2016, 18:40

I looked at this a little bit, the problem being, I don't really know how to write a script to do what I want. I don't know how to use controlsend, and after reading about it, I still don't fully understand
User avatar
lifeweaver
Posts: 144
Joined: 10 May 2014, 05:57
GitHub: lifeweaver
Location: OH

Re: Send Script to Multiple Windows

15 Jun 2016, 10:52

JakeK0202 wrote:I looked at this a little bit, the problem being, I don't really know how to write a script to do what I want. I don't know how to use controlsend, and after reading about it, I still don't fully understand
I'm sorry to hear that, perhaps another, basic example, will help?

Code: Select all

Run, notepad,,, notepad_pid1
Run, notepad,,, notepad_pid2
Sleep 500
SetKeyDelay, 0, 10

ControlSend,, test message to first notepad, ahk_pid %notepad_pid1%
ControlSend,, test message to second notepad, ahk_pid %notepad_pid2%

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], doubledave22, flyingDman, Getfree, Google [Bot], JoeWinograd, shipper and 158 guests