duhu Posted August 5, 2005 Posted August 5, 2005 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
quaizywabbit Posted August 5, 2005 Posted August 5, 2005 post what code you have so far..... [u]Do more with pre-existing apps![/u]ANYGUIv2.8
duhu Posted August 5, 2005 Author Posted August 5, 2005 Heres what ive done so far, but now im stuck expandcollapse popup; ----------------------------------------------------------------------------;; 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" ) quaizywabbit Posted August 5, 2005 quaizywabbit Active Members 455 picked the wrong day to quit sniffin' glue Posted August 5, 2005 (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 August 6, 2005 by quaizywabbit [u]Do more with pre-existing apps![/u]ANYGUIv2.8
duhu Posted August 5, 2005 Author Posted August 5, 2005 Thanx very very much!! One more question if you dont mind, i cant see the gui, its disappearing very fast! Do you know why? Anyway thanx again!
quaizywabbit Posted August 5, 2005 Posted August 5, 2005 i fixed the code above (forgot the guisetstate() and while/wend loop) [u]Do more with pre-existing apps![/u]ANYGUIv2.8
kcd-clan Posted August 6, 2005 Posted August 6, 2005 (edited) Its not working . The X buttion dose not work. Edited August 6, 2005 by kcd-clan Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()
quaizywabbit Posted August 6, 2005 Posted August 6, 2005 edited it to exit properly...see above [u]Do more with pre-existing apps![/u]ANYGUIv2.8
duhu Posted August 6, 2005 Author Posted August 6, 2005 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!
quaizywabbit Posted August 6, 2005 Posted August 6, 2005 post the vbs script...autoit can probably emulate it [u]Do more with pre-existing apps![/u]ANYGUIv2.8
duhu Posted August 6, 2005 Author Posted August 6, 2005 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
quaizywabbit Posted August 6, 2005 Posted August 6, 2005 $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
duhu Posted August 6, 2005 Author Posted August 6, 2005 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
duhu Posted August 6, 2005 Author Posted August 6, 2005 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now