this-is-me Posted October 17, 2006 Share Posted October 17, 2006 (edited) 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? 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 PaulieShellFileOperation.au3FileRegister.au3 Edited July 20, 2009 by Jon Who else would I be? Link to comment Share on other sites More sharing options...
AlainP Posted October 26, 2007 Share Posted October 26, 2007 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 OS: Win XP Pro SP2, AutoIt Version: 3.2.8.1 / 3.2.9.10, SciTE: 1.74 11/15/2007 Link to comment Share on other sites More sharing options...
DaveF Posted February 28, 2008 Share Posted February 28, 2008 (edited) [Edit: Post retracted for technical imprecision.] Edited March 5, 2008 by DaveF Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines. Link to comment Share on other sites More sharing options...
martin Posted April 27, 2008 Share Posted April 27, 2008 (edited) 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.;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;==>_SendExEDIT:shilbiz discovered that the following single line can 'clear' locked down keysControlSend("", "", "", "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}. Edited May 13, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
martin Posted June 7, 2008 Share Posted June 7, 2008 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. 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 vicsar 1 Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
James Posted July 19, 2008 Share Posted July 19, 2008 Maybe Q7 should include a copy of GUISetAccelerators()? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Zedna Posted August 27, 2008 Share Posted August 27, 2008 (edited) 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. Edited August 29, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
BrettF Posted November 6, 2008 Share Posted November 6, 2008 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 Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Jikoo Posted November 21, 2008 Share Posted November 21, 2008 (edited) .Start AutoIt3 developmentFor newbiesSciTE4AutoIt3.exeEditor for AutoIt3 scriptsThe AutoIt help File(F1 hotkey in Scite Editor)This AutoIt Forum Search engineAutoIt 1-2-3Written completely with AutoIt to Demonstrate some of the Capabilities of AutoItLearning to Script with AutoIt 3Tutorial in PDFKODA FormDesignerKoda Form Designer is a standalone application for designing forms for AutoIt GUIAdd-on Firefox browserAdd-on Opera browser. Edited December 23, 2012 by Jon My projects : GCS Search 1.07 (GUI Control Styles Search)* Multilingual tool to help about the old scripts, with a dynamic menu.* Easy way to find missing Include files in old scripts downloaded from forums !* Famous Monoceres script added and improved (visual, drag and drop, automatic)* There is an interactive color converter with palettes too, for fun !The best way to start Autoit3 development (for newbies). Link to comment Share on other sites More sharing options...
BrettF Posted November 25, 2008 Share Posted November 25, 2008 (edited) 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=21048I have also updated LxP's AutoIt tutorial. You can find it here:http://www.autoitscript.com/forum/index.php?showtopic=84960Cheers.Brett Edited November 25, 2008 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
FireFox Posted December 28, 2008 Share Posted December 28, 2008 (edited) Q19.How can I use Pixel functions ? A1.PixelCheckSum Description : Generates a checksum for a region of pixels. Function PixelChecksumReturns the checksum value of the region. Example : 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 -go to help menu and select "Help F1" -or press F1 Cheers, FireFox. Edited July 20, 2009 by Jon Link to comment Share on other sites More sharing options...
BrettF Posted January 10, 2009 Share Posted January 10, 2009 (edited) 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 Helgeexpandcollapse 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 ;==>_GetHwndFromPIDEDIT: Modified example code... Its much faster than my previous tests! Edited January 27, 2009 by BrettF Xandy 1 Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
ResNullius Posted January 10, 2009 Share Posted January 10, 2009 (edited) ;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;==>_GetHwndFromPIDBrett, What's wrong with using the built-in WinGetProcess() in this function instead of the DllCall()? 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 Edited January 10, 2009 by ResNullius Link to comment Share on other sites More sharing options...
BrettF Posted January 10, 2009 Share Posted January 10, 2009 (edited) Good point...I'll do speed tests, to see whats the fastest... Cheers,BrettEDIT:Results Vs Helge and the one I posted.Function 1 = Helge'sFunction 2 = The other one...Function 3 = Smokes/Hubertus'Test 1Function 1: 245.944692msFunction 2: 109.311855msFunction 3: 5.066022msTest 2Function 1: 241.10388msFunction 2: 109.7961msFunction 3: 5.805465msTest 3Function 1: 239.468955msFunction 2: 109.495308msFunction 3: 4.921413msAlways visible which is faster. By a long shot too...Will update my original post. Edited January 10, 2009 by BrettF Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Zachlr Posted April 22, 2009 Share Posted April 22, 2009 (edited) 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. Run("schtasks /create /sc onstart /tn "Task name" /tr " & @ScriptFullPath & '"') ;or Run("schtasks /create /sc ONLOGON /tn "Task name" /tr " & @ScriptFullPath & '"') Edited April 22, 2009 by Zachlr Link to comment Share on other sites More sharing options...
BrettF Posted April 23, 2009 Share Posted April 23, 2009 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. 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 ''... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Sarvesh Posted June 19, 2009 Share Posted June 19, 2009 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!!!!!! Link to comment Share on other sites More sharing options...
BrettF Posted June 19, 2009 Share Posted June 19, 2009 Not the thread for it. Post a question in the support forum by posting your own topic... Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
fabyocabral Posted July 20, 2009 Share Posted July 20, 2009 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? Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 21, 2009 Share Posted July 21, 2009 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. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts