Jump to content

Recommended Posts

Sorry for this stupid question but i tried and i didnt make it.

Now heres my problem: Im triing to make a gui with 2 buttons, start and exit, ok ive made the gui but when i double click on it it quickly diisapear.Now,, the start button, i want to run a vbs script (that defrag the hdd) and the exit button to exit the gui.I now is quite simple but i didn fully understand the help file, so im asking if someone please give an example of the script that has 2 buttons, one that call an external file , and the other exits.

so pllss someone helpme if you can, ill appreciate that, and sorry for my eng.

Doohooodogg

Link to post
Share on other sites

Heres what ive done so far, but now im stuck

; ----------------------------------------------------------------------------;; AutoIt Version: 3.1.0; Author:         A.N.Other <myemail@nowhere.com>;; Script Function:; Template AutoIt script.;; ----------------------------------------------------------------------------; Script Start - Add your code below here#include <GUIConstants.au3>Opt("GUICoordMode",2)Opt("GUIOnEventMode", 1); the guiiGUICreate ( "Defrag-er" , 500 , 500 )GUICtrlCreateLabel("Welcome to Defrag-er", 30, 10)GUICtrlSetOnEvent ( 4, "defragpressed" )GUICtrlCreateButton ( "Defrag Now", 10, 50 )GUICtrlCreateButton ( "Exit", 10, 60 )GUISetIcon ( "data\icon.ico" )


            
        

        

        
    

    

    
        Link to post
        
            
        
        
        

        
            Share on other sites
            

    
        
            

    

        
            

    

        
            

    

        
            

    

        
    

        
    

    

                    
                    
                    
                

                    

                    
                    






    

    

    
        
            


    
        
    

            
        
        
            
                

quaizywabbit
                

    
        
    
             3
    
        
    

            
            
                Posted 
                
            
        
    
    
        

quaizywabbit

        
            
                picked the wrong day to quit sniffin' glue
            
            

            
                


    
        
    

                
            
            Active Members
            
            
                
                    

    
        
    
             3
    
        
    

                    
                
                455 posts

                
                

            
        
    
    
        



    
        
            
                
                    
                    
                    
                    
                    
                
            
            
                
                    
                    
                        
                        
                            Share
                        
                        
                        
                        
                            
                                
                            
                            
                            
                            
                            
                            
                        
                    
                
                
            
        

        
            Posted  
            
            
                
                    (edited)
                
                
            
        
    

    


    
        
        
            #include <GUIConstants.au3>
Opt("GUICoordMode",2)
Opt("GUIOnEventMode", 1)



; the guii
$gui = GUICreate ( "Defrag-er" , 500 , 500 )
$label = GUICtrlCreateLabel("Welcome to Defrag-er", 30, 10)
$defrag = GUICtrlCreateButton ( "Defrag Now", 10, 50 )
GUICtrlSetOnEvent ( $defrag, "defragpressed" )

$vamoose = GUICtrlCreateButton ( "Exit", 10, 60 )
GUICtrlSetOnEvent ( $vamoose, "vamoose" )
GUISetOnEvent($GUI_EVENT_CLOSE, "vamoose")
GUISetIcon ( "data\icon.ico" )
GUISetState()
While 1
sleep(1000);idle
WEnd
func vamoose()
    Exit
EndFunc
Func defragpressed()
;Your event code goes here
EndFunc

this should get you heading in a better direction......Keep reading the Help file!!!!

EDIT: added event for main gui close 'X' button..

Edited by quaizywabbit
[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to post
Share on other sites

I dont know if this is the right place but if not the please excuse me.

i needed the above example to create a gui that has 2 buttons, defrag now and exit.

The defrag button is used to call a vbs script that defrag all my drives, but it gives me an errror like "Cannot execute external program" or something like that.Is there any add-on or something like that to allow runing other types of scripts/files?

Thanx.

Srry for my eng and if this is not the right place to ask this!

Link to post
Share on other sites

Heres is the dfrag.vbs

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run ("%systemdrive%\INSTALL\CD\A120\setup.msi /qn REBOOT=REALLYSUPPRESS")

WScript.Sleep 12000

WshShell.SendKeys "{TAB}"

WScript.Sleep 1000

WshShell.SendKeys "{ENTER}"

WScript.Sleep 9000

WshShell.SendKeys "{ENTER}"

WScript.Quit

Link to post
Share on other sites

$WshShell = ObjCreate("WScript.Shell")
$WshShell.Run ("%systemdrive%\INSTALL\CD\A120\setup.msi /qn REBOOT=REALLYSUPPRESS")
Sleep(12000)
$WshShell.SendKeys "{TAB}"
Sleep(1000)
$WshShell.SendKeys "{ENTER}"
Sleep (9000)
$WshShell.SendKeys "{ENTER}"
$WshShell = 0
exit

you'll need the latest beta version

I haven't really used COM before, so I may have missed something...

[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to post
Share on other sites

Jessus Christ, i was so dumb, that was another script, i inverted the names from a mistake, heres the defrag script:

Dim Act, Fso, strDrv, Drvs

Set Act = CreateObject("Wscript.shell")

Set Fso = CreateObject("Scripting.FileSystemObject")

Drvs = Array("C:\","D:\","E:\","F:\","G:\","H:\","I:\","J:\","K:\","L:\","M:\","N:\","O:\","P:\",_

"Q:\","R:\","S:\","T:\","U:\","V:\","W:\","X:\","Y:\","Z:\")

For Each strDrv In Drvs

If Fso.DriveExists(strDrv) Then

Act.Run("Defrag " & strDrv & " -F"),1,true

End If

Next

Link to post
Share on other sites

Man....i was so stupid, that was another vbs script. The real script that i want is this:

Dim Act, Fso, strDrv, Drvs

Set Act = CreateObject("Wscript.shell")

Set Fso = CreateObject("Scripting.FileSystemObject")

Drvs = Array("C:\","D:\","E:\","F:\","G:\","H:\","I:\","J:\","K:\","L:\","M:\","N:\","O:\","P:\",_

"Q:\","R:\","S:\","T:\","U:\","V:\","W:\","X:\","Y:\","Z:\")

For Each strDrv In Drvs

If Fso.DriveExists(strDrv) Then

Act.Run("Defrag " & strDrv & " -F"),1,true

End If

Next

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...