Trying to find a solution for jumping to a label

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
BruceO
Posts: 12
Joined: 06 Sep 2019, 11:15

Trying to find a solution for jumping to a label

Post by BruceO » 02 Jun 2023, 11:53

Win 9 Position test.ahk
In my win F9 function i m trying to figure out hoe to get to one of my windows move sections in my code. i tryed using a goto label but got a error massage saying that the label is not in the current scope. I tryed setung the widows move section a a added function and tryed calling it from the Gui function but that failed also. Any help would be greatly appreciated. The Alt/Cntl NumPad functiond all work as i have designed them.

[Mod edit: Removed extraneous tags.]

Rohwedder
Posts: 7624
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Trying to find a solution for jumping to a label

Post by Rohwedder » 03 Jun 2023, 04:18

Hallo,
I have not found any goto to any label in your script!

BruceO
Posts: 12
Joined: 06 Sep 2019, 11:15

Re: Trying to find a solution for jumping to a label

Post by BruceO » 03 Jun 2023, 07:09

Sorry Uploaded the wrong script copy. Look at the (Window F9) section where after the script receives a selection answer. I check to see which selection was chosen and then try to goto that routine to move the selected screen to the chosen position.

Code: Select all

#Requires AutoHotkey v2.0
#Warn
#SingleInstance

#Include "WiseGui.ahk"									; the sub routine to display error messges


global XX, YY, PadNum1											; Set some global varibles for the folloting routines.

WinTitle := "A"

WP1 := "NO"
WP2 := "NO"
WP3 := "NO"
WP4 := "NO"
WP5 := "NO"
WP6 := "NO"
WP7 := "NO"
WP8 := "NO"
WP9 := "NO"

#F9::
{
	MyGui := Gui()
	MyDLL := MyGui.Name := "Select Position"
	MyDLL := MyGui.Title := "Select Position"
	MyDDL := MyGui.Add("DropDownList", "vPosition x75", ["Lower Right Corner" , "Lower Center" , "Lower Left Corner" ,
					"Center Right Side" , "Center Screen" , "Center Left Side" , "Top Right Side" , "Top Center" ,
					"Top Left Side"])
	MyDDL.ToolTip := "Choose a screen store location from the list."
	Btn := MyGui.Add("Button", "Default w50 xm", "OK")
	Btn.OnEvent("Click", ProcessUserInput)
	MyGui.OnEvent("Close", ProcessUserInput)
	MyGui.OnEvent("Escape", ProcessUserInput)

	ProcessUserInput(*)
	{
		Saved := MyGui.Submit()  ; Save the contents of named controls into an object.
		MsgBox("You entered '" Saved.Position "'.")
		POS := Saved.Position
		MsgBox "POS = " POS
		If (POS = "Lower Right Corner")
		{
			goto PadNum1
		}
		else
		return
	}

	MyGui.Show "w250"

	OnMessage(0x0200, On_WM_MOUSEMOVE)

	On_WM_MOUSEMOVE(wParam, lParam, msg, Hwnd)
	{
		static PrevHwnd := 0
		if (Hwnd != PrevHwnd)
		{
			Text := "", ToolTip() ; Turn off any previous tooltip.
			CurrControl := GuiCtrlFromHwnd(Hwnd)
			if CurrControl
			{
				if !CurrControl.HasProp("ToolTip")
					return ; No tooltip for this control.
				Text := CurrControl.ToolTip
				SetTimer () => ToolTip(Text), -1000
				SetTimer () => ToolTip(), -4000 ; Remove the tooltip.
			}
			PrevHwnd := Hwnd
		}
	}
}

NoWinDo(&XX, &YY, &PP)									; Call routine to display a error message.
	{
	WiseGui("No Window", "Theme: E",					; Set call routine name and message type.
		"MainText: No Window Found",					; Set main title text.
		"MainAlign: 0",									; Aline the title text to center of error message.
		"FontMain: s16",								; Set text size.
		("SubText: There Was No Window Found in Position: " PP " at " XX " - " YY ""),	; Set secondary text message.
		"SubAlign: 0",									; Aline secondary message center for display.
		"FontSub: s18",									; Set text size for secandary message.
		"Move: , " )									; move message to center of monitor and display it.
	Sleep(3000)											; Display the message for 3000 ms.
	WiseGui("No Window") ; Kill							; Kill the error message.
	return												; Return from calling routine.
	}


ActWinIN(&XX, &YY, &PP)
	{
	WiseGui("Active Window", "Theme: E",
		"MainText: Window Position In Use",
		"MainAlign: 0",
		"FontMain: s16",
		"TextColor: 0XFF0000",
		("SubText: There is allready a Window stored in Position: " PP " at " XX " - " YY " . Please select another location to store your window. Press Left Mouse Button to dismiss."),
		"SubAlign: 0",
		"FontSub: s18",
		"Move: , " )
	Sleep(3000)
	WiseGui("Active Window") ; Kill
	return
	}


WinStorInfo(&PP)										; Call routine to diplay a information message.
	{
	Global X, Y, W, H, XX, YY							; Set Global var for this routine.
	WinGetPos(&X, &Y, &W, &H, WinTitle)					; Get the windows position and size for the info Message.
	YY := (Y/2)											; Devide the windows Y position in half.
	WW := (W/1.75)										; Devide the windows width by 1.75.
	HH := (H//2)										; Devide the windows height by by 2.
	WW := (W-WW)										; Subtract the windows devided width form the windows width.
	HH := (H-HH)										; Subtract the windows devided height from the windows height
	XX := (X+WW)										; Add the windows X pos location with the new windows width.
	YY := (Y+HH)										; Add the windows Y pos location with the new windows hight.
	WiseGui("Storage Window Location", "Theme: I",		; Set call routine name and message type
		"FontMain: s14 Bold Italic Underline, Comic Sans MS",	; Set font type, size, a attrubit.
		"MainText: To Restore Window",					; Set main text message.
		"FontSub: s12 norm, arial",						; Set subtext font type and size.
		"SubText: Use the CONTROL key and Number Pad Key " PP " .",	; Set subtext message.
		"SubAlign: 0",									; Aline subtext message to center.
		"Move: " XX ", " YY "")							; Move the info message to the center of the moved window and display it.
	Sleep(4000)											; Hold the info message on the screen for 4000 ms.
	WiseGui("Storage Window Location") ; Kill			; Kill the info message.
	return												; Return to the calling routine.
}



if  (A_ScreenHeight < "1024" or A_ScreenWidth < "1280")	; Check to see if the display screen is greater than 1280 x 1024
{
	MsgBox "Screen Size To Small for this program."     ; Screen size is less than 1280 x 1024 disply error message
	ExitApp												; exit the script
}
else
{
	Win9PosizeW := (A_ScreenWidth//3)					; Set 3 equal screen width sizes
	Win9PosizeH := (A_ScreenHeight//3)					; Set 3 equal screen height sizes
	WinSizeW := Win9PosizeW - 10						; Set the storage window width size
	WinSizeH := Win9PosizeH - 10						; Set the storage window height size
	WinLoc1Y := 5 + WinSizeH + 10 + WinSizeH + 10		; Set the Y position for window storage 1 location
	WinLoc2Y := 5 + WinSizeH + 10 + WinSizeH + 10		; Set the Y position for window storage 2 location
	WinLoc2X := 5 + WinSizeW + 10						; Set the X position for window storage 2 Location
	WinLoc3Y := 5 + WinSizeH + 10 + WinSizeH + 10		; Set the Y position for window storage 3 location
	WinLoc3X := 5 + WinSizeW + 10 + WinSizeW + 10		; Set the X position for window storage 3 Location
	WinLoc4Y := 5 + WinSizeH + 10						; Set the Y position for window storage 4 location
	WinLoc5Y := 5 + WinSizeH + 10						; Set the Y position for window storage 5 Location
	WinLoc5X := 5 + WinSizeW + 10						; Set the X position for window storage 5 Location
	WinLoc6Y := 5 + WinSizeH + 10						; Set the Y position for window storage 6 Location
	WinLoc6X := 5 + WinSizeW + 10 + WinSizeW + 10		; Set the X position for window storage 6 Location
														; Window storage location 7 is hard coded at 5X5
	WinLoc8X := 5 + WinSizeW + 10						; Set the X position for window storage 8 location Y Pos is hard coded at 5
	WinLoc9X := 5 + WinSizeW + 10 + WinSizeW + 10		; Set the X position for window storage 9 Location Y Pos is hard coded at 5
}





!NumPad0::												; Number alt pad 0 or Ins will exit the script
!NumPadIns::
;LButton::
{
	ExitApp
}

PadNum1:
!Numpad1::												; alt number pad 1 or alt number pad END will move a active window to pos 1
!NumpadEnd::											; This corrspands to the number pad setup
^Numpad1::												; Control number pad 1 or control number pad END will move the window stored
^NumpadEnd::											; in position 1 back to it's original position and size
{
	Global WP1, X1, Y1, W1, H1, XX, YY, PP, Title1		; Set globl varibles for Num Pad 1/END routine
	PP := 1												; Set pre use varible
	XX := 5
	YY := WinLoc1Y
	if GetKeyState("Control")							; Check if CONTROL was pressed
	{
		if (WP1 = "YES")								; Check if a window was saved in pos 1
		{
			WinActivate Title1							; Activate the window in pos 1
			WinSetTransparent "off", TiTle1				; Renove the windows transparentsy
			WinMove(X1, Y1, W1, H1, WinTitle)			; Move the windoe back to it's orginal position and size
			WP1 := "NO"									; Change to no window stored in pos 1

		}
		else
			NoWinDO(&XX, &YY, &PP)						; display error massage that no window was found in pos 1
	}
	else
	{
		if (WP1 = "NO")									; Check to see if a window in stored in pos 1
		{
			WinGetPos(&X1, &Y1, &W1, &H1, WinTitle)		; Get the current position and size of the active window to be moved
			Title1 := WinGetTitle("A")					; Store the active windows title
			WinMove(5, WinLoc1Y, WinSizeW, WinSizeH, Wintitle) ; Now move the active window to it's new windows storage location
			WP1 := "YES"								; Now set the indictor that a window is stored in location 1
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle1				; Set the moved window Transparent.
		}
		else
			ActWinIN(&XX, &YY, &PP)						; Someone tryed to store another active window in storage position 1
														; Send an error massage that there is all ready a window stored in position 1
	}

	Return												; exit this routine and wait for another Alt/Ctrl Numpad request
}

!Numpad2::												; The following Alt/Ctrl sequences are all the same as above
!NumpadDown::
^NumPad2::
^NumPadDown::
{
	global WP2, X2, Y2, W2, H2, XX, YY, PP, Title2
	PP := 2
	XX := WinLoc2x
	YY := WinLoc2Y
	if GetKeyState("Control")
	{
		if (WP2 = "YES")
		{
			WinActivate Title2
			WinSetTransparent "off", TiTle2
			WinMove(X2, Y2, W2, H2, WinTitle)
			WP2 := "NO"
		}
		else
			NoWinDO(&XX, &YY, &PP)
	}
	else
		if (WP2 = "NO")
		{
			WinGetPos(&X2, &Y2, &W2, &H2, WinTitle)
			Title2 := WinGetTitle("A")
			WinMove(WinLoc2x, WinLoc2Y, WinSizeW, WinSizeH, WinTitle)
			WP2 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle2
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!Numpad3::
!NumpadPgDn::
^NumPad3::
^NumpadPgDn::
{
	global WP3, X3, Y3, W3, H3, XX, YY, PP, TiTle3
	PP := 3
	XX := 2560
	YY := 1066
	if GetKeyState("Control")
	{
		if (WP3 = "YES")
		{
			WinActivate TiTle3
			WinSetTransparent "off", TiTle3
			WinMove(X3, Y3, W3, H3, WinTitle)
			WP3 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP3 = "NO")
		{
			WinGetPos(&X3, &Y3, &W3, &H3, WinTitle)
			Title3 := WinGetTitle("A")
			WinMove(WinLoc3X, WinLoc3Y, WinSizeW, WinSizeH, WinTitle)
			WP3 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle3
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad4::
!NumpadLeft::
^Numpad4::
^NumpadLeft::
{
	Global WP4, X4, Y4, W4, H4, XX, YY, PP, TiTle4
	PP := 4
	XX := 5
	YY := 533
	if GetKeyState("Control")
	{
		if (WP4 = "YES")
		{
			WinActivate TiTle4
			WinSetTransparent "off", TiTle4
			WinMove(X4, Y4, W4, H4, WinTitle)
			WP4 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP4 = "NO")
		{
			WinGetPos(&X4, &Y4, &W4, &H4, WinTitle)
			TiTle4 := WinGetTitle("A")
			WinMove(5, WinLoc4Y, WinSizeW, WinSizeH, WinTitle)
			WP4 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle4
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad5::
!NumPadClear::
^Numpad5::
^NumpadClear::
{
	Global WP5, X5, Y5, W5, H5, XX, YY, PP, TiTle5
	PP :=5
	XX := 1273
	YY := 533
	if GetKeyState("Control")
	{
		if (WP5 = "YES")
		{
			WinActivate TiTle5
			WinSetTransparent "off", TiTle5
			WinMove(X5, Y5, W5, H5, WinTitle)
			WP5 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP5 = "NO")
		{
			WinGetPos(&X5, &Y5, &W5, &H5, WinTitle)
			TiTle5 := WinGetTitle("A")
			WinMove(WinLoc5X, WinLoc5Y, WinSizeW, WinSizeH, WinTitle)
			WP5 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle5
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad6::
!NumPadRight::
^Numpad6::
^NumpadRight::
{
	Global WP6, X6, Y6, W6, H6, XX, YY, PP, TiTle6
	PP :=6
	XX := 2560
	YY := 533
	if GetKeyState("Control")
	{
		if (WP6 = "YES")
		{
			WinActivate TiTle6
			WinSetTransparent "off", TiTle6
			WinMove(X6, Y6, W6, H6, WinTitle)
			WP6 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP6 = "NO")
		{
			WinGetPos(&X6, &Y6, &W6, &H6, WinTitle)
			TiTle6 := WinGetTitle("A")
			WinMove(WinLoc6X, WinLoc6Y, WinSizeW, WinSizeH, WinTitle)
			WP6 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle6
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad7::
!NumPadHome::
^Numpad7::
^NumPadHome::
{
	Global WP7, X7, Y7, W7, H7, XX, YY, PP, TiTle7
	PP :=7
	XX := 5
	YY := 5
	if GetKeyState("Control")
	{
		if (WP7 = "YES")
		{
			WinActivate TiTle7
			WinSetTransparent "off", TiTle7
			WinMove(X7, Y7, W7, H7, WinTitle)
			WP7 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP7 = "NO")
		{
			WinGetPos(&X7, &Y7, &W7, &H7, WinTitle)
			TiTle7 := WinGetTitle("A")
			WinMove(5, 5, WinSizeW, WinSizeH, WinTitle)
			WP7 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle7
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad8::
!NumPadUp::
^NumPad8::
^NumPadUp::
{
	Global WP8, X8, Y8, W8, H8, XX, YY, PP, TiTle8
	PP := 8
	XX := 1273
	YY := 5
	if GetKeyState("Control")
	{
		if (WP8 = "YES")
		{
			WinActivate TiTle8
			WinSetTransparent "off", TiTle8
			WinMove(X8, Y8, W8, H8, WinTitle)
			WP8 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP8 = "NO")
		{
			WinGetPos(&X8, &Y8, &W8, &H8, WinTitle)
			TiTle8 := WinGetTitle("A")
			WinMove(WinLoc8X, 5, WinSizeW, WinSizeH, WinTitle)
			WP8 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle8
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad9::
!NumPadPgUp::
^NumPad9::
^NumPadPgUp::
{
	Global WP9, X9, Y9, W9, H9, XX, YY, PP, TiTle9
	PP := 9
	XX := 2560
	YY := 5
	if GetKeyState("Control")
	{
		if (WP9 = "YES")
		{
			WinActivate TiTle9
			WinSetTransparent "off", TiTle9
			WinMove(X9, Y9, W9, H9, WinTitle)
			WP9 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP9 = "NO")
		{
			WinGetPos(&X9, &Y9, &W9, &H9, WinTitle)
			TiTle9 := WinGetTitle("A")
			WinMove(WinLoc9X, 5, WinSizeW, WinSizeH, WinTitle)
			WP9:= "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle9
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

Rohwedder
Posts: 7624
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Trying to find a solution for jumping to a label

Post by Rohwedder » 03 Jun 2023, 10:47

Perhaps (untested) ?:

Code: Select all

#Requires AutoHotkey v2.0
#Warn
#SingleInstance

#Include "WiseGui.ahk"									; the sub routine to display error messges


global XX, YY											; Set some global varibles for the folloting routines.

WinTitle := "A"

WP1 := "NO"
WP2 := "NO"
WP3 := "NO"
WP4 := "NO"
WP5 := "NO"
WP6 := "NO"
WP7 := "NO"
WP8 := "NO"
WP9 := "NO"

#F9::
{
	MyGui := Gui()
	MyDLL := MyGui.Name := "Select Position"
	MyDLL := MyGui.Title := "Select Position"
	MyDDL := MyGui.Add("DropDownList", "vPosition x75", ["Lower Right Corner" , "Lower Center" , "Lower Left Corner" ,
					"Center Right Side" , "Center Screen" , "Center Left Side" , "Top Right Side" , "Top Center" ,
					"Top Left Side"])
	MyDDL.ToolTip := "Choose a screen store location from the list."
	Btn := MyGui.Add("Button", "Default w50 xm", "OK")
	Btn.OnEvent("Click", ProcessUserInput)
	MyGui.OnEvent("Close", ProcessUserInput)
	MyGui.OnEvent("Escape", ProcessUserInput)

	ProcessUserInput(*)
	{
		Saved := MyGui.Submit()  ; Save the contents of named controls into an object.
		MsgBox("You entered '" Saved.Position "'.")
		POS := Saved.Position
		MsgBox "POS = " POS
		If (POS = "Lower Right Corner")
			PadNum1()
	}

	MyGui.Show "w250"

	OnMessage(0x0200, On_WM_MOUSEMOVE)

	On_WM_MOUSEMOVE(wParam, lParam, msg, Hwnd)
	{
		static PrevHwnd := 0
		if (Hwnd != PrevHwnd)
		{
			Text := "", ToolTip() ; Turn off any previous tooltip.
			CurrControl := GuiCtrlFromHwnd(Hwnd)
			if CurrControl
			{
				if !CurrControl.HasProp("ToolTip")
					return ; No tooltip for this control.
				Text := CurrControl.ToolTip
				SetTimer () => ToolTip(Text), -1000
				SetTimer () => ToolTip(), -4000 ; Remove the tooltip.
			}
			PrevHwnd := Hwnd
		}
	}
}

NoWinDo(&XX, &YY, &PP)									; Call routine to display a error message.
	{
	WiseGui("No Window", "Theme: E",					; Set call routine name and message type.
		"MainText: No Window Found",					; Set main title text.
		"MainAlign: 0",									; Aline the title text to center of error message.
		"FontMain: s16",								; Set text size.
		("SubText: There Was No Window Found in Position: " PP " at " XX " - " YY ""),	; Set secondary text message.
		"SubAlign: 0",									; Aline secondary message center for display.
		"FontSub: s18",									; Set text size for secandary message.
		"Move: , " )									; move message to center of monitor and display it.
	Sleep(3000)											; Display the message for 3000 ms.
	WiseGui("No Window") ; Kill							; Kill the error message.
	return												; Return from calling routine.
	}


ActWinIN(&XX, &YY, &PP)
	{
	WiseGui("Active Window", "Theme: E",
		"MainText: Window Position In Use",
		"MainAlign: 0",
		"FontMain: s16",
		"TextColor: 0XFF0000",
		("SubText: There is allready a Window stored in Position: " PP " at " XX " - " YY " . Please select another location to store your window. Press Left Mouse Button to dismiss."),
		"SubAlign: 0",
		"FontSub: s18",
		"Move: , " )
	Sleep(3000)
	WiseGui("Active Window") ; Kill
	return
	}


WinStorInfo(&PP)										; Call routine to diplay a information message.
	{
	Global X, Y, W, H, XX, YY							; Set Global var for this routine.
	WinGetPos(&X, &Y, &W, &H, WinTitle)					; Get the windows position and size for the info Message.
	YY := (Y/2)											; Devide the windows Y position in half.
	WW := (W/1.75)										; Devide the windows width by 1.75.
	HH := (H//2)										; Devide the windows height by by 2.
	WW := (W-WW)										; Subtract the windows devided width form the windows width.
	HH := (H-HH)										; Subtract the windows devided height from the windows height
	XX := (X+WW)										; Add the windows X pos location with the new windows width.
	YY := (Y+HH)										; Add the windows Y pos location with the new windows hight.
	WiseGui("Storage Window Location", "Theme: I",		; Set call routine name and message type
		"FontMain: s14 Bold Italic Underline, Comic Sans MS",	; Set font type, size, a attrubit.
		"MainText: To Restore Window",					; Set main text message.
		"FontSub: s12 norm, arial",						; Set subtext font type and size.
		"SubText: Use the CONTROL key and Number Pad Key " PP " .",	; Set subtext message.
		"SubAlign: 0",									; Aline subtext message to center.
		"Move: " XX ", " YY "")							; Move the info message to the center of the moved window and display it.
	Sleep(4000)											; Hold the info message on the screen for 4000 ms.
	WiseGui("Storage Window Location") ; Kill			; Kill the info message.
	return												; Return to the calling routine.
}



if  (A_ScreenHeight < "1024" or A_ScreenWidth < "1280")	; Check to see if the display screen is greater than 1280 x 1024
{
	MsgBox "Screen Size To Small for this program."     ; Screen size is less than 1280 x 1024 disply error message
	ExitApp												; exit the script
}
else
{
	Win9PosizeW := (A_ScreenWidth//3)					; Set 3 equal screen width sizes
	Win9PosizeH := (A_ScreenHeight//3)					; Set 3 equal screen height sizes
	WinSizeW := Win9PosizeW - 10						; Set the storage window width size
	WinSizeH := Win9PosizeH - 10						; Set the storage window height size
	WinLoc1Y := 5 + WinSizeH + 10 + WinSizeH + 10		; Set the Y position for window storage 1 location
	WinLoc2Y := 5 + WinSizeH + 10 + WinSizeH + 10		; Set the Y position for window storage 2 location
	WinLoc2X := 5 + WinSizeW + 10						; Set the X position for window storage 2 Location
	WinLoc3Y := 5 + WinSizeH + 10 + WinSizeH + 10		; Set the Y position for window storage 3 location
	WinLoc3X := 5 + WinSizeW + 10 + WinSizeW + 10		; Set the X position for window storage 3 Location
	WinLoc4Y := 5 + WinSizeH + 10						; Set the Y position for window storage 4 location
	WinLoc5Y := 5 + WinSizeH + 10						; Set the Y position for window storage 5 Location
	WinLoc5X := 5 + WinSizeW + 10						; Set the X position for window storage 5 Location
	WinLoc6Y := 5 + WinSizeH + 10						; Set the Y position for window storage 6 Location
	WinLoc6X := 5 + WinSizeW + 10 + WinSizeW + 10		; Set the X position for window storage 6 Location
														; Window storage location 7 is hard coded at 5X5
	WinLoc8X := 5 + WinSizeW + 10						; Set the X position for window storage 8 location Y Pos is hard coded at 5
	WinLoc9X := 5 + WinSizeW + 10 + WinSizeW + 10		; Set the X position for window storage 9 Location Y Pos is hard coded at 5
}





!NumPad0::												; Number alt pad 0 or Ins will exit the script
!NumPadIns::
;LButton::
{
	ExitApp
}


!Numpad1::												; alt number pad 1 or alt number pad END will move a active window to pos 1
!NumpadEnd::											; This corrspands to the number pad setup
^Numpad1::												; Control number pad 1 or control number pad END will move the window stored
^NumpadEnd::
{
	PadNum1()
}
PadNum1()											; in position 1 back to it's original position and size
{
	Global WP1, X1, Y1, W1, H1, XX, YY, PP, Title1		; Set globl varibles for Num Pad 1/END routine
	PP := 1												; Set pre use varible
	XX := 5
	YY := WinLoc1Y
	if GetKeyState("Control")							; Check if CONTROL was pressed
	{
		if (WP1 = "YES")								; Check if a window was saved in pos 1
		{
			WinActivate Title1							; Activate the window in pos 1
			WinSetTransparent "off", TiTle1				; Renove the windows transparentsy
			WinMove(X1, Y1, W1, H1, WinTitle)			; Move the windoe back to it's orginal position and size
			WP1 := "NO"									; Change to no window stored in pos 1

		}
		else
			NoWinDO(&XX, &YY, &PP)						; display error massage that no window was found in pos 1
	}
	else
	{
		if (WP1 = "NO")									; Check to see if a window in stored in pos 1
		{
			WinGetPos(&X1, &Y1, &W1, &H1, WinTitle)		; Get the current position and size of the active window to be moved
			Title1 := WinGetTitle("A")					; Store the active windows title
			WinMove(5, WinLoc1Y, WinSizeW, WinSizeH, Wintitle) ; Now move the active window to it's new windows storage location
			WP1 := "YES"								; Now set the indictor that a window is stored in location 1
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle1				; Set the moved window Transparent.
		}
		else
			ActWinIN(&XX, &YY, &PP)						; Someone tryed to store another active window in storage position 1
														; Send an error massage that there is all ready a window stored in position 1
	}

	Return												; exit this routine and wait for another Alt/Ctrl Numpad request
}

!Numpad2::												; The following Alt/Ctrl sequences are all the same as above
!NumpadDown::
^NumPad2::
^NumPadDown::
{
	global WP2, X2, Y2, W2, H2, XX, YY, PP, Title2
	PP := 2
	XX := WinLoc2x
	YY := WinLoc2Y
	if GetKeyState("Control")
	{
		if (WP2 = "YES")
		{
			WinActivate Title2
			WinSetTransparent "off", TiTle2
			WinMove(X2, Y2, W2, H2, WinTitle)
			WP2 := "NO"
		}
		else
			NoWinDO(&XX, &YY, &PP)
	}
	else
		if (WP2 = "NO")
		{
			WinGetPos(&X2, &Y2, &W2, &H2, WinTitle)
			Title2 := WinGetTitle("A")
			WinMove(WinLoc2x, WinLoc2Y, WinSizeW, WinSizeH, WinTitle)
			WP2 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle2
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!Numpad3::
!NumpadPgDn::
^NumPad3::
^NumpadPgDn::
{
	global WP3, X3, Y3, W3, H3, XX, YY, PP, TiTle3
	PP := 3
	XX := 2560
	YY := 1066
	if GetKeyState("Control")
	{
		if (WP3 = "YES")
		{
			WinActivate TiTle3
			WinSetTransparent "off", TiTle3
			WinMove(X3, Y3, W3, H3, WinTitle)
			WP3 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP3 = "NO")
		{
			WinGetPos(&X3, &Y3, &W3, &H3, WinTitle)
			Title3 := WinGetTitle("A")
			WinMove(WinLoc3X, WinLoc3Y, WinSizeW, WinSizeH, WinTitle)
			WP3 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle3
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad4::
!NumpadLeft::
^Numpad4::
^NumpadLeft::
{
	Global WP4, X4, Y4, W4, H4, XX, YY, PP, TiTle4
	PP := 4
	XX := 5
	YY := 533
	if GetKeyState("Control")
	{
		if (WP4 = "YES")
		{
			WinActivate TiTle4
			WinSetTransparent "off", TiTle4
			WinMove(X4, Y4, W4, H4, WinTitle)
			WP4 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP4 = "NO")
		{
			WinGetPos(&X4, &Y4, &W4, &H4, WinTitle)
			TiTle4 := WinGetTitle("A")
			WinMove(5, WinLoc4Y, WinSizeW, WinSizeH, WinTitle)
			WP4 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle4
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad5::
!NumPadClear::
^Numpad5::
^NumpadClear::
{
	Global WP5, X5, Y5, W5, H5, XX, YY, PP, TiTle5
	PP :=5
	XX := 1273
	YY := 533
	if GetKeyState("Control")
	{
		if (WP5 = "YES")
		{
			WinActivate TiTle5
			WinSetTransparent "off", TiTle5
			WinMove(X5, Y5, W5, H5, WinTitle)
			WP5 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP5 = "NO")
		{
			WinGetPos(&X5, &Y5, &W5, &H5, WinTitle)
			TiTle5 := WinGetTitle("A")
			WinMove(WinLoc5X, WinLoc5Y, WinSizeW, WinSizeH, WinTitle)
			WP5 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle5
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad6::
!NumPadRight::
^Numpad6::
^NumpadRight::
{
	Global WP6, X6, Y6, W6, H6, XX, YY, PP, TiTle6
	PP :=6
	XX := 2560
	YY := 533
	if GetKeyState("Control")
	{
		if (WP6 = "YES")
		{
			WinActivate TiTle6
			WinSetTransparent "off", TiTle6
			WinMove(X6, Y6, W6, H6, WinTitle)
			WP6 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP6 = "NO")
		{
			WinGetPos(&X6, &Y6, &W6, &H6, WinTitle)
			TiTle6 := WinGetTitle("A")
			WinMove(WinLoc6X, WinLoc6Y, WinSizeW, WinSizeH, WinTitle)
			WP6 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle6
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad7::
!NumPadHome::
^Numpad7::
^NumPadHome::
{
	Global WP7, X7, Y7, W7, H7, XX, YY, PP, TiTle7
	PP :=7
	XX := 5
	YY := 5
	if GetKeyState("Control")
	{
		if (WP7 = "YES")
		{
			WinActivate TiTle7
			WinSetTransparent "off", TiTle7
			WinMove(X7, Y7, W7, H7, WinTitle)
			WP7 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP7 = "NO")
		{
			WinGetPos(&X7, &Y7, &W7, &H7, WinTitle)
			TiTle7 := WinGetTitle("A")
			WinMove(5, 5, WinSizeW, WinSizeH, WinTitle)
			WP7 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle7
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad8::
!NumPadUp::
^NumPad8::
^NumPadUp::
{
	Global WP8, X8, Y8, W8, H8, XX, YY, PP, TiTle8
	PP := 8
	XX := 1273
	YY := 5
	if GetKeyState("Control")
	{
		if (WP8 = "YES")
		{
			WinActivate TiTle8
			WinSetTransparent "off", TiTle8
			WinMove(X8, Y8, W8, H8, WinTitle)
			WP8 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP8 = "NO")
		{
			WinGetPos(&X8, &Y8, &W8, &H8, WinTitle)
			TiTle8 := WinGetTitle("A")
			WinMove(WinLoc8X, 5, WinSizeW, WinSizeH, WinTitle)
			WP8 := "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle8
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

!NumPad9::
!NumPadPgUp::
^NumPad9::
^NumPadPgUp::
{
	Global WP9, X9, Y9, W9, H9, XX, YY, PP, TiTle9
	PP := 9
	XX := 2560
	YY := 5
	if GetKeyState("Control")
	{
		if (WP9 = "YES")
		{
			WinActivate TiTle9
			WinSetTransparent "off", TiTle9
			WinMove(X9, Y9, W9, H9, WinTitle)
			WP9 := "NO"
		}
		else
			NoWinDo(&XX, &YY, &PP)
	}
	else
		if (WP9 = "NO")
		{
			WinGetPos(&X9, &Y9, &W9, &H9, WinTitle)
			TiTle9 := WinGetTitle("A")
			WinMove(WinLoc9X, 5, WinSizeW, WinSizeH, WinTitle)
			WP9:= "YES"
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle9
		}
		else
			ActWinIN(&XX, &YY, &PP)
	Return
}

BruceO
Posts: 12
Joined: 06 Sep 2019, 11:15

New Problem: (Error: This variable has not been assigned a value.)

Post by BruceO » 05 Jun 2023, 11:40

I set a string of (YES or NO) to CntlSet in my F9 routine and pass it to any of me NumPad routines. The problem is that if i bypas the F9 routine and do a NumPad routine the script is senning out a error message .
Error: This variable has not been assigned a value.

Specifically: parameter CntlSet

218: XX := 5
219: YY := WinLoc1Y
▶ 223: If (GetKeyState("Control") or CntlSet = "YES")
224: {
225: If (WP1 = "YES")
see attaches code snip for reference

Code: Select all

MyGui := Gui()										; Start Gui panel setup.
	MyDLL := MyGui.Name := "Select Position"			; Set name of MyGui
	if GetKeyState("Control")							; Check if CONTROL was pressed
	{
		CntlSet := "YES"								; If Control key ws pressed set Var CntlSet to YES.
		MyDLL := MyGui.Title := "Restore Position"		; Set title bar of the Drop Down List.
		MyDDL := MyGui.Add("DropDownList", "vPosition w150 x60 Choose1", ["Position to Restore" , "Lower Left Corner" , "Lower Center" ,
					"Lower Right Corner" , "Center Left Side" , "Center Screen" , "Center Right Side" , "Top Left Side" ,
					"Top Center" , "Top Right Side"])	; Set the DDL items to be displayed.
		MyDDL.ToolTip := "Choose a screens store location to Restore."	; Add a tool tip to be displayed as needed.
	}
farther down

Code: Select all

	Saved := MyGui.Submit()  						; Save the contents of named controls into an object.
		POS := Saved.Position							; Retrive the select item from the DDL.
		{
			If (POS = "Lower Left Corner")				; Check witch iten was selected in the DDL
				PadNum1(&CntlSet)			
and NumPad routine where i am getting the error message but only if i do a ALT NumPad routine any other pass from the F9 routine or a Control NumPad routine i do not get a error message.

Code: Select all

	PadNum1(&CntlSet)

}
PadNum1(&CntlSet)
{
	Global WP1, X1, Y1, W1, H1, XX, YY, PP, Title1,		; Set globl varibles for Num Pad 1/END routine
	PP := 1												; Set pre use varible
	XX := 5
	YY := WinLoc1Y
	;state := GetKeyState("Control")
	;MsgBox "The Control state is = " state " And WP1 = " WP1
	;msgbox "CNTLSET = " CntlSet
	if (GetKeyState("Control") or CntlSet = "YES")	; Check if CONTROL was pressed [b][u]( I am getting the error message from this line)[/u][/b]
	{
		if (WP1 = "YES")								; Check if a window was saved in pos 1
		{
			WinActivate Title1							; Activate the window in pos 1
			WinSetTransparent "off", TiTle1				; Renove the windows transparentsy
			WinMove(X1, Y1, W1, H1, WinTitle)			; Move the windoe back to it's orginal position and size
			WP1 := "NO"									; Change to no window stored in pos 1

		}
		else
			NoWinDO(&XX, &YY, &PP)						; display error massage that no window was found in pos 1
	}
	else
	{
		if (WP1 = "NO")									; Check to see if a window in stored in pos 1
		{
			WinGetPos(&X1, &Y1, &W1, &H1, WinTitle)		; Get the current position and size of the active window to be moved
			Title1 := WinGetTitle("A")					; Store the active windows title
			WinMove(5, WinLoc1Y, WinSizeW, WinSizeH, Wintitle) ; Now move the active window to it's new windows storage location
			WP1 := "YES"								; Now set the indictor that a window is stored in location 1
			WinStorInfo(&PP)
			WinSetTransparent 130, TiTle1				; Set the moved window Transparent.
		}
		else
			ActWinIN(&XX, &YY, &PP)						; Someone tryed to store another active window in storage position 1
														; Send an error massage that there is all ready a window stored in position 1
	}

	Return												; exit this routine and wait for another Alt/Ctrl Numpad request
}
How can i get this routine to not through up a error message? The routine works like it wa scriped to but just put up the error message only on a ALT-NUMPAD routine request.

Post Reply

Return to “Ask for Help (v2)”