Is it possible to run the script only on the 2nd monitor?

Ask gaming related questions (AHK v1.1 and older)
xsensimilla
Posts: 11
Joined: 24 May 2021, 10:22

Is it possible to run the script only on the 2nd monitor?

Post by xsensimilla » 10 Jun 2021, 12:46

Greetings, I am running 3 world of warcraft clients, 2 of them are running on the 2nd monitor, 1 client is on my main monitor. I want this script to run only on the 2nd monitor side. Is such coding possible? thanks all.

Code: Select all

#MaxThreadsPerHotkey 2
F9::
enable := !enable
SoundBeep, 1000 + 500 * enable
While enable
{
 WinGet, wowid, List, World of Warcraft
 Loop, %wowid%
  ControlSend,, r, % "ahk_id " wowid%A_Index%
 Random, r, 25000, 35000
 Sleep, r
}
Return
Rohwedder
Posts: 7623
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Is it possible to run the script only on the 2nd monitor?

Post by Rohwedder » 11 Jun 2021, 03:30

Hallo,
provided that the 2nd monitor is to the right of the 1st monitor according to its coordinates, try:

Code: Select all

#MaxThreadsPerHotkey 2
F9::
enable := !enable
SoundBeep, 1000 + 500 * enable
While enable
{
	WinGet, wowid, List, World of Warcraft
	Loop, %wowid%
	{
		WinGetPos , X,,,,% "ahk_id " wowid%A_Index%
		IF (X + 10 > A_ScreenWidth)
			ControlSend,, r,% "ahk_id " wowid%A_Index%
	}
	Random, r, 25000, 35000
	Sleep, r
}
Return
(If you were also familiar with the World of Autohotkey, you would use a Timer instead of #MaxThreadsPerHotkey 2 and the long Sleep.)
xsensimilla
Posts: 11
Joined: 24 May 2021, 10:22

Re: Is it possible to run the script only on the 2nd monitor?

Post by xsensimilla » 12 Jun 2021, 05:50

@mikeyww can you help me?
xsensimilla
Posts: 11
Joined: 24 May 2021, 10:22

Re: Is it possible to run the script only on the 2nd monitor?

Post by xsensimilla » 12 Jun 2021, 05:51

Rohwedder wrote:
11 Jun 2021, 03:30
Hallo,
provided that the 2nd monitor is to the right of the 1st monitor according to its coordinates, try:

Code: Select all

#MaxThreadsPerHotkey 2
F9::
enable := !enable
SoundBeep, 1000 + 500 * enable
While enable
{
	WinGet, wowid, List, World of Warcraft
	Loop, %wowid%
	{
		WinGetPos , X,,,,% "ahk_id " wowid%A_Index%
		IF (X + 10 > A_ScreenWidth)
			ControlSend,, r,% "ahk_id " wowid%A_Index%
	}
	Random, r, 25000, 35000
	Sleep, r
}
Return
(If you were also familiar with the World of Autohotkey, you would use a Timer instead of #MaxThreadsPerHotkey 2 and the long Sleep.)
my 2nd monitor is on the left
xsensimilla
Posts: 11
Joined: 24 May 2021, 10:22

Re: Is it possible to run the script only on the 2nd monitor?

Post by xsensimilla » 12 Jun 2021, 05:58

@Rohwedder hi thanks for help but my 2nd monitor is on the left
Rohwedder
Posts: 7623
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Is it possible to run the script only on the 2nd monitor?

Post by Rohwedder » 12 Jun 2021, 09:25

Then
perhaps:

Code: Select all

SysGet, MoN, 80
Loop,% MoN
	SysGet, Mo%A_Index%, MonitorWorkArea,% A_Index
Return
#MaxThreadsPerHotkey 2
F9::
enable := !enable
SoundBeep, 1000 + 500 * enable
While enable
{
	WinGet, wowid, List, World of Warcraft
	Loop, %wowid%
	{
		WinGetPos, X,, Width,,% "ahk_id " wowid%A_Index%
		WinCenter := X + Width//2
		IF WinCenter between %Mo2Left% and %Mo2Right%
			ControlSend,, r,% "ahk_id " wowid%A_Index%
	}
	Random, r, 25000, 35000
	Sleep, r
}
Return
Edit: If Var [not] between Lower and Upper is "legacy" and requires %operators% ,
Last edited by Rohwedder on 13 Jun 2021, 00:10, edited 1 time in total.
xsensimilla
Posts: 11
Joined: 24 May 2021, 10:22

Re: Is it possible to run the script only on the 2nd monitor?

Post by xsensimilla » 12 Jun 2021, 11:18

Rohwedder wrote:
12 Jun 2021, 09:25
Then
perhaps:

Code: Select all

SysGet, MoN, 80
Loop,% MoN
	SysGet, Mo%A_Index%, MonitorWorkArea,% A_Index
Return
#MaxThreadsPerHotkey 2
F9::
enable := !enable
SoundBeep, 1000 + 500 * enable
While enable
{
	WinGet, wowid, List, World of Warcraft
	Loop, %wowid%
	{
		WinGetPos, X,, Width,,% "ahk_id " wowid%A_Index%
		WinCenter := X + Width//2
		IF WinCenter between Mo2Left and Mo2Right
			ControlSend,, r,% "ahk_id " wowid%A_Index%
	}
	Random, r, 25000, 35000
	Sleep, r
}
Return
not working :(
Rohwedder
Posts: 7623
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Is it possible to run the script only on the 2nd monitor?

Post by Rohwedder » 13 Jun 2021, 00:14

Made a correction, please try again.
xsensimilla
Posts: 11
Joined: 24 May 2021, 10:22

Re: Is it possible to run the script only on the 2nd monitor?

Post by xsensimilla » 13 Jun 2021, 02:57

Rohwedder wrote:
13 Jun 2021, 00:14
Made a correction, please try again.
Thank you very much for taking your precious time to deal with my problem. I would also like to state that I admire the Germans and their business disciplines, stay well.
Post Reply

Return to “Gaming Help (v1)”