Jump to content
Sign in to follow this  
Guest b.byers

Button execution issue

Recommended Posts

Guest b.byers

I'm trying to have a script execute based on what button is selected. Each button would execute a different set of commands.

Thx

b.byers

Here is my script so far.

#include <GuiConstants.au3>;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000GuiCreate("Machine Selection", 201, 91,(@DesktopWidth-201)/2, (@DesktopHeight-91)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)$Label_1 = GuiCtrlCreateLabel("Select Machine Type", 50, 10, 110, 20)$Button_2 = GuiCtrlCreateButton("Desktop", 20, 50, 60, 30)$Button_3 = GuiCtrlCreateButton("Laptop/Tablet", 100, 50, 80, 30)GuiSetState()While 1  $msg = GuiGetMsg()  Select  Case $msg = $GUI_EVENT_CLOSE    If $msg = $Button_2 Then MsgBox (0,"","Desktop was selected" &@ComputerName)        ;RunWait(@ComSpec & " /c " & 'netdom.exe Join' &@ComputerName '/Domain:domainname /OU:OU=WinXP,OU=Desktop,OU=Clients,DC=Domain,DC=com /Userd:TriWest\username /Passwordd:*', "", @SW_HIDE)  If $msg = $Button_3 Then MsgBox (0,"","Laptop was selected" &@ComputerName) ;RunWait(@ComSpec & " /c " & 'netdom.exe Join' &@ComputerName '/Domain:domainname /OU:OU=WinXP,OU=Laptop,OU=Clients,DC=Domain,DC=com /Userd:TriWest\username /Passwordd:*', "", @SW_HIDE)   ExitLoop        ;;; EndSelectWEnd


            
        

        
            
                
                    

        
        
            
                
                    
                
            
            
            
        
    


                
            
            
                
                    
                    
                    
                
                
                    
                
            
        

        
    

    
        
            Share this post
            
            Link to post
            
            
            

            
                Share on other sites
                

    
        
            

    

        
            

    

        
            

    

        
            

    

        
            

    

        
    

            
        
    

    

                    
                        
                            


     (adsbygoogle = window.adsbygoogle || []).push({});

                        
                    
                
                    
                    
                    






    

    
        
            
BigDod
              

    
        
    
             515
    
        
    

        
        
            

    
        
    

        
    
    
        
BigDod   

    
        
    
             515
    
        
    

        
        
            
                The Mayor of Mirth
            
            

            
                

    
        
    

            
            Jokers
            
                
            
            
                

    
        
    
             515
    
        
    

                7,316 posts
                
                

            
        
    
    
        


    

    
        
            
                
                
                
                    
                
                
            
        

        
            Posted 
            
                
                
            
        
    

    


    
        
        
            This is how I would do it but i am no expert.
#include <GuiConstants.au3>

;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

Opt("GUIOnEventMode", 1)

GuiCreate("Machine Selection", 201, 91)

GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

$Label_1 = GuiCtrlCreateLabel("Select Machine Type", 50, 10, 110, 20)
$Button1 = GuiCtrlCreateButton("Desktop", 20, 50, 60, 30)
$Button2 = GuiCtrlCreateButton("Laptop/Tablet", 100, 50, 80, 30)

GUICtrlSetOnEvent($Button1, "Dtop")
GUICtrlSetOnEvent($Button2, "Ltop")

GuiSetState(@SW_SHOW)
While 1
      Sleep(100)  
WEnd

Func CLOSEClicked()
   Exit
 EndFunc
 
Func Dtop()
;RunWait(@ComSpec & " /c " & 'netdom.exe Join' &@ComputerName '/Domain:domainname /OU:OU=WinXP,OU=Desktop,OU=Clients,DC=Domain,DC=com /Userd:TriWest\username /Passwordd:*', "", @SW_HIDE)
    MsgBox (0,"","Desktop was selected" &@ComputerName)
EndFunc

Func Ltop()
;RunWait(@ComSpec & " /c " & 'netdom.exe Join' &@ComputerName '/Domain:domainname /OU:OU=WinXP,OU=Laptop,OU=Clients,DC=Domain,DC=com /Userd:TriWest\username /Passwordd:*', "", @SW_HIDE)
MsgBox (0,"","Laptop was selected" &@ComputerName)
EndFunc


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites
Dickb

With the While loop it looks like this:

#include <GuiConstants.au3>

;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GUICreate("Machine Selection", 201, 91, (@DesktopWidth - 201) / 2, (@DesktopHeight - 91) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Label_1 = GUICtrlCreateLabel("Select Machine Type", 50, 10, 110, 20)
$Button_2 = GUICtrlCreateButton("Desktop", 20, 50, 60, 30)
$Button_3 = GUICtrlCreateButton("Laptop/Tablet", 100, 50, 80, 30)

GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_2
            MsgBox(0, "", "Desktop was selected" & @ComputerName)
           ;RunWait(@ComSpec & " /c " & 'netdom.exe Join' &@ComputerName '/Domain:domainname /OU:OU=WinXP,OU=Desktop,OU=Clients,DC=Domain,DC=com /Userd:TriWest\username /Passwordd:*', "", @SW_HIDE)
        Case $msg = $Button_3
            MsgBox(0, "", "Laptop was selected" & @ComputerName)
           ;RunWait(@ComSpec & " /c " & 'netdom.exe Join' &@ComputerName '/Domain:domainname /OU:OU=WinXP,OU=Laptop,OU=Clients,DC=Domain,DC=com /Userd:TriWest\username /Passwordd:*', "", @SW_HIDE)
        Case Else
           ;;;
    EndSelect
WEnd

Exit

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  

×