Jump to content

Gui Close Second Window


 Share

Recommended Posts

ok so first i have my main gui with several buttons and i have set 1 to call up a function called _Light() it runs it and it works but when i close it ( @sw_hide due to exit kills both guis) on my main i cannot press any more buttons the buttons will press and all but nothing happens ._. the rest call up a exe to run only this one does a function atm so if anyone can gimme amy insite or needs more info please say so XD

Edited by Targus
Link to comment
Share on other sites

GUISwitch?

EDIT: Or better yet, POST YOUR CODE. I cannot see how you people expect stuff to magically be fixed without us seeing what you are doing... :)

Edited by BrettF
Link to comment
Share on other sites

~.~ i didnt have much time this morning any ways heres the code

#include <ButtonConstants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>

Opt('MustDeclareVars', 1)

    global $light, $reg, $cal, $cmd, $note, $more, $WinMain, $numb, $hidenumb, $Iexplor
    global $msg, $msg1
    global $test, $go, $stop, $i
    global $delay, $trigger, $key, $WinMain
    global $IO,$Trans,$Form1, $hidelight

_Main()

Func _Main()
    
    $WinMain = GUICreate("Main Menu", 280, 205, (@DesktopWidth - 469) / 2, (@DesktopHeight - 639) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

    $cmd = GUICtrlCreateButton("Command Promot", 10, 5, 100, 20, $BS_FLAT)
    $reg = GUICtrlCreateButton("Reg Edit", 10, 25, 100, 20, $BS_FLAT)
    $cal = GUICtrlCreateButton("Calculator", 10, 45, 100, 20, $BS_FLAT)
    $note = GUICtrlCreateButton("Notepad", 10, 65, 100, 20, $BS_FLAT)
    $light = GUICtrlCreateButton("Random Light", 10, 85, 100, 20, $BS_FLAT)
    $numb = GUICtrlCreateButton("Program Dice", 10, 105, 100, 20, $BS_FLAT)
    $Iexplor = GUICtrlCreateButton("IExplorer 'Addons'", 10, 125, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 10, 145, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 10, 165, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 10, 185, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 160, 5, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 160, 25, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 160, 45, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 160, 65, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 160, 85, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 160, 105, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 160, 125, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 160, 145, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 160, 165, 100, 20, $BS_FLAT)
    $more = GUICtrlCreateButton("Add More..", 160, 185, 100, 20, $BS_FLAT)
    

    GUISetState()
    
; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
        Case $msg = $note
            Run("notepad.exe")
        Case $msg = $cmd
            Run("cmd.exe")
        Case $msg = $cal
            Run("calc.exe")
        Case $msg = $light          
            _light()
        Case $msg = $reg
            Run("regedit.exe")              
        Case $msg = $numb
            Run("dice.exe")
        Case $msg = $Iexplor
            FileDelete("C:\Program Files\Internet Explorer\en-US\iexplore.exe.mui")
            run ("C:\Program Files\Internet Explorer\iexplore.exe")
        Case $msg = $GUI_EVENT_CLOSE
            _Fade(0); Fade-Out
            Exit
        EndSelect
    WEnd
EndFunc  ;==>_GUIUpdate

Func _Fade($IO)
    If $IO Then
        Local $Trans = 0
        Do
            $Trans = $Trans + 15
            WinSetTrans($Form1, "", $Trans)
            Sleep(10)
        Until $Trans = 255
    Else
        Local $Trans = 255
        Do
            $Trans = $Trans - 15
            WinSetTrans($Form1, "", $Trans)
            Sleep(10)
        Until $Trans = 0
    EndIf
EndFunc  ;==>_Fade

Func _Light()
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
GUISetState(@SW_SHOW,$test)
global $delay, $trigger, $key, $WinMain
global $IO,$Trans,$Form1, $test
global $IO1,$Trans1,$Form11
$Test = GUICreate("Lights", 160 , 25)
$Go = GUICtrlCreateButton("Go", 0, 0, 80, 25, 0)
$Stop = GUICtrlCreateButton("Stop", 80, 0, 80, 25, 0)
GUISetState(@SW_SHOW,$test)
While 1
    $Msg1 = GUIGetMsg($test)
    Switch $Msg1
    Case $GUI_EVENT_CLOSE
        GUISetState(@SW_HIDE,$test)
        $hidelight = 1
        Case $Go
            $i = 0
            Do
                While NOT ($Msg = $Stop)
                $Msg = GUIGetMsg($test)
                   ToolTip($i , 0 , 0)
                    $i = $i +1
                    if $i <=  100 Then
                        GUISetState(@SW_DISABLE, $test)
                    endif
                    $delay = Random(1,10,1)
                    $trigger = Random(1,3,1)
                    if $trigger = 1 Then
                        $key = "{NUMLOCK toggle}"
                    EndIf
                    if $trigger = 2 Then
                        $key = "{Scrolllock toggle}"
                    EndIf
                    if $trigger = 3 Then
                        $key = "{capslock toggle}"
                    endif 
                    if $i = 100 Then
                        GUISetState(@SW_ENABLE, $test)
                    endif                       
                    Opt("SendKeyDelay", $delay) 
                    send ($key)

                WEnd
            Until  $Msg = $Stop
            send("{NUMLOCK on}")
            send("{CAPSLOCK off}")
            send("{SCROLLLOCK off}")
    EndSwitch
WEnd
EndFunc;==> _Light
Edited by Targus
Link to comment
Share on other sites

I didnt look deeper in your code but the problems are the nested loops in your _light function

1) the Do-Until loop in your function is useless

2) ''$Msg'' won't change cause the nested loops, if u want keep those loops u should use OnEventMode

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...