Sign in to follow this  
Followers 0
WundaGirl

Noob need HOw to

9 posts in this topic

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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()

Share this post


Link to post
Share on other sites

#4 ·  Posted (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

Opt("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 by dasiuss

Share this post


Link to post
Share on other sites

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

Opt("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

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by Richard Robertson

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

I realized there was another mistake. I edited my post above which should be correct now.

Share this post


Link to post
Share on other sites

Thanks that was definitely a noobie mistake. Works great thanks

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  
Followers 0