Blue_Drache Posted April 16, 2007 Share Posted April 16, 2007 Attached is the code in question. Never mind the remmed out #include, it makes no difference to the problem. Anyway, the GUI was working flawlessly until I decided to put in a standard window menu. I created them, added them to the loop, and bang... the main GUI loop is reading the $mnuitem events without user input. What have I done wrong? expandcollapse popup#region - Includes and Options ; #include <BCBS-SupportFunctions.au3> ; REM this out at home, unrem at work. #include <IE.au3> #include <GUIConstants.au3> #include <Date.au3> Opt("TrayIconDebug", 1) Opt("WinTitleMatchMode", 4) #endregion #region - Global Variables ; Declare constants Global Const $h_black = 0x000000, $h_red = 0xFF0000, $h_green = 0x00FF00, $h_blue = 0x0000FF Global Const $h_cyan = 0x00FFFF, $h_magenta = 0xFF00FF, $h_yellow = 0xFFFF00, $h_white = 0xFFFFFF ; Declare objects and window handles. These are global. Global $oIE_CRU, $oCRUForm, $o_fCRUSearchValue, $o_fCRUSearchField, $o_fCRUSelect Global $oIE_RTB, $oRTBFormMember, $oRTBFormPatient, $o_fRTBDivision, $o_fRTBGroup, $o_fRTBIDNumber, $a_RTBTable[2] Global $oIE_FSS, $oFSSForm, $o_fFSSSearchValue, $o_fFSSSearchField, $o_fFSSSelect Global $hwndFile, $hwndCRU, $hwndRTB, $objTemp ; Declare String variables Dim $strMSG, $strResponse, $strIndexNumber, $strDCN, $strGroup, $strUID, $strSCCF, $strPaid Dim $strPaidDate, $strCXDate, $strFName, $strLName ; Declare Integer variables Dim $intCount, $intLoop, $i_debug, $intDateDiff, $intModFlag ; Declare Binaries and Variants Dim $varTemp, $binASO, $binRecoverable, $varWin #endregion #region - Initialize Non-GUI Variables ; Initialize variables. $varWin = $c If Not WinExists($c) Then $varWin = $d $i_debug = 1 ; debug message box control. Set to 1 to turn on message box notification. Also handles CrashRun() functionality. $hwndFile = FileOpen(@TempDir & "\IETemp.txt", 2) If @error Then DBP("File Creation Error", 80, $i_debug) Exit 80 EndIf $prevlicp = ClipGet() $version = "CRU Assist - v 0.30" SetVersion ($version) #endregion #region - GUI Variables ; Declare main GUI variables Dim $hwndGUI, $guiHelp, $gui_MSG, $guiTemp, $winSize ; Declare buttons Dim $btnGo, $btnLaunchRTB, $btnLaunchCRU, $btnLaunchFSS, $btnExit ; Declare labels Dim $lblCRU, $lblCRUText[3], $lblRTB[2], $lblFSS[2], $lblGreen[4], $lblRed[4] ; Declare imgages Dim $imgGreen[4], $imgRed[4], $imgYellow[4], $imgCorpLogo $imgGreen[0] = @ScriptDir & "\Green.gif" $imgRed[0] = @ScriptDir & "\Red.gif" $imgYellow[0] = @ScriptDir & "\Yellow.gif" ; Declare text input boxes Dim $nptIndex ; Declare checkmark boxes Dim $chkSteps[21] ; Set this back down if there aren't 20 steps. $chkSteps[0] = UBound($chkSteps) - 1 ; Declare the menus and items Dim $mnuCfg, $mnuHelp, $mnuitemOptions, $mnuitemHelp, $mnuitemAbout #endregion #region - GUI Create $hwndGUI = GUICreate($version & " - GUI", 450, 400, 0, 0) $winSize = WinGetPos($hwndGUI) WinMove($hwndGUI, "", @DesktopWidth / 2 - $winSize[2] / 2, 0) ; center on monitor width at top. Default position. Write config file to remember last position. $mnuCfg = GUICtrlCreateMenu("&Config") $mnuitemOptions = GUICtrlCreateMenuitem("&Options", $mnuCfg) $mnuHelp = GUICtrlCreateMenu("&Help") $mnuitemHelp = GUICtrlCreateMenuitem("Help" & @TAB & "F1", $mnuHelp) $mnuitemAbout = GUICtrlCreateMenuitem("&About", $mnuHelp) $nptIndex = GUICtrlCreateInput("", 15, 15, ($winSize[2] / 2) - 100, 20) $guiTemp = ControlGetPos($hwndGUI, "", $nptIndex) $btnGo = GUICtrlCreateButton("&Go", ($guiTemp[2] / 2) - 20, $guiTemp[1] + $guiTemp[3] + 5, 60, 25) $btnExit = GUICtrlCreateButton("E&xit", ($guiTemp[2] / 2), $winSize[3] - 85, 60, 25) $imgRed[1] = GUICtrlCreatePic($imgRed[0], $guiTemp[0] + 15, $guiTemp[1] + $guiTemp[3] + 45, 35, 35) $imgYellow[1] = GUICtrlCreatePic($imgYellow[0], $guiTemp[0] + 15, $guiTemp[1] + $guiTemp[3] + 45, 35, 35) $imgGreen[1] = GUICtrlCreatePic($imgGreen[0], $guiTemp[0] + 15, $guiTemp[1] + $guiTemp[3] + 45, 35, 35) GUICtrlSetState($imgRed[1], $GUI_HIDE) GUICtrlSetState($imgYellow[1], $GUI_HIDE) $guiTemp = ControlGetPos($hwndGUI, "", $imgGreen[1]) $lblCRUText[0] = "CRU Not Detected" ; red $lblCRUText[1] = "CRU Detected and Enabled" ; green $lblCRUText[2] = "Please update claim." ; yellow $lblCRU = GUICtrlCreateLabel($lblCRUText[1], $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1], $winSize[2] / 2 - 45, $guiTemp[3]) $btnLaunchCRU = GUICtrlCreateButton("Lauch &CRU Website", $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1] + $guiTemp[3], 150, 25) GUICtrlSetState($btnLaunchCRU, $GUI_DISABLE) $imgGreen[2] = GUICtrlCreatePic($imgGreen[0], $guiTemp[0], $guiTemp[1] + $guiTemp[3] + 45, 35, 35) $imgRed[2] = GUICtrlCreatePic($imgRed[0], $guiTemp[0], $guiTemp[1] + $guiTemp[3] + 45, 35, 35) GUICtrlSetState($imgRed[2], $GUI_HIDE) $guiTemp = ControlGetPos($hwndGUI, "", $imgGreen[2]) $lblRTB[0] = GUICtrlCreateLabel("RTB Not Detected", $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1], $winSize[2] / 2 - 45, $guiTemp[3]) GUICtrlSetState($lblRTB[0], $GUI_HIDE) $lblRTB[1] = GUICtrlCreateLabel("RTB Detected and Enabled", $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1], $winSize[2] / 2 - 45, $guiTemp[3]) $btnLaunchRTB = GUICtrlCreateButton("Lauch &RTB Website", $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1] + $guiTemp[3], 150, 25) GUICtrlSetState($btnLaunchRTB, $GUI_DISABLE) $imgGreen[3] = GUICtrlCreatePic($imgGreen[0], $guiTemp[0], $guiTemp[1] + $guiTemp[3] + 45, 35, 35) $imgRed[3] = GUICtrlCreatePic($imgRed[0], $guiTemp[0], $guiTemp[1] + $guiTemp[3] + 45, 35, 35) GUICtrlSetState($imgRed[3], $GUI_HIDE) $guiTemp = ControlGetPos($hwndGUI, "", $imgGreen[3]) $lblFSS[0] = GUICtrlCreateLabel("FSS Not Detected", $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1], $winSize[2] / 2 - 45, $guiTemp[3]) GUICtrlSetState($lblFSS[0], $GUI_HIDE) $lblFSS[1] = GUICtrlCreateLabel("FSS Detected and Enabled", $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1], $winSize[2] / 2 - 45, $guiTemp[3]) $btnLaunchFSS = GUICtrlCreateButton("Lauch &FSS Website", $guiTemp[0] + $guiTemp[2] + 10, $guiTemp[1] + $guiTemp[3], 150, 25) GUICtrlSetState($btnLaunchFSS, $GUI_DISABLE) GUICtrlCreateGroup("Progress Meter", ($winSize[2] / 2) + 10, $guiTemp[0], ($winSize[2] / 2) - 30, $winSize[3] - 75) GUICtrlSetState($btnGo, $GUI_DEFBUTTON) GUICtrlSetTip($nptIndex, "Enter the CRU Tracking Number here.") GUICtrlSetTip($btnGo, "Start the process") GUICtrlSetTip($btnExit, "Exit the program.") GUICtrlSetTip($btnLaunchCRU, "Launch IE and display the CRU login") GUISetHelp('Notepad "' & @ScriptDir & '\help.txt"') $hwndCRU = WinGetHandle("FSU Detail", "") ; get CRU window handle If @error Then ; set lolipop to red on GUI and activate greyed out "launch" button GUICtrlSetData($lblCRU, $lblCRUText[0]) GUICtrlSetState($imgGreen[1], $GUI_HIDE) GUICtrlSetState($imgRed[1], $GUI_SHOW) GUICtrlSetState($btnLaunchCRU, $GUI_ENABLE) DBP("Unable to locate Claims Recovery window", 0, 0) EndIf $hwndRTB = WinGetHandle("Real Time Benefits", "") ; get RTB window handle If @error Then ; set lolipop to red on GUI and activate greyed out "launch" button GUICtrlSetState($lblRTB[1], $GUI_HIDE) GUICtrlSetState($lblRTB[0], $GUI_SHOW) GUICtrlSetState($imgGreen[2], $GUI_HIDE) GUICtrlSetState($imgRed[2], $GUI_SHOW) GUICtrlSetState($btnLaunchRTB, $GUI_ENABLE) DBP("Unable to locate Real Time Benefits window", 0, 0) EndIf $hwndFSS = WinGetHandle("FSS", "") ; get window handle If @error Then ; set lolipop to red on GUI and activate greyed out "launch" button GUICtrlSetState($lblFSS[1], $GUI_HIDE) GUICtrlSetState($lblFSS[0], $GUI_SHOW) GUICtrlSetState($imgGreen[3], $GUI_HIDE) GUICtrlSetState($imgRed[3], $GUI_SHOW) GUICtrlSetState($btnLaunchFSS, $GUI_ENABLE) DBP("Unable to locate Financial Suspense System window", 0, 0) EndIf #endregion #region - Primary GUI Data Loop GUISetState(@SW_SHOW, $hwndGUI) While 1 Sleep(10) If Mod(@SEC, 7) = 0 Then ; Check the status of the buttons and lamps once every 7 seconds. Change if required. If $intModFlag = 0 Then _LoliCheck() $intModFlag = 1 EndIf Else $intModFlag = 0 EndIf $gui_MSG = GUIGetMsg() Select Case $gui_MSG = $GUI_EVENT_CLOSE Or $gui_MSG = $btnExit Exit Case $gui_MSG = $btnGo _btn("GO") DBP("Awaiting new input" & @LF, 0, 0) WinActivate($varWin) Case $gui_MSG = $btnLaunchCRU _btn("CRU") Case $gui_MSG = $btnLaunchRTB _btn("RTB") Case $gui_MSG = $btnLaunchFSS _btn("FSS") case $mnuitemOptions MsgBox(0,$version,"Options not implemented yet") Case $mnuitemAbout MsgBox(0, $version, $version) Case $mnuitemHelp Run('Notepad "' & @ScriptDir & '\help.txt"') EndSelect WEnd Exit #endregion Func CrashRun($oIE, $i_flag = 0) ClipPut(_IEDocReadHTML($oIE)) If $i_flag = 0 Then FileWrite($hwndFile, _IEDocReadHTML($oIE)) FileClose($hwndFile) Run('Notepad "' & @TempDir & '\IETemp.txt"') Sleep(1000) FileDelete($hwndFile) EndIf EndFunc ;==>CrashRun Func DBP($s_msg, $i_err = 0, $i_flag = 0) ; s_msg is the message displayed, $i_err is the error code ; $i_flag toggles messagebox display. Easily converts your debug notes into a custom errorhandler $s_msg = "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] " & $s_msg ConsoleWrite($s_msg & " Error: " & $i_err & @LF) If $i_flag = 1 Then MsgBox(0x1010, $version, $s_msg & @LF & "Error: " & $i_err) SetError($i_err) ; returns $i_err as @error EndFunc ;==>DBP Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Blue_Drache Posted April 17, 2007 Author Share Posted April 17, 2007 bump. Please help. Thank you. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
GaryFrost Posted April 17, 2007 Share Posted April 17, 2007 bump. Please help. Thank you.Codes incomplete, either minimize the code so somone can help you or include all the functions/code being used. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Holger Posted April 17, 2007 Share Posted April 17, 2007 @Blue: Your problem is the "Select - Case" in the main msg loop. If you use "Select case" you need to use the "case" for every control like: ... case $gui_MSG = $mnuitemOptions ... Case $gui_MSG = $mnuitemAbout ... Otherwise you have to use "Switch - EndSwitch" like: ... $gui_MSG = GUIGetMsg() Switch $gui_MSG Case GUI_EVENT_CLOSE, $btnExit Exit ... case $mnuitemOptions MsgBox(0,$version,"Options not implemented yet") ... EndSwitch Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView Link to comment Share on other sites More sharing options...
Blue_Drache Posted April 17, 2007 Author Share Posted April 17, 2007 (edited) Codes incomplete, either minimize the code so somone can help you or include all the functions/code being used.Horse Hockey. All relevant code is included. In fact... to "minimize the code" I'd remove the two extra functions I included.@Blue: Your problem is the "Select - Case" in the main msg loop.Odd. *tinkers with the loop* Oh, jeez. I see what I did. I mixed Switch/Case syntax with Select/Case syntax. Thank you, Holger. Edited April 17, 2007 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
GaryFrost Posted April 17, 2007 Share Posted April 17, 2007 Horse Hockey. All relevant code is included. In fact... to "minimize the code" I'd remove the two extra functions I included.Odd. *tinkers with the loop* Oh, jeez. I see what I did. I mixed Switch/Case syntax with Select/Case syntax. Thank you, Holger. Wasn't in the mood to look through code that couldn't be run without errors, obviously Holger didn't mind.You know what you can do with Horse Hockey.... SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. 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