• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

AutoIT Frequently Asked Questions (FAQ) / Autoit help

Status
Not open for further replies.

DDoSer

The Real DDoSer
User
Joined
Oct 9, 2013
Messages
352
Reputation
0
Reaction score
4,578
Points
243
Credits
0
‎11 Years of Service‎
51%
1. How can I run a DOS program from within AutoIt?

If you wanted to run something like a DOS "Dir" command then you must run it though the command interpreter (command.com or cmd.exe depending on your OS). The @ComSpec macro contains the correct location of this file. You should use the RunWait() function as it waits for the DOS program to finish before continuing with the next line of the script. Here is an example of running the DOS Dir command on the C: drive: (effectively running the command command.com /c Dir C:\ )

Code:
>RunWait(@ComSpec & " /c Dir C:\")


2. Why can I only use Run() to execute .exe files? What about .msi / .txt and others?

Only a few file extensions are usually "runable" - these are .exe, .bat, .com, .pif. Other file types like .txt and .msi are actually executed with another program. When you double click on a "myfile.msi" file what actually happens in the background is that "msiexec.exe myfile.msi" is executed. So to run a .msi file from AutoIt you would do:

Code:
>RunWait("msiexec myfile.msi")
Or, run the command "start" which will automatically work out how to execute the file for you:

Code:
>RunWait(@ComSpec & " /c Start myfile.msi")
Or, use the ShellExecuteWait function which will automatically work out how to execute the file for you:

Code:
>ShellExecuteWait("myfile.msi")


3. Why do I get errors when I try and use double quotes (") ?

If you want to use double-quotes inside a string then you must "double them up". So for every one quote you want you should use two. For example if you wanted to set a variable to the string: A word in "this" sentence has quotes around it! You would do:

Code:
>$var = "A word in ""this"" sentence has quotes around it!"
or use single quotes instead:

Code:
>$var = 'A word in "this" sentence has quotes around it!'


4. What do the window "title" and "text" parameters mean?

There is a detailed description
This link is hidden for visitors. Please Log in or register now.
.



5. Why can't I print a variable using "My var is $variable"?

If you have a variable called $msg and you want to print in inside a MsgBox then this will NOT work:

Code:
>MsgBox(0, "Example", "My variable is $msg")
It will actually print My variable is $msg. What you need to do is tell AutoIt to join the string and the variable together using the & operator:

Code:
>MsgBox(0, "Example", "My variable is " & $msg)
Advanced: If you have many variables to add into a string then you may find the StringFormat() function useful. For example, if I wanted to insert $var1 to $var5 into a string then it may be easier to do:

Code:
> $msg = StringFormat("Var1 is %s, Var2 is %s, Var3 is %s, Var4 is %s", $var1, $var2, $var3, $var4)
    MsgBox(0, "Example", $msg)


6. When I use Send() to send a variable odd things happen?

If you are sending the contents of a variable then be mindful that if it contains special send characters like ! ^ + {SPACE} then these will be translated into special keystrokes - rarely what is wanted. To overcome this use the RAW mode of Send() that does not translate special keys:

Code:
>Send($myvar, 1)


7. What is the difference between the return value and @error?

Generally a return value is used to indicate the success of a function. But, if a function is already returning something ( like WinGetText() ) then we need to have a way of working out if the function was successful, so we set @error instead.



8. How can I exit my script with a hot-key?

Ah, an easy one. If you want to make your script exit when you press a certain key combination then use the HotKeySet() function to make a user function run when the desired key is pressed. This user function should just contain the Exit keyword.

Here some code that will cause the script to exit when CTRL+ALT+x is pressed:

Code:
>HotKeySet("^!x", "MyExit")
...
...
; Rest of Script
...
...
Func MyExit()
   Exit
EndFunc


9. How can I use a custom icon when compiling my scripts?

You need to run the full compiler program (rather than just right-clicking a script and selecting compile). This page describes the compiler in detail.



10. How can I make sure only one copy of my script is run?

Use the _Singleton() function. See the User Defined Functions documentation for more information on _Singleton() and how to use it.



11. What are the current technical limits of AutoIt v3?

You can see it here
This link is hidden for visitors. Please Log in or register now.




12. I get a missing picture symbol in the Help file under the Examples.

This should be the Open button that enable you to open the Examples in the Help file.

This issue is that the hhctrl.ocx isn't properly registered or corrupted.

Try registering it by doing "regsvr32 hhctrl.ocx" from the command prompt or check if the file is still valid.




You have question? Your code don't work correctly?


Ask for autoit v3 help HERE




 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top