goodone Posted September 23, 2018 Share Posted September 23, 2018 (edited) Hi, Newbie here... I have these mixed of code from autoit forum and combined to request user to send email with their order # for order verification. It works correctly if I use only FORM2 GUI and problem arise, When I add form 2 after form 1. Most likely I am calling it wrongly. and mixed of while loop blocking me going to "congrats msg". After typing order number and clicking Ok, it should call the sendmail function and will show that congrats msg. It only works if I delete the first while loop after Form1 and call RequestAccessCode() function directly. Can someone please tell me how do I correct this? Thanks expandcollapse popup#Region ### START Koda GUI section ### $Form1 = GUICreate("Beta", 516, 220, -1, -1) $Group4 = GUICtrlCreateGroup(" ACCESS CODE", 201, 16, 129, 81) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $REQUESTCODE = GUICtrlCreateButton("REQUEST", 216, 47, 97, 33) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $REQUESTCODE RequestAccessCode() EndSwitch WEnd Func RequestAccessCode() MsgBox($MB_SYSTEMMODAL, "Notice!", "Demo Notice") Sleep(500) $Form2 = GUICreate("Access Code Request Form", 251, 161, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) $label1 = GUICtrlCreateLabel("Inpute your order" & @CRLF & "number", 50, 20) Global $Input1 = GUICtrlCreateInput("", 24, 96, 201, 21, $ES_NUMBER) GUICtrlSetLimit(-1, 4) Global $Button1 = GUICtrlCreateButton("OK", 24, 128, 75, 25) Global $Button2 = GUICtrlCreateButton("Cancel", 152, 130, 75, 25) GUISetState(@SW_SHOW) EndFunc While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 If StringLen(GUICtrlRead($Input1)) < 4 Then GUICtrlSetData($Input1, "") Else Sleep(1000) SendRequestEmail() Sleep(1000) MsgBox($MB_SYSTEMMODAL, "", "Congrats Msg") Exit EndIf Case $Button2 Exit EndSwitch WEnd Func SendRequestEmail() $OrderNumber = GUICtrlRead($Input1) ;~ Email function EndFunc ;==>SendRequestEmail Edited September 23, 2018 by goodone Link to comment Share on other sites More sharing options...
careca Posted September 24, 2018 Share Posted September 24, 2018 I would suggest using "on event" instead of getmsg, only one loop with everything. Can't atm do anything with your code as im not home. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Zedna Posted September 24, 2018 Share Posted September 24, 2018 Definitely look here: https://www.autoitscript.com/wiki/Managing_Multiple_GUIs Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted September 24, 2018 Share Posted September 24, 2018 Here is your code with fixed the most obvious mistakes: expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Global $Input1 #region ### START Koda GUI section ### $Form1 = GUICreate("Beta", 516, 220, -1, -1) $Group4 = GUICtrlCreateGroup(" ACCESS CODE", 201, 16, 129, 81) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $REQUESTCODE = GUICtrlCreateButton("REQUEST", 216, 47, 97, 33) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $REQUESTCODE RequestAccessCode() EndSwitch WEnd Func RequestAccessCode() MsgBox($MB_SYSTEMMODAL, "Notice!", "Demo Notice") $Form2 = GUICreate("Access Code Request Form", 251, 161, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) $label1 = GUICtrlCreateLabel("Inpute your order" & @CRLF & "number", 50, 20) Global $Input1 = GUICtrlCreateInput("", 24, 96, 201, 21, $ES_NUMBER) GUICtrlSetLimit(-1, 4) Global $Button1 = GUICtrlCreateButton("OK", 24, 128, 75, 25) Global $Button2 = GUICtrlCreateButton("Cancel", 152, 130, 75, 25) GUISetState(@SW_SHOW, $Form2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 If StringLen(GUICtrlRead($Input1)) < 4 Then GUICtrlSetData($Input1, "") Else SendRequestEmail() MsgBox($MB_SYSTEMMODAL, "", "Congrats Msg") ExitLoop EndIf Case $Button2 ExitLoop EndSwitch WEnd GUISetState(@SW_HIDE, $Form2) EndFunc ;==>RequestAccessCode Func SendRequestEmail() $OrderNumber = GUICtrlRead($Input1) MsgBox(0, "Email Test", $OrderNumber) ;~ Email function EndFunc ;==>SendRequestEmail goodone 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
goodone Posted September 24, 2018 Author Share Posted September 24, 2018 16 hours ago, Zedna said: Here is your code with fixed the most obvious mistakes: expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Global $Input1 #region ### START Koda GUI section ### $Form1 = GUICreate("Beta", 516, 220, -1, -1) $Group4 = GUICtrlCreateGroup(" ACCESS CODE", 201, 16, 129, 81) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $REQUESTCODE = GUICtrlCreateButton("REQUEST", 216, 47, 97, 33) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $REQUESTCODE RequestAccessCode() EndSwitch WEnd Func RequestAccessCode() MsgBox($MB_SYSTEMMODAL, "Notice!", "Demo Notice") $Form2 = GUICreate("Access Code Request Form", 251, 161, -1, -1, BitXOR($GUI_SS_DEFAULT_GUI, $WS_MINIMIZEBOX)) $label1 = GUICtrlCreateLabel("Inpute your order" & @CRLF & "number", 50, 20) Global $Input1 = GUICtrlCreateInput("", 24, 96, 201, 21, $ES_NUMBER) GUICtrlSetLimit(-1, 4) Global $Button1 = GUICtrlCreateButton("OK", 24, 128, 75, 25) Global $Button2 = GUICtrlCreateButton("Cancel", 152, 130, 75, 25) GUISetState(@SW_SHOW, $Form2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 If StringLen(GUICtrlRead($Input1)) < 4 Then GUICtrlSetData($Input1, "") Else SendRequestEmail() MsgBox($MB_SYSTEMMODAL, "", "Congrats Msg") ExitLoop EndIf Case $Button2 ExitLoop EndSwitch WEnd GUISetState(@SW_HIDE, $Form2) EndFunc ;==>RequestAccessCode Func SendRequestEmail() $OrderNumber = GUICtrlRead($Input1) MsgBox(0, "Email Test", $OrderNumber) ;~ Email function EndFunc ;==>SendRequestEmail Thank you very much. This worked perfectly fine Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now