Using WinActivate and a Global Variable (Trying Global Messagelist?)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
blad4
Posts: 315
Joined: 07 Oct 2015, 11:06

Using WinActivate and a Global Variable (Trying Global Messagelist?)

25 Jun 2017, 09:30

Adapting from a previous script and cannot code, so this could be completely wrong. But I have this

Code: Select all

global MessageList := [[1, 2], [3, 4], [5, 6], [7, 8]]
Which is essentially a string of WinActivates. My windows are identified with #1, #2, #3 and I have two screens so I want to be able to toggle between each of the following four functions using WheelUp and WheelDown only:

WinActivate #1 and WinActivate #2

WinActivate #3 and WinActivate #4

WinActivate #5 and WinActivate #6

WinActivate #7 and WinActivate #8

Trying to use ++Index > 5 for WheelUp and the opposite for WheelDown but failing.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Using WinActivate and a Global Variable (Trying Global Messagelist?)

25 Jun 2017, 15:31

Like this ?

Code: Select all

CoordMode, Mouse, Screen

index := 1

WheelDown::Activate(index -= 1)
WheelUp::Activate(index += 1)

Activate(ByRef index) {
	Static MessageList := [[1, 2], [3, 4], [5, 6], [7, 8]]
	
	index := index > MessageList.Length() ? 1 : (index < 1 ? MessageList.Length() : index)
	
	for i, v in MessageList[index] {
		WinActivate(v)
	}
	
	MouseGetPos, x, y
	ToolTip, % index, % x - 20, % y
}
Please excuse my spelling I am dyslexic.
blad4
Posts: 315
Joined: 07 Oct 2015, 11:06

Re: Using WinActivate and a Global Variable (Trying Global Messagelist?)

25 Jun 2017, 17:58

Thank you Capn Odin. Looks very promising. Just getting a 'call to nonexistent function 'WinActivate v' ' when trying to execute
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: Using WinActivate and a Global Variable (Trying Global Messagelist?)

25 Jun 2017, 18:06

Sorry I forgot it wasn't a function.

Code: Select all

CoordMode, Mouse, Screen

index := 1

WheelDown::Activate(index -= 1)
WheelUp::Activate(index += 1)

Activate(ByRef index) {
	Static MessageList := [[1, 2], [3, 4], [5, 6], [7, 8]]
	
	index := index > MessageList.Length() ? 1 : (index < 1 ? MessageList.Length() : index)
	
	for i, v in MessageList[index] {
		WinActivate, % v
	}
	
	MouseGetPos, x, y
	ToolTip, % index, % x - 20, % y
}
Edit: I think this is better for you since you wanted a (super) global list.

Code: Select all

CoordMode, Mouse, Screen

Global MessageList := [[1, 2], [3, 4], [5, 6], [7, 8]]
index := 1

WheelDown::Activate(index -= 1)
WheelUp::Activate(index += 1)

Activate(ByRef index) {

	index := index > MessageList.Length() ? 1 : (index < 1 ? MessageList.Length() : index)
	
	for i, v in MessageList[index] {
		WinActivate, % v
	}
	
	MouseGetPos, x, y
	ToolTip, % index, % x - 20, % y
}
Please excuse my spelling I am dyslexic.
blad4
Posts: 315
Joined: 07 Oct 2015, 11:06

Re: Using WinActivate and a Global Variable (Trying Global Messagelist?)

26 Jun 2017, 05:32

Thanks again Capn. No errors this time but unfortunately doesn't seem to execute as desired. I.e. on first execution of WheelDown, tooltip tells me the number '4' but only window 8 is activated (where 7 also needed to be).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 275 guests