Sign in to follow this  
Followers 0
Th3W1z4rd

GUI closes and don't reopen!

3 posts in this topic

Hello everyone!

I wrote a program on 2 files. The program just open 2 windows when you press the about botton, but when I unload them, I'm not able to use the menu again...as it was impossible to create agai the window...someone can help me? Here's the code

main file:

#include <Constants.au3>
#include <GUIConstants.au3>
#include "about.au3"
#NoTrayIcon

Opt("TrayMenuMode",1) 

Global $act = 1
Global $proc = "AutoItv3"

HotKeySet("{RIGHT}","_MouseRight")
HotKeySet("{LEFT}","_MouseLeft")
HotKeySet("{UP}","_MouseUp")
HotKeySet("{DOWN}","_MouseDown")
HotKeySet("{ENTER}","_MouseClick")
HotKeySet("{SPACE}","_MouseDoubleClick")
HotKeySet("{END}","_EndProgram")
HotKeySet("{PAUSE}","_ChangeScriptStatus")
HotKeySet("{PGDN}","_ScrollMouseDown")
HotKeySet("{PGUP}","_ScrollMouseUp")


$help = TrayCreateItem("Help")
$about = TrayCreateItem("About")
$exit = TrayCreateItem("Exit")

TraySetState()

While 1
    
    $msg = TrayGetMsg()

    Select
        Case $msg = 0
            ContinueLoop
        Case $msg = $help
            $title = "Help..."
            $text = "FRECCE -> Muove il cursore nella direzione voluta" & @CRLF & "ENTER -> Click singolo con il pulsante primario" & @CRLF & "SPACE -> Doppio click con il pulsante primario" & @CRLF & "PG DOWN -> Preme il pulsante primario del mouse" & @CRLF & "PG UP -> RIlascia il pulsante primario del mouse" & @CRLF & "PAUSE -> Attiva\Disattiva il programma" & @CRLF & "END -> Termina il programma"
            MsgBox(64,$title,$text)
        Case $msg = $about
            _loadAbout()
        Case $msg = $exit
            Exit 0
    EndSelect
    
    If ProcessExists($proc) Then
        ProcessSetPriority($proc, 4)
    EndIf

WEnd

Func _MouseRight()
    If $act = 1 Then
        $pos = MouseGetPos()
        MouseMove($pos[0] + 10,$pos[1], 0)
    Else
        HotKeySet("{RIGHT}")
        Send("{RIGHT}")
        HotKeySet("{RIGHT}","_MouseRight")
    EndIf
EndFunc

Func _MouseLeft()
    If $act = 1 Then
        $pos = MouseGetPos()
        MouseMove($pos[0] - 10,$pos[1], 0)
    Else
        HotKeySet("{LEFT}")
        Send("{LEFT}")
        HotKeySet("{LEFT}","_MouseLeft")
    EndIf
EndFunc

Func _MouseUp()
    If $act = 1 Then
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] - 10, 0)
    Else
        HotKeySet("{UP}")
        Send("{UP}")
        HotKeySet("{UP}","_MouseUp")
    EndIf
EndFunc

Func _MouseDown()
    If $act = 1 Then
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] + 10, 0)
    Else
        HotKeySet("{DOWN}")
        Send("{DOWN}")
        HotKeySet("{DOWN}","_MouseDown")
    EndIf
EndFunc

Func _MouseClick()
    If $act = 1 Then
        MouseClick("main")
    Else
        HotKeySet("{Enter}")
        Send("{Enter}")
        HotKeySet("{Enter}","_MouseClick")
    EndIf
    
EndFunc

Func _MouseDoubleClick()
    If $act = 1 Then
        $pos = MouseGetPos()
        MouseClick("main", $pos[0], $pos[1], 2)
    Else
        HotKeySet("{Space}")
        Send("{Space}")
        HotKeySet("{Space}","_MouseDoubleClick")
    EndIf
EndFunc

Func _EndProgram()
    Exit 0
EndFunc

func _ChangeScriptStatus()
    If $act=1 Then
        $act = 0
    Else
        $act = 1
    EndIf
EndFunc

Func _ScrollMouseDown()
    If $act=1 Then
        MouseDown("main")
    Else
        HotKeySet("{PGDN}")
        Send("{PGDN}")
        HotKeySet("{PGDN}","_ScrollMouseDown")
    EndIf
EndFunc

Func _ScrollMouseUp()
    If $act=1 Then
        MouseUp("main")
    Else
        HotKeySet("{PGUP}")
        Send("{PGUP}")
        HotKeySet("{PGUP}","_ScrollMouseUp")
    EndIf
EndFunc

And the about.au3 file

#NoTrayIcon
#include <GUIConstants.au3>

Func _loadAbout()
    #Region ### START Koda GUI section ### Form=
    $AboutMsgBox = GUICreate("About...", 317, 63, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
    GUISetIcon("Info.ico")
    $Label1 = GUICtrlCreateLabel("Arrow Keys Commander 1.0 alpha", 104, 8, 202, 22)
    GUICtrlSetFont(-1, 10, 400, 0, "@Arial Unicode MS")
    $Label2 = GUICtrlCreateLabel("Created by", 104, 32, 67, 22)
    GUICtrlSetFont(-1, 10, 400, 0, "@Arial Unicode MS")
    $email = GUICtrlCreateLabel("Roberto Orgiu", 176, 32, 84, 22)
    GUICtrlSetFont(-1, 10, 400, 4, "@Arial Unicode MS")
    GUICtrlSetColor(-1, 0x0000FF)
    GUICtrlSetCursor (-1, 0)
    $Pic1 = GUICtrlCreatePic("somerights20_0.jpg", 8, 8, 89, 36, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    GUICtrlSetCursor (-1, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete()

            Case $email
                Run(@ComSpec & " /c " & 'start mailto:roberto.orgiu@gmail.com?subject=Arrow Keys Commander', "", @SW_HIDE)
            Case $Pic1
                _show()
        EndSwitch
    WEnd
EndFunc

Func _show()
    
    $license = GUICreate("Licenza", 269, 303, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
    GUISetIcon("Info.ico")
    GUISetCursor (7)
    GUISetBkColor(0xFFFFFF)
    $Pic1 = GUICtrlCreatePic("CreativeCommonsLogo.jpg", 0, 0, 268, 68, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Label1 = GUICtrlCreateLabel("Tu sei libero:", 96, 80, 79, 22)
    GUICtrlSetFont(-1, 10, 400, 2, "@Arial Unicode MS")
    GUICtrlSetCursor (-1, 7)
    $Label2 = GUICtrlCreateLabel("Alle seguenti condizioni:", 64, 160, 145, 22)
    GUICtrlSetFont(-1, 10, 400, 2, "@Arial Unicode MS")
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Pic2 = GUICtrlCreatePic("share_0.jpg", 40, 104, 44, 44, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Pic3 = GUICtrlCreatePic("remix_0.jpg", 184, 104, 44, 44, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Pic4 = GUICtrlCreatePic("by_0.jpg", 40, 184, 44, 44, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Pic5 = GUICtrlCreatePic("nc-eu_0.jpg", 112, 184, 44, 44, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Pic6 = GUICtrlCreatePic("sa_0.jpg", 184, 184, 44, 44, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    GUICtrlSetState(-1, $GUI_DISABLE)
    $Pic7 = GUICtrlCreatePic("somerights20_0.jpg", 80, 256, 105, 36, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
    GUICtrlSetCursor (-1, 0)
    GUISetState(@SW_SHOW, $license)


    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete()
            Case $Pic7
                Run(@ComSpec & " /c " & 'start http://creativecommons.org/licenses/by-nc-sa/2.5/it/', "", @SW_HIDE)
        EndSwitch
    WEnd
EndFunc

If you try to execute this program, you notice that once you exit the About window, it is not possible to create it once more :) why?

Share this post


Link to post
Share on other sites



Hello everyone!

I wrote a program on 2 files. The program just open 2 windows when you press the about botton, but when I unload them, I'm not able to use the menu again...as it was impossible to create agai the window...someone can help me? Here's the code

And the about.au3 file

#NoTrayIcon
#include <GUIConstants.au3>

Func _loadAbout()

; ...

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete()

            Case $email
                Run(@ComSpec & " /c " & 'start mailto:roberto.orgiu@gmail.com?subject=Arrow Keys Commander', "", @SW_HIDE)
            Case $Pic1
                _show()
        EndSwitch
    WEnd
EndFunc

If you try to execute this program, you notice that once you exit the About window, it is not possible to create it once more :( why?

Nothing in this While/WEnd loop exits the loop. When it receives $GUI_EVENT_CLOSE it deletes the gui and then is still trapped in the loop. Add "ExitLoop" after the GuiDelete().

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Nothing in this While/WEnd loop exits the loop. When it receives $GUI_EVENT_CLOSE it deletes the gui and then is still trapped in the loop. Add "ExitLoop" after the GuiDelete().

:)

perfect! I added "ExitLoop" after every GUIDelete() and now it works! thank you!

Share this post


Link to post
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
Sign in to follow this  
Followers 0