MattX Posted November 27, 2009 Share Posted November 27, 2009 What am I missing here ? The hotkey works fine - it brings up the GUI box with both buttons but I want to be able to close the box as well but still have the main script running. The GUI box is inside the showmessage() func. I would apprecite some help or guidence. expandcollapse popup#Include <Constants.au3> #include <ScreenCapture.au3> #include <IE.au3> Dim $portalsite = "http://stjohns02:9675/helpdesk" Dim $helpdesk_screenshots = "c:\helpdesk_screenshots" Opt("TrayMenuMode",1) HotKeySet("+!h", "ShowMessage") ;Shift-Alt-h If FileExists("c:\helpdesk_screenshots") Then FileDelete("c:\helpdesk_screenshots\*.jpg") Else DirCreate("c:\helpdesk_screenshots") EndIf Func ShowMessage() $Form1 = GUICreate("Portal Launcher", 220, 110, 348, 309) $helpmenu = GUICtrlCreateMenu("Help") $infoitem = GUICtrlCreateMenuitem("About", $helpmenu) GUISetBkColor(0x0066FF) $Button1 = GUICtrlCreateButton("Screen Shot", 10, 20, 89, 49 ) $Button2 = GUICtrlCreateButton("To Portal", 120, 20, 89, 49 ) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $Button1 _ScreenCapture_Capture($helpdesk_screenshots & "\helpdesk_Image1.jpg") sleep(2000) _IECreate($portalsite) Case $nMsg = $Button2 _IECreate($portalsite) Case $nMsg = $infoitem MsgBox(0, "Portal Launcher 1B", "Written By Matt." & @CRLF & "Comments & Suggestions to:" & @CRLF & "matt") EndSelect WEnd EndFunc $settingsitem = TrayCreateMenu("Settings") $displayitem = TrayCreateItem("Screen Shot", $settingsitem) $portal = TrayCreateItem("Portal", $settingsitem) TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop case $msg = $displayitem _ScreenCapture_Capture($helpdesk_screenshots & "\helpdesk_Image1.jpg") sleep(2000) _IECreate($portalsite) case $msg = $portal _IECreate($portalsite) Case $msg = $aboutitem MsgBox(0, "Portal Launcher 1B", "Written By Matt." & @CRLF & "Comments & Suggestions to:" & @CRLF & "matt") ; Remember to comment out $exititem so prog can't be closed or keep it in if you want users to close !! Case $msg = $exititem ExitLoop EndSelect WEnd Link to comment Share on other sites More sharing options...
water Posted November 27, 2009 Share Posted November 27, 2009 (edited) Insert #include <GUIConstants.au3> at the beginning of your script and change your GUI-loop to: While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $Button1 _ScreenCapture_Capture($helpdesk_screenshots & "\helpdesk_Image1.jpg") sleep(2000) _IECreate($portalsite) Case $nMsg = $Button2 _IECreate($portalsite) Case $nMsg = $infoitem MsgBox(0, "Portal Launcher 1B", "Written By Matt." & @CRLF & "Comments & Suggestions to:" & @CRLF & "matt") Case $nMsg = $GUI_EVENT_CLOSE GUIDelete($Form1) EndSelect WEnd And shouldn't you change lineCase $msg = $exititem ExitLooptoCase $msg = $exititem Exitso that the script really exits? Edited November 27, 2009 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
MattX Posted November 27, 2009 Author Share Posted November 27, 2009 Thanks - working great now. Trust me to forget the GUIConstants. [ That will teach me for re-using code from another one of my old scripts !! ] Insert #include <GUIConstants.au3> at the beginning of your script and change your GUI-loop to: While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $Button1 _ScreenCapture_Capture($helpdesk_screenshots & "\helpdesk_Image1.jpg") sleep(2000) _IECreate($portalsite) Case $nMsg = $Button2 _IECreate($portalsite) Case $nMsg = $infoitem MsgBox(0, "Portal Launcher 1B", "Written By Matt." & @CRLF & "Comments & Suggestions to:" & @CRLF & "matt") Case $nMsg = $GUI_EVENT_CLOSE GUIDelete($Form1) EndSelect WEnd And shouldn't you change lineCase $msg = $exititem ExitLooptoCase $msg = $exititem Exitso that the script really exits? Link to comment Share on other sites More sharing options...
MattX Posted November 27, 2009 Author Share Posted November 27, 2009 One more quick question, after the hotkey has been used, how come the options in the system tray no longer work ? [ even after closing the GUI box ? ] Link to comment Share on other sites More sharing options...
water Posted November 27, 2009 Share Posted November 27, 2009 My fault Please insert a "Return" so that the script leaves the SHowMessage function: Case $nMsg = $GUI_EVENT_CLOSE GUIDelete($Form1) Return ; <== Was missing My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
MattX Posted November 27, 2009 Author Share Posted November 27, 2009 My fault Please insert a "Return" so that the script leaves the SHowMessage function: Case $nMsg = $GUI_EVENT_CLOSE GUIDelete($Form1) Return ; <== Was missing Your fault !!?? You have helped me out !! Thanks. Link to comment Share on other sites More sharing options...
water Posted November 27, 2009 Share Posted November 27, 2009 Your fault !!??Yes, my fault, because I've written the the part of code where the script went into an infinite loop But on the other hand i wished that all mistakes I make are as easily to locate and repair My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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