x' v3.3.14.2 ©1999-2015 jonathan bennett & autoit team autoit … · autoit via an...
TRANSCRIPT
'X'
v3.3.14.2
©1999-2015JonathanBennett&AutoItTeam
AutoItv3Homepage
IntroductionAutoItv3isafreewareBASIC-likescriptinglanguagedesignedforautomatingtheWindowsGUI.Itusesacombinationofsimulatedkeystrokes,mousemovementandwindow/controlmanipulationinordertoautomatetasksinawaynotpossibleorreliablewithotherlanguages(e.g.VBScriptandSendKeys).
AutoItXisaDLLversionofAutoItv3thatprovidesasubsetofthefeaturesofAutoItviaanActiveX/COMandDLLinterface.ThismeansthatyoucanaddAutoIt-likefeaturestoyourfavouritescriptingandprogramminglanguages,e.g.VB,VBScript,Delphi,C,C++,Kixtart,andmostotherlanguagesthatsupporttheuseofDLLs.
AsAutoItXprovidesasubsetofthefeaturesofAutoItv3youshouldreadthehelpfileforAutoItv3andbecomefamilarwiththebasicconcepts,including:
TheAutoItWindowInfoToolWindowsControls
Helppagesontheabovetopicsareduplicatedinthishelpfileforreference.
TheoriginalversionofAutoItcamewithtwocontrols:AutoItX(aCOM/ActiveXcontrol)andAutoItDLL(aDLLcontrol).InthisnewversionboththeCOMandDLLversionshavebeencombinedintothesingleAutoItXcontrolwhichprovidesbothmethodsofaccess.
HowyouuseAutoItXdependsonthehostlanguageyouwanttouse.IfyouareusingsomethingthatsupportsCOMobjectaccess(likeVBScript)thenusingAutoItXasaCOMcontrolisrecommended.IfyouwanttouseAutoItXfromalanguagesuchasCthenusingitasaDLLissimplest.
ThroughoutthishelpfileexamplesforCOM/ActiveXusagearegivenusingVBScript,andstandardDLLusageusingC/C++.TheseareexpectedtobethemostcommonwaysofusingAutoItX(andthetwothatIammostfamiliarwith).UsersofotherlanguagesshouldcheckouttheAutoItXsectionontheAutoItForumforhelpandadviceshouldyouneedit.
SoftwareLicenseAutoIt
Author:JonathanBennettandtheAutoItTeamWWW:https://www.autoitscript.com/site/autoit/Email:supportatautoitscriptdotcom________________________________________________________
END-USERLICENSEAGREEMENTFORTHISSOFTWARE
ThisEnd-UserLicenseAgreement("EULA")isalegalagreementbetweenyou(eitheranindividualorasingleentity)andthementionedauthorofthisSoftwareforthesoftwareproductidentifiedabove,whichincludescomputersoftwareandmayincludeassociatedmedia,printedmaterials,and"online"orelectronicdocumentation("SOFTWAREPRODUCT").Byinstalling,copying,orotherwiseusingtheSOFTWAREPRODUCT,youagreetobeboundbythetermsofthisEULA.IfyoudonotagreetothetermsofthisEULA,donotinstallorusetheSOFTWAREPRODUCT.
SOFTWAREPRODUCTLICENSE
TheSOFTWAREPRODUCTisprotectedbycopyrightlawsandinternationalcopyrighttreaties,aswellasotherintellectualpropertylawsandtreaties.TheSOFTWAREPRODUCTislicensed,notsold.
ThedefinitionofSOFTWAREPRODUCTdoesnotincludesanyfilesgeneratedbytheSOFTWAREPRODUCT,suchascompiledscriptfilesintheformofstandaloneexecutables.
1.GRANTOFLICENSE
ThisEULAgrantsyouthefollowingrights:
InstallationandUse.YoumayinstallanduseanunlimitednumberofcopiesoftheSOFTWAREPRODUCT.
ReproductionandDistribution.YoumayreproduceanddistributeanunlimitednumberofcopiesoftheSOFTWAREPRODUCTeitherinwholeorinpart;eachcopyshouldincludeallcopyrightandtrademarknotices,andshallbe
accompaniedbyacopyofthisEULA.CopiesoftheSOFTWAREPRODUCTmaybedistributedasastandaloneproductorincludedwithyourownproduct.
CommercialUse.YoumayusetheSOFTWAREPRODUCTforcommercialpurposes.Youmaysellforprofitandfreelydistributescriptsand/orcompiledscriptsthatwerecreatedwiththeSOFTWAREPRODUCT.
Reverseengineering.YoumaynotreverseengineerordisassembletheSOFTWAREPRODUCT.
2.COPYRIGHT
AlltitleandcopyrightsinandtotheSOFTWAREPRODUCT(includingbutnotlimitedtoanyimages,photographs,animations,video,audio,music,text,and"applets"incorporatedintotheSOFTWAREPRODUCT),theaccompanyingprintedmaterials,andanycopiesoftheSOFTWAREPRODUCTareownedbytheAuthorofthisSoftware.TheSOFTWAREPRODUCTisprotectedbycopyrightlawsandinternationaltreatyprovisions.Therefore,youmusttreattheSOFTWAREPRODUCTlikeanyothercopyrightedmaterial.
MISCELLANEOUS
IfyouacquiredthisproductintheUnitedKingdom,thisEULAisgovernedbythelawsoftheUnitedKingdom.IfthisproductwasacquiredoutsidetheUnitedKingdom,thenlocallawmayapply.
ShouldyouhaveanyquestionsconcerningthisEULA,orifyoudesiretocontacttheauthorofthisSoftwareforanyreason,pleasecontacthim/herattheemailaddressmentionedatthetopofthisEULA.
LIMITEDWARRANTY
1.NOWARRANTIES
TheAuthorofthisSoftwareexpresslydisclaimsanywarrantyfortheSOFTWAREPRODUCT.TheSOFTWAREPRODUCTandanyrelateddocumentationisprovided"asis"withoutwarrantyofanykind,eitherexpressorimplied,including,withoutlimitation,theimpliedwarrantiesormerchantability,fitnessforaparticularpurpose,ornon-infringement.TheentireriskarisingoutofuseorperformanceoftheSOFTWAREPRODUCTremainswithyou.
2.NOLIABILITYFORDAMAGES
InnoeventshalltheauthorofthisSoftwarebeliableforanydamageswhatsoever(including,withoutlimitation,damagesforlossofbusinessprofits,businessinterruption,lossofbusinessinformation,oranyotherpecuniaryloss)arisingoutoftheuseoforinabilitytousethisproduct,eveniftheAuthorofthisSoftwarehasbeenadvisedofthepossibilityofsuchdamages.Becausesomestates/jurisdictionsdonotallowtheexclusionorlimitationofliabilityforconsequentialorincidentaldamages,theabovelimitationmaynotapplytoyou.
[ENDOFLICENSE]
AutoItWindowInformationToolAutoItv3comeswithastandalonetoolcalledtheAutoItWindowInfoTool(ProgramFiles\AutoIt3\Au3Info.exe).Au3Infoallowsyoutogetinformationfromaspecifiedwindowthatcanbeusedtoeffectivelyautomateit.Informationthatcanbeobtainedincludes:
WindowtitlesTextonthewindow(visibleandhidden)WindowsizeandpositionContentsofthestatusbarPositionofthemousepointerColorofthepixelsunderneaththemousepointerDetailsoftheControlunderneaththemousepointer
TouseAu3Infojustrunit(fromthecommandlineorStartmenu).Au3Infowillremainthetopmostwindowatalltimessothatyoucanreadit.Onceactivemovetothewindowyouareinterestedinandactivateit-thecontentsofAu3Infowillchangetoshowtheinformationthatisavailable.WiththehelpofAu3Infoyoushouldbeautomatinginnotime!
WhenAu3InfoisrunningyoumaywanttocopytextdirectlyfromitusingCTRL-Candthenpasteitintoyourscripttoavoidspelling/caseerrors.Forthetabsthathaveinformationinalistview(likethecontrolinformationshownbelow)justdouble-clickonanentrytocopyittotheclipboard.Thiscanbedifficultwhenyouwanttocapturepixel/mouseinformationasitkeepschanging!Tohelpwiththisyoucan"freeze"theoutputofAu3InfobypressingCTRL-ALT-F.Pressthekeysagainto"unfreeze".
HereisanexampleofAu3InfoinusewiththeWindows"WordPad"editor:
WindowTitlesandText(Basic)Whenautomating,mostwindowscanbeuniquelyidentifiedbytheirtitleoracombinationoftheirtitle&text.AndbyusingAutoItWindowInfoTool(orevenbysight)thisinformationiseasytoobtain.Thetitlesofmostwindowsarefairlyobvious,forexampleUntitled-Notepadisthetitleofthenotepad.exeeditorandinmanycasesthisisenoughtoautomate.
Note:Ifablankstring""isgivenforbothtitleandtextthenthecurrentlyActivewindowwillbeused(thisisnottrueinsomeofthemoreadvancedWinTitleMatchModes)!
Windowtitlesandtextarecasesensitive.Youmustmatchthecaseandpunctuationexactly.Toavoidproblemsselectthetitle/textintheWindowInfoToolandusectrl-ctocopyitandthenpasteitdirectlyintoyourscript.
MostofAutoIt'swindowfunctionshavespaceforatitleandtextentry,hereistheWinWaitActivefunction.Thisfunctionpausesexecutionofthescriptuntilthespecifiedwindowappearsandisactive.
WinWaitActive"title",["text"],[timeout]
titleistheonlyrequiredparameterforthisfunction,boththetextandtimeoutareoptional.Insomefunctionsthetextparameterisnotoptional,ifyoudonotwishtospecifyanytextthenjustuse""(ablankstring).Ablankstring,ornothingatall,inthetexttellsAutoItthatanytextisvalid.
Tousetheabovefunctionwithanynotepadwindowboththesemethodswillwork:
oAutoIt.WinWaitActive"Untitled-Notepad"
and
oAutoIt.WinWaitActive"Untitled-Notepad",""
Ifthesamenotepadwindowhad"Thisisalineoftext"typedintothewindow,theWindowInfoToolwouldshow:
NotethattheWindowInfoToolhasseenthetitleandtextofthenotepadwindow.WhatevertheWindowInfoToolcanseeiswhatAutoItcansee.Nowwehaveenoughinformationtoidentifythisexactwindoweveniftherearelotsofothernotepadwindowsopen.Inthiscaseweuse:
oAutoIt.WinWaitActive"Untitled-Notepad","Thisissometext!"
WindowTextThewindowtextconsistsofallthetextthatAutoItcan"see".Thiswillusuallybethingslikethecontentsofeditcontrols(asabovewith"Thisisalineoftext")butwillalsoincludeothertextlike:
Buttontextlike&Yes,&No,&Next(the&indicatesanunderlinedletter)Dialogtextlike"Areyousureyouwishtocontinue?"ControltextMisctext-sometimesyoudon'tknowwhatitis:)
Theimportantthingisthatyoucanusethetextalongwiththetitletouniquelyidentifyawindowtoworkwith.
Whenyouspecifythetextparameterinawindowfunctionitistreatedasasubstring.Sofortheexampleaboveifyouusedthetext"issome"youwouldgetamatch.
WhathasbeendescribedisthedefaultmodethatAutoItoperatesin,thereareanumberofmoreadvancedmodestousewhenthingsarenotassimpleasthis.
Note:Hiddenwindowcanbematchedby"title"onlyif"text"isempty("").
WindowTitlesandText(Advanced)AutoItoperatesinoneofthree"Windowmatching"modes.ThemodesaresetwiththeAutoItSetOptionfunctionusingtheWinTitleMatchModeoption.
Mode1(default)
Matchespartialtitlesfromthestart.
InthismodetheawindowtitledUntitled-Notepadwouldbematchedby"Untitled-Notepad","Untitled","Un",etc.
eg.
oAutoIt.WinWait"Untitled"
Mode2
Matchesanysubstringinthetitle.
InthismodeawindowtitledUntitled-Notepadwouldbematchedby"Untitled-Notepad","Untitled","Notepad","pad",etc.
eg.
oAutoIt.WinWait"Notepad"
Mode3
Exacttitlematch.
InthismodeawindowtitledUntitled-Notepadwouldonlybematchedby"Untitled-Notepad"
Mode4(Keptforbackwardcompatibility)
Advancedmode
MustbereplacedwithAdvancedWindowDescriptionswhichdoesnotneedanymodetobeset.
Mode-1to-4
Forcelowercasematchaccordingtoothertypeofmatch.
AdvancedWindowDescriptionsAspecialdescriptioncanbeusedasthewindowtitleparameter.Thisdescriptioncanbeusedtoidentifyawindowbythefollowingproperties:
TITLE-WindowtitleCLASS-TheinternalwindowclassnameREGEXPTITLE-WindowtitleusingaregularexpressionREGEXPCLASS-WindowclassnameusingaregularexpressionLAST-LastwindowusedinapreviousAutoItcommandACTIVE-CurrentlyactivewindowX\Y\W\H-ThepositionandsizeofawindowINSTANCE-The1-basedinstancewhenallgivenpropertiesmatchHANDLE-ThehandleaddressasreturnedbyamethodlikeWinGetHandle
Oneormorepropertiesareusedinthetitleparameterofawindowcommandintheformat:
[PROPERTY1:Value1;PROPERTY2:Value2]
Note:ifaValuemustcontaina";"itmustbedoubled.
e.g.Waitawindowofclassname"Notepad"
oAutoIt.WinWaitActive"[CLASS:Notepad]",""
e.g.Closethecurrentlyactivewindow
oAutoIt.WinClose"[ACTIVE]",""
e.g.Waitforthe2ndinstanceofawindowwithtitle"MyWindow"andclassname"MyClass"
oAutoIt.WinWaitActive"[TITLE:MyWindow;CLASS:MyClass;INSTANCE:2]",""
Note:ifaValuemustcontaina";"itmustbedoubled.
ControlsOneofthebestnewfeatureswithAutoItv3istheabilitytoworkdirectlywithcertaintypesofWindowControls.Almosteverythingyouseeonawindowisacontrolofsomekind:buttons,listboxes,editfields,statictextareallcontrols.InfactNotepadisjustonebig"Edit"control!BecauseAutoItworksdirectlywithacontroltheyprovideamorereliablewaytoautomatethanjustsendingkeystrokes.
Note:AutoItonlyworkswithstandardMicrosoftcontrols-someapplicationswritetheirowncustomcontrolswhichmaylooklikeastandardMScontrolbutmayresistautomation.Experiment!
UsingtheAutoItWindowInfoToolyoucanmoveyourmousearoundthewindowyouareinterestedinandyouwillbegiveninformationofthecontrolthatiscurrentlyunderyourmouse.Informationoncontrolsisgiveninanumberofways,theseare:
ControlIDClassNameNNText
WheneveryouseeaControl...()commandexpectingacontrolIDparameter(mostofthem)youcanuseanyoneofthesemethods.ThemethodyouchoosewillvarybypersonalpreferenceandtheinformationyouareabletoretrievefromtheAutoItWindowInfoTool.Ingeneral,thebestmethodtouseistheControlID,withtheothermethodsbeingusedwhenaControlIDisnotavailableorisnotunique(usuallywithstatictexteachpieceoftextactuallyhasthesameControlIDsoyouwillneedtouseoneoftheothermethodstoworkwiththosecontrols).
ControlIDTheControlIDistheinternalnumericidentifierthatwindowsgivestoeachcontrol.Itisgenerallythebestmethodofindentifyingcontrols.InadditiontotheAutoItWindowInfoTool,otherapplicationssuchasscreenreadersfortheblindandMicrosofttools/APIsmayallowyoutogetthisControlID.
ClassNameNNEachMicrosoftstandardcontrolhasa"classname"suchas"button"or"edit".InAutoItthisiscombinedwiththe"instance"ofthatcontroltogivethe"ClassNameNN"method.Ifyouhaveasimpledialogwithafewbuttonsonittheywillgenerallybereferredtoas"Button1","Button2","Button3",etc.
ThismethodisusefulwhentheControlIDisnotapplicable(forstatictextorcustomcontrols).
TextYouwillnoticethatAu3Infogivesyouthetextitcanseeonacontrol,forexampleonaNextbuttonyoumightseethetext&Next-the&indicatesthatthenextletterisunderlinedandiscommonwhenworkingwithmenusandcontrols.Youcanusethistexttoidentifyacontrolinplaceofthe"ClassNameNN"ifyoulike-howeverifmanycontrolshavethesametextyouwillrunintoproblems.
LookunderthecontentsforMethodReference\WindowManagement\Controlsforalistofthefunctionsthatworkwithcontrols.
UsingtheCOMInterfaceBeforeyoucanusetheCOMinterfacetoAutoItXitneedstobe"registered"(ThisisdoneautomaticallywhenyouinstallthefullversionofAutoItbutyoumayneedtodoitmanuallyifyouareusingAutoItXseparately).
ToregistertheCOMinterface:
1.Openacommandprompt
2.Changedirectory(usingCD)tothedirectorythatcontainsAutoItX3.dll
3.Typeregsvr32.exeAutoItX3.dllandpressenter
ThenameoftheAutoItXcontrolisAutoItX3.Control
HereisanexampleofcallingatheRunmethodofthecontrolfromVBScript:
SetoAutoIt=WScript.CreateObject("AutoItX3.Control")
oAutoIt.Run("notepad.exe")
MethodReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method Description
AutoItSetOption ChangestheoperationofvariousAutoItfunctions/parameters
ClipGet RetrievestextfromtheclipboardClipPut WritestexttotheclipboardControlClick SendsamouseclickcommandtoagivencontrolControlCommand SendsacommandtoacontrolControlDisable Disablesor"grays-out"acontrolControlEnable Enablesa"grayed-out"controlControlFocus Setsinputfocustoagivencontrolonawindow
ControlGetFocus ReturnstheControlRef#ofthecontrolthathaskeyboardfocuswithinaspecifiedwindow
ControlGetHandle Retrievestheinternalhandleofacontrol
ControlGetPosHeight Retrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetPosWidth Retrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetPosX Retrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetPosY Retrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetText RetrievestextfromacontrolControlHide HidesacontrolControlListView SendsacommandtoaListView32control
ControlMove MovesacontrolwithinawindowControlSend SendsastringofcharacterstoacontrolControlSetText SetstextofacontrolControlShow ShowsacontrolthatwashiddenControlTreeView SendsacommandtoaTreeView32controlDriveMapAdd MapsanetworkdriveDriveMapDel DisconnectsanetworkdriveDriveMapGet Retreivesthedetailsofamappeddrive
IsAdmin Checksifthecurrentuserhasadministratorprivileges
MouseClick PerformamouseclickoperationMouseClickDrag Performamouseclickanddragoperation
MouseDown Performamousedowneventatthecurrentmouseposition
MouseGetCursor ReturnsacursorIDNumberofthecurrentMouseCursor
MouseGetPosX RetrievesthecurrentXpositionofthemousecursorMouseGetPosY RetrievesthecurrentYpositionofthemousecursorMouseMove Movesthemousepointer
MouseUp Performamouseupeventatthecurrentmouseposition
MouseWheel Movesthemousewheelupordown.XPONLYPixelChecksum Generatesachecksumforaregionofpixels
PixelGetColor Returnsapixelcoloraccordingtox,ypixelcoordinates
PixelSearch Searchesarectangleofpixelsforthepixelcolorprovided
ProcessClose TerminatesanamedprocessProcessExists Checkstoseeifaspecifiedprocessexists
ProcessSetPriority ChangesthepriorityofaprocessProcessWait Pausesscriptexecutionuntilagivenprocessexists
ProcessWaitClose Pausesscriptexecutionuntilagivenprocessdoesnotexist
Run RunsanexternalprogramRunAs RunsanexternalprogramRunAsWait Runsanexternalprogram
RunWait Runsanexternalprogramandpausesscriptexecutionuntiltheprogramfinishes
Send SendssimulatedkeystrokestotheactivewindowShutdown ShutsdownthesystemSleep PausescriptexecutionStatusbarGetText RetrievesthetextfromastandardstatusbarcontrolToolTip CreatesatooltipanywhereonthescreenWinActivate Activates(givesfocusto)awindow
WinActive Checkstoseeifaspecifiedwindowexistsandiscurrentlyactive
WinClose ClosesawindowWinExists Checkstoseeifaspecifiedwindowexists
WinGetCaretPosX Returnsthecoordinatesofthecaretintheforegroundwindow
WinGetCaretPosY Returnsthecoordinatesofthecaretintheforegroundwindow
WinGetClassList RetrievestheclassesfromawindowWinGetClientSizeHeight Retrievesthesizeofagivenwindow'sclientareaWinGetClientSizeWidth Retrievesthesizeofagivenwindow'sclientareaWinGetHandle RetrievestheinternalhandleofawindowWinGetPosHeight RetrievesthepositionandsizeofagivenwindowWinGetPosWidth Retrievesthepositionandsizeofagivenwindow
WinGetPosX RetrievesthepositionandsizeofagivenwindowWinGetPosY Retrievesthepositionandsizeofagivenwindow
WinGetProcess RetrievestheProcessID(PID)associatedwithawindow
WinGetState RetrievesthestateofagivenwindowWinGetText RetrievesthetextfromawindowWinGetTitle RetrievesthefulltitlefromawindowWinKill ForcesawindowtocloseWinList RetrievesalistofwindowsWinMenuSelectItem InvokesamenuitemofawindowWinMinimizeAll MinimizesallwindowsWinMinimizeAllUndo UndoesapreviousWinMinimizeAllfunctionWinMove Movesand/orresizesawindowWinSetOnTop Changeawindow's"AlwaysOnTop"attribute
WinSetState Shows,hides,minimizes,maximizes,orrestoresawindow
WinSetTitle ChangesthetitleofawindowWinSetTrans Setsthetransparencyofawindow
WinWait Pausesexecutionofthescriptuntiltherequestedwindowexists
WinWaitActive Pausesexecutionofthescriptuntiltherequestedwindowisactive
WinWaitClose Pausesexecutionofthescriptuntiltherequestedwindowdoesnotexist
WinWaitNotActive Pausesexecutionofthescriptuntiltherequestedwindowisnotactive
EnvironmentmethodsReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method DescriptionClipGet RetrievestextfromtheclipboardClipPut Writestexttotheclipboard
MethodReference
ClipGetRetrievestextfromtheclipboard
ClipGet
ReturnValueSuccess: Returnsastringcontainingthetextontheclipboard.
Failure: SetsoAutoIt.errorto1ifclipboardisemptyorcontainsanon-textentry.
RelatedClipPut
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
text=oAutoIt.ClipGet()
WScript.Echo"Clipboardcontains:"&text
MethodReference
ClipPutWritestexttotheclipboard
ClipPut"value"
Parametersvalue Thetexttowritetotheclipboard.
ReturnValueSuccess: Returns1.Failure: Returns0.
RemarksAnyexistingclipboardcontentsareoverwritten.
RelatedClipGet
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ClipPut"Iamcopiedtotheclipboard"
File,DirectoryandDiskmethodsReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method DescriptionDriveMapAdd MapsanetworkdriveDriveMapDel DisconnectsanetworkdriveDriveMapGet Retreivesthedetailsofamappeddrive
MethodReference
DriveMapAddMapsanetworkdrive
DriveMapAdd"device","remoteshare"[,flags[,
"user"[,"password"]]]
Parameters
device
Thedevicetomap,forexample"O:"or"LPT1:".Ifyoupassablankstringforthisparameteraconnectionismadebutnotmappedtoaspecificdrive.Ifyouspecify"*"anunuseddriveletterwillbeautomaticallyselected.
remoteshare Theremotesharetoconnecttointheform"\\server\share".
flags
Optional:Acombinationofthefollowing:0=default1=Persistantmapping8=Showauthenticationdialogifrequired
user Optional:Theusernametousetoconnect.Intheform"username"or"domain\username".
password Optional:Thepasswordtousetoconnect.
ReturnValueSuccess: Returns1.(SeeRemarks)
Failure: Returns0ifanewmappingcouldnotbecreatedandsetsoAutoIt.error(seebelow).(SeeRemarks)
RemarksWhenthefunctionfails(returns0)oAutoIt.errorcontainsextendedinformation:1=Undefined/Othererror2=Accesstotheremotesharewasdenied3=Thedeviceisalreadyassigned4=Invaliddevicename5=Invalidremoteshare6=Invalidpassword
Note:Whenusing"*"forthedeviceparameterthedriveletterselectedwillbereturnedinsteadof1or0,e.g."U:".Iftherewasanerrorusing"*"thenablankstring""willbereturned.
RelatedDriveMapDel,DriveMapGet
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'MapXdriveto\\myserver\stuffusingcurrentuse
r
oAutoIt.DriveMapAdd"X:","\\myserver\stuff"
'MapXdriveto\\myserver2\stuff2usingtheuser
"jon"from"domainx"withpassword"tickle"
oAutoIt.Drivemap"X:","\\myserver2\stuff2",0,"do
mainx\jon","tickle"
MethodReference
DriveMapDelDisconnectsanetworkdrive
DriveMapDel"device"
Parametersdrive Thedevicetodisconnect,e.g."O:"or"LPT1:".
ReturnValueSuccess: Returns1.Failure: Returns0ifthedisconnectionwasunsuccessful.
RemarksIfaconnectionhasnodrivelettermappedyoumayusetheconnectionnametodisconnect,e.g.\\server\share
RelatedDriveMapAdd,DriveMapGet
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'MapXdriveto\\myserver\stuffusingcurrentuse
r
oAutoIt.DriveMapAdd"X:","\\myserver\stuff"
'Disconnect
oAutoIt.DriveMapDel"X:"
MethodReference
DriveMapGetRetreivesthedetailsofamappeddrive
DriveMapGet"device"
Parametersdevice Thedevice(driveorprinter)lettertoquery.Eg."O:"or"LPT1:"
ReturnValueSuccess: Returnsdetailsofthemapping,e.g.\\server\shareFailure: Returnsablankstring""andsetsoAutoIt.errorto1.
RelatedDriveMapAdd,DriveMapDel
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'MapXdriveto\\myserver\stuffusingcurrentuse
r
oAutoIt.DriveMapAdd"X:","\\myserver\stuff"
'Getdetailsofthemapping
WScript.Echo"DriveX:ismappedto"&DriveMapGet
("X:")
GraphicmethodsReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method DescriptionPixelChecksum GeneratesachecksumforaregionofpixelsPixelGetColor Returnsapixelcoloraccordingtox,ypixelcoordinatesPixelSearch Searchesarectangleofpixelsforthepixelcolorprovided
MethodReference
PixelChecksumGeneratesachecksumforaregionofpixels
PixelChecksumleft,top,right,bottom[,step]
Parametersleft leftcoordinateofrectangle.top topcoordinateofrectangle.right rightcoordinateofrectangle.bottom bottomcoordinateofrectangle.
stepOptional:Insteadofchecksummingeachpixeluseavaluelargerthan1toskippixels(forspeed).E.g.Avalueof2willonlycheckeveryotherpixel.Defaultis1.
ReturnValueReturnsthechecksumvalueoftheregion.
RemarksPerformingachecksumofaregionisverytimeconsuming,sousethesmallestregionyouareabletoreduceCPUload.Onsomemachinesachecksumofthewholescreencouldtakemanyseconds!
Achecksumonlyallowsyoutoseeif"something"haschangedinaregion-itdoesnottellyouexactlywhathaschanged.
Whenusingastepvaluegreaterthan1youmustbearinmindthatthechecksummingbecomeslessreliableforsmallchangesasnoteverypixelischecked.
RelatedPixelChecksum,PixelCoordMode(Option),PixelGetColor,PixelSearch
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'Getinitialchecksum
checksum=oAutoIt.PixelChecksum(0,0,50,50)
MethodReference
PixelGetColorReturnsapixelcoloraccordingtox,ypixelcoordinates
PixelGetColorx,y
Parametersx xcoordinateofpixel.y ycoordinateofpixel.
ReturnValueSuccess: Returnsdecimalvalueofpixel'scolor.Failure: Returns-1ifinvalidcoordinates.
RelatedMouseGetPosX,MouseGetPosY,PixelCoordMode(Option),PixelSearch
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
var=oAutoIt.PixelGetColor(10,100)
WScript.Echo"Thecoloris"&var
MethodReference
PixelSearchSearchesarectangleofpixelsforthepixelcolorprovided
PixelSearchleft,top,right,bottom,color[,
shade-variation][,step]]
Parametersleft leftcoordinateofrectangle.top topcoordinateofrectangle.right rightcoordinateofrectangle.bottom bottomcoordinateofrectangle.color colorvalueofpixeltofind(indecimalorhex).
shade-variation
Optional:Anumberbetween0and255toindicatetheallowednumberofshadesofvariationofthered,green,andbluecomponentsofthecolor.Defaultis0(exactmatch).
stepOptional:Insteadofsearchingeachpixeluseavaluelargerthan1toskippixels(forspeed).E.g.Avalueof2willonlycheckeveryotherpixel.Defaultis1.
ReturnValueSuccess: Returnsa2elementarraycontainingthepixel'scoordinatesFailure: SetsoAutoIt.errorto1ifcolorisnotfound.
RemarksThesearchisperformedtop-to-bottom,left-to-right,andthefirstmatchisreturned.
Performingasearchofaregioncanbetimeconsuming,sousethesmallestregionyouareabletoreduceCPUload.
RelatedPixelChecksum,PixelCoordMode(Option),PixelGetColor
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
value=oAutoIt.PixelSearch(0,0,100,100,0)
IfoAutoIt.error=1Then
WScript.Echo"Colornotfound"
Else
WScript.Echo"Colorfoundat:"&value(0)&","
&value(1)
EndIf
KeyboardControlmethodsReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method DescriptionSend Sendssimulatedkeystrokestotheactivewindow
MethodReference
SendSendssimulatedkeystrokestotheactivewindow
Send"keys"[,flag]
Parameterskeys Thesequenceofkeystosend.
flag
Optional:Changeshow"keys"isprocessed:flag=0(default),Textcontainsspecialcharacterslike+and!toindicateSHIFTandALTkeypresses.flag=1,keysaresentraw.
ReturnValueNone.
RemarksSeetheAppendixforsometips.
The"Send"commandsyntaxissimilartothatofScriptItandtheVisualBasic"SendKeys"command.Charactersaresentaswrittenwiththeexceptionofthefollowingcharacters:
'!'ThistellsAutoIttosendanALTkeystroke,thereforeSend("Thisistext!a")wouldsendthekeys"Thisistext"andthenpress"ALT+a".
N.B.SomeprogramsareverychoosyaboutcapitallettersandALTkeys,i.e."!A"isdifferentto"!a".ThefirstsaysALT+SHIFT+A,thesecondisALT+a.Ifindoubt,uselowercase!
'+'ThistellsAutoIttosendaSHIFTkeystroke,thereforeSend("Hell+o")wouldsendthetext"HellO".Send("!+a")wouldsend"ALT+SHIFT+a".
'^'ThistellsAutoIttosendaCONTROLkeystroke,thereforeSend("^!a")wouldsend"CTRL+ALT+a".
N.B.SomeprogramsareverychoosyaboutcapitallettersandCTRLkeys,i.e."^A"isdifferentto"^a".ThefirstsaysCTRL+SHIFT+A,thesecondisCTRL+a.Ifindoubt,uselowercase!
'#'ThehashnowsendsaWindowskeystroke;therefore,Send("#r")wouldsendWin+rwhichlaunchestheRundialogbox.
YoucansetSendCapslockModetomakeCAPSLOCKdisabledatthestartofaSendoperationandrestoreduponcompletion.However,ifauserisholdingdowntheShiftkeywhenaSendfunctionbegins,
textmaybesentinuppercase.OneworkaroundistoSend("{SHIFTDOWN}{SHIFTUP}")beforetheotherSendoperations.
Certainspecialkeyscanbesentandshouldbeenclosedinbraces:
N.B.Windowsdoesnotallowthesimulationofthe"CTRL-ALT-DEL"combination!
SendCommand(ifzeroflag) ResultingKeypress
{!} !{#} #{+} +{^} ^{{} {{}} }{SPACE} SPACE{ENTER} ENTERkeyonthemainkeyboard{ALT} ALT{BACKSPACE}or{BS} BACKSPACE{DELETE}or{DEL} DELETE{UP} Cursorup{DOWN} Cursordown{LEFT} Cursorleft{RIGHT} Cursorright{HOME} HOME{END} END{ESCAPE}or{ESC} ESCAPE{INSERT}or{INS} INS
{PGUP} PageUp{PGDN} PageDown{F1}-{F12} Functionkeys{TAB} TAB{PRINTSCREEN} PrintScreenkey{LWIN} LeftWindowskey{RWIN} RightWindowskey{NUMLOCKon} NUMLOCK(on/off/toggle){CAPSLOCKoff} CAPSLOCK(on/off/toggle){SCROLLLOCKtoggle} SCROLLLOCK(on/off/toggle){BREAK} forCtrl+Breakprocessing{PAUSE} PAUSE{NUMPAD0}-{NUMPAD9} Numpaddigits
{NUMPADMULT} NumpadMultiply{NUMPADADD} NumpadAdd{NUMPADSUB} NumpadSubtract{NUMPADDIV} NumpadDivide{NUMPADDOT} Numpadperiod{NUMPADENTER} Enterkeyonthenumpad{APPSKEY} WindowsAppkey{LALT} LeftALTkey{RALT} RightALTkey{LCTRL} LeftCTRLkey{RCTRL} RightCTRLkey{LSHIFT} LeftShiftkey{RSHIFT} RightShiftkey{SLEEP} ComputerSLEEPkey
{ALTDOWN} HoldstheALTkeydownuntil{ALTUP}issent
{SHIFTDOWN} HoldstheSHIFTkeydownuntil{SHIFTUP}issent
{CTRLDOWN} HoldstheCTRLkeydownuntil{CTRLUP}issent
{LWINDOWN} HoldstheleftWindowskeydownuntil{LWINUP}issent
{RWINDOWN} HoldstherightWindowskeydownuntil{RWINUP}issent
{ASCnnnn} SendtheALT+nnnnkeycombination{BROWSER_BACK} XPOnly:Selectthebrowser"back"button{BROWSER_FORWARD} XPOnly:Selectthebrowser"forward"button{BROWSER_REFRESH} XPOnly:Selectthebrowser"refresh"button{BROWSER_STOP} XPOnly:Selectthebrowser"stop"button{BROWSER_SEARCH} XPOnly:Selectthebrowser"search"button{BROWSER_FAVORITES} XPOnly:Selectthebrowser"favorites"button
{BROWSER_HOME} XPOnly:Launchthebrowserandgotothehomepage
{VOLUME_MUTE} XPOnly:Mutethevolume{VOLUME_DOWN} XPOnly:Reducethevolume{VOLUME_UP} XPOnly:Increasethevolume{MEDIA_NEXT} XPOnly:Selectnexttrackinmediaplayer{MEDIA_PREV} XPOnly:Selectprevioustrackinmediaplayer{MEDIA_STOP} XPOnly:Stopmediaplayer{MEDIA_PLAY_PAUSE} XPOnly:Play/pausemediaplayer{LAUNCH_MAIL} XPOnly:Launchtheemailapplication{LAUNCH_MEDIA} XPOnly:Launchmediaplayer{LAUNCH_APP1} XPOnly:Launchuserapp1{LAUNCH_APP2} XPOnly:Launchuserapp2
TosendtheASCIIvalueA(sameaspressingALT+065onthenumerickeypad)Send("{ASC65}")
Singlekeyscanalsoberepeated,e.g.Send("{DEL4}");PressestheDELkey4timesSend("{S30}");Sends30'S'charactersSend("+{TAB4});PressesSHIFT+TAB4times
Toholdakeydown(generallyonlyusefulforgames)Send("{adown}");HoldstheAkeydownSend("{aup}");ReleasestheAkey
Tosetthestateofthecapslock,numlockandscrolllockkeysSend("{NumLockon}");TurnstheNumLockkeyonSend("{CapsLockoff}");TurnstheCapsLockkeyoffSend("{ScrollLocktoggle}");TogglesthestateofScrollLock
Ifyouwithtouseavariableforthecount,try$n=4Send("+{TAB"&$n&"}")
IfyouwishtosendtheASCIIvalueAfourtimes,thentry$x=Chr(65)Send("{"&$x&"4}")
MostlaptopcomputerkeyboardshaveaspecialFnkey.Thiskeycannotbesimulated.
Note,bysettingtheflagparameterto1theabove"special"processingwillbedisabled.Thisisusefulwhenyouwanttosendsometextcopiedfromavariableandyouwantthetextsentexactlyaswritten.
Forexample,openFolderOptions(inthecontrolpanel)andtrythefollowing:
Send("{TAB}") Navigatetonextcontrol(button,checkbox,etc)
Send("+{TAB}") Navigatetopreviouscontrol.
Send("^{TAB}") NavigatetonextWindowTab(onaTabbeddialogwindow)
Send("^+{TAB}") NavigatetopreviousWindowTab.Send("{SPACE}") Canbeusedtotoggleacheckboxorclickabutton.Send("{+}") Usuallychecksacheckbox(ifit'sa"real"checkbox.)Send("{-}") Usuallyunchecksacheckbox.Send("{NumPadMult}") RecursivelyexpandsfoldersinaSysTreeView32.
UseAlt-keycombostoaccessmenuitems.Also,openNotepadandtrythefollowing:Send("!f")SendAlt+f,theaccesskeyforNotepad'sfilemenu.Tryotherletters!
Send("{DOWN}") Movedownamenu.Send("{UP}") Moveupamenu.Send("{LEFT}") Moveleftwardtonewmenuorexpandasubmenu.Send("{RIGHT}") Moverightwardtonewmenuorcollapseasubmenu.
RelatedControlSend,SendAttachmode(Option),SendKeyDelay(Option),SendKeyDownDelay(Option)
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.Send"#r"
oAutoIt.WinWaitActive"Run"
oAutoIt.Send"notepad.exe{Enter}"
oAutoIt.WinWaitActive"Untitled-"
oAutoIt.Send"Today'stime/dateis{F5}"
MessageBoxesandDialogsmethodsReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method DescriptionToolTip Createsatooltipanywhereonthescreen
MethodReference
ToolTipCreatesatooltipanywhereonthescreen
ToolTip"text"[,x,y]
Parameterstext Thetextofthetooltip.(Anemptystringclearsadisplayingtooltip)x,y Thex,ypositionofthetooltip.
ReturnValueNone.
RemarksIfthexandycoordinatesareomittedthe,tipisplacednearthemousecursor.Ifthecoordswouldcausethetooltiptorunoffscreen,itisrepositionedtovisible.Tooltipappearsuntilitiscleared,untilscriptterminates,orsometimesuntilitisclickedupon.Youmayusealinefeedcharactertocreatemulti-linetooltips.
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'Thiswillcreateatooltipintheupperleftoft
hescreen
oAutoIt.ToolTip"Thisisatooltip",0,0
oAutoIt.Sleep2000'Sleeptogivetooltiptimeto
display
MiscelaneousmethodsReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method Description
AutoItSetOption ChangestheoperationofvariousAutoItfunctions/parameters
IsAdmin Checksifthecurrentuserhasadministratorprivileges
MethodReference
AutoItSetOptionChangestheoperationofvariousAutoItfunctions/parameters
AutoItSetOption"option",param
Parametersoption Theoptiontochange.SeeRemarks.param Theparameter(variesbyoption).SeeRemarks.
ReturnValueReturnsthevalueoftheprevioussetting.
RemarksYoumayuseOptasanalternativetoAutoItSetOption.
AutoItwillhaltwithanerrormessageiftherequestedoptionisunknown.Optionsareasfollows:
Option Param
CaretCoordMode
Setsthewaycoordsareusedinthecaretfunctions,eitherabsolutecoordsorcoordsrelativetothecurrentactivewindow:0=relativecoordstotheactivewindow1=absolutescreencoordinates(default)2=relativecoordstotheclientareaoftheactivewindow
MouseClickDelayAltersthelengthofthebriefpauseinbetweenmouseclicks.Timeinmillisecondstopause(default=10).
MouseClickDownDelay Altersthelengthaclickishelddownbeforerelease.Timeinmillisecondstopause(default=10).
MouseClickDragDelayAltersthelengthofthebriefpauseatthestartandendofamousedragoperation.Timeinmillisecondstopause(default=250).
MouseCoordMode
Setsthewaycoordsareusedinthemousefunctions,eitherabsolutecoordsorcoordsrelativetothecurrentactivewindow:0=relativecoordstotheactivewindow1=absolutescreencoordinates(default)2=relativecoordstotheclientareaoftheactivewindow
PixelCoordMode
Setsthewaycoordsareusedinthepixelfunctions,eitherabsolutecoordsorcoordsrelativetothecurrentactivewindow:0=relativecoordstotheactivewindow1=absolutescreencoordinates(default)2=relativecoordstotheclientareaoftheactive
window
SendAttachMode
SpecifiesifAutoItattachesinputthreadswhenusingthenSend()function.Whennotattaching(defaultmode=0)detectingthestateofcapslock/scrolllockandnumlockcanbeunreliableunderNT4.However,whenyouspecifyattachmode=1theSend("{...down/up}")syntaxwillnotworkandtheremaybeproblemswithsendingkeysto"hung"windows.ControlSend()ALWAYSattachesandisnotaffectedbythismode.0=don'tattach(default)1=attach
SendCapslockMode
SpecifiesifAutoItshouldstorethestateofcapslockbeforeaSendfunctionandrestoreitafterwards.0=don'tstore/restore1=storeandrestore(default)
SendKeyDelay
Altersthethelengthofthebriefpauseinbetweensentkeystrokes.Timeinmillisecondstopause(default=5).Sometimesavalueof0doesnotwork;use1instead.
SendKeyDownDelay
Altersthelengthoftimeakeyishelddownbeforereleasedduringakeystroke.Forapplicationsthattakeawhiletoregisterkeypresses(andmanygames)youmayneedtoraisethisvaluefromthedefault.Timeinmillisecondstopause(default=1).
WinDetectHiddenText
Specifiesifhiddenwindowtextcanbe"seen"bythewindowmatchingfunctions.0=Donotdetecthiddentext(default)1=Detecthiddentext
WinSearchChildren
Allowsthewindowsearchroutinestosearchchildwindowsaswellastop-levelwindows.0=Onlysearchtop-levelwindows(default)1=Searchtop-levelandchildwindowsAltersthemethodthatisusedtomatchwindowtextduringsearchoperations.1=Complete/Slowmode(default)
WinTextMatchMode
2=QuickmodeInquickmodeAutoItcanusuallyonly"see"dialogtext,buttontextandthecaptionsofsomecontrols.Inthedefaultmodemuchmoretextcanbeseen(forinstancethecontentsoftheNotepadwindow).Ifyouarehavingperformanceproblemswhenperformingmanywindowsearchesthenchangingtothe"quick"modemayhelp.
WinTitleMatchMode
Altersthemethodthatisusedtomatchwindowtitlesduringsearchoperations.1=Matchthetitlefromthestart(default)2=Matchanysubstringinthetitle3=Exacttitlematch4=Advancedmode,seeWindowTitles&Text(Advanced)
WinWaitDelayAltershowlongascriptshouldbrieflypauseafterasuccessfulwindow-relatedoperation.Timeinmillisecondstopause(default=250).
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oldvalue=oAutoIt.Opt("SendAttachMode",0)
MethodReference
IsAdminChecksifthecurrentuserhasadministratorprivileges
IsAdmin
ReturnValueSuccess: Returns1ifthecurrentuserhasadministratorprivileges.Failure: Returns0ifuserlacksadminprivileges.
RemarksThisfunctionwillalwaysreturn1underWindow95/98/Me.
RelatedRunAs,RunAsWait
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
IfoAutoIt.IsAdminThenWScript.Echo"Adminrights
detected"
MouseControlmethodsReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method DescriptionMouseClick PerformamouseclickoperationMouseClickDrag PerformamouseclickanddragoperationMouseDown PerformamousedowneventatthecurrentmousepositionMouseGetCursor ReturnsacursorIDNumberofthecurrentMouseCursorMouseGetPosX RetrievesthecurrentXpositionofthemousecursorMouseGetPosY RetrievesthecurrentYpositionofthemousecursorMouseMove MovesthemousepointerMouseUp PerformamouseupeventatthecurrentmousepositionMouseWheel Movesthemousewheelupordown.XPONLY
MethodReference
MouseClickPerformamouseclickoperation
MouseClick"button"[,x,y[,clicks[,speed]]]
Parameters
button Thebuttontoclick:"left","right","middle","main","menu","primary","secondary".
x,y Optional:Thex/ycoordinatestomovethemouseto.Ifnoxandycoordsaregiven,thecurrentpositionisused.
clicks Optional:Thenumberoftimestoclickthemouse.Defaultis1.
speedOptional:thespeedtomovethemouseintherange1(fastest)to100(slowest).Aspeedof0willmovethemouseinstantly.Defaultspeedis10.
ReturnValueNone.
RemarksIfthebuttonisanemptystring,theleftbuttonwillbeclicked.
Ifthebuttonisnotinthelist,thenoAutoIt.errorwillbesetto1.
Iftheuserhasswappedtheleftandrightmousebuttonsinthecontrolpanel,thenthebehaviourofthebuttonsisdifferent."Left"and"right"alwaysclickthosebuttons,whetherthebuttonsareswappedornot.The"primary"or"main"buttonwillbethemainclick,whetherornotthebuttonsareswapped.The"secondary"or"menu"buttonswillusuallybringupthecontextmenu,whetherthebuttonsareswappedornot.
Button Normal Swapped"" Left Left"left" Left Left"middle" Middle Middle"right" Right Right"primary" Left Right"main" Left Right"secondary" Right Left"menu" Right Left
RelatedMouseClickDrag,MouseCoordMode(Option),MouseGetPosX,MouseGetPosY,MouseMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'Doubleclickatthecurrentmousepos
oAutoIt.MouseClick"left"
oAutoIt.MouseClick"left"
'Doubleclickat0,500
oAutoIt.MouseClick"left",0,500,2
MethodReference
MouseClickDragPerformamouseclickanddragoperation
MouseClickDrag"button",x1,y1,x2,y2[,speed]
Parameters
button Thebuttontoclick:"left","right","middle","main","menu","primary","secondary".
x1,y1 Thex/ycoordstostartthedragoperationfrom.x2,y2 Thex/ycoordstostartthedragoperationto.
speedOptional:thespeedtomovethemouseintherange1(fastest)to100(slowest).Aspeedof0willmovethemouseinstantly.Defaultspeedis10.
ReturnValueNone.
RemarksIfthebuttonisanemptystring,theleftbuttonwillbeclicked.
Ifthebuttonisnotinthelist,thenoAutoIt.errorwillbesetto1.
Iftheuserhasswappedtheleftandrightmousebuttonsinthecontrolpanel,thenthebehaviourofthebuttonsisdifferent."Left"and"right"alwaysclickthosebuttons,whetherthebuttonsareswappedornot.The"primary"or"main"buttonwillbethemainclick,whetherornotthebuttonsareswapped.The"secondary"or"menu"buttonswillusuallybringupthecontextmenu,whetherthebuttonsareswappedornot.SeethetableinMouseClickformoreexplaination
RelatedMouseClick,MouseCoordMode(Option),MouseGetPosX,MouseGetPosY,MouseMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'Leftclickdragfrom0,200to600,700
oAutoIt.MouseClickDrag"left",0,200,600,700
MethodReference
MouseDownPerformamousedowneventatthecurrentmouseposition
MouseDown"button"
Parameters
button Thebuttontoclick:"left","right","middle","main","menu","primary","secondary".
ReturnValueNone.
RemarksMouseClick.Useresponsibly:ForeveryMouseDownthereshouldeventuallybeacorrespondingMouseUpevent.
RelatedMouseClick,MouseClickDrag,MouseCoordMode(Option),MouseGetPosX,MouseGetPosY,MouseMove,MouseUp
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.MouseDown"left"
oAutoIt.Sleep100
oAutoIt.MouseUp"left"
MethodReference
MouseGetCursorReturnsacursorIDNumberofthecurrentMouseCursor
MouseGetCursor
ReturnValueReturnsacursorIDNumber:0=UNKNOWN(thisincludespointingandgrabbinghandicons)1=APPSTARTING2=ARROW3=CROSS4=HELP5=IBEAM6=ICON7=NO8=SIZE9=SIZEALL10=SIZENESW11=SIZENS12=SIZENWSE13=SIZEWE14=UPARROW15=WAIT
RelatedMouseGetPosX,MouseGetPosY
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.Sleep2000'allowtimetomovemousebefor
ereportingID
cursor=oAutoIt.MouseGetCursor()
WScript.Echo"ID="&cursor
MethodReference
MouseGetPosXRetrievesthecurrentXpositionofthemousecursor
MouseGetPosX
ReturnValueReturnsthecurrentXpositionofthemousecursor.
RemarksSeeMouseCoordModeforrelative/absolutepositionsettings.Ifrelativepositioning,numbersmaybenegative.
RelatedMouseClick,MouseClickDrag,MouseCoordMode(Option),MouseGetPosY,MouseMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
posx=oAutoIt.MouseGetPosX()
posy=oAutoIt.MouseGetPosX()
WScript.Echo"Mousex,y:"&posx&","&posy
MethodReference
MouseGetPosYRetrievesthecurrentYpositionofthemousecursor
MouseGetPosY
ReturnValueReturnsthecurrentYpositionofthemousecursor.
RemarksSeeMouseCoordModeforrelative/absolutepositionsettings.Ifrelativepositioning,numbersmaybenegative.
RelatedMouseClick,MouseClickDrag,MouseCoordMode(Option),MouseGetPosX,MouseMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
posx=oAutoIt.MouseGetPosX()
posy=oAutoIt.MouseGetPosX()
WScript.Echo"Mousex,y:"&posx&","&posy
MethodReference
MouseMoveMovesthemousepointer
MouseMovex,y[,speed]
Parametersx Thescreenxcoordinatetomovethemouseto.y Thescreenycoordinatetomovethemouseto.
speedOptional:thespeedtomovethemouseintherange1(fastest)to100(slowest).Aspeedof0willmovethemouseinstantly.Defaultspeedis10.
ReturnValueUsermousemovementishinderedduringanon-instantaneousMouseMoveoperation.IfMouseCoordModeisrelativepositioning,numbersmaybenegative.
RelatedMouseClick,MouseClickDrag,MouseCoordMode(Option),MouseGetPosX,MouseGetPosY
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.MouseMove10,100
oAutoIt.MouseMove700,700,0
MethodReference
MouseUpPerformamouseupeventatthecurrentmouseposition
MouseUp"button"
Parameters
button Thebuttontoclick:"left","right","middle","main","menu","primary","secondary".
ReturnValueNone.
RemarksMouseClick.Useresponsibly:ForeveryMouseDownthereshouldeventuallybeacorrespondingMouseUpevent.
RelatedMouseClick,MouseClickDrag,MouseCoordMode(Option),MouseDown,MouseGetPosX,MouseGetPosY,MouseMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.MouseDown"left"
oAutoIt.Sleep100
oAutoIt.MouseUp"left"
MethodReference
MouseWheelMovesthemousewheelupordown.XPONLY
MouseWheel"direction"[,clicks]
Parametersdirection "up"or"down"clicks Optional:Thenumberoftimestomovethewheel.Defaultis1.
ReturnValueNone.
RemarksIfthedirectionisnotrecognized,oAutoIt.errorissetto1.
RelatedMouseClick,MouseClickDrag,MouseCoordMode(Option),MouseGetPosX,MouseGetPosY,MouseMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'Movethewheelup10times
oAutoIt.MouseWheel"up",10
ProcessmethodsReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method DescriptionProcessClose TerminatesanamedprocessProcessExists CheckstoseeifaspecifiedprocessexistsProcessSetPriority ChangesthepriorityofaprocessProcessWait PausesscriptexecutionuntilagivenprocessexistsProcessWaitClose PausesscriptexecutionuntilagivenprocessdoesnotexistRun RunsanexternalprogramRunAs RunsanexternalprogramRunAsWait Runsanexternalprogram
RunWait Runsanexternalprogramandpausesscriptexecutionuntiltheprogramfinishes
Shutdown Shutsdownthesystem
MethodReference
ProcessCloseTerminatesanamedprocess
ProcessClose"process"
Parametersprocess ThetitleorPIDoftheprocesstoterminate.
ReturnValueNone.(Returns1regardlessofsuccess/failure.)
RemarksProcessnamesareexecutableswithoutthefullpath,e.g.,"notepad.exe"or"winword.exe"Ifmultipleprocesseshavethesamename,theonewiththehighestPIDisterminated--regardlessofhowrecentlytheprocesswasspawned.PIDistheuniquenumberwhichidentifiesaProcess.APIDcanbeobtainedthroughtheProcessExistsorRuncommands.InordertoworkunderWindowsNT4.0,ProcessCloserequiresthefilePSAPI.DLL(includedintheAutoItinstallationdirectory).Theprocessispolledapproximatelyevery250milliseconds.
RelatedProcessExists,ProcessWait,ProcessWaitClose,Run,WinClose
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ProcessClose"notepad.exe"
PID=oAutoIt.ProcessExists("notepad.exe")
oAutoIt.ProcessClose(PID)
MethodReference
ProcessExistsCheckstoseeifaspecifiedprocessexists
ProcessExists"process"
Parametersprocess ThenameorPIDoftheprocesstocheck.
ReturnValueSuccess:ReturnsthePIDoftheprocess.Failure:Returns0ifprocessdoesnotexist.
RemarksProcessnamesareexecutableswithoutthefullpath,e.g.,"notepad.exe"or"winword.exe"PIDistheuniquenumberwhichidentifiesaProcess.InordertoworkunderWindowsNT4.0,ProcessExistsrequiresthefilePSAPI.DLL(includedintheAutoItinstallationdirectory).Theprocessispolledapproximatelyevery250milliseconds.
RelatedProcessClose,ProcessWait,ProcessWaitClose,WinExists
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
IfProcessExists("notepad.exe")Then
WScript.Echo"Notepadisrunning."
EndIf
MethodReference
ProcessSetPriorityChangesthepriorityofaprocess
ProcessSetPriority"process",priority
Parametersprocess ThenameorPIDoftheprocesstocheck.
priority
Aflagwhichdetermineswhatprioritytoset0-Idle/Low1-BelowNormal(NotsupportedonWindows95/98/ME)2-Normal3-AboveNormal(NotsupportedonWindows95/98/ME)4-High5-Realtime(Usewithcaution,maymakethesystemunstable)
ReturnValueSuccess:Returns1.Failure:Returns0andsetsoAutoIt.errorto1.MaysetoAutoIt.errorto2ifattemptingtouseanunsupportedpriorityclass.
RemarksAboveNormalandBelowNormalpriorityclassesarenotsupportedonWindows95/98/ME.Ifyoutrytousethemonthoseplatforms,thefunctionwillfailandoAutoIt.errorwillbesetto2.
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.Run"Notepad.exe"
oAutoIt.ProcessSetPriority"notepad.exe",0
'NotepadshouldnowhaveIdle/Lowpriority
MethodReference
ProcessWaitPausesscriptexecutionuntilagivenprocessexists
ProcessWait"process"[,timeout]
Parametersprocess Thenameoftheprocesstocheck.
timeout Optional:Specifieshowlongtowait(defaultistowaitindefinitely).
ReturnValueSuccess:Returns1.Failure:Returns0ifthewaittimedout.
RemarksProcessnamesareexecutableswithoutthefullpath,e.g.,"notepad.exe"or"winword.exe"InordertoworkunderWindowsNT4.0,ProcessWaitrequiresthefilePSAPI.DLL(includedintheAutoItinstallationdirectory).Theprocessispolledapproximatelyevery250milliseconds.
ThisfunctionistheonlyprocessfunctionnottoacceptaPID.BecausePIDsareallocatedrandomly,waitingforaparticularPIDtoexistdoesn'tmakesense.
RelatedProcessClose,ProcessExists,ProcessWaitClose,RunWait,WinWait,WinWaitActive
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ProcessWait"notepad.exe"
MethodReference
ProcessWaitClosePausesscriptexecutionuntilagivenprocessdoesnotexist
ProcessWaitClose"process"[,timeout]
Parametersprocess ThenameorPIDoftheprocesstocheck.
timeout Optional:Specifieshowlongtowait(defaultistowaitindefinitely).
ReturnValueSuccess:Returns1.Failure:Returns0ifwaittimedout.
RemarksProcessnamesareexecutableswithoutthefullpath,e.g.,"notepad.exe"or"winword.exe"PIDistheuniquenumberwhichidentifiesaProcess.APIDcanbeobtainedthroughtheProcessExistsorRuncommands.InordertoworkunderWindowsNT4.0,ProcessWaitCloserequiresthefilePSAPI.DLL(includedintheAutoItinstallationdirectory).Theprocessispolledapproximatelyevery250milliseconds.
RelatedProcessClose,ProcessExists,ProcessWaitClose,RunWait,WinWaitClose
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'waitsuntilnoinstanceofnotepad.exeexists
oAutoIt.ProcessWaitClose"notepad.exe"
'Thiswillwaituntilthisparticularinstanceof
notepadhasexited
PID=oAutoIt.Run("notepad.exe")
oAutoIt.ProcessWaitClose(PID)
MethodReference
RunRunsanexternalprogram
Run"filename"[,"workingdir"[,show_flag]]
Parametersfilename Thenameoftheexecutable(EXE,BAT,COM,orPIF)torun.workingdir Optional:Theworkingdirectory.
show_flag
Optional:The"show"flagoftheexecutedprogram:SW_HIDE=HiddenwindowSW_MINIMIZE=MinimizedwindowSW_MAXIMIZE=Maximizedwindow
ReturnValueSuccess:ThePIDoftheprocessthatwaslaunched.Failure:seeRemarks.
RemarksAfterrunningtherequestedprogramthescriptcontinues.TopauseexecutionofthescriptuntilthespawnedprogramhasfinishedusetheRunWaitfunctioninstead.
Theerrorpropertyissetto1asanindicationoffailure.
RelatedRunAs,RunAsWait,RunWait
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.Run"Notepad.exe","",oAutoIt.SW_MAXIMIZE
MethodReference
RunAsRunsanexternalprogram
RunAs"user","domain","password",logon_flag,
"filename"[,"workingdir"[,show_flag]]
Parametersusername Theusernametouse.domain Thedomainnametouse.password Thepasswordtouse.
logon_flag 0=donotloadtheuserprofile,1=(default)loadtheuserprofile,2=usefornetcredentialsonly
filename Thenameoftheexecutable(EXE,BAT,COM,orPIF)torun.workingdir Optional:Theworkingdirectory.
show_flag
Optional:The"show"flagoftheexecutedprogram:SW_HIDE=HiddenwindowSW_MINIMIZE=MinimizedwindowSW_MAXIMIZE=Maximizedwindow
ReturnValueSuccess:ThePIDoftheprocessthatwaslaunched.Failure:seeRemarks.
RemarksAfterrunningtherequestedprogramthescriptcontinues.TopauseexecutionofthescriptuntilthespawnedprogramhasfinishedusetheRunWaitfunctioninstead.
Theerrorpropertyissetto1asanindicationoffailure.
RelatedRun,RunAsWait,RunWait
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.Run"Notepad.exe","",oAutoIt.SW_MAXIMIZE
MethodReference
RunAsWaitRunsanexternalprogram
RunAsWait"user","domain","password",logon_flag,
"filename"[,"workingdir"[,show_flag]]
Parametersusername Theusernametouse.domain Thedomainnametouse.password Thepasswordtouse.
logon_flag 0=donotloadtheuserprofile,1=(default)loadtheuserprofile,2=usefornetcredentialsonly
filename Thenameoftheexecutable(EXE,BAT,COM,orPIF)torun.workingdir Optional:Theworkingdirectory.
show_flag
Optional:The"show"flagoftheexecutedprogram:SW_HIDE=HiddenwindowSW_MINIMIZE=MinimizedwindowSW_MAXIMIZE=Maximizedwindow
ReturnValueSuccess:ThePIDoftheprocessthatwaslaunched.Failure:seeRemarks.
RemarksAfterrunningtherequestedprogramthescriptpausesuntiltheprogramterminates.TorunaprogramandthenimmediatelycontinuescriptexecutionusetheRunfunctioninstead.
Someprogramswillappeartoreturnimmediatelyeventhoughtheyarestillrunning;theseprogramsspawnanotherprocess-youmaybeabletousetheProcessWaitClosefunctiontohandlethesecases.
Theerrorpropertyissetto1asanindicationoffailure.
RelatedRun,RunAsWait,RunWait
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.Run"Notepad.exe","",oAutoIt.SW_MAXIMIZE
MethodReference
RunWaitRunsanexternalprogramandpausesscriptexecutionuntiltheprogramfinishes
RunWait"filename"[,"workingdir"[,flag]]
Parametersfilename Thenameoftheexecutable(EXE,BAT,COM,PIF)torun.workingdir Optional:Theworkingdirectory.
flag
Optional:The"show"flagoftheexecutedprogram:SW_HIDE=HiddenwindowSW_MINIMIZE=MinimizedwindowSW_MAXIMIZE=Maximizedwindow
ReturnValueSuccess: Returnstheexitcodeoftheprogramthatwasrun.Failure: seeRemarks.
RemarksAfterrunningtherequestedprogramthescriptpausesuntiltheprogramterminates.TorunaprogramandthenimmediatelycontinuescriptexecutionusetheRunfunctioninstead.
Someprogramswillappeartoreturnimmediatelyeventhoughtheyarestillrunning;theseprogramsspawnanotherprocess-youmaybeabletousetheProcessWaitClosefunctiontohandlethesecases.
Theerrorpropertyissetto1asanindicationoffailure.
RelatedProcessWait,ProcessWaitClose,RunAs,RunAsWait,RunWait
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
val=oAutoIt.RunWait("Notepad.exe","C:\WINDOWS",
oAutoIt.SW_MAXIMIZE)
'scriptwaitsuntilNotepadcloses
WScript.Echo"Programreturnedwithexitcode:"&v
al
MethodReference
ShutdownShutsdownthesystem
Shutdown(code)
Parameterscode Acombinationofshutdowncodes.See"remarks".
ReturnValueSuccess: Returns1.Failure: Returns0.
RemarksTheshutdowncodeisacombinationofthefollowingvalues:0=Logoff1=Shutdown2=Reboot4=Force8=Powerdown
Addtherequiredvaluestogether.Toshutdownandpowerdown,forexample,thecodewouldbe9(shutdown+powerdown=1+8=9).
Standbyorhibernatecanbeachievedwiththird-partysoftwaresuchashttp://grc.com/wizmo/wizmo.htm
RelatedProcessClose
Example
'Forceareboot
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.Shutdown6
TimerandDelaymethodsReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method DescriptionSleep Pausescriptexecution
MethodReference
SleepPausescriptexecution
Sleepdelay
Parametersdelay Amountoftimetopause(inmilliseconds).
ReturnValueNone.
RemarksMaximumsleeptimeis2147483647milliseconds(24days).
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.Sleep5000'fiveseconds
WindowmethodsReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method DescriptionWinActivate Activates(givesfocusto)awindow
WinActive Checkstoseeifaspecifiedwindowexistsandiscurrentlyactive
WinClose ClosesawindowWinExists Checkstoseeifaspecifiedwindowexists
WinGetCaretPosX Returnsthecoordinatesofthecaretintheforegroundwindow
WinGetCaretPosY Returnsthecoordinatesofthecaretintheforegroundwindow
WinGetClassList RetrievestheclassesfromawindowWinGetClientSizeHeight Retrievesthesizeofagivenwindow'sclientareaWinGetClientSizeWidth Retrievesthesizeofagivenwindow'sclientareaWinGetHandle RetrievestheinternalhandleofawindowWinGetPosHeight RetrievesthepositionandsizeofagivenwindowWinGetPosWidth RetrievesthepositionandsizeofagivenwindowWinGetPosX RetrievesthepositionandsizeofagivenwindowWinGetPosY Retrievesthepositionandsizeofagivenwindow
WinGetProcess RetrievestheProcessID(PID)associatedwithawindow
WinGetState RetrievesthestateofagivenwindowWinGetText RetrievesthetextfromawindowWinGetTitle Retrievesthefulltitlefromawindow
WinKill ForcesawindowtocloseWinList RetrievesalistofwindowsWinMenuSelectItem InvokesamenuitemofawindowWinMinimizeAll MinimizesallwindowsWinMinimizeAllUndo UndoesapreviousWinMinimizeAllfunctionWinMove Movesand/orresizesawindowWinSetOnTop Changeawindow's"AlwaysOnTop"attribute
WinSetState Shows,hides,minimizes,maximizes,orrestoresawindow
WinSetTitle ChangesthetitleofawindowWinSetTrans Setsthetransparencyofawindow
WinWait Pausesexecutionofthescriptuntiltherequestedwindowexists
WinWaitActive Pausesexecutionofthescriptuntiltherequestedwindowisactive
WinWaitClose Pausesexecutionofthescriptuntiltherequestedwindowdoesnotexist
WinWaitNotActive Pausesexecutionofthescriptuntiltherequestedwindowisnotactive
ControlsmethodsReferenceBelowisacompletelistofthemethodsavailableinAutoItX.Clickonamethodnameforadetaileddescription.
Method DescriptionControlClick SendsamouseclickcommandtoagivencontrolControlCommand SendsacommandtoacontrolControlDisable Disablesor"grays-out"acontrolControlEnable Enablesa"grayed-out"controlControlFocus Setsinputfocustoagivencontrolonawindow
ControlGetFocus ReturnstheControlRef#ofthecontrolthathaskeyboardfocuswithinaspecifiedwindow
ControlGetHandle Retrievestheinternalhandleofacontrol
ControlGetPosHeight Retrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetPosWidth Retrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetPosX Retrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetPosY Retrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetText RetrievestextfromacontrolControlHide HidesacontrolControlListView SendsacommandtoaListView32controlControlMove MovesacontrolwithinawindowControlSend SendsastringofcharacterstoacontrolControlSetText SetstextofacontrolControlShow Showsacontrolthatwashidden
ControlTreeView SendsacommandtoaTreeView32controlStatusbarGetText Retrievesthetextfromastandardstatusbarcontrol
MethodReference
ControlClickSendsamouseclickcommandtoagivencontrol
ControlClick"title","text","controlID"[,button
[,clicks[,x[,y]]]]
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.
button Optional:Thebuttontoclick,"left","right"or"middle".Defaultistheleftbutton.
clicks Optional:Thenumberoftimestoclickthemouse.Defaultis1.
x Optional:Thexpositiontoclickwithinthecontrol.Defaultiscenter.
y Optional:Theypositiontoclickwithinthecontrol.Defaultiscenter.
ReturnValueSuccess: Returns1.Failure: Returns0.
RemarksSomecontrolswillresistclickingunlesstheyaretheactivewindow.UsetheWinActive()functiontoforcethecontrol'swindowtothetopbeforeusingControlClick().Using2forthenumberofclickswillsendadouble-clickmessagetothecontrol-thiscanevenbeusedtolaunchprogramsfromanexplorercontrol!
RelatedControlCommand,MouseClick,WinActivate
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ControlClick"Untitled-","","MDIClient1"
MethodReference
ControlCommandSendsacommandtoacontrol
ControlCommand"title","text","controlID",
"command","option"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.command Thecommandtosendtothecontrol.
option Additionalparameterrequiredbysomecommands;use""ifparameterisnotrequired.
ReturnValueDependsoncommandastablebelowshows.Incaseofanerror(suchasaninvalidcommandorwindow/control),oAutoIt.error=1.
Command,Option ReturnValue"IsVisible","" Returns1ifControlisvisible,0otherwise"IsEnabled","" Returns1ifControlisenabled,0otherwise"ShowDropDown","" DropsaComboBox"HideDropDown","" UNdropsaComboBox"AddString",'string' AddsastringtotheendinaListBoxorComboBox"DelString",occurrence
DeletesastringaccordingtooccurrenceinaListBoxorComboBox
"FindString",'string' ReturnsoccurrencerefoftheexactstringinaListBoxorComboBox
"SetCurrentSelection",occurrence
SetsselectiontooccurrencerefinaListBoxorComboBox
"SelectString",'string' SetsselectionaccordingtostringinaListBoxorComboBox
"IsChecked","" Returns1ifButtonischecked,0otherwise"Check","" ChecksradioorcheckButton"UnCheck","" UnchecksradioorcheckButton"GetCurrentLine","" Returnstheline#wherethecaretisinanEdit"GetCurrentCol","" Returnsthecolumn#wherethecaretisinanEdit"GetCurrentSelection",""
ReturnsnameofthecurrentlyselectediteminaListBoxorComboBox
"GetLineCount","" Returns#oflinesinanEdit"GetLine",line# Returnstextatline#passedofanEdit"GetSelected","" ReturnsselectedtextofanEdit"EditPaste",'string' Pastesthe'string'attheEdit'scaretposition
"CurrentTab","" ReturnsthecurrentTabshownofaSysTabControl32
"TabRight","" MovestothenexttabtotherightofaSysTabControl32
"TabLeft","" MovestothenexttabtotheleftofaSysTabControl32
RemarksCertaincommandsthatworkonnormalComboandListBoxesdonotworkon"ComboLBox"controls.WhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".UseAU3_Spy.exetoobtainacontrol'snumber.
WhenusingtextinsteadofClassName#in"Control"commands,besuretousetheentiretextofthecontrol.Partialtextwillfail.
RelatedControlClick,ControlDisable,ControlEnable,ControlFocus,ControlGetPosX,ControlGetPosY,ControlGetText,ControlHide,ControlMove,ControlSetText,ControlShow,StatusbarGetText,WinGetClassList,WinMenuSelectItem
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ControlCommand"Untitled-Notepad","","E
dit1","GetLineCount",""
MethodReference
ControlDisableDisablesor"grays-out"acontrol
ControlDisable"title","text","controlID"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.
ReturnValueSuccess: Returns1.Failure: Returns0.
RemarksWhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,ControlEnable,ControlHide
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ControlDisable"Untitled-","","MDIClient
1"
MethodReference
ControlEnableEnablesa"grayed-out"control
ControlEnable"title","text","controlID"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.
ReturnValueSuccess: Returns1.Failure: Returns0.
RemarksUsewithcaution.WhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,ControlDisable,ControlShow
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ControlEnable"Untitled-","","MDIClient1
"
MethodReference
ControlFocusSetsinputfocustoagivencontrolonawindow
ControlFocus"title","text","controlID"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.
ReturnValueSuccess: Returns1.Failure: Returns0.
RemarksWhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,WinActivate
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ControlFocus"Untitled-Notepad","","Edi
t1"
MethodReference
ControlGetFocusReturnstheControlRef#ofthecontrolthathaskeyboardfocuswithinaspecifiedwindow
ControlGetFocus"title"[,"text"]
Parameterstitle Titleofwindowtocheck.text Optional:Textfromwindowtocheck.
ReturnValue
Success: ReturnsControlRef#ofthecontrolthathaskeyboardfocuswithinaspecifiedwindow.
Failure: ReturnsablankstringandsetsoAutoIt.errorto1ifwindowisnotfound.
RelatedControlCommand,ControlFocus,WinActive
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
a=oAutoIt.ControlGetFocus("Untitled-Notepad")
MethodReference
ControlGetHandleRetrievestheinternalhandleofacontrol
ControlGetHandle"title","text","controlID"
Parameterstitle Thetitleofthewindowtoread.text Thetextofthewindowtoread.controlID Thecontroltointeractwith.SeeControls.
ReturnValueSuccess: Returnsastringcontainingthecontrolhandlevalue.
Failure: Returns""(blankstring)andsetsoAutoIt.errorto1ifnowindowmatchesthecriteria.
RelatedWinTitleMatchMode(Option)
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
handle=oAutoIt.ControlGetHandle("Untitled-Notep
ad","","Edit1")
MethodReference
ControlGetPosXRetrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetPosX"title","text","controlID"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.
ReturnValueSuccess: ReturnstheXcoordinateofthecontrol.Failure: SetsoAutoIt.errorto1.
RemarksWhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,ControlGetPosHeight,ControlGetPosWidth,ControlGetPosY,ControlMove,WinMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
posx=ControlGetPosX("Untitled-Notepad","","Ed
it1")
posy=ControlGetPosY("Untitled-Notepad","","Ed
it1")
poswidth=ControlGetPosWidth("Untitled-Notepad",
"","Edit1")
posheight=ControlGetPosHeight("Untitled-Notepad
","","Edit1")
MethodReference
ControlGetPosYRetrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetPosY"title","text","controlID"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.
ReturnValueSuccess: ReturnstheYcoordinateofthecontrol.Failure: SetsoAutoIt.errorto1.
RemarksWhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,ControlGetPosHeight,ControlGetPosWidth,ControlGetPosX,ControlMove,WinMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
posx=ControlGetPosX("Untitled-Notepad","","Ed
it1")
posy=ControlGetPosY("Untitled-Notepad","","Ed
it1")
poswidth=ControlGetPosWidth("Untitled-Notepad",
"","Edit1")
posheight=ControlGetPosHeight("Untitled-Notepad
","","Edit1")
MethodReference
ControlGetPosWidthRetrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetPosWidth"title","text","controlID"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.
ReturnValueSuccess: Returnsthewidthofthecontrol.Failure: SetsoAutoIt.errorto1.
RemarksWhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,ControlGetPosHeight,ControlGetPosX,ControlGetPosY,ControlMove,WinMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
posx=ControlGetPosX("Untitled-Notepad","","Ed
it1")
posy=ControlGetPosY("Untitled-Notepad","","Ed
it1")
poswidth=ControlGetPosWidth("Untitled-Notepad",
"","Edit1")
posheight=ControlGetPosHeight("Untitled-Notepad
","","Edit1")
MethodReference
ControlGetPosHeightRetrievesthepositionandsizeofacontrolrelativetoit'swindow
ControlGetPosHeight"title","text","controlID"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.
ReturnValueSuccess: Returnstheheightofthecontrol.Failure: SetsoAutoIt.errorto1.
RemarksWhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,ControlGetPosWidth,ControlGetPosX,ControlGetPosY,ControlMove,WinMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
posx=ControlGetPosX("Untitled-Notepad","","Ed
it1")
posy=ControlGetPosY("Untitled-Notepad","","Ed
it1")
poswidth=ControlGetPosWidth("Untitled-Notepad",
"","Edit1")
posheight=ControlGetPosHeight("Untitled-Notepad
","","Edit1")
MethodReference
ControlGetTextRetrievestextfromacontrol
ControlGetText"title","text","controlID"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.
ReturnValueSuccess: Returnstextfromacontrol.Failure: SetsoAutoIt.errorto1andreturnsablankstringof"".
RemarksWhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,ControlSetText,StatusbarGetText,WinGetText
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
var=oAutoIt.ControlGetText("Untitled-Notepad",
"","Edit1")
MethodReference
ControlHideHidesacontrol
ControlHide"title","text","controlID"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.
ReturnValueSuccess: Returns1.Failure: Returns0ifwindow/controlisnotfound.
RemarksWhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,ControlShow,WinSetState
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ControlHide"Untitled-","","MDIClient1"
MethodReference
ControlListViewSendsacommandtoaListView32control
ControlListView"title","text","controlID",
"command","option1","option2"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.command Thecommandtosendtothecontrol(seebelow).
option1 Additionalparameterrequiredbysomecommands;use""ifparameterisnotrequired.
option2 Additionalparameterrequiredbysomecommands;use""ifparameterisnotrequired.
ReturnValueDependsoncommandastablebelowshows.Incaseofanerror(suchasaninvalidcommandorwindow/controlcouldnotbefound)then@errorissetto1.
Allitems/subitemsare0based.Thismeansthatthefirstitem/subiteminalistis0,thesecondis1,andsoon.
Ina"Details"viewofaListView32control,the"item"canbethoughtofasthe"row"andthe"subitem"asthe"column".
Command,Option1,Option2 Operation"DeSelect",From[,To] Deselectsoneormoreitems."FindItem","stringtofind"[,SubItem]
Returnstheitemindexofthestring.Returns-1ifthestringisnotfound.
"GetItemCount" Returnsthenumberoflistitems.
"GetSelected"[,option]
Returnsastringcontainingtheitemindexofselecteditems.Ifoption=0(default)onlythefirstselecteditemisreturned.Ifoption=1thenalltheselecteditemsarereturneddelimitedby|,e.g:"0|3|4|10".Ifnoitemsareselectedablank""stringisreturned.
"GetSelectedCount" Returnsthenumberofitemsthatareselected."GetSubItemCount" Returnsthenumberofsubitems."GetText",Item,SubItem Returnsthetextofagivenitem/subitem.
"IsSelected",Item Returns1iftheitemisselected,otherwisereturns0.
"Select",From[,To] Selectsoneormoreitems."SelectAll" Selectsallitems."SelectClear" Clearstheselectionofallitems."SelectInvert" Invertsthecurrentselection.
"ViewChange","view" Changesthecurrentview.Validviewsare"list","details","smallicons","largeicons".
RelatedControlClick,ControlCommand,ControlDisable,ControlEnable,ControlFocus,ControlGetPosX,ControlGetPosY,ControlGetText,ControlHide,ControlMove,ControlSetText,ControlShow,ControlTreeView,StatusbarGetText,WinGetClassList,WinMenuSelectItem
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ControlListView"C:\ProgramFiles\NSIS",""
,"SysListView321","SelectAll","",""
oAutoIt.ControlListView"C:\ProgramFiles\NSIS",""
,"SysListView321","Deselect","2","5"
MethodReference
ControlMoveMovesacontrolwithinawindow
ControlMove"title","text","controlID",x,y[,
width[,height]]
Parameterstitle Thetitleofthewindowtomove.text Thetextofthewindowtomove.controlID Thecontroltointeractwith.SeeControls.x Xcoordinatetomoveto.y Ycoordinatetomoveto.width Optional:Newwidthofthewindow.height Optional:Newheightofthewindow.
ReturnValueSuccess: Returns1.Failure: Returns0ifwindow/controlisnotfound.
RemarksWhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,WinMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ControlMove"Untitled-","","MDIClient1",
0,0,200,200
MethodReference
ControlSendSendsastringofcharacterstoacontrol
ControlSend"title","text","controlID","string"
[,flag]
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.string Stringofcharacterstosendtothecontrol.
flag
Optional:Changeshow"keys"isprocessed:flag=0(default),Textcontainsspecialcharacterslike+toindicateSHIFTand{LEFT}toindicateleftarrow.flag=1,keysaresentraw.
ReturnValueSuccess: Returns1.Failure: Returns0ifwindow/controlisnotfound.
RemarksControlSendcanbequiteusefultosendcapitalletterswithoutmessingupthestateof"Shift."
WhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".Note,thisfunctioncannotsendallthecharactersthattheusualSendfunctioncan(notablyALTkeys)butitcansendmostofthem--eventonon-activeorhiddenwindows!
RelatedControlCommand,Send
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ControlSend"Untitled","","Edit1","This
isalineoftextinthenotepadwindow"
MethodReference
ControlSetTextSetstextofacontrol
ControlSetText"title","text","controlID","new
text"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.newtext Thenewtexttobesetintothecontrol.
ReturnValueSuccess: Returns1.Failure: Returns0ifwindow/controlisnotfound.
RemarksWhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,ControlGetText
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.Run"notepad.exe"
oAutoIt.WinWait"Untitled-"
oAutoIt.ControlSetText"Untitled-","","Edit1","
NewTextHere"
MethodReference
ControlShowShowsacontrolthatwashidden
ControlShow"title","text","controlID"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.
ReturnValueSuccess: Returns1.Failure: Returns0ifwindow/controlisnotfound.
RemarksWhenusingacontrolnameintheControlfunctions,youneedtoaddanumbertotheendofthenametoindicatewhichcontrol.Forexample,iftheretwocontrolslistedcalled"MDIClient",youwouldrefertotheseas"MDIClient1"and"MDIClient2".
RelatedControlCommand,ControlEnable,ControlHide
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ControlShow"Untitled-","","MDIClient1"
MethodReference
ControlTreeViewSendsacommandtoaTreeView32control
ControlTreeView"title","text","controlID",
"command","option1","option2"
Parameterstitle Thetitleofthewindowtoaccess.text Thetextofthewindowtoaccess.controlID Thecontroltointeractwith.SeeControls.command Thecommandtosendtothecontrol(seebelow).
option1 Additionalparameterrequiredbysomecommands;use""ifparameterisnotrequired.
option2 Additionalparameterrequiredbysomecommands;use""ifparameterisnotrequired.
ReturnValueDependsoncommandastablebelowshows.Incaseofanerror(suchasaninvalidcommandorwindow/controlcouldnotbefound)then@errorissetto1.
Command,Option1,Option2 Operation"Check","item" Checksanitem(iftheitemsupportsit)."Collapse","item" Collapsesanitemtohideitschildren."Exists","item" Returns1ifanitemexists,otherwise0."Expand","item" Expandsanitemtoshowitschildren.
"GetItemCount","item" Returnsthenumberofchildrenforaselecteditem.
"GetSelected"[,UseIndex]Returnstheitemreferenceofthecurrentselectionusingthetextreferenceoftheitem(orindexreferenceifUseIndexissetto1).
"GetText","item" Returnsthetextofanitem.
"IsChecked" Returnsthestateofanitem.1:checked,0:unchecked,-1:notacheckbox.
"Select","item" Selectsanitem."Uncheck","item" Unchecksanitem(iftheitemsupportsit).
RelatedControlClick,ControlCommand,ControlDisable,ControlEnable,ControlFocus,ControlGetPosX,ControlGetPosY,ControlGetText,ControlHide,ControlListView,ControlMove,ControlSetText,ControlShow,StatusbarGetText,WinGetClassList,WinMenuSelectItem
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.ControlListView"C:\","","SysTreeView321"
,"SelectAll","",""
oAutoIt.ControlListView"C:\","","SysTreeView321"
,"Deselect","2","5"
MethodReference
StatusbarGetTextRetrievesthetextfromastandardstatusbarcontrol
StatusbarGetText"title"[,"text"[,part]]
Parameterstitle Thetitleofthewindowtocheck.text Optional:Thetextofthewindowtocheck.
partOptional:The"part"numberofthestatusbartoread-thedefaultis1.1isthefirstpossiblepartandusuallytheonethatcontainstheusefulmessageslike"Ready""Loading...",etc.
ReturnValueSuccess: Returnsthetextread.
Failure: ReturnsemptystringandsetsoAutoIt.errorto1ifnotextcouldberead.
RemarksThisfunctionsattemptstoreadthefirststandardstatusbaronawindow(Microsoftcommoncontrol:msctls_statusbar32).SomeprogramsusetheirownstatusbarsorspecialversionsoftheMScommoncontrolwhichStatusbarGetTextcannotread.Forexample,StatusbarTextdoesnotworkontheprogramTextPad;however,thefirstregionofTextPad'sstatusbarcanbereadusingControlGetText("TextPad","","HSStatusBar1")StatusbarGetTextcanworkonwindowsthatareminimizedorevenhidden.
RelatedControlCommand,ControlGetText
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.AutoItSetOption("WinTitleMatchMode",2)
text=oAutoIt.StatusbarGetText"InternetExplorer"
WScript.Echo"InternetExplorer'sstatusbarsays:
"&text
MethodReference
WinActivateActivates(givesfocusto)awindow
WinActivate"title"[,"text"]
Parameterstitle Thetitleofthewindowtoactivate.text Optional:Thetextofthewindowtoactivate.
ReturnValueNone.
RemarksYoucanusetheWinActivefunctiontocheckifWinActivatesucceeded.Ifmultiplewindowsmatchthecriteria,thewindowthatwasmostrecentlyactiveistheoneactivated.WinActivateworksonminimizedwindows.However,awindowthatis"AlwaysOnTop"couldstillcoverupawindowyouActivated.
RelatedWinClose,WinSetState,WinTitleMatchMode(Option)
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.WinActivate"Untitled-Notepad",""
MethodReference
WinActiveCheckstoseeifaspecifiedwindowexistsandiscurrentlyactive
WinActive"title"[,"text"]
Parameterstitle Thetitleofthewindowtoactivate.text Optional:Thetextofthewindowtoactivate.
ReturnValueSuccess: Returns1.Failure: Returns0ifwindowisnotactive.
RelatedWinExists,WinTitleMatchMode(Option),WinWait,WinWaitActive,WinWaitClose,WinWaitNotActive
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
IfoAutoIt.WinActive("Untitled-")Then
WScript.Echo"Windowwasactive"
EndIf
MethodReference
WinCloseClosesawindow
WinClose"title"[,"text"]
Parameterstitle Thetitleofthewindowtoclose.text Optional:Thetextofthewindowtoclose.
ReturnValueNone.
RemarksThisfunctionsendsaclosemessagetoawindow,theresultdependsonthewindow(itmayasktosavedata,etc.).Toforceawindowtoclose,usetheWinKillfunction.Ifmultiplewindowsmatchthecriteria,thewindowthatwasmostrecentlyactiveisclosed.
RelatedWinActivate,WinExists,WinKill,WinSetState,WinTitleMatchMode(Option)
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.WinClose"Untitled-Notepad",""
MethodReference
WinExistsCheckstoseeifaspecifiedwindowexists
WinExists"title"[,"text"]
Parameterstitle Thetitleofthewindowtocheck.text Optional:Thetextofthewindowtocheck.
ReturnValueReturns1ifthewindowexists,otherwisereturns0.
RemarksWinExistwillreturn1evenifawindowishidden.
RelatedWinActive,WinTitleMatchMode(Option),WinWait,WinWaitActive,WinWaitClose,WinWaitNotActive
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
IfoAutoIt.WinExists("Untitled-")Then
WScript.Echo"Windowexists"
EndIf
MethodReference
WinGetCaretPosXReturnsthecoordinatesofthecaretintheforegroundwindow
WinGetCaretPosX
ReturnValueSuccess: ReturnstheXcoordinateofthecaret.Failure: SetsoAutoIt.errorto1.
RemarksWinGetCaretPosmightnotreturnaccuratevaluesforMultipleDocumentInterface(MDI)applicationsifabsoluteCaretCoordModeisused.Seeexampleforaworkaround.Note:Someapplicationsreportstaticcoordinatesregardlessofcaretposition!
RelatedCaretCoordMode(Option)
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
x=oAutoIt.WinGetCaretPosX()
y=oAutoIt.WinGetCaretPosY()
MethodReference
WinGetCaretPosYReturnsthecoordinatesofthecaretintheforegroundwindow
WinGetCaretPosY
ReturnValueSuccess: ReturnstheYcoordinateofthecaret.Failure: SetsoAutoIt.errorto1.
RemarksWinGetCaretPosmightnotreturnaccuratevaluesforMultipleDocumentInterface(MDI)applicationsifabsoluteCaretCoordModeisused.Seeexampleforaworkaround.Note:Someapplicationsreportstaticcoordinatesregardlessofcaretposition!
RelatedCaretCoordMode(Option)
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
x=oAutoIt.WinGetCaretPosX()
y=oAutoIt.WinGetCaretPosY()
MethodReference
WinGetClassListRetrievestheclassesfromawindow
WinGetClassList"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValueSuccess: Returnsastringcontainingthewindowclassesread.
Failure: Returnsnumeric1andsetsoAutoIt.errorto1ifnowindowmatchesthecriteria.
RemarksClassnamesarelinefeedseparated.WinGetClassListworksonbothminimizedandhiddenwindows.Upto64KBoftextcanberetrieved.Ifmultiplewindowsmatchthecriteria,theclassesarereadfromthemostrecentlyactivewindow.
RelatedControlCommand,WinGetText
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
text=oAutoIt.WinGetClassList("Untitled-","")
WScript.Echo"Textreadwas:"&text
MethodReference
WinGetClientSizeWidthRetrievesthesizeofagivenwindow'sclientarea
WinGetClientSizeWidth"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValueSuccess: Returnsthewidthofthewindow'sclientareaFailure: Returnsnumeric1andsetsoAutoIt.errorto1ifwindowsisnotfound.
RemarksIfthewindowisminimized,thereturnedwidthandheightvaluesarebothzero.However,WinGetClientSizeworkscorrectlyon(non-minimized)hiddenwindows.Ifthewindowtitle"ProgramManager"isused,thefunctionwillreturnthesizeofthedesktop.WinGetClientSize("")matchestheactivewindow.Ifmultiplewindowsmatchthecriteria,themostrecentlyactivewindowisused.
RelatedWinGetPosX,WinGetPosY,WinMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
$width=oAutoIt.WinGetClientSizeWidth("")
$height=oAutoIt.WinGetClientSizeHeight("")
MethodReference
WinGetClientSizeHeightRetrievesthesizeofagivenwindow'sclientarea
WinGetClientSizeHeight"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValueSuccess: Returnstheheightofthewindow'sclientareaFailure: Returnsnumeric1andsetsoAutoIt.errorto1ifwindowsisnotfound.
RemarksIfthewindowisminimized,thereturnedwidthandheightvaluesarebothzero.However,WinGetClientSizeworkscorrectlyon(non-minimized)hiddenwindows.Ifthewindowtitle"ProgramManager"isused,thefunctionwillreturnthesizeofthedesktop.WinGetClientSize("")matchestheactivewindow.Ifmultiplewindowsmatchthecriteria,themostrecentlyactivewindowisused.
RelatedWinGetPosX,WinGetPosY,WinMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
$width=oAutoIt.WinGetClientSizeWidth("")
$height=oAutoIt.WinGetClientSizeHeight("")
MethodReference
WinGetHandleRetrievestheinternalhandleofawindow
WinGetHandle"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValueSuccess: Returnsastringcontainingthewindowhandlevalue.
Failure: Returns""(blankstring)andsetsoAutoIt.errorto1ifnowindowmatchesthecriteria.
RemarksThisfunctionisforusewiththeadvancedWinTitleMatchModeoptionsthatallowyoutouseclassnamesandhandlestospecifywindowsratherthan"title"and"text".Onceyouhaveobtainedthehandleyoucanaccesstherequiredwindowevenifitstitlechanges.
RelatedWinTitleMatchMode(Option)
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
handle=oAutoIt.WinGetHandle("[CLASS:Notepad]",""
)
MethodReference
WinGetPosXRetrievesthepositionandsizeofagivenwindow
WinGetPosX"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValueSuccess: ReturnstheXcoordinateofthewindow.Failure: Returnsnumeric1andsetsoAutoIt.errorto1ifwindowsisnotfound.
RemarksWinGetPosXreturnsnegativenumberssuchas-32000forminimizedwindows,butworksfinewith(non-minimized)hiddenwindows.Ifthewindowtitle"ProgramManager"isused,thefunctionwillreturnthesizeofthedesktop.Ifmultiplewindowsmatchthecriteria,themostrecentlyactivewindowisused.
RelatedWinGetClientSizeHeight,WinGetClientSizeWidth,WinMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
x=oAutoIt.WinGetPosX("")
y=oAutoIt.WinGetPosY("")
width=oAutoIt.WinGetPosWidth("")
height=oAutoIt.WinGetPosHeight("")
MethodReference
WinGetPosYRetrievesthepositionandsizeofagivenwindow
WinGetPosY"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValueSuccess: ReturnstheYcoordinateofthewindow.Failure: Returnsnumeric1andsetsoAutoIt.errorto1ifwindowsisnotfound.
RemarksWinGetPosYreturnsnegativenumberssuchas-32000forminimizedwindows,butworksfinewith(non-minimized)hiddenwindows.Ifthewindowtitle"ProgramManager"isused,thefunctionwillreturnthesizeofthedesktop.Ifmultiplewindowsmatchthecriteria,themostrecentlyactivewindowisused.
RelatedWinGetClientSizeHeight,WinGetClientSizeWidth,WinMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
x=oAutoIt.WinGetPosX("")
y=oAutoIt.WinGetPosY("")
width=oAutoIt.WinGetPosWidth("")
height=oAutoIt.WinGetPosHeight("")
MethodReference
WinGetPosWidthRetrievesthepositionandsizeofagivenwindow
WinGetPosWidth"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValueSuccess: Returnsthewidthofthewindow.Failure: Returnsnumeric1andsetsoAutoIt.errorto1ifwindowsisnotfound.
RemarksWinGetPosreturnsnegativenumberssuchas-32000forminimizedwindows,butworksfinewith(non-minimized)hiddenwindows.Ifthewindowtitle"ProgramManager"isused,thefunctionwillreturnthesizeofthedesktop.Ifmultiplewindowsmatchthecriteria,themostrecentlyactivewindowisused.
RelatedWinGetClientSizeHeight,WinGetClientSizeWidth,WinMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
x=oAutoIt.WinGetPosX("")
y=oAutoIt.WinGetPosY("")
width=oAutoIt.WinGetPosWidth("")
height=oAutoIt.WinGetPosHeight("")
MethodReference
WinGetPosHeightRetrievesthepositionandsizeofagivenwindow
WinGetPosHeight"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValueSuccess: Returnstheheightofthewindow.Failure: Returnsnumeric1andsetsoAutoIt.errorto1ifwindowsisnotfound.
RemarksWinGetPosreturnsnegativenumberssuchas-32000forminimizedwindows,butworksfinewith(non-minimized)hiddenwindows.Ifthewindowtitle"ProgramManager"isused,thefunctionwillreturnthesizeofthedesktop.Ifmultiplewindowsmatchthecriteria,themostrecentlyactivewindowisused.
RelatedWinGetClientSizeHeight,WinGetClientSizeWidth,WinMove
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
x=oAutoIt.WinGetPosX("")
y=oAutoIt.WinGetPosY("")
width=oAutoIt.WinGetPosWidth("")
height=oAutoIt.WinGetPosHeight("")
MethodReference
WinGetProcessRetrievestheProcessID(PID)associatedwithawindow
WinGetProcess"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValueSuccess: ReturnsastringcontainingthenumericProcessID(PID).Failure: Returns"".
RelatedProcessWait,ProcessWaitClose
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
WScript.EchooAutoIt.WinGetProcess("Untitled-Note
pad")
MethodReference
WinGetStateRetrievesthestateofagivenwindow
WinGetState"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValue
Success:
Returnsavalueindicatingthestateofthewindow.MultiplevaluesareaddedtogethersouseBitAND()toexaminethepartyouareinterestedin:1=Windowexists2=Windowisvisible4=Windowsisenabled8=Windowisactive16=Windowisminimized32=Windowsismaximized
Failure: Returns0andsetsoAutoIt.errorto1ifthewindowisnotfound.
RelatedWinGetPosX,WinGetPosY
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
state=oAutoIt.WinGetState"Untitled",""
MethodReference
WinGetTextRetrievesthetextfromawindow
WinGetText"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValueReturnsastringcontainingthewindowtextread.
RemarksUpto64KBofwindowtextcanberetrieved.WinGetTextworksonminimizedwindows,butonlyworksonhiddenwindowsifyou'vesetAutoItSetOption("WinDetectHiddenText",1)IfmultiplewindowsmatchthecriteriaforWinGetText,theinformationforthemostrecentlyactivematchisreturned.UseWinGetText("")togettheactivewindow'stext.
RelatedControlGetText,WinGetTitle
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
text=oAutoIt.WinGetText("Untitled-","")
WScript.Echo"Textreadwas:"&text
MethodReference
WinGetTitleRetrievesthefulltitlefromawindow
WinGetTitle"title"[,"text"]
Parameterstitle Thetitleofthewindowtoread.text Optional:Thetextofthewindowtoread.
ReturnValueReturnsastringcontainingthecompletewindowtitle.Returnsnumeric0ifnotitlematch.
RemarksWinGetTitle("")returnstheactivewindow'stitle.WinGetTitleworksonbothminimizedandhiddenwindows.Ifmultiplewindowsmatchthecriteria,themostrecentlyactivewindowisused.
RelatedWinGetText,WinSetTitle,WinTitleMatchMode(Option)
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
title=oAutoIt.WinGetTitle"Untitled-",""
WScript.Echo"Fulltitlereadwas:"&title
MethodReference
WinKillForcesawindowtoclose
WinKill"title"[,"text"]
Parameterstitle Thetitleofthewindowtoclose.text Optional:Thetextofthewindowtoclose.
ReturnValueNone.(Alwaysreturns1regardlessofsuccess.)
RemarksThedifferencebetweenthisfunctionandWinCloseisthatWinKillwillforciblyterminatethewindowifitdoesn'tclosequicklyenough.Consequently,ausermightnothavetimetorespondtodialogspromptingtheusertosavedata.AlthoughWinKillcanworkonbothminimizedandhiddenwindows,somewindows(notablyexplorerwindows)canonlybeterminatedusingWinClose.
RelatedProcessClose,WinActivate,WinClose,WinSetState
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.WinKill"Untitled-",""
MethodReference
WinListRetrievesalistofwindows
WinList"title"[,"text"]
Parameterstitle Thetitleofthewindowtofind.text Optional:Thetextofthewindowtofind.
ReturnValue
Success:Returnsa2dimensionalarraycontainingthewindowtitlesandcorrespondinghandles.Thenumberofentriesisinelement0,0(seeexample).
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'Findallinstancesofthenotepadwindow
val=oAutoIt.WinList("[CLASS:Notepad]")
Fori=1toval(0,0)
WScript.Echo"Title:"&val(0,i)&"-Handle:"&
val(1,i)
Next
'Findallwindows(maybehundreds!)
val=oAutoIt.WinList("[ALL]")
Fori=1toval(0,0)
WScript.Echo"Title:"&val(0,i)&"-Handle:"&
val(1,i)
Next
MethodReference
WinMenuSelectItemInvokesamenuitemofawindow
WinMenuSelectItem"title","text","item"[,"item"
[,"item"[,"item"[,"item"[,"item"[,
"item"]]]]]]
Parameterstitle Thetitleofthewindowtoread.text Thetextofthewindowtoread.item TextofMenuItemitem Optional:TextofSubMenuitemitem Optional:TextofSubMenuitemitem Optional:TextofSubMenuitemitem Optional:TextofSubMenuitemitem Optional:TextofSubMenuitemitem Optional:TextofSubMenuitem
ReturnValueSuccess: Returns1.Failure: Returns0ifthemenucouldnotbefound.
RemarksYoushouldnotethatunderlinedmenuitemsactuallycontaina&charactertoindicatetheunderlining.Thus,themenuitemFilewouldactuallyrequirethetext"&File;",andConvertwouldrequire"Con|"Youcanaccessmenuitemsuptosixlevelsdeep;andthewindowcanbeinactive,minimized,and/orevenhidden.
WinMenuSelectItemwillonlyworkonstandardmenus.Unfortunately,manymenusinusetodayareactuallycustomwrittenortoolbars"pretending"tobemenus.ThisistrueformostMicrosoftapplications.
RelatedControlCommand,Send
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'ThiswillselectFile,PageSetupinnotepad
oAutoIt.WinMenuSelectItem"Untitled-","","&File
","PageSet&up..."
MethodReference
WinMinimizeAllMinimizesallwindows
WinMinimizeAll
ReturnValueNone.
RemarksSend("#m")isapossiblealternative.
RelatedWinMinimizeAllUndo,WinSetState
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.WinMinimizeAll
MethodReference
WinMinimizeAllUndoUndoesapreviousWinMinimizeAllfunction
WinMinimizeAllUndo
ReturnValueNone.
RemarksSend("#+m")isapossiblealternative.
RelatedWinMinimizeAll,WinSetState
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.WinMinimizeAllUndo
MethodReference
WinMoveMovesand/orresizesawindow
WinMove"title","text",x,y[,width[,height]]
Parameterstitle Thetitleofthewindowtomove/resize.text Thetextofthewindowtomove/resize.x Xcoordinatetomoveto.y Ycoordinatetomoveto.width Optional:Newwidthofthewindow.height Optional:Newheightofthewindow.
ReturnValueNone.
RemarksWinMovehasnoeffectonminimizedwindows,butWinMoveworksonhiddenwindows.Ifverywidthandheightaresmall(ornegative),thewindowwillgonosmallerthan112x27pixels.Ifwidthandheightarelarge,thewindowwillgonolargerthanapproximately[12+@DesktopWidth]x[12+@DesktopHeight]pixels.Negativevaluesareallowedforthexandycoordinates.Infact,youcanmoveawindowoffscreen;andifthewindow'sprogramisonethatremembersitslastwindowposition,thewindowwillappearinthecorner(butfullyon-screen)thenexttimeyoulaunchtheprogram.Ifmultiplewindowsmatchthecriteria,themostrecentlyactivewindowisused.
RelatedWinActivate,WinClose,WinGetClientSizeHeight,WinGetClientSizeWidth,WinGetPosX,WinGetPosY,WinSetState
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.WinMove"Untitled-","",0,0,200,200
MethodReference
WinSetOnTopChangeawindow's"AlwaysOnTop"attribute
WinSetOnTop"title","text",flag
Parameterstitle Thetitleofthewindowtoaffect.text Thetextofthewindowtoaffect.
flagDetermineswhetherthewindowshouldhavethe"TOPMOST"flagset.1=setontopflag,0=removeontopflag
ReturnValueNone.
RemarksThird-partyprogramswhichaddan"AlwaysOnTop"contextmenuentrymightnotupdatetheirmenuentrytoreflecttheAutoIt-inducedchangeinTOPMOSTstatus.
RelatedWinSetState
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.WinSetOnTop"Untitled-","",1
MethodReference
WinSetStateShows,hides,minimizes,maximizes,orrestoresawindow
WinSetState"title","text",flag
Parameterstitle Thetitleofthewindowtoshow.text Thetextofthewindowtoshow.
flag
The"show"flagoftheexecutedprogram:SW_HIDE=HidewindowSW_SHOW=ShowsapreviouslyhiddenwindowSW_MINIMIZE=MinimizewindowSW_MAXIMIZE=MaximizewindowSW_RESTORE=Undoesawindowminimizationormaximization
ReturnValueNone.
RemarksWinSetStateisareplacementforthebadlynamedWinShowfunction.WinShowisacceptedasanaliasbutthismaybewithdrawninthefuture.
Ifmultiplewindowsmatchthecriteria,themostrecentlyactivewindowisused.SW_MINIMIZEandSW_MAXIMIZEevenworkonmodaldialogwindows.
RelatedWinActivate,WinClose
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.WinSetState"Untitled-","",oAutoIt.SW_HI
DE
oAutoIt.Sleep3000
oAutoIt.WinSetState"Untitled-","",oAutoIt.SW_SH
OW
MethodReference
WinSetTitleChangesthetitleofawindow
WinSetTitle"title","text","newtitle"
Parameterstitle Thetitleofthewindowtochange.text Thetextofthewindowtochange.newtitle Thenewtitletogivetothewindow.
ReturnValueNone.
RemarksIfmultiplewindowsmatchthecriteriathetitleofmostrecentlyactivewindowischanged.
RelatedWinGetTitle,WinTitleMatchMode(Option)
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.WinSetTitle"Untitled-","","MyNewNote
pad"
MethodReference
WinSetTransSetsthetransparencyofawindow
WinSetTrans"title","text",transparency
Parameterstitle Thetitleofthewindowtochange.text Thetextofthewindowtochange.
transparency Anumberintherange0-255.Thelargerthenumber,themoretransparentthewindowwillbecome.
ReturnValueNon-zeroonsuccess,zeroonfailure.oAutoIt.errorwillbesetto1ifthefunctionisn'tsupportedonanOS.
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
oAutoIt.Run("notepad.exe","",oAutoIt.SW_MINIMIZE)
oAutoIt.WinWaitActive("Untitled-Notepad")
oAutoIt.WinSetTrans"Untitled-Notepad","",50
MethodReference
WinWaitPausesexecutionofthescriptuntiltherequestedwindowexists
WinWait"title"[,"text"[,timeout]]
Parameterstitle Thetitleofthewindowtocheck.text Optional:Thetextofthewindowtocheck.timeout Optional:Timeoutinseconds
ReturnValueSuccess: Returns1.Failure: Returns0iftimeoutoccurred.
RemarksThescriptpollsforwindowmatchevery250millisecondsorso.
RelatedWinActive,WinExists,WinWait,WinWaitActive,WinWaitClose,WinWaitDelay(Option),WinWaitNotActive
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'Waitforthewindow"Untitled"toexist
oAutoIt.Run"notepad.exe"
oAutoIt.WinWait"Untitled"
'Waitamaximumof5secondsfor"Untitled"toexis
t
oAutoIt.WinWait"Untitled","",5
MethodReference
WinWaitActivePausesexecutionofthescriptuntiltherequestedwindowisactive
WinWaitActive"title",["text"],[timeout]
Parameterstitle Thetitleofthewindowtocheck.text Optional:Thetextofthewindowtocheck.timeout Optional:Timeoutinseconds
ReturnValueSuccess: Returns1.Failure: Returns0iftimeoutoccurred.
RemarksAutoItpollsforawindowmatchevery250millisecondsorso.
RelatedWinActive,WinExists,WinWait,WinWaitClose,WinWaitDelay(Option),WinWaitNotActive
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'Waitforthewindow"Untitled"toexistandbeact
ive
oAutoIt.WinWaitActive"Untitled"
'Waitamaximumof5secondsfor"Untitled"toexis
tandbeactive
oAutoIt.WinWaitActive"Untitled","",5
MethodReference
WinWaitClosePausesexecutionofthescriptuntiltherequestedwindowdoesnotexist
WinWaitClose"title"[,"text"[,timeout]]
Parameterstitle Thetitleofthewindowtocheck.text Optional:Thetextofthewindowtocheck.timeout Optional:Timeoutinseconds
ReturnValueSuccess: Returns1.Failure: Returns0iftimeoutoccurred.
RemarksIfthewindowalreadydoesn'texistwhenthisfunctioniscalleditwillreturn0immediately.Thewindowispolledevery250millisecondsorso.
RelatedWinActive,WinExists,WinWait,WinWaitActive,WinWaitDelay(Option),WinWaitNotActive
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'Waitforthewindow"Untitled"tonotexist
oAutoIt.WinWaitClose"Untitled"
'Waitamaximumof5secondsfor"Untitled"tonot
exist
oAutoIt.WinWaitClose"Untitled","",5
MethodReference
WinWaitNotActivePausesexecutionofthescriptuntiltherequestedwindowisnotactive
WinWaitNotActive"title"[,"text"[,timeout]]
Parameterstitle Thetitleofthewindowtocheck.text Optional:Thetextofthewindowtocheck.timeout Optional:Timeoutinseconds
ReturnValueReturns0ifthetimeoutoccurred,otherwisereturns1.
RemarksThescriptpollsforawindowmatchevery250millisecondsorso.
RelatedWinActive,WinExists,WinWait,WinWaitActive,WinWaitClose,WinWaitDelay(Option)
Example
SetoAutoIt=WScript.CreateObject("AutoItX3.Contro
l")
'Waitforthewindow"Untitled"tonotbeactive
oAutoIt.WinWaitNotActive"Untitled"
'Waitamaximumof5secondsfor"Untitled"tonot
beactive
oAutoIt.WinWaitNotActive"Untitled","",5
PropertiesReferenceBelowisanlistofallthepropertiesavailableinAutoItX.
e.g.
SetoAutoIt=WScript.CreateObject("AutoItX3.Control")
error=oAutoIt.error()
Macro Description
error Statusoftheerrorflag(equivalenttothe@errormacroinAutoItv3)
version autoitXdllversion(equivalentto@AutoItVersionmacroinAutoItv3)
SW_HIDE Hidesthewindowandactivatesanotherwindow.
SW_MAXIMIZE Maximizesthespecifiedwindow.
SW_MINIMIZE Minimizesthespecifiedwindowandactivatesthenexttop-levelwindowintheZorder.
SW_RESTORE
Activatesanddisplaysthewindow.Ifthewindowisminimizedormaximized,thesystemrestoresittoitsoriginalsizeandposition.Anapplicationshouldspecifythisflagwhenrestoringaminimizedwindow.
SW_SHOW Activatesthewindowanddisplaysitinitscurrentsizeandposition.
SW_SHOWDEFAULTSetstheshowstatebasedontheSW_valuespecifiedbytheprogramthatstartedtheapplication.
SW_SHOWMAXIMIZED Activatesthewindowanddisplaysitasamaximizedwindow.
SW_SHOWMINIMIZED Activatesthewindowanddisplaysitasaminimizedwindow.
SW_SHOWMINNOACTIVE
Displaysthewindowasaminimizedwindow.ThisvalueissimilartoSW_SHOWMINIMIZED,exceptthewindowisnotactivated.
SW_SHOWNADisplaysthewindowinitscurrentsizeandposition.ThisvalueissimilartoSW_SHOW,exceptthewindowisnotactivated.
SW_SHOWNOACTIVATE
Displaysawindowinitsmostrecentsizeandposition.ThisvalueissimilartoSW_SHOWNORMAL,exceptthewindowisnotactived.
SW_SHOWNORMAL
Activatesanddisplaysawindow.Ifthewindowisminimizedormaximized,thesystemrestoresittoitsoriginalsizeandposition.Anapplicationshouldspecifythisflagwhendisplayingthewindowforthefirsttime.
UsingtheDLLInterfaceAutoItXcanbeusedasastandardDLLfromanylanguagecapableofcallingfunctionsinexternalDLLs.
ThefollowingfilesareprovidedtoallowyoutousetheDLLinC++:
AutoItX3_DLL.h-Clanguageheaderfileshowingtheexportedfunctionsandparameters
AutoItX3_DLL.lib-Microsoftformatimportlibrary(x86)
AutoItX3_x64_DLL.lib-Microsoftformatimportlibrary(x64)
AutoItX3.dll-ThemainAutoItXDLL(x86)
AutoItX3_x64.dll-ThemainAutoItXDLL(x64)
DocumentationforeachfunctionisnotprovidedasthefunctioncallsaresimilartotheCOMversionanditshouldbeeasytoworkoutwhatisrequiredwiththeCOMdocumentationandtheheaderfile.ThemaindifferencetotheCOMversionisthatthefunctionsthatreceivetext-suchasAU3_WinGetTitlehaveanadditionalparametercallednBufSize-thisshouldbesettotheavailablesizeoftheoutputtextbuffer.
e.g.TheprototypeforAU3_WinGetTextis:voidAU3_WinGetTitle(LPCWSTRszTitle,LPCWSTRszText,LPWSTRszRetText,intnBufSize);
ThereturnbufferisszRetText,andanexample(C++language)usagewouldbe:WCHARszMyTitle[200];
AU3_WinGetTitle("Untitled-Notepad","",szMyTitle,200);
MessageBox(NULL,szMyTitle,"Returnedwindowtitlewas:",MB_OK);
nBufSizeissimplyusedtoavoidbufferoverrunsinanytextthatispassedback.
Usingthe.NETInterfaceA.NETAssemblyinterfaceisprovidedtoallowtheuseofAutoItXDLLfunctionswithoutthetroubleofworkingwithDllImport.Theassemblyuses.NET2.0/CLR2.0andisstronglysignedformaximumcompatibilitywithyourprojects.
Thefollowingfilesareprovidedtoallow.NETuse:
AutoItX3.Assembly.dll-The.NETAssemblyforusingAutoItX.
AutoItX3.Assembly.xml-TheVisualStudioIntellisensehelpfileforthe.NETAssembly.
AutoItX3.dll-ThemainAutoItXDLL(x86)
AutoItX3_x64.dll-ThemainAutoItXDLL(x64)
UsingtheAssemblyfromVB/C#withininVisualStudioisveryeasy:
-AddareferencetoAutoItX3.Assembly.dlltoyourproject
-AddausingAutoIt;statementinthefilesyouwanttouseAutoItfunctions
-WritecodelikethisC#example:
usingAutoIt;
...
//Wow,thisisC#!
AutoItX.Run("notepad.exe");
AutoItX.WinWaitActive("Untitled");
AutoItX.Send("I'minnotepad");
IntPtrwinHandle=AutoItX.WinGetHandle("Untitled");
AutoItX.WinKill(winHandle);
-DistributeyourfinalexecutablewiththefilesAutoItX3.Assembly.dll,AutoItX3.dll,AutoItX3_x64.dll.
UsingthePowerShellCmdLetsAutoItXcanbeusedtoprovidePowerShellCmdLets.
ThefollowingfilesareprovidedtoallowPowerShelluse:
AutoItX.psd1-ThesignedPowerShellimportmanifest,thisisthefileyouwillimportintoyourscript.
AutoItX3.PowerShell.dll-ThePowerShellmodulecode
AutoItX3.Assembly.dll-The.NETAssemblyforusingAutoItX.ThisisusedbythePowerShellmodule.
AutoItX3.dll-ThemainAutoItXDLL(x86)
AutoItX3_x64.dll-ThemainAutoItXDLL(x64)
UsageofthecmdletswihinPowerShellisasfollows:
#Importthemodulemanfiest.
#IfAutoItisinstalledonthismachinethisstepwon'tberequired-itshouldbeauto-imported.
Import-Module.\AutoItX.psd1
#GetthelistofAutoItXcmdlets
Get-Command*AU3*
#Getdetailedhelpforaparticularcmdlet
Get-HelpGet-AU3WinText
AppendixReference
ASCIICharacters
SendKeyList
ASCIICharacterCodesThislistishelpfulwiththeAscandChrfunctions.TakenfromASCIICharacterSet
ControlCharacters(mostlynon-printing;mostusefulofthesearehighlightedinyellow.)
Char... Dec Hex Oct DescriptionNUL 0 00 000 NullcharacterSOH 1 01 001 Startofheading,=consoleinterruptSTX 2 02 002 Startoftext,maintenancemodeonHPconsoleETX 3 03 003 EndoftextEOT 4 04 004 Endoftransmission,notthesameasETBENQ 5 05 005 Enquiry,goeswithACK;oldHPflowcontrolACK 6 06 006 Acknowledge,clearsENQlogonhandBEL 7 07 007 Bell,ringsthebell...(PlaysWindows'defaultbeep)BS 8 08 010 Backspace,worksonHPterminals/computersHT 9 09 011 Horizontaltab,movetonexttabstopLF 10 0a 012 LineFeedVT 11 0b 013 VerticaltabFF 12 0c 014 FormFeed,pageejectCR 13 0d 015 CarriageReturnSO 14 0e 016 ShiftOut,alternatecharactersetSI 15 0f 017 ShiftIn,resumedefaultcharactersetDLE 16 10 020 DatalinkescapeDC1 17 11 021 XON,withXOFFtopauselistings;":okaytosend".DC2 18 12 022 Devicecontrol2,block-modeflowcontrolDC3 19 13 023 XOFF,withXONisTERM=18flowcontrol
DC4 20 14 024 Devicecontrol4NAK 21 15 025 NegativeacknowledgeSYN 22 16 026 SynchronousidleETB 23 17 027 Endtransmissionblock,notthesameasEOTCAN 24 18 030 Cancelline,MPEechoes!!!EM 25 19 031 Endofmedium,Control-YinterruptSUB 26 1a 032 SubstituteESC 27 1b 033 Escape,nextcharacterisnotechoedFS 28 1c 034 FileseparatorGS 29 1d 035 GroupseparatorRS 30 1e 036 Recordseparator,block-modeterminatorUS 31 1f 037 UnitseparatorDEL 127 7f 177 Delete(rubout),cross-hatchbox
PrintingCharacters(standardcharacters)
Char Dec Hex Oct Description 32 20 040 Space! 33 21 041 Exclamationmark" 34 22 042 Quotationmark("inHTML)# 35 23 043 Crosshatch(numbersign)$ 36 24 044 Dollarsign% 37 25 045 Percentsign& 38 26 046 Ampersand` 39 27 047 Closingsinglequote(apostrophe)( 40 28 050 Openingparentheses) 41 29 051 Closingparentheses
* 42 2a 052 Asterisk(star,multiply)+ 43 2b 053 Plus, 44 2c 054 Comma- 45 2d 055 Hyphen,dash,minus. 46 2e 056 Period/ 47 2f 057 Slant(forwardslash,divide)0 48 30 060 Zero1 49 31 061 One2 50 32 062 Two3 51 33 063 Three4 52 34 064 Four5 53 35 065 Five6 54 36 066 Six7 55 37 067 Seven8 56 38 070 Eight9 57 39 071 Nine: 58 3a 072 Colon; 59 3b 073 Semicolon< 60 3c 074 Lessthansign= 61 3d 075 Equalssign> 62 3e 076 Greaterthansign? 63 3f 077 Questionmark@ 64 40 100 At-signA 65 41 101 UppercaseAB 66 42 102 UppercaseBC 67 43 103 UppercaseCD 68 44 104 UppercaseDE 69 45 105 UppercaseE
F 70 46 106 UppercaseFG 71 47 107 UppercaseGH 72 48 110 UppercaseHI 73 49 111 UppercaseIJ 74 4a 112 UppercaseJK 75 4b 113 UppercaseKL 76 4c 114 UppercaseLM 77 4d 115 UppercaseMN 78 4e 116 UppercaseNO 79 4f 117 UppercaseOP 80 50 120 UppercasePQ 81 51 121 UppercaseQR 82 52 122 UppercaseRS 83 53 123 UppercaseST 84 54 124 UppercaseTU 85 55 125 UppercaseUV 86 56 126 UppercaseVW 87 57 127 UppercaseWX 88 58 130 UppercaseXY 89 59 131 UppercaseYZ 90 5a 132 UppercaseZ[ 91 5b 133 Openingsquarebracket\ 92 5c 134 Reverseslant(Backslash)] 93 5d 135 Closingsquarebracket^ 94 5e 136 Caret(Circumflex)_ 95 5f 137 Underscore` 96 60 140 Openingsinglequotea 97 61 141 Lowercasea
b 98 62 142 Lowercasebc 99 63 143 Lowercasecd 100 64 144 Lowercasede 101 65 145 Lowercaseef 102 66 146 Lowercasefg 103 67 147 Lowercasegh 104 68 150 Lowercasehi 105 69 151 Lowercaseij 106 6a 152 Lowercasejk 107 6b 153 Lowercasekl 108 6c 154 Lowercaselm 109 6d 155 Lowercasemn 110 6e 156 Lowercaseno 111 6f 157 Lowercaseop 112 70 160 Lowercasepq 113 71 161 Lowercaseqr 114 72 162 Lowercasers 115 73 163 Lowercasest 116 74 164 Lowercasetu 117 75 165 Lowercaseuv 118 76 166 Lowercasevw 119 77 167 Lowercasewx 120 78 170 Lowercasexy 121 79 171 Lowercaseyz 122 7a 172 Lowercasez{ 123 7b 173 Openingcurlybrace| 124 7c 174 Verticalline} 125 7d 175 Closingcurlybrace
~ 126 7e 176 Tilde(approximate)
ExtendedCharacterSet(ANSI)
Char Dec Hex Oct Description€ 128 80 200
129 81 201 Note:doesnotdisplayinthiscompiledhtmlhelpfile' 130 82 202ƒ 131 83 203" 132 84 204… 133 85 205† 134 86 206‡ 135 87 207ˆ 136 88 210‰ 137 89 211Š 138 8A 212‹ 139 8B 213Œ 140 8C 214
141 8D 215 Note:doesnotdisplayinthiscompiledhtmlhelpfileŽ 142 8E 216
143 8F 217 Note:doesnotdisplayinthiscompiledhtmlhelpfile� 144 90 220 Note:doesnotdisplayinthiscompiledhtmlhelpfile' 145 91 221' 146 92 222" 147 93 223" 148 94 224• 149 95 225
- 150 96 226- 151 97 227˜ 152 98 230™ 153 99 231š 154 9A 232› 155 9B 233œ 156 9C 234
157 9D 235 Note:doesnotdisplayinthiscompiledhtmlhelpfilež 158 9E 236Ÿ 159 9F 237 160 A0 240¡ 161 A1 241¢ 162 A2 242£ 163 A3 243¤ 164 A4 244¥ 165 A5 245¦ 166 A6 246§ 167 A7 247¨ 168 A8 250© 169 A9 251ª 170 AA 252« 171 AB 253¬ 172 AC 254
173 AD 255 Note:maynotdisplayinthiscompiledhtmlhelpfile® 174 AE 256¯ 175 AF 257° 176 B0 260± 177 B1 261
² 178 B2 262
³ 179 B3 263´ 180 B4 264µ 181 B5 265¶ 182 B6 266· 183 B7 267¸ 184 B8 270¹ 185 B9 271º 186 BA 272» 187 BB 273¼ 188 BC 274½ 189 BD 275¾ 190 BE 276¿ 191 BF 277À 192 C0 300Á 193 C1 301Â 194 C2 302Ã 195 C3 303Ä 196 C4 304Å 197 C5 305Æ 198 C6 306Ç 199 C7 307È 200 C8 310É 201 C9 311Ê 202 CA 312Ë 203 CB 313Ì 204 CC 314Í 205 CD 315
Î 206 CE 316
Ï 207 CF 317Ð 208 D0 320Ñ 209 D1 321Ò 210 D2 322Ó 211 D3 323Ô 212 D4 324Õ 213 D5 325Ö 214 D6 326× 215 D7 327Ø 216 D8 330Ù 217 D9 331Ú 218 DA 332Û 219 DB 333Ü 220 DC 334Ý 221 DD 335Þ 222 DE 336ß 223 DF 337à 224 E0 340á 225 E1 341â 226 E2 342ã 227 E3 343ä 228 E4 344å 229 E5 345æ 230 E6 346ç 231 E7 347è 232 E8 350
é 233 E9 351ê 234 EA 352
ë 235 EB 353ì 236 EC 354í 237 ED 355î 238 EE 356ï 239 EF 357ð 240 F0 360ñ 241 F1 361ò 242 F2 362ó 243 F3 363ô 244 F4 364õ 245 F5 365ö 246 F6 366÷ 247 F7 367ø 248 F8 370ù 249 F9 371ú 250 FA 372û 251 FB 373ü 252 FC 374ý 253 FD 375þ 254 FE 376ÿ 255 FF 377
SendKeylistQuickreferencefortheSend("keys"[,flag])Command.^Ctrl!Alt+Shift#Win
AutoItcansendallASCIIandExtendedASCIIcharacters(0-255),tosendUNICODEcharactersyoumustusethe"ASC"optionandthecodeofthecharacteryouwishtoSend(see{ASC}below).
TosendtheASCIIvalueA(sameaspressingALT+065onthenumerickeypad)
Send("{ASC065}")
(Whenusing2digitASCIIcodesyoumustusealeading0,otherwiseanobsolete437codepageisused).
TosendUNICODEcharactersenterthecharactercode,forexamplethissendsaChinesecharacter
Send("{ASC2709}")
Singlekeyscanalsoberepeated,e.g.
Send("{DEL4}");PressestheDELkey4times
Send("{S30}");Sends30'S'characters
Send("+{TAB4}");PressesShift+Tab4times
Toholdakeydown
Send("{adown}");HoldstheAkeydown
Send("{aup}");ReleasestheAkey
Ifyouwithtouseavariableforthecount,try
Local$iCount=4
Send("+{TAB"&$iCount&"}")
IfyouwishtosendtheASCIIvalueAfourtimes,thentry
Local$iChr=Chr(65)
Send("{"&$iChr&"4}")
MostlaptopcomputerkeyboardshaveaspecialFnkey.Thiskeycannotbesimulated.
Note,bysettingtheflagparameterto1the"keys"parameterissentRAW.Thisisusefulwhenyouwanttosendsometextcopiedfromavariableandyouwantthetextsentexactlyaswritten.
Sendisquiteusefulbecausewindowscanbenavigatedwithoutneedingamouse.
Forexample,openFolderOptions(inthecontrolpanel)andtrythefollowing:
Send("{TAB}") Navigatetonextcontrol(button,checkbox,etc)Send("+{TAB}") Navigatetopreviouscontrol.Send("^{TAB}") NavigatetonextWindowTab(onaTabbeddialogwindow)Send("^+{TAB}") NavigatetopreviousWindowTab.
Send("{SPACE}") Canbeusedtotoggleacheckboxorclickabutton.
Send("{+}") Usuallychecksacheckbox(ifit'sa"real"checkbox.)Send("{-}") Usuallyunchecksacheckbox.
Send("{NumPadMult}") RecursivelyexpandsfoldersinaSysTreeView32.
UseAlt-keycombostoaccessmenuitems.Also,openNotepadandtrythefollowing:
Send("!f") SendAlt+f,theaccesskeyforNotepad'sfilemenu.Tryotherletters!
Send("{DOWN}") Movedownamenu.
Send("{UP}") Moveupamenu.Send("{LEFT}") Moveleftwardtonewmenuorexpandasubmenu.
Send("{RIGHT}") Moverightwardtonewmenuorcollapseasubmenu.
SeeWindows'Help--pressWin+F1--foracompletelistofkeyboardshortcutsifyoudon'tknowtheimportanceofAlt+F4,PrintScreen,Ctrl+C,andsoon.
SendCommand(ifzeroflag) ResultingKeypress
{!} !{#} #{+} +{^} ^{{} {{}} }
{SPACE} SPACE{ENTER} ENTERkeyonthemainkeyboard
{ALT} ALT{BACKSPACE}or{BS} BACKSPACE{DELETE}or{DEL} DELETE
{UP} Uparrow{DOWN} Downarrow{LEFT} Leftarrow{RIGHT} Rightarrow{HOME} HOME{END} END
{ESCAPE}or{ESC} ESCAPE{INSERT}or{INS} INS
{PGUP} PGUP{PGDN} PGDN
{F1}-{F12} Functionkeys{TAB} TAB
{PRINTSCREEN} PRINTSCR{LWIN} LeftWindowskey{RWIN} RightWindowskey
{NUMLOCK} NUMLOCK{CAPSLOCK} CAPSLOCK
{SCROLLLOCK} SCROLLLOCK{BREAK} forCtrl+Breakprocessing{PAUSE} PAUSE
{NUMPAD0}-{NUMPAD9} Numpaddigits
{NUMPADMULT} NumpadMultiply{NUMPADADD} NumpadAdd{NUMPADSUB} NumpadSubtract
{NUMPADDIV} NumpadDivide{NUMPADDOT} Numpadperiod
{NUMPADENTER} Enterkeyonthenumpad{APPSKEY} WindowsAppkey{LALT} LeftALTkey{RALT} RightALTkey{LCTRL} LeftCTRLkey{RCTRL} RightCTRLkey{LSHIFT} LeftShiftkey{RSHIFT} RightShiftkey{SLEEP} ComputerSLEEPkey
{ALTDOWN} HoldstheALTkeydownuntil{ALTUP}issent
{SHIFTDOWN} HoldstheSHIFTkeydownuntil{SHIFTUP}issent
{CTRLDOWN} HoldstheCTRLkeydownuntil{CTRLUP}issent
{LWINDOWN} HoldstheleftWindowskeydownuntil{LWINUP}issent
{RWINDOWN} HoldstherightWindowskeydownuntil{RWINUP}issent
{ASCnnnn} SendtheALT+nnnnkeycombination
{BROWSER_BACK} Selectthebrowser"back"button{BROWSER_FORWARD} Selectthebrowser"forward"button{BROWSER_REFRESH} Selectthebrowser"refresh"button{BROWSER_STOP} Selectthebrowser"stop"button
{BROWSER_SEARCH} Selectthebrowser"search"button{BROWSER_FAVORITES} Selectthebrowser"favorites"button
{BROWSER_HOME} Launchthebrowserandgotothehomepage
{VOLUME_MUTE} Mutethevolume{VOLUME_DOWN} Reducethevolume{VOLUME_UP} Increasethevolume{MEDIA_NEXT} Selectnexttrackinmediaplayer{MEDIA_PREV} Selectprevioustrackinmediaplayer{MEDIA_STOP} Stopmediaplayer
{MEDIA_PLAY_PAUSE} Play/pausemediaplayer{LAUNCH_MAIL} Launchtheemailapplication{LAUNCH_MEDIA} Launchmediaplayer{LAUNCH_APP1} Launchuserapp1{LAUNCH_APP2} Launchuserapp2
CreditsAutoItXwasadaptedfromthemainAutoItsourcecodebyJonathanBennett.PleaseseethemainAutoIthelpfileforfullcredits.
HistoryIMPORTANT:Seehereforrecentscript-breakingchanges.
PleaseseethemainAutoIthelpfilewhichdetailsthehistoryofallcomponentsincludingAutoItX.
ScriptBreakingChangesinRecentVersionsThispagecontainsalistofallchangesmadeinrecentupdatesthatwillalmostcertainlybreakexistingscripts/sources.Pleasereadthislistcarefullywhenupgradingifyouhavenotbeenkeepingupwithdevelopmentsinthebetaversions.Ifanyoftheseissuesaffectyouthenyouwillneedtomodifyyourscripts/sources.
23rdDecember,2013-v3.3.10.0AutoItX:
Removed:RemovedDevCfilesandVisualStudio6files.Removed:ANSIversionsofSend/WinWaitfunctionsfromthenativeDLL.Removed:DLLImports:AU3_WinGetPosX,AU3_WinGetPosY,AU3_WinGetPosWidth,AU3_WinGetPosHeight.Removed:DLLImports:AU3_ControlGetPosX,AU3_ControlGetPosY,AU3_ControlGetPosWidth,AU3_ControlGetPosHeight.Removed:DLLImports:AU3_MousePosX,AU3_MouseGetPosY.Removed:DLLImports:AU3_WinGetClientSizeWidth,AU3_WinGetClientSizeHeight.Removed:DLLImports:AU3_WinGetCaretPosX,AU3_WinGetCaretPosY.Removed:DLLImports:AU3_CDTray,AU3_BlockInput.Removed:DLLImports:AU3_RunAsSet.Removed:COMMethods:CDTray,BlockInput.Removed:COMMethods:RunAsSet.Removed:Allregistryfunctions.Thesupportwaslimitedandthehostlanguagewillcertainlyhaveregistryfunctions.Removed:AllInifilefunctions.Asperregistryfunctions.Changed:RenamedAutoIt3.htoAutoItX3_DLL.h.
18thDecember,2009-v3.3.2.0AutoItX:
Removed:"ColorMode"optionremovedfromAutoItSetOption().
24thDecember,2008-v3.3.0.0AutoItX:
ThenativeversionoftheDLLnowexclusivelyusesUnicodestrings(LPWSTRandLPCWTSR).IfyoureallyneedANSIstringsthencontinuetousev3.2.12.1.Theeasiestworkaroundthoughistousea"wrapper"functiontosimplyconvertbetweenUnicodeandANSI.Alimitedselectionoffunctions(WinWait...andSend)haveanANSIversionbutitisnotintendedtoaddANSIversionsforanyothersunlessthereisalargedemand.