AutoIt Forums: Frequently Asked Questions (FAQs) - AutoIt Forums

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Frequently Asked Questions (FAQs) READ ME BEFORE POSTING!

#1 User is offline   this-is-me 

  • Pursuer of obscure functionality
  • PipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 2,370
  • Joined: 02-April 04

Posted 17 October 2006 - 03:58 AM

As a long time user of these forums, I have come to notice that many of the questions asked by first-time users are repeat questions that can sometimes be easily answered. Most of these answers are not provided in a reasonable time because a current forum user must search for the answer to the OP's question, thereby shifting the work from the OP to the forum frequenter. In other cases, the reponse is given in disgust or anger because the forum user has seen the question asked many times before. Therefore, I am here posting the answers to many of the newcomer's questions. I will number the questions to provide a simple and quick reference point that any forum user can link to.

Q1. How can I debug my script?
A1. This one has a myriad of answers, but the most effective is to begin by using the SciTE4AutoIt3 Editor to create or edit scripts. This program is useful in debugging for the following reasons:
  • Syntax highlighting allows for immediate viewing of any mistakes from unended script tags or quotes. This allows the scripter to visibly see the difference between the following incorrect code


Q18. Why isn't my thread getting any replies?
[indent]A1. Did you give a good description of the problem? If your title or explanation of the issue is not descriptive, users are likely to bypass your issue instead of helping. Post titles such as "Help Me", "I Have A Problem", "Question", "Help me fix my code", "This code doesn't work" or similarly worded question titles will not readily draw forum users to your post. Experienced users (which are your best hope of resolving the issue) will often skip your post altogether in cases like this. An example of a post title descriptive enough to attract users to assist you is "Problem with WinWaitClose", or "Loop never ends".

A2. Did you post example code? If you have not posted an example of the code you are having an issue with, then you will not recieve support. When posting a non-working script, please do so in the smallest amount of stand-alone code possible. If the code you post cannot run by itself on another person's computer, they will not be able to recreate the issue.

A3. Did you use proper english? Here are guidelines for posting properly in the english language:
  • Use proper case. THIS IS CONSIDERED YELLING. if you post in ALL UPPERCASE or all lowercase, you look like a doofus when you do.
  • Use proper punctuation. Complete sentences need only one trailing punctuation mark, not three!!! Writing a sentance without simple punctuation such as commas or other punctuation is considered lazy, which is considered a good judge of the poster's coding style. If you cannot summon the strength to write a sentence with correct punctuation, you will most likely miss simple coding mistakes such as unterminated quotes.

EDIT: 11-15-06 - Added changes suggested by Larry and Paulie

Attached File(s)


This post has been edited by Jon: 20 July 2009 - 04:41 PM

0

#2 User is offline   AlainP 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 11
  • Joined: 23-October 07
  • Location:Paris, France

Posted 26 October 2007 - 03:40 PM

View Postthis-is-me, on Oct 17 2006, 04:58 AM, said:

Q2. How can I debug my script?
A2. You can also debug a script on any computer by adding the following code to your script:
This debugging is completely transparent to the user, and is only viewable with a program such as DebugView from SysInternals http://www.sysinternals.com/Utilities/DebugView.html ...
A broken link to be updated (?) to http://www.microsoft.com/technet/sysintern.../debugview.mspx
0

#3 User is offline   DaveF 

  • Smells fanboyish.
  • Icon
  • Group: Developers(Dev)
  • Posts: 631
  • Joined: 28-May 04
  • Location:Arkansas, USA

Posted 28 February 2008 - 07:19 PM

[Edit: Post retracted for technical imprecision.]

This post has been edited by DaveF: 05 March 2008 - 08:32 PM

0

#4 User is offline   martin 

  • ~~\o/~~~/0\=¬''~~~
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 5,712
  • Joined: 24-October 04
  • Location:uk

Posted 27 April 2008 - 03:09 PM

I have often answered this question.

Why does the Ctrl key get stuck down after I run my script?
It could equally be the Shift or the Alt key.

If you use Send in a script and you have a problem with keys being stuck down then Send is the most likely culprit. A similar problem can occur with BlockInput. The solution is generally quite simple. If there is a key like Shfit or Alt held down at the start of the Send sequence, but that key is released by the time the Send sequence finishes then the key will get 'stuck' down. As an example of a solution, you could replace the Send function in your script with the _SendEx function below.

[ code='text' ]    ( Popup )
;Send the string $ss after the Shift Alt and Ctrl keys are released. Optionally give a warning after 1 sec if any of those keys still down. ;Requires misc.au3 to be included in the script for the _IsPressed function.   Func _SendEx($ss,$warn = "")       Local $iT = TimerInit()             While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")           if $warn <> "" and TimerDiff($iT) > 1000 Then               MsgBox(262144, "Warning", $warn)           EndIf         sleep(50)       WEnd       Send($ss)         EndFunc;==>_SendEx




EDIT:
shilbiz discovered that the following single line can 'clear' locked down keys
[ code='text' ]    ( Popup )
ControlSend("", "", "", "text", 0)

I don't know how he came up with it but it seems to work!

EDIT 2: As explained above, the _SendEx function waits for the Shift, Alt and Ctrl keys to be released or pops up a warning if the $warn parameter is not an empty string. Therefore it is not intended to be used when one of these modifyer keys has been set to be down using any combination of {ALTDOWN}, {SHIFTDOWN} and {ALTDOWN}.

This post has been edited by martin: 13 May 2009 - 08:33 PM

0

#5 User is offline   martin 

  • ~~\o/~~~/0\=¬''~~~
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 5,712
  • Joined: 24-October 04
  • Location:uk

Posted 07 June 2008 - 09:55 PM

View PostYggdrasil, on May 19 2008, 07:30 PM, said:

Q3 is wrong.

I tried and tried and wondered why I'd always get a message that my script is already running when it isn't and a look in the UDF help brought the answer:


Yes.
I think _Singleton is confusing. It might not return or it will return with either the handle to the mutex or the error for the mutex already existing.
I think this is easier.
[ code='text' ]    ( Popup )
If _MutexExists("MydeswswScriptName") Then ; We know the script is already running. Let the user know.     MsgBox(0, "Script Name", "This script is already running. Using multiple copies of this script at the same breaks the [(UltimaCoder)] License!")     Exit EndIf Func _MutexExists($sOccurenceName)     Local $ERROR_ALREADY_EXISTS = 183, $handle, $lastError         $sOccurenceName = StringReplace($sOccurenceName, "\", ""); to avoid error     $handle = DllCall("kernel32.dll", "int", "CreateMutex", "int", 0, "long", 1, "str", $sOccurenceName)     $lastError = DllCall("kernel32.dll", "int", "GetLastError")     Return $lastError[0] = $ERROR_ALREADY_EXISTS     EndFunc  ;==>_MutexExists

0

#6 User is offline   JamesBrooks 

  • Let's watch this city burn the world
  • PipPipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 7,394
  • Joined: 24-November 06
  • Gender:Male
  • Location:United Kingdom

Posted 20 July 2008 - 12:00 AM

Maybe Q7 should include a copy of GUISetAccelerators()?
0

#7 User is offline   Zedna 

  • AutoIt rulez!
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 6,249
  • Joined: 17-June 05
  • Location:Czech republic

Posted 27 August 2008 - 12:33 PM

Q21. Why my script doesn't work on locked station?
A21. On locked station any window will never be active (active is only dialog with text "Press Ctrl+Alt+Del")
In Windows locked state applications runs hidden (behind that visible dialog) and haven't focus and active status.

So generally don't use Send() MouseClick() WinActivate() WinWaitActive() WinActive() etc.
Instead use ControlSend() ControlSetText() ControlClick() WinWait() WinExists() WinMenuSelectItem() etc.

This way you may have your script resistive against another active windows.
and it's possibe to run such script from scheduler on locked Windows station.

This post has been edited by Zedna: 29 August 2008 - 01:08 PM

0

#8 User is offline   BrettF 

  • If the worlds end is today, its already tommorow in AUS
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 7,191
  • Joined: 02-October 06
  • Location:Brisbane, Australia

Posted 06 November 2008 - 11:57 AM

Q22. Why can't I decompile my script any more?

Decomplation is not supported any more, and is only available for the older versions of AutoIt (Version 3.2.5.1 and earlier compiled scripts).

Please do not post on this topic, but search the forums for decomplation.

Cheers,

Brett
0

#9 User is offline   Jikoo 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 69
  • Joined: 16-September 08
  • Location:France

Posted 21 November 2008 - 06:01 PM

.
Start AutoIt3 development
For newbies


Editor for AutoIt3 scripts


The AutoIt help File
(F1 hotkey in Scite Editor)




Written completely with AutoIt to Demonstrate some of the Capabilities of AutoIt

http://www.xpcleanmenu.hostrocket.com/Autoit/Images/Autoit-1-2-3.jpg


Tutorial in PDF


Koda Form Designer is a standalone application for designing forms for AutoIt GUI

http://www.autoitscript.com/fileman/users/lookfar/images/koda_small.gif



http://www.quadryders.com/images/forums/AutoIt/AutoItMenuScreenshot.jpg



http://creator-lab.ucoz.ru/Images/Opera_AutoIt.png

.

This post has been edited by Jikoo: 29 November 2008 - 07:51 PM

0

#10 User is offline   BrettF 

  • If the worlds end is today, its already tommorow in AUS
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 7,191
  • Joined: 02-October 06
  • Location:Brisbane, Australia

Posted 25 November 2008 - 08:21 AM

Q24. Where can I learn AutoIt? Are there any tutorials?
For this you have 2 main options availible.

There is AutoIt 1-2-3, an interactive classroom by Valauter. You may find it here:
http://www.autoitscript.com/forum/index.php?showtopic=21048

I have also updated LxP's AutoIt tutorial. You can find it here:
http://www.autoitscript.com/forum/index.php?showtopic=84960

Cheers.

Brett

This post has been edited by BrettF: 25 November 2008 - 09:57 PM

0

#11 User is offline   FireFox 

  • Quickest obfuscated spammer !!!
  • PipPipPipPipPipPip
  • Group: Full Members
  • Posts: 1,692
  • Joined: 10-November 08
  • Location:France

Posted 28 December 2008 - 02:38 PM

Q19.How can I use Pixel functions ?

[left]A1.PixelCheckSum
Description : Generates a checksum for a region of pixels.
Function PixelChecksumReturns the checksum value of the region.



Example :
http://img99.imageshack.us/img99/1289/pixelchecksumgr8.png



Q20.Who can help me for begin in autoit ?
Dont forget that AutoIt have helpfile for help you to check functions :)

1.Instead of going to autoit forum and ask for a simple function (Ex : What is GuiCreate ?) use autoit help :

-highlight function
http://img261.imageshack.us/img261/4162/highlightal4.png

-go to help menu and select "Help F1"
-or press F1
http://img261.imageshack.us/img261/5491/helpao8.png

Cheers, FireFox.

This post has been edited by Jon: 20 July 2009 - 04:43 PM

0

#12 User is offline   BrettF 

  • If the worlds end is today, its already tommorow in AUS
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 7,191
  • Joined: 02-October 06
  • Location:Brisbane, Australia

Posted 10 January 2009 - 08:08 AM

Question 25- I have run a program, but how can I get the window handle?

Refer to the following example, showing converting and use when manipulating the window. Function is based on work by Smoke_N/Hubertus and Helge
[ code='text' ]    ( ExpandCollapse - Popup )
;Run process $iPID = Run("Notepad.exe") ;Allow window to initialize... Sleep (500) ;Get HWND. $hWnd = _GetHwndFromPID($iPID) ;Maximize WinSetState($hWnd, "", @SW_MAXIMIZE) Sleep(2000);Wait 2 seconds ;Minimize WinSetState($hWnd, "", @SW_MINIMIZE) Sleep(2000);Wait 2 seconds ;Restore window WinSetState($hWnd, "", @SW_RESTORE) Sleep(2000);Wait 2 seconds ;Move top left corner of screen, and resize to 800x600 WinMove($hWnd, "", 0, 0, 800, 600) Sleep(2000);Wait 2 seconds ;Move to center of screen ;Calculate Center of screen. $x = (@DesktopWidth / 2) - 400; Desktop width divided by 2, then minus half the width of the window $y = (@DesktopHeight / 2) - 300; Desktop height divided by 2, then minus half the height of the window WinMove($hWnd, "", $x, $y) Sleep(2000);Wait 2 seconds ;Close notepad WinClose($hWnd) ;Function for getting HWND from PID Func _GetHwndFromPID($PID)     $hWnd = 0     $winlist = WinList()     Do         For $i = 1 To $winlist[0][0]             If $winlist[$i][0] <> "" Then                 $iPID2 = WinGetProcess($winlist[$i][1])                 If $iPID2 = $PID Then                     $hWnd = $winlist[$i][1]                     ExitLoop                 EndIf             EndIf         Next     Until $hWnd <> 0     Return $hWnd EndFunc  ;==>_GetHwndFromPID


EDIT: Modified example code... Its much faster than my previous tests!

This post has been edited by BrettF: 27 January 2009 - 07:36 AM

0

#13 User is offline   ResNullius 

  • Drink Deep, or Taste Not the Pierian Spring
  • PipPipPipPipPip
  • Group: Full Members
  • Posts: 963
  • Joined: 08-April 07
  • Gender:Male
  • Location:Canada, eh? (that's why I spells culur with a "u")

Posted 10 January 2009 - 10:05 AM

View PostBrettF, on Jan 9 2009, 11:08 PM, said:

[ code='text' ]    ( Popup )
;Function for getting HWND from PID Func _GetHwndFromPID($PID)     $hWnd = 0     $stPID = DllStructCreate("int")     Do         $winlist2 = WinList()         For $i = 1 To $winlist2[0][0]             If $winlist2[$i][0] <> "" Then                 DllCall("user32.dll", "int", "GetWindowThreadProcessId", "hwnd", $winlist2[$i][1], "ptr", DllStructGetPtr($stPID))                 If DllStructGetData($stPID, 1) = $PID Then                     $hWnd = $winlist2[$i][1]                     ExitLoop                 EndIf             EndIf         Next         Sleep(100)     Until $hWnd <> 0     Return $hWnd EndFunc;==>_GetHwndFromPID

Brett,
What's wrong with using the built-in WinGetProcess() in this function instead of the DllCall()? :D

Edit: You had also posted another version by Helge
http://www.autoitscript.com/forum/index.ph...st&p=601027
and Smoke_N made one that was modified by Hubertus.
Hube's original posts are gone, but a copy of the function is in the code in the post here:
http://www.autoitscript.com/forum/index.ph...st&p=621983

This post has been edited by ResNullius: 10 January 2009 - 10:28 AM

0

#14 User is offline   BrettF 

  • If the worlds end is today, its already tommorow in AUS
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 7,191
  • Joined: 02-October 06
  • Location:Brisbane, Australia

Posted 10 January 2009 - 11:54 AM

Good point...

I'll do speed tests, to see whats the fastest... :D


Cheers,

Brett

EDIT:
Results Vs Helge and the one I posted.
Function 1 = Helge's
Function 2 = The other one...
Function 3 = Smokes/Hubertus'

Test 1
Function 1: 245.944692ms
Function 2: 109.311855ms
Function 3: 5.066022ms

Test 2
Function 1: 241.10388ms
Function 2: 109.7961ms
Function 3: 5.805465ms

Test 3
Function 1: 239.468955ms
Function 2: 109.495308ms
Function 3: 4.921413ms


Always visible which is faster. By a long shot too...
Will update my original post.

This post has been edited by BrettF: 10 January 2009 - 12:04 PM

0

#15 User is offline   Zachlr 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 63
  • Joined: 14-December 07

Posted 22 April 2009 - 11:43 PM

Hi, I just want to add a third method to starting your program at start up. I think it will only work on Windows Vista. It is very simple, see below.

[ autoIt ]    ( Popup )
Run("schtasks /create /sc ONSTART /tn "Task name" /tr " & @ScriptFullPath & '"') ;or Run("schtasks /create /sc ONLOGON /tn "Task name" /tr " & @ScriptFullPath & '"')

This post has been edited by Zachlr: 22 April 2009 - 11:48 PM

0

#16 User is offline   BrettF 

  • If the worlds end is today, its already tommorow in AUS
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 7,191
  • Joined: 02-October 06
  • Location:Brisbane, Australia

Posted 23 April 2009 - 10:35 PM

View PostZachlr, on Apr 23 2009, 08:43 AM, said:

Hi, I just want to add a third method to starting your program at start up. I think it will only work on Windows Vista. It is very simple, see below.

[ autoIt ]    ( Popup )
Run("schtasks /create /sc ONSTART /tn "Task name" /tr " & @ScriptFullPath & '"') ;or Run("schtasks /create /sc ONLOGON /tn "Task name" /tr " & @ScriptFullPath & '"')

How about you check the syntax of that, specifically the use of "" and ''...
0

#17 User is offline   Sarvesh 

  • Newbie
  • Group: Members
  • Posts: 1
  • Joined: 19-June 09

Posted 19 June 2009 - 08:40 AM

View PostZedna, on Aug 27 2008, 06:03 PM, said:

Q21. Why my script doesn't work on locked station?
A21. On locked station any window will never be active (active is only dialog with text "Press Ctrl+Alt+Del")
In Windows locked state applications runs hidden (behind that visible dialog) and haven't focus and active status.

So generally don't use Send() MouseClick() WinActivate() WinWaitActive() WinActive() etc.
Instead use ControlSend() ControlSetText() ControlClick() WinWait() WinExists() WinMenuSelectItem() etc.

This way you may have your script resistive against another active windows.
and it's possibe to run such script from scheduler on locked Windows station.


Hi, i am having a script which opens a command prompt window and then sends commands to it. I want this script to run even if my workstation is locked. Yous said to use controlsend, however i have read that controlsend should not be used for sending commands to command prompt window. So now what to do...PLease help!!!!!!
0

#18 User is offline   BrettF 

  • If the worlds end is today, its already tommorow in AUS
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 7,191
  • Joined: 02-October 06
  • Location:Brisbane, Australia

Posted 19 June 2009 - 09:03 AM

Not the thread for it. Post a question in the support forum by posting your own topic...
0

#19 User is offline   fabyocabral 

  • Newbie
  • Group: Members
  • Posts: 2
  • Joined: 20-July 09

Posted 20 July 2009 - 07:26 PM

I have a window that always has the same name in the title for example: Microsoft Internet Explorer.
But what it´s into this window (Microsoft Internet Explorer) i can´t select the text, so I can´t indentify a new window during a procces, somebody help me?
0

#20 User is online   PsaltyDS 

  • Most Venerable Penguin
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 9,704
  • Joined: 12-December 05
  • Location:Victoria Crater, Mars

Posted 21 July 2009 - 10:47 PM

View Postfabyocabral, on 20 July 2009 - 02:26 PM, said:

I have a window that always has the same name in the title for example: Microsoft Internet Explorer.
But what it´s into this window (Microsoft Internet Explorer) i can´t select the text, so I can´t indentify a new window during a procces, somebody help me?


See post #18.

First, search for other posts on the same topic for the answer.
If you don't find it post your own new topic.
Be careful to post in the correct forum (which General Help and Support is).
Do not post questions into the FAQ sticky topic.

:mellow:
1

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users