Jump to content

Noob need HOw to


Recommended Posts

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

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

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
Link to comment
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

Link to comment
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\PackageStudio.exe"

You were writing "Program Files" twice.

Edited by Richard Robertson
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...