Sign in to follow this  
Followers 0
Jabez

Invoking an autoit script

7 posts in this topic

In several instances I am doing some initial processing in Winbatch and then invoking an autoit script to complete my process. The problem occurs when I issue a RunWait(Winbatch) command to invoke a specific autoit script. What happens is the editor starts. According to the registry the default process is RUN not EDIT. Can you shed any light on this problem. I can get around it by using a different version of the Run command. I would prefer not to use this second version of the Run command as it more complicated.

This is the Winbatch function being attemped

RunWait("C:\Program Files\Autoit3\myau3s\test04.au3", " ")

and this is the one that works but I do not like

RunShell("C:\Program Files\autoit3\autoit3.exe","test04.au3","C:\Program Files\autoit3\myau3s\",@Normal,@WAIT)

Share this post


Link to post
Share on other sites



Why are you using WinBatch instead of doing it in AutoIt?

Does WinBatch have a ShellExecute command?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I didn't try it in winbatch but if it is paying attention to the registry and doing a "run" and your settings are correct it should work. the second command is the command that is actually being run to run your au3 file. it's not a stand alone executable. is there a reason you aren't compiling them into exe files?

one thing you could try is changing the "open" registry setting and making it the same as the "run". this is what my registry settings look like (these are default settings when i chose "run script option), if you copy it into a .reg you can import it directly.

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\AutoIt3Script]
@="AutoIt v3 Script"
[HKEY_CLASSES_ROOT\AutoIt3Script\DefaultIcon]
@="C:\\Program Files (x86)\\AutoIt3\\Icons\\au3script_v10.ico"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell]
@="Run"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Compile]
@="Compile Script"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Compile\Command]
@="\"C:\\Program Files (x86)\\AutoIt3\\Aut2Exe\\Aut2Exe.exe\" /in \"%l\""
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Compile with Options]
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Compile with Options\Command]
@="\"C:\\Program Files (x86)\\AutoIt3\\SciTE\\AutoIt3Wrapper\\AutoIt3Wrapper.exe\" /ShowGui /in \"%l\""
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\CompileX64]
@="Compile Script (x64)"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\CompileX64\Command]
@="\"C:\\Program Files (x86)\\AutoIt3\\Aut2Exe\\Aut2Exe_x64.exe\" /in \"%l\""
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\CompileX86]
@="Compile Script (x86)"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\CompileX86\Command]
@="\"C:\\Program Files (x86)\\AutoIt3\\Aut2Exe\\Aut2Exe.exe\" /in \"%l\""
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Edit]
@="Edit Script"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Edit\Command]
@="\"C:\\Program Files (x86)\\AutoIt3\\SciTE\\SciTE.exe\" \"%1\""
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Open]
@="Open"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Open\Command]
@="\"C:\\Program Files (x86)\\AutoIt3\\SciTE\\SciTE.exe\" \"%1\""
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Run]
@="Run Script"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Run\Command]
@="\"C:\\Program Files (x86)\\AutoIt3\\AutoIt3.exe\" \"%1\" %*"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\RunX64]
@="Run Script (x64)"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\RunX64\Command]
@="\"C:\\Program Files (x86)\\AutoIt3\\AutoIt3_x64.exe\" \"%1\" %*"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\RunX86]
@="Run Script (x86)"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\RunX86\Command]
@="\"C:\\Program Files (x86)\\AutoIt3\\AutoIt3.exe\" \"%1\" %*"
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Tidy]
[HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Tidy\Command]
@="\"C:\\Program Files (x86)\\AutoIt3\\SciTE\\Tidy\\Tidy.exe\" \"%1\""
Edited by tlman12

Share this post


Link to post
Share on other sites

Thank for your responses.

The reason for using Winbatch is that I have been using it for about 16 years and I feel comfortable using it.

I have been using autoit for 1 month. Winbatch does have a ShellExecute function but it does not have a

wait feature.

While changing the registry might be an option, I try to stay away from that due to some rather disasterous

experiences.

I prefer to work in the interpretative mode rather than the exe mode due to speed of changing.

In all of my previous occurrences using the RUN command and just specifying the file, the associated program

specified in the registry has been invoked.

RUN("any txt file") and notepad starts

Run("any mp3") and my mp3 player program starts

Share this post


Link to post
Share on other sites

Have you tried converting the autoit script into and executable and call that instead? Also though the longer command may be ugly; but it is very specific and you are using automation software so just automate it :P

Share this post


Link to post
Share on other sites

The reason for using Winbatch is that I have been using it for about 16 years and I feel comfortable using it.

I have been using autoit for 1 month. Winbatch does have a ShellExecute function but it does not have a

wait feature.

Eh...WinBatch uses the TimeDelay function, which is very similar to the Sleep function in Autoit.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Eh...WinBatch uses the TimeDelay function, which is very similar to the Sleep function in Autoit.

or you can compile this into an exe

if $cmdLine[0] <> "" Then
if IsNumber($cmdLine[1]) Then
Sleep($cmdLine[1])
EndIf
EndIf

i do this for batch scripting because there isn't a good sleep function, but all you do is call it from your script of whatever language and pass it the milliseconds to sleep. so runwait(sleep.exe 500) will sleep for a half a second.

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