Jump to content

Buttons


Recommended Posts

I recently started experimenting with GUI's and i can't believe how i ever lived without it ^^

Well, the thing is that i've made a button in a GUI that has to be pushable many times, its for selecting an install path. Problem is, that it only works once

The only reason i can come up with is that

after

Case $msg = $button

$msg is still $button

I've searched the forums for 2 hours now, searching for buttons, button event, button presses and so on. Anyone who can help me?

Link to comment
Share on other sites

  • Moderators

I recently started experimenting with GUI's and i can't believe how i ever lived without it ^^

Well, the thing is that i've made a button in a GUI that has to be pushable many times, its for selecting an install path. Problem is, that it only works once

The only reason i can come up with is that

after

Case $msg = $button

$msg is still $button

I've searched the forums for 2 hours now, searching for buttons, button event, button presses and so on. Anyone who can help me?

Ummmm ... have an actual script or at least a reproduction to work with? I mean... I can guess and say that your arguements are wrong or your not in a While/WEnd loop, but my crystal ball is broken today, and won't be back from the shop until Next week at an unknown time.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Ummmm ... have an actual script or at least a reproduction to work with? I mean... I can guess and say that your arguements are wrong or your not in a While/WEnd loop, but my crystal ball is broken today, and won't be back from the shop until Next week at an unknown time.

aahhhh... ahahah. :D

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

Sorry, my fault

#include <GUIConstants.au3>

#NoTrayIcon



GUICreate ( "Mod Installer" , 400 , 200 , -1 , -1 )
GUISetState(@SW_SHOW)
GUISetBKColor (0x5a7cba)
GUICtrlCreateLabel( "What mods do you want to install?", 10, 5, 400, 20)
GUICtrlCreateLabel( "Select directory to install to. Usually SteamApps/SourceMods/Gmod9/mods/", 10, 105, 400, 20)
$cb1 = GUICtrlCreateCheckbox ("PHX Models Pack 2", 10, 20, 120, 20)
$cb2 = GUICtrlCreateCheckbox ("Baj's Custom entities", 10, 40, 120, 20)
$cb3 = GUICtrlCreateCheckbox ("Gmod Plus", 10, 60, 120, 20)
$checkcb1 = GUICtrlRead($cb1)
$checkcb2 = GUICtrlRead($cb2)
$checkcb3 = GUICtrlRead($cb3)
$dest = FileSelectFolder("Select directory to install to. Usually SteamApps/SourceMods/Gmod9/mods/", "", 1)
$button = GUICtrlCreateButton ("Install", 300, 170, 90, 22)
$browse = GUICtrlCreateButton ("Browse", 200, 170, 90, 22)
GUICtrlCreateLabel( $dest, 30, 140, 350, 20)

$1 = 0
$2 = 0
$3 = 0
GUICtrlCreateGroup ("Directory", 20, 125, 365, 40)







While 1
    

    $msg = GUIGetMsg()



    
    Select 
    Case $msg = $browse 
            $dest = FileSelectFolder("Select directory to install to. Usually SteamApps/SourceMods/Gmod9/mods/", "", 1)
         $msg = 0
        
EndSelect
Select
    Case $msg = $button
            MsgBox( 0, "Info", "Gmod9 Mods Installer will now install the selected mods and rebuild the Modcache, this may take a while")
            If $dest = "" Then
                MsgBox( 1, "Error", "You have to select a folder")
                    EndIf
        $msg = 0
        

            if $checkcb1 = $GUI_CHECKED Then 
                DirCopy( "files/Phoenix_storms_MP2", $dest & "\Phoenix_storms_MP2", 1)
                DirCopy( "files/PhoeniX_icons", $dest & "\PhoeniX_icons", 1)                                        
                DirCopy( "files/PhoeniX_icons", $dest & "\-modcache", 1)
                DirCopy( "files/Phoenix_storms_MP2", $dest & "\-modcache", 1)
                                        EndIf
            
            
            if $checkcb2 = $GUI_CHECKED Then 
                DirCopy( "files/Custom_Entities", $dest & "\Custom_Entities", 1)
                DirCopy( "files/Custom_Entities", $dest & "\-modcache", 1)
                                        EndIf
        
            
            
            
            if $checkcb3 = $GUI_CHECKED Then 
                DirCopy( "files/GmodPlus", $dest & "\GmodPlus", 1)
                DirCopy( "files/GmodPlus", $dest & "\-modcache", 1)
                                        EndIf
            
        MsgBox( 0, "Info", "Installation succesful")
ExitLoop
EndSelect

If $msg = $GUI_EVENT_CLOSE Then ExitLoop

Wend
Link to comment
Share on other sites

added some features for easy error handling and stuff, i split the 2 functions just to make it easier if you were going with a succesful install or unsuccesful

#include <GUIConstants.au3>
#NoTrayIcon
$1 = 0
$2 = 0
$3 = 0
GUICreate ( "Mod Installer" , 400 , 200 , -1 , -1 )
GUISetState(@SW_SHOW)
GUISetBKColor (0x5a7cba)
GUICtrlCreateLabel( "What mods do you want to install?", 10, 5, 400, 20)
GUICtrlCreateLabel( "Select directory to install to. Usually SteamApps/SourceMods/Gmod9/mods/", 10, 105, 400, 20)
$cb1 = GUICtrlCreateRadio ("PHX Models Pack 2", 10, 20, 120, 20)
$cb2 = GUICtrlCreateRadio ("Baj's Custom entities", 10, 40, 120, 20)
$cb3 = GUICtrlCreateRadio ("Gmod Plus", 10, 60, 120, 20)
$dest = FileSelectFolder("Select directory to install to. Usually SteamApps/SourceMods/Gmod9/mods/", "", 1)
$button = GUICtrlCreateButton ("Install", 300, 170, 90, 22)
$browse = GUICtrlCreateButton ("Browse", 200, 170, 90, 22)
$destination = GUICtrlCreateLabel( $dest, 30, 140, 350, 20)
GUICtrlCreateGroup ("Directory", 20, 125, 365, 40)
While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $browse
            $dest = FileSelectFolder("Select directory to install to. Usually SteamApps/SourceMods/Gmod9/mods/", "", 1)
            GUICtrlSetData($destination,$dest)
    Case $msg = $button
            MsgBox( 0, "Info", "Gmod9 Mods Installer will now install the selected mods and rebuild the Modcache, this may take a while")
    If $dest = "" Then
        NotComplete("1")
    ElseIf GUICtrlRead($cb1) = $GUI_CHECKED Then
                DirCopy( "files/Phoenix_storms_MP2", $dest & "\Phoenix_storms_MP2", 1)
                DirCopy( "files/PhoeniX_icons", $dest & "\PhoeniX_icons", 1)                                        
                DirCopy( "files/PhoeniX_icons", $dest & "\-modcache", 1)
                DirCopy( "files/Phoenix_storms_MP2", $dest & "\-modcache", 1)
                Complete("1")
    Elseif GUICtrlRead($cb2) = $GUI_CHECKED Then
                DirCopy( "files/Custom_Entities", $dest & "\Custom_Entities", 1)
                DirCopy( "files/Custom_Entities", $dest & "\-modcache", 1)
                Complete("2")
    Elseif GUICtrlRead($cb3) = $GUI_CHECKED Then
                DirCopy( "files/GmodPlus", $dest & "\GmodPlus", 1)
                DirCopy( "files/GmodPlus", $dest & "\-modcache", 1)
                Complete("3")
    Elseif GUICtrlRead($cb1) = $GUI_UNCHECKED or GUICtrlRead($cb2) = $GUI_UNCHECKED or GUICtrlRead($cb3) = $GUI_UNCHECKED Then
    NotComplete("2")
    EndIf
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
EndSelect
Wend

Func Complete($install)
    If $install = "1" Then
    MsgBox( 0, "Info", "Installation of PHX Models Pack 2 succesful")
    Exit
    Elseif $install = "2" Then
    MsgBox( 0, "Info", "Installation of Baj's Custom entities succesful")
    Exit
    ElseIf $install = "3" Then
    MsgBox( 0, "Info", "Installation of Gmod Plus succesful")
    Exit
    Else
    MsgBox(0,"Info","Unkown Error")
    EndIf
EndFunc
Func NotComplete($error)
    If $error = "1" Then
    MsgBox( 0, "Info", "Installation unsuccesful" & @CRLF & "Error: No Location Selected.")
    Elseif $error = "2" Then
    MsgBox( 0, "Info", "Installation unsuccesful" & @CRLF & "Error: No Mod Checked.")
    Endif
EndFunc
Edited by thatsgreat2345
Link to comment
Share on other sites

Thanks alot Thatsgreat2345, only thing is, that im using checkboxes, bu that shouldnt be too hard to change, else ill let you know ^^

There, changed it, thanks again, will make installing mods alot easier ^^

Edited by Geeky
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...