Jump to content

Can't get GUI box to close


MattX
 Share

Recommended Posts

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.

#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

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 line

Case $msg = $exititem
    ExitLoop
to
Case $msg = $exititem
    Exit
so that the script really exits? Edited 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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 line

Case $msg = $exititem
    ExitLoop
to
Case $msg = $exititem
    Exit
so that the script really exits?

Link to comment
Share on other sites

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Your fault !!??

Yes, my fault, because I've written the the part of code where the script went into an infinite loop Posted Image

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...