Page 1 of 1

Send Script to Multiple Windows

Posted: 09 Jun 2016, 19:50
by JakeK0202
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

Re: Send Script to Multiple Windows

Posted: 10 Jun 2016, 06:43
by lifeweaver
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

Re: Send Script to Multiple Windows

Posted: 10 Jun 2016, 18:40
by JakeK0202
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

Re: Send Script to Multiple Windows

Posted: 15 Jun 2016, 10:52
by lifeweaver
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%