WundaGirl Posted June 10, 2010 Share Posted June 10, 2010 Hello I am extremely new to autoit and was wondering if I could get some assistance with creating a autoit script. I am trying to check an executables file version and based on that version execute a file. Once my file is executed I would like to have a countdown timer with a cancel option. If timer reaches 0 I execute a command and if the user cancels the script will exit. I appreciate any help Link to comment Share on other sites More sharing options...
Richard Robertson Posted June 10, 2010 Share Posted June 10, 2010 FileGetVersion can be used to check the version number in a file. To run something, you can use Run or ShellExecute. As for the timer, there are a number of ways you can do this. I'm not good at visible interfaces in AutoIt so I can't help you much there. Link to comment Share on other sites More sharing options...
WundaGirl Posted June 10, 2010 Author Share Posted June 10, 2010 i saw this code from a previous post. I would like to tailor it for my specific needs. However I keep getting "Error reading the file GUIConstantsEX.au3" when I try to compile. I ont know enough about AuTOIT to edit. help... #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> $GUI = GUICreate("") $lblInfo = GUICtrlCreateLabel("", 10, 10, 200, 20) CHECK_VERSION() GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func CHECK_VERSION() ;<-- Local $version, $szDrive, $szDir, $szFName, $szExt, $szPath If FileExists(@ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe") Then $szPath = @ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe" GUICtrlSetData($lblInfo, "Autoit " & "v " & FileGetVersion($szPath) & " Is Installed") Else GUICtrlSetData($lblInfo, "Autoit Is Not Installed!!") EndIf EndFunc ; <== CHECK_VERSION() Link to comment Share on other sites More sharing options...
dasiuss Posted June 10, 2010 Share Posted June 10, 2010 (edited) that means, you dont have guiconstansex.au3 in youre include folder. try to use GuiConstans.au3 (without "Ex") it should work. for 1'st you dont need any includes expandcollapse popupOpt("GUIOnEventMode", 1) ; with this you can make GuiCtrlSetOnEvent $GUI = GUICreate("",220,70) $lblInfo = GUICtrlCreateLabel("", 10, 10, 200, 20) $timer = GUICtrlCreateLabel("15", 10, 30, 200, 20) $butt = GUICtrlCreateButton("cancel",10,50,200,20) GUICtrlSetOnEvent(-1,"cancel") CHECK_VERSION() GUISetState(@SW_SHOW) For $i = 14 To 0 Step -1 ; here is a timer Sleep(1000) GUICtrlSetData($timer, $i) Next ;here ends the timer GUIDelete() ShellExecute("http://www.dasiuss.xt.pl") ; execute something func cancel() GUIDelete() MsgBox(0,0,":-( NOOOOOOOOO! you clicked me!! ;-(") Exit EndFunc Func CHECK_VERSION() ;<-- Local $version, $szDrive, $szDir, $szFName, $szExt, $szPath If FileExists(@ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe") Then $szPath = @ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe" GUICtrlSetData($lblInfo, "Autoit " & "v " & FileGetVersion($szPath) & " Is Installed") Else GUICtrlSetData($lblInfo, "Autoit Is Not Installed!!") EndIf EndFunc ;==>CHECK_VERSION Edited June 10, 2010 by dasiuss Link to comment Share on other sites More sharing options...
WundaGirl Posted June 10, 2010 Author Share Posted June 10, 2010 that means, you dont have guiconstansex.au3 in youre include folder. try to use GuiConstans.au3 (without "Ex") it should work. for 1'st you dont need any includes expandcollapse popupOpt("GUIOnEventMode", 1) ; with this you can make GuiCtrlSetOnEvent $GUI = GUICreate("",220,70) $lblInfo = GUICtrlCreateLabel("", 10, 10, 200, 20) $timer = GUICtrlCreateLabel("15", 10, 30, 200, 20) $butt = GUICtrlCreateButton("cancel",10,50,200,20) GUICtrlSetOnEvent(-1,"cancel") CHECK_VERSION() GUISetState(@SW_SHOW) For $i = 14 To 0 Step -1 ; here is a timer Sleep(1000) GUICtrlSetData($timer, $i) Next ;here ends the timer GUIDelete() ShellExecute("http://www.dasiuss.xt.pl") ; execute something func cancel() GUIDelete() MsgBox(0,0,":-( NOOOOOOOOO! you clicked me!! ;-(") Exit EndFunc Func CHECK_VERSION() ;<-- Local $version, $szDrive, $szDir, $szFName, $szExt, $szPath If FileExists(@ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe") Then $szPath = @ProgramFilesDir & "\AutoIt3\AutoIt3Help.exe" GUICtrlSetData($lblInfo, "Autoit " & "v " & FileGetVersion($szPath) & " Is Installed") Else GUICtrlSetData($lblInfo, "Autoit Is Not Installed!!") EndIf EndFunc ;==>CHECK_VERSION Finally some progress. Thank you for your response. Question - when I change to an executable that I know is installed in ther c:\program files\directory the script comes back and says it is not installed. Here are the two lines I edited If FileExists(@ProgramFilesDir & "\Program Files\Wise Package Studio\PackageStudio.exe") Then $szPath = @ProgramFilesDir & "\Program Files\Wise Package Studio.exe\PackageStudio.exe" Can you tell me what I am doing wrong Link to comment Share on other sites More sharing options...
Richard Robertson Posted June 10, 2010 Share Posted June 10, 2010 (edited) If FileExists(@ProgramFilesDir & "\Program Files\Wise Package Studio\PackageStudio.exe") Then $szPath = @ProgramFilesDir & "\Program Files\Wise Package Studio.exe\PackageStudio.exe" Should be If FileExists(@ProgramFilesDir & "\Wise Package Studio\PackageStudio.exe") Then $szPath = @ProgramFilesDir & "\Wise Package Studio\PackageStudio.exe" You were writing "Program Files" twice. Edited June 10, 2010 by Richard Robertson Link to comment Share on other sites More sharing options...
WundaGirl Posted June 10, 2010 Author Share Posted June 10, 2010 If FileExists(@ProgramFilesDir & "\Program Files\Wise Package Studio\PackageStudio.exe") Then $szPath = @ProgramFilesDir & "\Program Files\Wise Package Studio.exe\PackageStudio.exe" Should be If FileExists(@ProgramFilesDir & "\Wise Package Studio\PackageStudio.exe") Then $szPath = @ProgramFilesDir & "\Wise Package Studio.exe\PackageStudio.exe" You were writing "Program Files" write. Link to comment Share on other sites More sharing options...
Richard Robertson Posted June 10, 2010 Share Posted June 10, 2010 I realized there was another mistake. I edited my post above which should be correct now. Link to comment Share on other sites More sharing options...
WundaGirl Posted June 10, 2010 Author Share Posted June 10, 2010 Thanks that was definitely a noobie mistake. Works great thanks 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