Jump to content

problem after clicking start button


vladedoty
 Share

Recommended Posts

i have this problem with my GUI.

I have a start button that goes to a function.

after clicking the start button, I click the x to exit out and nothing happens. But before the start button i pressed it works fine

I also have a tray icon with the exit on it but that works fine.

Here is some of my script.

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode",1)   ;==>MinToTray
Opt("TrayAutoPause",0)
Global $mainGui = GUICreate("Program", 633, 454, 192, 114)
Global $nMsg
Global $botPath, $profPath

Global $startBtn = GUICtrlCreateButton("Start", 336, 416, 123, 25, BitOR($WS_GROUP,$WS_BORDER))
GUICtrlSetFont($startBtn, 10, 800, 0, "MS Sans Serif")
Global $path = GUICtrlCreateButton("....", 551, 231, 33, 21, $WS_GROUP)
Global $text = GUICtrlCreateButton("....", 551, 263, 33, 21, $WS_GROUP)

TraySetIcon()
$hideitem = TrayCreateItem("Hide")
TrayItemSetOnEvent(-1,"Hide")
$restoreitem = TrayCreateItem("Restore")
TrayItemSetOnEvent(-1,"RestoreClick")
$aboutitem  = TrayCreateItem("About")
TrayItemSetOnEvent(-1,"AboutClick")
$exititem  = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitEvent")
TraySetState()

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $startBtn
            Start()
        Case $cmdPath
            Path()
        Case $cmdText
            Text()
    EndSwitch
WEnd

func Path()
    $path = FileOpenDialog("Outlook.exe", "C:\", "Execute (*.exe)") ; browse for file
    GUICtrlSetData($pathTxt, $path) ; display file path in text box
EndFunc

func Text()
    $text = FileOpenDialog("", "C:\", "Text (*.txt)") ; browse for file
    GUICtrlSetData($TextTxt, $text) ; display file path in text box
EndFunc

Func Hide()
    GUISetState(@SW_HIDE, $mainGUI)
EndFunc

Func AboutClick()
    MsgBox(64, "About", "coded by vladedoty.  This version is a basic version.  Updates and upgrades will be made continuously.")
EndFunc   ;==>AboutClicked

Func RestoreClick()
    GUISetState(@SW_SHOW, $mainGUI)
EndFunc   ;==>RestoreClicked

Func ExitEvent()
    Exit
EndFunc
Link to comment
Share on other sites

i have this problem with my GUI.

I have a start button that goes to a function.

after clicking the start button, I click the x to exit out and nothing happens. But before the start button i pressed it works fine

I also have a tray icon with the exit on it but that works fine.

Here is some of my script.

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode",1)   ;==>MinToTray
Opt("TrayAutoPause",0)
Global $mainGui = GUICreate("Program", 633, 454, 192, 114)
Global $nMsg
Global $botPath, $profPath

Global $startBtn = GUICtrlCreateButton("Start", 336, 416, 123, 25, BitOR($WS_GROUP,$WS_BORDER))
GUICtrlSetFont($startBtn, 10, 800, 0, "MS Sans Serif")
Global $path = GUICtrlCreateButton("....", 551, 231, 33, 21, $WS_GROUP)
Global $text = GUICtrlCreateButton("....", 551, 263, 33, 21, $WS_GROUP)

TraySetIcon()
$hideitem = TrayCreateItem("Hide")
TrayItemSetOnEvent(-1,"Hide")
$restoreitem = TrayCreateItem("Restore")
TrayItemSetOnEvent(-1,"RestoreClick")
$aboutitem  = TrayCreateItem("About")
TrayItemSetOnEvent(-1,"AboutClick")
$exititem  = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ExitEvent")
TraySetState()

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $startBtn
            Start()
        Case $cmdPath
            Path()
        Case $cmdText
            Text()
    EndSwitch
WEnd

func Path()
    $path = FileOpenDialog("Outlook.exe", "C:\", "Execute (*.exe)") ; browse for file
    GUICtrlSetData($pathTxt, $path) ; display file path in text box
EndFunc

func Text()
    $text = FileOpenDialog("", "C:\", "Text (*.txt)") ; browse for file
    GUICtrlSetData($TextTxt, $text) ; display file path in text box
EndFunc

Func Hide()
    GUISetState(@SW_HIDE, $mainGUI)
EndFunc

Func AboutClick()
    MsgBox(64, "About", "coded by vladedoty.  This version is a basic version.  Updates and upgrades will be made continuously.")
EndFunc   ;==>AboutClicked

Func RestoreClick()
    GUISetState(@SW_SHOW, $mainGUI)
EndFunc   ;==>RestoreClicked

Func ExitEvent()
    Exit
EndFunc

and then my start function has other functions in it. The actual program runs fine. Just after it completes the start button doesn't work anymore so I have to shut the program down and restart it. Also the x in the top right of the window doesn't close out the program after the start button has been clicked. The tray icon works fine.

Func Start()
    Opt("WinTitleMatchMode", 2)
    $type = ControlGetText($mainGUI, "", $typeCmb)
    $color = ControlGetText($mainGUI, "", $colorCmb)
    $shape = ControlGetText($mainGUI, "", $shapeCmb)
    $readPath = ControlGetText($mainGUI, "", $pathTxt)
    $readText = ControlGetText($mainGUI, "", $TextTxt)
    If Not WinExists($Window1, "") Then
        MsgBox(1, "Window 1 not opened", "Please restart the program.", 3)
        ProcessClose("Shape.exe")
    ElseIf $readPath == "" Then
        MsgBox(1, "Please enter Path", "Please restart program")
        ProcessClose("Shape.exe")
    ElseIf $readText == "" Then
        MsgBox(1, "Please enter Text", "Please restart program")
        ProcessClose("Shape.exe")
    Else
        MoveWindow()
        AdlibEnable("AddMinute", 60000)
        StartShape()
    EndIf
EndFunc   ;==>Start
Edited by vladedoty
Link to comment
Share on other sites

Hi please post your entire script, however big it may be. It's impossible to understand what you have written here, because of the fact that there are too many undefined variables and too many undefined functions.

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com
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...