royjm248 Posted October 9, 2008 Share Posted October 9, 2008 I thought I have this right but the ok button is not working with the event?Check_Disk_Utility.au3 Link to comment Share on other sites More sharing options...
November Posted October 9, 2008 Share Posted October 9, 2008 (edited) Hi there, I saw your script and i beliave you miss the statements for buttons capture, try to and this to your script: expandcollapse popup#include <GUIConstantsEx.au3> $first = GUICreate("Disk Check Utility") GUICtrlCreateLabel("This utility will AUTOMATE the task of checking your system disk for errors", 10, 20) $okButton = GUICtrlCreateButton("OK", 50, 50, 60) GUISetOnEvent($okButton, "_OkButton") GUISetState(@SW_SHOW) While 1 $first = GUIGetMsg() Select case $first = $GUI_EVENT_CLOSE _close() case $first = $okButton _okbutton() ;case $first = anymore statements EndSelect Sleep(10);wait WEnd ;GUICreate("Confirmation") ;$yes = GUICtrlCreateButton("Yes", 50, 70) ;$no = GUICtrlCreateButton("No", 75, 70) ;$bool = False Func _OkButton() ;user chooses to run application MsgBox(0, "GUI Event", "You pressed OK!") Exit Run("cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send("chkdsk /x /r{enter}") Sleep(2000) Send("n {enter}") Sleep(1000) WinActivate("C:\WINDOWS\system32\cmd.exe") WinClose("C:\WINDOWS\system32\cmd.exe") Sleep(1000) EndFunc ;==>_OkButton Func _Close() ;user chose to close befor running Exit EndFunc ;==>_Close Cheers Edited October 9, 2008 by november Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
cherdeg Posted October 9, 2008 Share Posted October 9, 2008 (edited) I thought I have this right but the ok button is not working with the event? Just use this, it's working: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=Check Disk Utility.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> Opt("GUICoordMode", 1) $first = GUICreate("Disk Check Utility") $ge_Label_ok = GUICtrlCreateLabel("This utility will AUTOMATE the task of checking your system disk for errors", 10, 20) $ge_Label_driveletter = GUICtrlCreateLabel("Please enter the driveletter of the disk to scan:", 10, 50) $ge_Input_driveletter = GUICtrlCreateInput("", 10, 80, 130, 21) $ge_Button_ok = GUICtrlCreateButton("OK", 250, 250, 60) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Close() ExitLoop Case $ge_Button_ok $s_driveletter = GUICtrlRead($ge_Input_driveletter) _OkButton() ExitLoop EndSwitch WEnd Func _OkButton() ;user chooses to run application $s_cmd = "chkdsk.exe /x /r " & $s_driveletter ;~ MsgBox("", "TEST", $s_cmd) RunWait(@ComSpec & " /c " & $s_cmd, "", @SW_SHOW) EndFunc ;==>_OkButton Func _Close() ;user chose to close befor running Exit EndFunc ;==>_Close Edited October 9, 2008 by cherdeg Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 9, 2008 Share Posted October 9, 2008 Hi there, I saw your script and i beliave you miss the statements for buttons capture, try to and this to your script: expandcollapse popup#include <GUIConstantsEx.au3> $first = GUICreate("Disk Check Utility") GUICtrlCreateLabel("This utility will AUTOMATE the task of checking your system disk for errors", 10, 20) $okButton = GUICtrlCreateButton("OK", 50, 50, 60) GUISetOnEvent($okButton, "_OkButton") GUISetState(@SW_SHOW) While 1 $first = GUIGetMsg() Select case $first = $GUI_EVENT_CLOSE _close() case $first = $okButton _okbutton() ;case $first = anymore statements EndSelect Sleep(10);wait WEnd Func _OkButton() ;user chooses to run application MsgBox(0, "GUI Event", "You pressed OK!") Exit Run("cmd.exe") WinWaitActive("C:\WINDOWS\system32\cmd.exe") Send("chkdsk /x /r{enter}") Sleep(2000) Send("n {enter}") Sleep(1000) WinActivate("C:\WINDOWS\system32\cmd.exe") WinClose("C:\WINDOWS\system32\cmd.exe") Sleep(1000) EndFunc ;==>_OkButton Func _Close() ;user chose to close befor running Exit EndFunc ;==>_Close Cheers @november: You were missing some things for using Event Mode: 1. You have to set the event mode with Opt(). 2. Note the difference between GuiSetOnEvent() and GuiCtrlSetOnEvent(). 3. Once you do set event mode, GuiGetMsg() won't work anymore, and isn't needed. Try it this way: #include <GUIConstantsEx.au3> Opt("GuiOnEventMode", 1) $first = GUICreate("Disk Check Utility", 500, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") GUICtrlCreateLabel("This utility will AUTOMATE the task of checking your system disk for errors", 10, 20) $okButton = GUICtrlCreateButton("OK", 50, 50, 60) GUICtrlSetOnEvent($okButton, "_OkButton") GUISetState(@SW_SHOW) While 1 Sleep(10); wait WEnd Func _OkButton() ;user chooses to run application MsgBox(0, "GUI Event", "You pressed OK!") ; <snip> EndFunc ;==>_OkButton Func _Close() ;user chose to close befor running Exit EndFunc ;==>_Close Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
November Posted October 10, 2008 Share Posted October 10, 2008 @november: You were missing some things for using Event Mode: 1. You have to set the event mode with Opt(). 2. Note the difference between GuiSetOnEvent() and GuiCtrlSetOnEvent(). 3. Once you do set event mode, GuiGetMsg() won't work anymore, and isn't needed. Try it this way: #include <GUIConstantsEx.au3> Opt("GuiOnEventMode", 1) $first = GUICreate("Disk Check Utility", 500, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") GUICtrlCreateLabel("This utility will AUTOMATE the task of checking your system disk for errors", 10, 20) $okButton = GUICtrlCreateButton("OK", 50, 50, 60) GUICtrlSetOnEvent($okButton, "_OkButton") GUISetState(@SW_SHOW) While 1 Sleep(10); wait WEnd Func _OkButton() ;user chooses to run application MsgBox(0, "GUI Event", "You pressed OK!") ; <snip> EndFunc ;==>_OkButton Func _Close() ;user chose to close befor running Exit EndFunc ;==>_Close Hi there PsaltyDS I know It's a personal issue... i never liked to used event mode Call me old fashion Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
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