Sign in to follow this  
Followers 0
Joshuaaaa

Coding a button to open up GUI "Form1" (INDEX) after it's been hidden?

3 posts in this topic

#1 ·  Posted (edited)

I've got it, on my index GUI, so that when I select "Archer" in the checkbox, and click "Select" it opens up my second GUI (Form2). Now I want it so that when I simply click the button entitled "Class_Select" on Form2, it opens back up my index (Form1).

I just can't figure it out because I've only ever had a button open up another "Form" if X is checked in checkbox...

Here is my code:

#include <GUIConstants.au3>
#include <misc.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("CoBrother 1.0", 201, 241, 207, 128)
GUISetIcon("C:\Documents and Settings\Mom\Desktop\New Folder\cofriend.ico")
GUISetBkColor(0xFFFFE1)
$Archer = GUICtrlCreateRadio("Archer", 24, 40, 113, 17)
$Taoist = GUICtrlCreateRadio("Taoist", 24, 72, 113, 17)
$Trojan = GUICtrlCreateRadio("Trojan", 24, 104, 113, 17)
$Warrior = GUICtrlCreateRadio("Warrior", 24, 136, 113, 17)
$Select = GUICtrlCreateButton("Select", 56, 192, 75, 25, 0)
$Class = GUICtrlCreateGroup("Class", 8, 16, 185, 161)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Select
            If _IsChecked($Archer) Then Runner()
    EndSwitch
WEnd

Func Runner()
    
    GUISetState( @SW_HIDE, $Form1) 
    
    #include <GUIConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("CoBrother 1.0", 201, 251, 207, 128)
    GUISetIcon("C:\Documents and Settings\Mom\Desktop\New Folder\cofriend.ico")
    GUISetBkColor(0xFFFFE1)
    $Auto_scatter = GUICtrlCreateCheckbox("Auto scatter", 32, 136, 97, 17)
    $Left_click_jump = GUICtrlCreateCheckbox("Left click jump", 32, 176, 97, 17)
    $Other = GUICtrlCreateGroup("Other", 8, 112, 185, 105)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $TG = GUICtrlCreateGroup("TG", 8, 8, 185, 105)
    $Scatter_and_bow = GUICtrlCreateRadio("Scatter and bow", 32, 32, 113, 17)
    $Intensify_leveler = GUICtrlCreateRadio("Intensify leveler", 32, 72, 113, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Class_Select = GUICtrlCreateButton("Class Select", 16, 224, 80, 25, 0)
    $Run = GUICtrlCreateButton("Run", 104, 224, 80, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    
    
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Run
            WinSetState("CoBrother 1.0", "", @SW_MINIMIZE)
            If BitAND(GUICtrlRead($Left_click_jump), $GUI_CHECKED) Then
 Send("{LCTRL Down}")
Sleep(0); 0 seconds
Send("{LCTRL Up}")
                EndIf
            If BitAND(GUICtrlRead($Auto_scatter), $GUI_CHECKED) Then
                 Do
     MouseClick ("SECONDARY") 
     Sleep(1); 1= .01sec
 Until _IsPressed ("09")

            EndIf
    EndSwitch
WEnd
    
    
    
    
    GUIDelete($Form2)
    GUISetState( @SW_SHOW, $Form1)
    
EndFunc ;==>Runner

Func _IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc
Edited by Joshuaaaa

Share this post


Link to post
Share on other sites

#2 ·  Posted (edited)

#include <GUIConstants.au3>
#include <misc.au3>
;Form1
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("CoBrother 1.0", 201, 241, 207, 128)
GUISetIcon("C:\Documents and Settings\Mom\Desktop\New Folder\cofriend.ico")
GUISetBkColor(0xFFFFE1)
$Archer = GUICtrlCreateRadio("Archer", 24, 40, 113, 17)
$Taoist = GUICtrlCreateRadio("Taoist", 24, 72, 113, 17)
$Trojan = GUICtrlCreateRadio("Trojan", 24, 104, 113, 17)
$Warrior = GUICtrlCreateRadio("Warrior", 24, 136, 113, 17)
$Select = GUICtrlCreateButton("Select", 56, 192, 75, 25, 0)
$Class = GUICtrlCreateGroup("Class", 8, 16, 185, 161)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;Form2
 #Region ### START Koda GUI section ### Form=
    $Form2 = GUICreate("CoBrother 1.0", 201, 251, 207, 128)
    GUISetIcon("C:\Documents and Settings\Mom\Desktop\New Folder\cofriend.ico")
    GUISetBkColor(0xFFFFE1)
    $Auto_scatter = GUICtrlCreateCheckbox("Auto scatter", 32, 136, 97, 17)
    $Left_click_jump = GUICtrlCreateCheckbox("Left click jump", 32, 176, 97, 17)
    $Other = GUICtrlCreateGroup("Other", 8, 112, 185, 105)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $TG = GUICtrlCreateGroup("TG", 8, 8, 185, 105)
    $Scatter_and_bow = GUICtrlCreateRadio("Scatter and bow", 32, 32, 113, 17)
    $Intensify_leveler = GUICtrlCreateRadio("Intensify leveler", 32, 72, 113, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $Class_Select = GUICtrlCreateButton("Class Select", 16, 224, 80, 25, 0)
    $Run = GUICtrlCreateButton("Run", 104, 224, 80, 25, 0)
    #EndRegion ### END Koda GUI section ###
    
While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Select
            If _IsChecked($Archer) Then _ToggleGUI($Form1,$Form2)
        Case $Class_Select
             _ToggleGUI($Form1,$Form2)
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Run
            WinSetState("CoBrother 1.0", "", @SW_MINIMIZE)
            If BitAND(GUICtrlRead($Left_click_jump), $GUI_CHECKED) Then
                Send("{LCTRL Down}")
                Sleep(0); 0 seconds
                Send("{LCTRL Up}")
                EndIf
            If BitAND(GUICtrlRead($Auto_scatter), $GUI_CHECKED) Then
                 Do
                     MouseClick ("SECONDARY") 
                     Sleep(1); 1= .01sec
                Until _IsPressed ("09")

            EndIf
    EndSwitch
WEnd

    


Func _IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

Func _ToggleGUI($hForm_1,$hForm_2)
    If BitAND(WinGetState($hForm_1),2)=2 Then
        GUISetState(@SW_SHOW,$hForm_2)
        GUISetState(@SW_HIDE,$hForm_1)
    Else
        GUISetState(@SW_SHOW,$hForm_1)
        GUISetState(@SW_HIDE,$hForm_2)
    EndIf
EndFunc

I don't know if it's really effective though...

-edit-

slightly improved.

Edited by Nahuel

Share this post


Link to post
Share on other sites

Work great, thanks alot :)

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