help with gui

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
G_Allen

help with gui

24 Sep 2017, 14:44

I have a gui (Gui 1:) that has a button when clicked opens another gui (gui 2:)
Gui 2: has two edit boxes, variables vSubj and vMsg.
Gui 2: has a button that runs an INIWrite script.
Once this is done, I no longer need Gui 2:
I need help with destroying Gui 2:, returning to Gui 1:, and proceeding with Process
User avatar
Spawnova
Posts: 554
Joined: 08 Jul 2015, 00:12
Contact:

Re: help with gui

24 Sep 2017, 15:01

To destroy gui 2, Gui 2:Destroy
Call that in your button press label.

If you still need help please post your code, it makes it much easier for us.
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: help with gui

24 Sep 2017, 15:08

Hi.
Try

Code: Select all

2GuiClose
or

Code: Select all

Gui, 2: destroy
in combine with

Code: Select all

Gui, 1: default
and similar commands.
As Spawnova said, without seeing your code, real sensible support is difficult.
Einfach nur ein toller Typ. :mrgreen:
G_Allen

Re: help with gui

24 Sep 2017, 16:33

When I run this, after the Write: label runs, when I try to input into the edit boxes on Gui 1, Gui 2 pops up again.

Code: Select all

#SingleInstance force
Gui, 1:New
Gui, Add, Picture,x152 y119 w250 h150 BackgroundTrans, C:\Users\Gary & Kim Miller\Documents\AutoHotkey\eTEXT_PCtoCellPhone.png
Gui, Add, Edit,  x152 y40 w40 h20 vArea Limit3 gLabel1, 
Gui, Add, Edit,  x202 y40 w40 h20 vPre Limit3 gLabel2, 
Gui, Add, Edit,  x252 y40 w60 h20 vNum Limit4 gLabel3, 
Gui, Add, Button, x320 y35 w90 h30 gSub1, Look Up Carrier
Gui, Add, Text, x37 y80 w400 h20 , If you know the cell phone provider, check below and send text.
gui, add, ComboBox, x37 y119 w90 h300 gChkCarrier vDDList, Altel|AT&T|Boost Mobile|Sprint|T-Mobile|US Cellular|Verizon|Virgin Mobile
Gui, Add, link, x150 y300 w300 h20, <a href="http://www.data24-7.com/signup.php?affcode=NCFC">Upgrade</a> to eMAIL Text to Cell Pro
Gui, Add, button, x150 y320 w30 h30 gLabel4, OK
Gui, Add, Text, x170 y320 w300 h20, Set/Change pre-set message.
Gui, Add, Button, x37 y250 w90 h30 gSub2, Send Text
Gui, Show, w473 h373 , 
return

ButtonOK:
Gui, Submit, NoHide
Sub1:
{
;MsgBox, %Area%%Pre%%Num%
Number = %Area%%Pre%%Num%
;Number := "4178613971"

web_browser := ComObjCreate("InternetExplorer.Application")

web_browser.Visible := true

web_browser.Navigate("http://www.freecarrierlookup.com/")
WinMaximize, % "ahk_id " web_browser.HWND
while web_browser.busy
	sleep 100

sleep 1000

input := web_browser.document.getElementById("large")

input.value := Number
sleep, 1000
}
ChkCarrier:

GuiControlGet, DDList 
;MsgBox  "%DDList%".


IfEqual, DDList, Altel
{
	;MsgBox,  %area%%Pre%%Num%@sms.altelwireless.com
	Carrier := "@sms.altelwireless.com"
	;MsgBox, %area%%Pre%%Num%%Carrier%
}	
IfEqual, DDList, AT&T
{
	Carrier := "@txt.att.net"
	;msgbox, %area%%Pre%%Num%@txt.att.net
}
IfEqual, DDList, Boost Mobile 
{
	Carrier := "@sms.myboostmobile.com"  
	;msgbox, %area%%Pre%%Num%@sms.myboostmobile.com  
}	
IfEqual, DDList, Sprint 
{
	Carrier := "@messaging.sprintpcs.com"
	;msgbox, %area%%Pre%%Num%@messaging.sprintpcs.com
}
IfEqual, DDList, T-Mobile
{
	Carrier := "@tmomail.net"
	;msgbox, %area%%Pre%%Num%@tmomail.net
}
IfEqual, DDList, United States Cellular Corp
{
	Carrier := "@email.uscc.net"
	;msgbox, %area%%Pre%%Num%@email.uscc.net
}
IfEqual, DDList, Verizon
{
	Carrier := "@vtext.com"
}
IfEqual, DDList, Virgin Mobile
{
	Carrier := "@vmobl.com"
	;msgbox, %Provider%
}
return
Sub2:
IniRead, Value, % INIFile, % TxtMsg, SubjectProgress, m2 b zh0, Text here
IniRead, Val, % INIFile,  % TxtMsg, Text_Body

Run, mailto:%area%%Pre%%Num%%Carrier%?subject=%Value%&body=%Val%
;Run "C:\Program Files\Microsoft Office 15\root\office15\OUTLOOK.EXE" /c ipm.note /m "%area%%Pre%%Num%%Carrier%&subject=S and H FARM SUPPLY &body=TheParts you ordered are here and ready for pick up. Thanks. No reply necessary."

return
Write:


INIWrite,%      "`tSubject`t`t= "      Field1  "`n"
           .    "`tText_Body`t= " Field2  "`n"
           
           ,% INIFile,% TexMsg 


Gui 2:Destroy

return

Label1:
 Gui, Submit, NoHide 
 If StrLen(Area) > 2
  GuiControl, Focus, Pre
  
 Label2:
 Gui, Submit, NoHide
 If StrLen(Pre) > 2
  GuiControl, Focus, Num 
 
 Label3:
 Gui, Submit, NoHide
 If StrLen(Num) > 3
  GuiControl, Focus, OK
  
Label4:

Gui, 2:new, , SetTextMessage
Gui, Add, Text, x10				w90		h20						, Subject: the subject line of your text. ;1st line shown in text message
Gui, Add, Text, x+20			wp30	hp						, Your text message.
Gui, Add, Edit, x10		y+10	wp		hp		vField1 		, Your Name/Business
Gui, Add, Edit, x+10	y36		w180	hp		vField2 		, The message you want to send.
Gui, Add, Button,x10	y+5		w70		h20		gWrite  		, Save
Gui, 2:Show

Return

Reload
Sleep 10000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
MsgBox, 4,, The script could not be reloaded. Would you like to open it for editing?
IfMsgBox, Yes, Edit
return
User avatar
Spawnova
Posts: 554
Joined: 08 Jul 2015, 00:12
Contact:

Re: help with gui

24 Sep 2017, 20:11

The reason that happens is because you have no returns on your labels, so the code keeps going down until it reaches a return, once it leaves label3 it goes right into label4, which creates gui 2
adding a return after those labels will fix that issue, however there are several other small issues as well. I've edited your script that should fix the problems.

Code: Select all

#SingleInstance force

INIFile := "phone.ini" ;you have reference to an INIFile variable

Carriers := [] ;create empty array
Carriers["Altel"] := "@sms.altelwireless.com" ;array[provider] := address
Carriers["AT&T"] := "@txt.att.net"
Carriers["Boost Mobile"] := "@sms.myboostmobile.com"
Carriers["Sprint"] := "@messaging.sprintpcs.com"
Carriers["T-Mobile"] := "@tmomail.net"
Carriers["US Cellular"] := "@email.uscc.net"
Carriers["Verizon"] := "@vtext.com"
Carriers["Virgin Mobile"] := "@vmobl.com"

Gui, 1:New
;Gui, Add, Picture,x152 y119 w250 h150 BackgroundTrans, C:\Users\Gary & Kim Miller\Documents\AutoHotkey\eTEXT_PCtoCellPhone.png
Gui, Add, Edit,  x152 y40 w40 h20 vArea Limit3 gLabel1, 
Gui, Add, Edit,  x202 y40 w40 h20 vPre Limit3 gLabel2, 
Gui, Add, Edit,  x252 y40 w60 h20 vNum Limit4 gLabel3, 
Gui, Add, Button, x320 y35 w90 h30 gSub1, Look Up Carrier
Gui, Add, Text, x37 y80 w400 h20 , If you know the cell phone provider, check below and send text.
gui, add, ComboBox, x37 y119 w90 h300 gChkCarrier vDDList, Altel|AT&T|Boost Mobile|Sprint|T-Mobile|US Cellular|Verizon|Virgin Mobile
Gui, Add, link, x150 y300 w300 h20, <a href="http://www.data24-7.com/signup.php?affcode=NCFC">Upgrade</a> to eMAIL Text to Cell Pro
Gui, Add, button, x150 y320 w30 h30 gLabel4, OK
Gui, Add, Text, x170 y320 w300 h20, Set/Change pre-set message.
Gui, Add, Button, x37 y250 w90 h30 gSub2, Send Text
Gui, Show, w473 h373 , 
return

Sub1:
gui,submit,nohide
Number := area pre num

web_browser := ComObjCreate("InternetExplorer.Application")
web_browser.Visible := true
web_browser.Navigate("http://www.freecarrierlookup.com/")

WinMaximize, % "ahk_id " web_browser.HWND
while web_browser.busy
	sleep 100
sleep 1000

input := web_browser.document.getElementById("large")
input.value := Number
return

ChkCarrier:
GuiControlGet, DDList 	
Carrier := Carriers[DDList]
return

Sub2:
IniRead, subjectText, % INIFile, settings, subject, defaultTextIfEmpty
IniRead, bodyText, % INIFile, settings, body, defaultTextIfEmpty
msgbox % "mailto:" area Pre Num Carrier "?subject=" subjectText "&body=" bodyText
Run, % "mailto:" area Pre Num Carrier "?subject=" subjectText "&body=" bodyText
;Run "C:\Program Files\Microsoft Office 15\root\office15\OUTLOOK.EXE" /c ipm.note /m "%area%%Pre%%Num%%Carrier%&subject=S and H FARM SUPPLY &body=TheParts you ordered are here and ready for pick up. Thanks. No reply necessary."
return

Write:
gui 2:submit,nohide
INIWrite,% Field1,% INIFile,settings,subject
INIWrite,% Field2,% INIFile,settings,body
Gui 2:Destroy
return

Label1:
 Gui, Submit, NoHide 
 If StrLen(Area) > 2
  GuiControl, Focus, Pre
return
  
Label2:
 Gui, Submit, NoHide
 If StrLen(Pre) > 2
  GuiControl, Focus, Num
return
 
Label3:
 Gui, Submit, NoHide
 If StrLen(Num) > 3
  GuiControl, Focus, OK
return
 
Label4:
Gui, 2:new, , SetTextMessage
Gui, Add, Text, x10				w90		h20						, Subject: the subject line of your text. ;1st line shown in text message
Gui, Add, Text, x+20			wp30	hp						, Your text message.
Gui, Add, Edit, x10		y+10	wp		hp		vField1 		, Your Name/Business
Gui, Add, Edit, x+10	y36		w180	hp		vField2 		, The message you want to send.
Gui, Add, Button,x10	y+5		w70		h20		gWrite  		, Save
Gui, 2:Show
Return
Guest

Re: help with gui

24 Sep 2017, 20:24

Thanks, Spawnova

I had just noticed the missing returns and had come back to my post to tell you I had found the problem.
Thanks again Spawnova for helping with cleaning up my script.
My education in
AutoHotKey continues to grow.
Thanks.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 338 guests