[SOLVED] Second GUI displays Blank Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
HotkeyPOC
Posts: 2
Joined: 14 Oct 2018, 21:16

[SOLVED] Second GUI displays Blank

14 Oct 2018, 21:41

Hey guys! I'm new to the forums and relatively new to using AHK.

I am running into an issue with my script showing my second GUI. Both GUIs are meant to replicate a simple MsgBox and prevent users from continuing until they have selected "OK" or something similar.

Note: I use GUIs instead of MsgBoxes simply because I can center the GUI on the active window more easily, which is necessary since my team at work uses multiple monitors/displays.

The first GUI window works perfectly, but when my script attempts to Show the second GUI window, I get a blank window popup that can only be exited if the AHK file is exited.

Until I can get the second one to work, I will resort to just using the first, but having that second window is very helpful for my team at work since we process so many requests (as a support office). Any help is greatly appreciated!

Here is my code as well:

Code: Select all

Gui1:
	Gui 1:New,, Loading...
	Gui 1:+AlwaysOnTop +ToolWindow -Caption +Border
	Gui 1:Color, White
	Gui 1:Font, s11, Segoe UI
	Gui 1:Add, Text,, % "Continue after page loads!"
	Gui 1:Add, Text ; spacer
	Gui 1:Add, Button, Default w80 gOK, OK
return

Gui2:
	Gui 2:New,, Professional Counseling
	Gui 2:Default
	Gui 2:+AlwaysOnTop +ToolWindow -Caption +Border
	Gui 2:Color, White
	Gui 2:Font, s11, Segoe UI
	Gui 2:Add, Text,, % "If COEX-MA-D, Select 50+ sections only!"
	Gui 2:Add, Text ; spacer
	Gui 2:Add, Button, Default w80 gTYBRO, Thanks Bro!
return

OK:
{
	Gui 1:Cancel
		sleep 50
	If (CourseSub = "COUN")
		gosub, COUN
	else
		gosub, SearchAndSelect
}
return

TYBRO:
{
	Gui 2:Cancel
}
return

GuiClose: 
2GuiClose:

; ----------------------------------------------------------------- ;

SmartReg:
#IfWinActive, Manual Registration
`::
	Send, {Shift down}{Home}{Shift up}
		sleep 20
	Send, ^c
		sleep 20
	ClipWait
	RegClip := Clipboard
	{
		CourseSub := SubStr(RegClip, 1, 4)
		CourseNum := SubStr(RegClip, 6, 3)
		CourseSec := SubStr(RegClip, 10, 1)
	}
		sleep 200
	Send ^{pgdn}
		sleep 100
	Send {F6}
		sleep 300
	Send {F9}
		sleep 300
	WinGetPos mX, mY, mW, mH, Application Navigator
	Gui 1:Show, % "x" mX+(mW/2)-100 " y" mY+(mH/2)-50 " w225 h125", Loading...
return

SearchAndSelect:
{
	Loop, 2
	{
		Send {tab}
			sleep 50
	}
	SendInput 1%CourseSec%
		sleep 75
	Loop, 2
	{
		Send {tab}
			sleep 50
	}
	SendInput %CourseSub%
		sleep 75
	Loop, 2
	{
		Send {tab}
			sleep 50
	}
	SendInput %CourseNum%
		sleep 75
	Loop, 4
	{
		Send {tab}
			sleep 50
	}
	Send {down}
		sleep 75
	SendInput >0
		sleep 175
	Send {F8}
		sleep 150
	Send !s
		sleep 150
	Send {Esc}
}
return

COUN:
{
	Loop, 2
	{
		Send {tab}
			sleep 50
	}
	SendInput 1%CourseSec%
		sleep 75
	Loop, 2
	{
		Send {tab}
			sleep 50
	}
	SendInput %CourseSub%
		sleep 75
	Loop, 2
	{
		Send {tab}
			sleep 50
	}
	SendInput %CourseNum%
		sleep 75
	Loop, 4
	{
		Send {tab}
			sleep 50
	}
	Send {down} 	
		sleep 75
	SendInput >0
		sleep 175
	Send {F8}
		sleep 50
	Gui 2:Show, % "x" mX+(mW/2)-100 " y" mY+(mH/2)-50 " w225 h125", Professional Counseling
}
return	
Last edited by HotkeyPOC on 15 Oct 2018, 13:10, edited 2 times in total.
just me
Posts: 9458
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Second GUI displays Blank  Topic is solved

14 Oct 2018, 23:36

Code: Select all

...
return ; <<<<< the following code will never be executed because of this return

Gui2:
	Gui 2:New,, Professional Counseling
	Gui 2:Default
	Gui 2:+AlwaysOnTop +ToolWindow -Caption +Border
	Gui 2:Color, White
	Gui 2:Font, s11, Segoe UI
	Gui 2:Add, Text,, % "If COEX-MA-D, Select 50+ sections only!"
	Gui 2:Add, Text ; spacer
	Gui 2:Add, Button, Default w80 gTYBRO, Thanks Bro!
return
-> Why do some lines in my script never execute?
HotkeyPOC
Posts: 2
Joined: 14 Oct 2018, 21:16

Re: Second GUI displays Blank

15 Oct 2018, 13:08

@just me

Thanks for pointing that out! I was not aware I needed to execute these immediately, but after re-reading the Gui section in the Help file it makes sense. I was scouring all over the Gui section for an answer and thought maybe I had something wrong with identifying the Gui windows. It works just fine now that I removed the return from Gui1.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 235 guests