version 2.64 - (c)1999- 2002 jonathan bennett · autoit is a simple tool that can simulate key...

150
Version 2.64 - (C)1999- 2002 Jonathan Bennett (Email: [email protected]) AutoIt Homepage AutoIt is a simple tool that can simulate key presses, mouse movements and window commands (maximize, minimize, wait for, etc.) in order to automate any windows based task (or even windowed DOS tasks). AutoIt was primarily designed to assist in automatically installing software that cannot be automatically installed by other means. This is most useful during a PC rollout where hundreds or thousands of client machines need to be automatically installed. However, AutoIt is not limited to software installation and can be used to automate most simple windows tasks. When AutoIt is executed, it reads a specified script file. This script file allows AutoIt to perform a number of functions, these include: Executing programs (Windows applications, DOS commands, etc.) Sending keystrokes and mouse clicks (all characters, keyboard layout independent). Window functions (e.g. minimizing, hiding, restoring, waiting for, activating).

Upload: nguyenque

Post on 21-Sep-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

Version2.64-(C)1999-2002JonathanBennett

(Email:[email protected])

AutoItHomepage

AutoItisasimpletoolthatcansimulatekeypresses,mousemovementsandwindowcommands(maximize,minimize,waitfor,etc.)inordertoautomateanywindowsbasedtask(orevenwindowedDOStasks).

AutoItwasprimarilydesignedtoassistinautomaticallyinstallingsoftwarethatcannotbeautomaticallyinstalledbyothermeans.ThisismostusefulduringaPCrolloutwherehundredsorthousandsofclientmachinesneedtobeautomaticallyinstalled.However,AutoItisnotlimitedtosoftwareinstallationandcanbeusedtoautomatemostsimplewindowstasks.

WhenAutoItisexecuted,itreadsaspecifiedscriptfile.ThisscriptfileallowsAutoIttoperformanumberoffunctions,theseinclude:

Executingprograms(Windowsapplications,DOScommands,etc.)Sendingkeystrokesandmouseclicks(allcharacters,keyboardlayoutindependent).Windowfunctions(e.g.minimizing,hiding,restoring,waitingfor,activating).

Simpletextclipboardfunctions.Simpleregistryfunctions.Simplestringandvariablefunctions.

ScriptscanalsobecompiledintostandaloneexecutablesusingAut2Exe.

Bestofall,itssmall(selfcontained.exe,noDLL's,noregistryentries)andFREE!

ThereisalsoanActiveXcontrolversionofAutoItcalledAutoItX.ThisisastandalonecontrolthatcanbeusedtogreateffectunderotherscriptinglanguagessuchasWSH/VBScript.

Stillneeded,non-Englishversionsofthisfile!(Inanyformat,aslongasyouarewillingtohelpmaintain)-Checkthenon-EnglishdownloadsattheAutoItHomepagetoseewhatlanguageshavecurrentlybeendone.EmailmeforthebaseHTMLfiles.

IntendedUse

ThisprogramisintendedforperformingsimpleautomationtasksinWindows.Itisnotintendedasthe"be-allandend-all"ofscripting.Whenperformingcomplextasks(registrymanipulation,textfileparsing,complexloops,etc.)IwouldrecommendusingAutoItinconjunctionwithafully-fledgedscriptinglanguage(suchasWSHorKixtart-bothfree)andusingAutoItto"fillinthegaps".ThecurrentethosofAutoItis"Ifitcan'tbedoneonasingleline-it'sprobablytoocomplicated".Thisapproachhasworkedwellsofar,andhelpedtokeepthesizeofAutoItdown(itisatinyexecutable!).

IpersonallyuseAutoItforlargePCrollouts.IuseKixtart/WSHasa"back-end"tocopyfiles,runfiles,edittheregistryandthenuseittocallAutoItwhenIneedtoperformconfigurationsthatcanonlybeusuallyachievedbymanualinput(softwareinstallation,configuringcontrolpanel,changingdriveletters,etc.).

License

Author:JonathanBennettWWW:http://www.hiddensoft.com/AutoIt/Email:[email protected]________________________________________________________

END-USERLICENSEAGREEMENTFORTHISSOFTWARE

Important-readcarefully:

ThisEnd-UserLicenseAgreement("EULA")isalegalagreementbetweenyou(eitheranindividualorasingleentity)andthementionedauthorofthisSoftwareforthesoftwareproductidentifiedabove,whichincludescomputersoftwareandmayincludeassociatedmedia,printedmaterials,and"online"orelectronicdocumentation("SOFTWAREPRODUCT").Byinstalling,copying,orotherwiseusingtheSOFTWAREPRODUCT,youagreetobeboundbythetermsofthisEULA.IfyoudonotagreetothetermsofthisEULA,donotinstallorusetheSOFTWAREPRODUCT.

SOFTWAREPRODUCTLICENSE

TheSOFTWAREPRODUCTisprotectedbycopyrightlawsandinternationalcopyrighttreaties,aswellasotherintellectualpropertylawsandtreaties.TheSOFTWAREPRODUCTislicensed,notsold.ThedefinitionofSOFTWAREPRODUCTincludesanyfilesgeneratedbytheSOFTWAREPRODUCT,suchascompiledscriptfilesintheformofstandaloneexecutables.

1.GRANTOFLICENSE.

ThisEULAgrantsyouthefollowingrights:

InstallationandUse.YoumayinstallanduseanunlimitednumberofcopiesoftheSOFTWAREPRODUCT.

ReproductionandDistribution.YoumayreproduceanddistributeanunlimitednumberofcopiesoftheSOFTWAREPRODUCT;providedthateachcopyshallbeatrueandcompletecopy,includingallcopyrightandtrademarknotices,andshallbeaccompaniedbyacopyofthisEULA.CopiesoftheSOFTWAREPRODUCTmaybedistributedasastandaloneproductorincludedwithyourownproduct.

CommercialUse.IftheSOFTWAREPRODUCTistobeincludedinasolutionorproductthatwillbesoldforprofit,youarerequiredtoacknowledgeinyourproductdocumentationand/orhelpfiles,thatthisSOFTWAREPRODUCTwasused.YouarefurtherrequiredtoprovidealinktothewebhomepagespecifiedatthetopofthisEULA.

2.COPYRIGHT.

AlltitleandcopyrightsinandtotheSOFTWAREPRODUCT(includingbutnotlimitedtoanyimages,photographs,animations,video,audio,music,text,and"applets"incorporatedintotheSOFTWAREPRODUCT),theaccompanyingprintedmaterials,andanycopiesoftheSOFTWAREPRODUCTareownedbytheAuthorofthisSoftware.TheSOFTWAREPRODUCTisprotectedbycopyrightlawsandinternationaltreatyprovisions.Therefore,youmusttreattheSOFTWAREPRODUCTlikeanyothercopyrightedmaterial.

MISCELLANEOUS

IfyouacquiredthisproductintheUnitedKingdom,thisEULAisgovernedbythelawsoftheUnitedKingdom.IfthisproductwasacquiredoutsidetheUnitedKingdom,thenlocal

lawmayapply.ShouldyouhaveanyquestionsconcerningthisEULA,orifyoudesiretocontacttheauthorofthisSoftwareforanyreason,pleasecontacthim/herattheemailaddressmentionedatthetopofthisEULA.

LIMITEDWARRANTY

NOWARRANTIES.

TheAuthorofthisSoftwareexpresslydisclaimsanywarrantyfortheSOFTWAREPRODUCT.TheSOFTWAREPRODUCTandanyrelateddocumentationisprovided"asis"withoutwarrantyofanykind,eitherexpressorimplied,including,withoutlimitation,theimpliedwarrantiesormerchantability,fitnessforaparticularpurpose,ornoninfringement.TheentireriskarisingoutofuseorperformanceoftheSOFTWAREPRODUCTremainswithyou.

NOLIABILITYFORDAMAGES.

InnoeventshalltheauthorofthisSoftwarebeliableforanydamageswhatsoever(including,withoutlimitation,damagesforlossofbusinessprofits,businessinterruption,lossofbusinessinformation,oranyotherpecuniaryloss)arisingoutoftheuseoforinabilitytousethisproduct,eveniftheAuthorofthisSoftwarehasbeenadvisedofthepossibilityofsuchdamages.

Becausesomestates/jurisdictionsdonotallowtheexclusionorlimitationofliabilityforconsequentialorincidentaldamages,theabovelimitationmaynotapplytoyou.

[ENDOFLICENSE]

Whatdoesthelicensemean?

Licensesareparticularlyhardtofollow,soherearemyanswerstothemostfrequentlyaskedlicensequestions:

GENERAL

CanIdistributethebaseAutoItexecutable(AutoIt.exe)orcompiledscriptsaspartofmyscript/solution.YES.

CanImodifytheAutoItexecutableorcompiledscripts(changingresources,andversioninformationinordertopassoffAutoItasyourownprogram).NO.Youareonlyallowedtochangetheiconincompiledscripts,andthisfacilityisprovidedbyAut2Exe.

Ifyourequireanalternativelicenseagreementthenemailmeandmakemeanoffer:)

NON-COMMERCIALUSE

Fornon-commercialuse,a"mention"thatyouareusingAutoItinyourproduct/solutionandalinktotheAutoIthomepagewouldbeverymuchappreciated.

COMMERCIALUSE

YouarerequiredtomentionthatAutoItwasusedinyour

product/solution.YouarealsorequiredtoprovidealinktotheAutoIthomepage.

Note:Commercial-Useimpliesthatyouaresellingyoursolution/productforprofit.UsingAutoItwithinanorganisation(forexample,internalscriptedbuilds)isnotclassedascommercial-use.

RunningAutoIt

AutoItcanbeexecutedfromthecommandline,orbydouble-clickingonitsiconfromtheWindowsExplorer.

>>>N.B.TheONLYfilethatisnecessaryforAutoIttorunis"AutoIt.exe",puttingthisfileinthepathonanyPCwillallowyoutorunAutoItscriptsonthatPCusingthecommandlinesyntaxbelow.<<<

CommandLineSyntax

AutoItisexecutedfromthecommandlineinthefollowingways(makesureAutoIt.exeisinyourpath,oryourunthecommandsfromthedirectorythatAutoItisinstalled):

AutoIt.exe/reveal

AutoIt.exe<filenameofscriptfile>

AutoIt.exe/c"ScriptCmd,ScriptParam"

RevealMode

Whenin"reveal"mode,theAutoItwindowwillstaytopmost.Asyouclickonotherwindowstomakethemactive,AutoItwilldisplaytheirwindowtitles,themousecoordinatesrelativetothatwindow,andanyothertextonthewindowthatmayhelptodistinguishitfromotherwindowsofthesametitle.AswithMSScriptIt,notalltextonawindowcanbe"seen"-experiment!

InformationontheAutoItrevealscreencanbehighlightedwiththemouseandcopiedtotheclipboardwith"CTRL-C",thiscanthenbepastedintoanotherprogram/texteditor.

ScriptMode

AutoItwillexecutethescriptfilenamegivenonthecommandline.Thefilecanhaveanyextension(ifyouusetheinstallationroutine,.autwillbeautomaticallyregistered.Rightclickingona.autfilewillenableyoutorunoreditthescript).

SingleCommandMode

AutoItwillexecutethescriptcontainedinquotesasasinglecommand.ThisisveyrusefulforrunningAutoItcommandsfromotherbatchfilesorWSH/kixtartwithouthavingtoprovideaseparatescriptfile.Forexample:

AutoIt.exe/c"WinWaitActive,Untitled-Notepad"

UsingCommandLineParameters

ParameterscanbepassedtotheAutoItscriptfromthecommandlinewhenusingthefollowingsyntax:

AutoIt.exe<filenameofscriptfile>param1param2param3........param_nn

(Note:previousversionsofAutoItrequired/ptobeusedtoindicatethatcommandlineparameterswerepresent,thisisnolongerrequiredorsupported).

TheseparametersareusablefromthescriptfileastheENVvariables%1%,%2%,%3%,etc.Thevariable%0%willalsocontainthenumberofparameterspassed.

Ifaparameterneedstocontainspaces,thenencloseitindoublequotes,e.g.:

AutoIt.exetestscript.aut"D:\Alongpathname"var2

%1%wouldequalD:\Alongpathname

%2%wouldequalvar2

WindowTitlesandWindowText

Anumberofscriptcommandshave"WindowTitle"and"WindowText"asparameters."WindowTitle"istextthatappearsinthewindowstitlebar."WindowText"isanyothertextonthatwindow,e.g.textonbuttonssuchas"OK"and"Cancel".

Having"WindowText"allowsyoutodistinguishbetweenmultiplewindowsthathavethesametitle.

Neitherthetitlenortextneedstobecompletelyspecified.i.e."Untitled-No"willmatchawindowwiththetitle"Untitled-Notepad".SeethetextontheSetTitleMatchModecommandforadditionstothis.

Usethe"/reveal"modetoseewhattextispresentonawindow.

N.B.WindowstitlesandtextareCASESENSITIVE!!!!!

Conventions

Parametersareshowninangledbrackets,optionalparametersareshowninsquarebrackets.

e.g.<cmd>,<parameter1>[,<parameter2>]

Thisisacommand,followedbyacommaandparameter1,optionallyfollowedbyacommaandparameter2.

i.e.<cmd>,<parameter1>

OR

<cmd>,<parameter1>,<parameter2>

ScriptFileSyntax

Thescriptfileisastandardtextfile(createdwithanytexteditor,suchasnotepad.exe)thatcanbegivenanyextension(although.autisthepreferredextension).Eachlinecancontaineitheracommand,acomment,alabel,orbeleftblank.

N.B.Themaximumnumberofcharactersperlineis16384.Anyextracharacterswillbeignored.

;Startofscript;Commentsareindicatedbyasemi-colon

<Cmd>,<CmdParameters><Cmd2>,<Cmd2Parameters><Cmd3>,<Cmd3Parameters>

;Thisisalabel,itmustendwithacolon(:)anditisusedforcommandssuchasGosubandGoto.label:

;EndofscriptExit

;StartoftheADLIBsection[ADLIB]<Title>,<Text>,<Cmd>,<CmdParameters>

The[ADLIB]Section

The[ADLIB]sectionisoptional,andifpresentshouldbeplacedattheendofthescriptfile.TheADLIBsectionisdesignedtocopewithunexpectedconditions.TheADLIBsectionconsistsofsinglelinecommandsthatcheckifawindowisactiveandifso,sendkeystoit.TheADLIBsectionmuststartwiththeline"[ADLIB]".

TheformatofthealineintheADLIBsectionis:

<WindowTitle>,<WindowText>,<Command>

e.g.Run,Notepad.exeWinWaitActive,Untitled-NotepadSend,12345678#!{F4}WinWaitClose,Untitled-Notepad

[ADLIB]Notepad,savethechanges?,Send,!n

WithouttheADLIBsection,thisscriptwouldneverendasNotepadwouldnevercloseuntilsomeonerespondedtothemessage"Doyouwanttosavethechanges?".

ADLIBcommandsmustcontainawindowtitleandsometextonthewindow.Ifthereisnotextonthewindow,orifyoudon'twanttospecifyany,thenyoumustusetwocommas.

e.g.Run,Notepad.exe

WinWaitActive,Untitled-NotepadSend,12345678#!{F4}WinWaitClose,Untitled-Notepad

[ADLIB]Notepad,,Send,!n

The"#include"Command

InanAutoItscript,otherscriptscanbeincludedusingthe"#include"command:

#include<filenametoinclude>

e.g.

include.autMsgBox,0,Example,Thisisfromthe"include.aut"fileExit

script.aut#includeinclude.autMsgBox,0,Example,Thisisfromthe"script.aut"fileExit

Runningthescript.autscriptwilloutputthemessagebox"Thisisfromthe'include.aut'file",followedby"Thisisfromthe'script.aut'file".

#includecanbeusedanywhereinthemainbodyofthescript(nottheADLIBsection)andwillincludethespecifiedfileatthatposition.(IftheincludefilecontainsanADLIBsection,itwillbeaddedtotheoverallADLIBsection!).

SendCommandSyntax

The"Send"commandsyntaxissimilartothatofScriptItandtheVisualBasic"SendKeys"command.Charactersaresentaswrittenwiththeexceptionofthefollowingcharacters:

'!'ThistellsAutoIttosendanALTkeystroke,therefore"Send,Thisistext!a"wouldsendthekeys"Thisistext"andthenpress"ALT+a".

N.B.SomeprogramsareverychoosyaboutcapitallettersandALTkeys,i.e."!A"isdifferentto"!a".ThefirstsaysALT+SHIFT+A,thesecondisALT+a.Ifindoubt,uselowercase!

'+'ThistellsAutoIttosendaSHIFTkeystroke,therefore"Send,Hell+o"wouldsendthetext"HellO"."Send,!+a"wouldsend"ALT+SHIFT+a".

'^'ThistellsAutoIttosendaCONTROLkeystroke,therefore"Send,^!a"wouldsend"CTRL+ALT+a".

N.B.SomeprogramsareverychoosyaboutcapitallettersandCTRLkeys,i.e."^A"isdifferentto"^a".ThefirstsaysCTRL+SHIFT+A,thesecondisCTRL+a.Ifindoubt,uselowercase!

'#'Thehashisusedasakeydelimitertomakealineeasiertoread.i.e."Send,H#e#l#l#o"isthesameas"Send,Hello".

Certainspecialkeyscanbesentandshouldbeenclosedinbraces:

N.B.Windowsdoesnotallowthesimulationofthe"CTRL-ALT-DEL"combination!

SendCommand ResultingKeypress

{!} !{#} #{+} +{^} ^{{} {{}} }

{SPACE} SPACE{ENTER} ENTER{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} PGUP{PGDN} PGDN

{F1}-{F12} Functionkeys{TAB} TAB

{PRINTSCREEN} PRINTSCR{LWIN} LeftWindowskey{RWIN} RightWindowskey

{NUMLOCK} NUMLOCK{CTRLBREAK} Ctrl+break

{PAUSE} PAUSE{CAPSLOCK} CAPSLOCK

{NUMPAD0}-{NUMPAD9} Numpaddigits{NUMPADMULT} NumpadMultiply{NUMPADADD} NumpadAdd{NUMPADSUB} NumpadSubtract{NUMPADDIV} NumpadDivide{NUMPADDOT} Numpadperiod{APPSKEY} WindowsAppkey

{ALTDOWN} HoldstheALTkeydownuntil{ALTUP}issent

{SHIFTDOWN} HoldstheSHIFTkeydownuntil{SHIFTUP}issent

{CTRLDOWN} HoldstheCTRLkeydownuntil{CTRLUP}issent

{LWINDOWN} HoldstheleftWindowskeydownuntil{LWINUP}issent

{RWINDOWN} HoldstherightWindowskeydownuntil{RWINUP}issent

{ASCnnnn} SendtheALT+nnnnkeycombination

TosendtheASCIIvalueA(sameaspressingALT+65onthenumerickeypad)Send,{ASC65}

Singlekeyscanalsoberepeated,e.g.

Send,{DEL4}PressestheDELkey4timesSend,{S30}Sends30'S'charactersSend,+{TAB4}PressesSHIFT+TAB4times

SpecialCharacters

Theslash'\',comma','andpercent'%'aretreatedasspecialcharacters,andyoumustbecarefulwhenusingthem.

','isusedtoseparateparametersinthescriptfile.'%'isusedtoindicateDOSvariables.

Ifyouwishtouseanyofthischaractersliterally,youmustprecedethemwiththeslash'\'character,i.e."\,"or"\%".Ifyouwishtousealiteral'\'youmustprecedethisalso,i.e."\\".

The"\n"and"\t"sequencescanbeusedtodenotenewlinesandtabsintheAutoItoutputfunctionsMsgBoxandInputBox.

EnvironmentVariables

YoucanuseDOSenvironmentvariablesanywhereinanAutoItscript.AsinDOSbatchfiles,justincludethevariableenclosedinpercent(%)symbols.

Forexample,ifyouwanttosendthecurrentDOSpathtothenotepadwindowyoucoulddo:

Run,notepad.exeWinWaitActive,Untitled-NotepadSend,ThisistheDOSpath%PATH%

e.g.Thisexamplesetsthevariabletestandthenoutputsitinamessagebox.SetEnv,test,ThisissomeoutputMsgBox,0,Example,%test%

N.B.Becauseofitsspecialstatus,ifyouwanttoactuallyuseapercentsignwithoutitbeingchangedintoavariable,youmustusetheescapecharacter'\'first.e.g.Send,Thiswillsendasinglepercentsign\%

Youcanalsouse"SetEnv"tosetvariables..

N.B.ManyAutoItcommandsspecificallystatethattheytakeavariableasaparameter,inthesecasesthe%symbolisNOTused.AnumberoftheexamplesthatcomewithAutoItdemonstratethis.

TheClipboardVariable

Thevariable%CLIPBOARD%isspecial,andwhenusedwillbesubstitutedforthetextcontentsoftheclipboard.Forexample,ifyoucopythetext"Hello!"totheclipboardandthenrunthefollowingscript:

MsgBox,0,Example,Thecontentsoftheclipboardis:%clipboard%

Thetext"Thecontentsoftheclipboardis:Hello!"willbeoutputtothescreen.

Similarly,ifyouwanttosendtexttotheclipboardyoucanusetheSetEnvcommand.E.g.Toputthetext"I'msomepastedtext"intotheclipboardyoucanrun:

SetEnv,clipboard,I'msomepastedtext

SpecialVariables

ThereareanumberofspecialvariablesinAutoItthesearedescribedbelow:

AutoItVariable Contains

A_OSTYPE ThetypeofOperatingSystembeingrun.Either"WIN32_WINDOWS"or"WIN32_NT".

A_OSVERSION "WIN_XP","WIN_2000","WIN_NT4","WIN_95","WIN_98","WIN_ME".

A_SCRIPTNAME Thecurrentscriptname,e.g."myscript.aut".A_SCRIPTDIR Thedirectorythatthecurrentscriptresidesin.

A_SCRIPTFULLPATH Thefullpathnameofthecurrentscript,e.g."C:\Windows\Scripts\myscript.aut".

A_WORKINGDIR Thecurrentworkingdirectory.A_NUMBATCHLINES Thecurrentsettingofthe"SetBatchLines"command.

A_SEC Secondsaftertheminute(00-59)A_MIN Minutesafterthehour(00-59)A_HOUR Hoursaftermidnight(00-23)A_MDAY Dayofthemonth(01-31)A_MON Monthoftheyear(01-12)A_YEAR Thecurrentyear(4digitformat,e.g.2000)A_WDAY Dayoftheweek(1-7)A_YDAY Dayoftheyear(1-366)

AdlibOnAdlibOff

Thiswillenable/diableprocessingofthe[ADLIB]section.

BlockInput,<on|off>

Thiscommandwithdisablebothmouseandkeyboardinput.Thisonlyworksonvariousoperatingsystemconfigurationsasindicatedbelow:

OperatingSystem "BlockInput"Results Windows95 Noeffect.

Windows98 UserinputisblockedbutAutoItisalsounabletosimulateinput.

WindowsNT4(WithoutServicePack6) Noeffect.

WindowsNT4(WithServicePack6)

UserinputisblockedandAutoItcansimulateinput.

Windows2000 UserinputisblockedandAutoItcansimulateinput.

Inputwillbeautomaticallyenabledwhenthescriptcloses.

Break,<on|off>

ThiscommandtellsAutoItwhetherornottheusercancloseAutoIt.Defaultis"on"(i.e.usercancloseAutoIt)

e.g.Break,On

DetectHiddenText,<on|off>

Someprogramsusehiddenwindowsandhiddentextonwindows(e.g.BackupExec)thiscancauseproblemswhentryingtoscriptthem.ThiscommandallowsyoutotellAutoItwhetherornottodetectthishiddentext.Defaultis"off".

Exit[,<exitcode>]

Thiscommandwillendthescript.Iftheoptional<exitcode>isused,thiswillreturnthenumericexitcodetothecallingprocess.ThiscanbeusedinDOSbatchfileslikeso:

@ECHOOFFAutoIt.exemyscript.autECHOExitcodeofAutoItwas%ERRORLEVEL%

EnvAdd,<Variable>,<Value>EnvSub,<Variable>,<Value>EnvMult,<Variable>,<Value>EnvDiv,<Variable>,<Value>

Allowsyoutoadd,subtract,multiplyanddividewithEnvvariables.Ifthevariableorvalueisnotnumeric,itwillbetakentobezero(0).Notethisfunctionsperfromonlyinteger(wholenumber)functions-anyremaindersaredropped.

e.g.SetEnv,test,20EnvAdd,test,20

MsgBox,0,Example,%test%

Thiswilloutput"40"tothescreen.

FileAppend,<Text>,<Filename>

Thiscommandwillappend"Text"totheendofafile.Ifthefiledoesnotexist,itwillbecreated.

e.g.FileAppend,Thisisline1\nThisisline2\n,myfile.txt

Thiswillappendtwolinesoftextto"myfile.txt",notetheuseof"\n"toindicateanewlineisrequired.

Ifthecommandissuccessful%ERRORLEVEL%issetto0,otherwiseitissetto1.

FileCopy,<Source>,<Destination>,[1|0]

Thiscommandwillcopyafileorfilesfrom<Source>to<Destination>.Simplewildcards(*)aresupported.Iftheoptionallastparameteris1thenexistingfilesareoverwritten.

e.g.FileCopy,C:\\*.exe,C:\\TestDir\\*.exe

Ifthecommandissuccessful%ERRORLEVEL%issetto0,otherwiseitissetto1.

FileCreateDir,<Directory>

Thiscommandwillcreatethedirectory<Directory>.

e.g.FileCreateDir,C:\\TestDir

Ifthecommandissuccessful%ERRORLEVEL%issetto0,otherwiseitissetto1.

FileDelete,<File>

Thiscommandwilldeletethespecified<File>.Wildcardsaresupported.

e.g.FileDelete,C:\\Test\\*.aut

Thiswilldeleteallfilescalled*.autintheC:\Testdirectory.

Ifthecommandissuccessful%ERRORLEVEL%issetto0,otherwiseitissetto1.

FileInstall,<Source>,<Destination>,[1|0]

ThiscommandisadirectivefortheAut2Execompilerandallowsyoutoaddextrafilestotheresultingcompiledscriptandtocopythemtothediskduringexecutionofthescript.

Thefile<Source>isaddedduringscriptcompilation.Whenthecompiledscriptisexecutedandthesame"FileInstall"commandhasbeenreached,thefileisthenextractedto<Destination>.Thelastoptionalparametercanbesetto1toindicatethatexistingfilesshouldbeoverwritten.

Filesaddedtoascriptarecompressedandalsoencrypted.

Ifthiscommandisusedinannormal(uncompiled)script,asimplefilecopywillbeperformedinstead--thiswillhelpthetestingofscriptsthatwilleventuallybecompiled.

Note:Wildcardsarenotsupported.

e.g.FileInstall,C:\\atool.exe,%TEMP%\\atool.exe

Ifthecommandissuccessful%ERRORLEVEL%issetto0,otherwiseitissetto1.

FileReadLine,<Variable>,<Filename>,<Line>

Thiscommandwillreadalinefromafileoftextintoavariable.Line1istakentobethefirstline.

e.g.FileReadLine,test,myfile.txt,1

Willreadthefirstlineof"myfile.txt"intothe%test%variable.

Ifthecommandissuccessful%ERRORLEVEL%issetto0,otherwiseitissetto1.

FileRemoveDir,<Directory>

Thiscommandwilldeletethedirectory<Directory>.Note:thedirectorymustbeempty.

e.g.

FileRemoveDir,C:\\TestDir

Ifthecommandissuccessful%ERRORLEVEL%issetto0,otherwiseitissetto1.

FileSelectFile,<FilenameVar>,<1|0>[,<WorkingDirectory>]

Thiscommandwillshowthestandardfileselectiondialog.Ifthesecondparameteris"1"thenthefilenamemustalreadyexist.Oncompletion,%ERRORLEVEL%issetto0ifsuccessful.Iftheusercancelstooperation%ERRORLEVEL%issetto1.

e.g.ToprompttheuserforafilenamethatalreadyexistsFileSelectFile,filenamevar,1MsgBox,0,Example,Filenameselectedwas%filenamevar%

e.g.Toprompttheuserforafilenamethatalreadyexists,andinitiallyopeninthe"C:\MyFiles"directoryFileSelectFile,filenamevar,1,C:\\MyFilesMsgBox,0,Example,Filenameselectedwas%filenamevar%

Gosub,<label>Return

JustliketheoldBASICcommands.Gosubwillbranchtoaspecifiedlabel.ReturnwillreturntothelineaftertheGosubcommand.

e.g.SetEnv,MyMessage,Thisisthefirstmessage!Gosub,mysubroutineSetEnv,MyMessage,Thisisthesecondmessage!Gosub,mysubroutine

SetEnv,MyMessage,Thisisthethirdmessage!Gosub,mysubroutineExit

mysubroutine:MsgBox,0,AutoIt,%MyMessage%Return

Goto,<label>

Scriptexecutionwillcontinueatthespecifiedlabel.

e.g.;Thisscriptwillloopforevermyloop:Sleep,10Goto,myloop

HideAutoItDebug,<on|off>

ThiscommandcanbeusedtocompletelyhidetheAutoItscriptoutputtotheAutoItwindowduringexecution.

e.g.HideAutoItDebug,Off

HideAutoItWin,<on|off>

ThiscommandcanbeusedtocompletelyhidetheAutoItwindowandtrayiconfromtheuser.

e.g.HideAutoItWin,On

IfInString,<StringVariable>,<SearchString>,<Command>IfNotInString,<StringVariable>,<SearchString>,<Command>

Checkstoseeifthecontentsofthe<SearchStringVariable>is/isnotpresentinthestring<String>.Iftheconditionismet,<Command>willbeexecuted.

Ifamatchwasmade,%ERRORLEVEL%willbesetto0.Otherwise,%ERRORLEVEL%willbesetto1.

e.g.Tocheckiftheword"Hello"isinthestring"Hellothisisastring"SetEnv,search,HellothisisastringIfInString,search,Hello,MsgBox,0,Matched,Yes,thesearchstringwasfound

(Thiswilloutput"Yes,thesearchstringwasfound)

IfWinExist,<WindowTitle>,[<WindowText>],<Command>IfWinNotExist,<WindowTitle>,[<WindowText>],<Command>IfWinActive,<WindowTitle>,[<WindowText>],<Command>IfWinNotActive,<WindowTitle>,[<WindowText>],<Command>

Iftheconditionismet(i.e.thewindowtitleandtextexists,isactive,doesn'texist,isinactive)thenthescriptwillexecutethe<Command>.

N.B.IfnowindowtextistobegivenyouMUSTincludetheextracomma.e.g.IfWinExist,WinTitle,WinText,Goto,label1IfWinExist,WinTitle,,Goto,label1

IfEqual,<variable>,<text>,<Command>IfNotEqual,<variable>,<text>,<Command>

WillcomparetheDOSvariable<variable>with<text>andbranchdependingontheresult.

e.g.InputBox,MyVar,AutoIt,Pleaseentertheword:WOMBLEIfEqual,MyVar,WOMBLE,Goto,matchMsgBox,0,AutoIt,Youdidnttypethecorrectword!Exitmatch:MsgBox,0,AutoIt,Welldone!Youtypedinthecorrectword!

IfGreater,<variable>,<number>,<Command>IfGreaterOrEqual,<variable>,<number>,<Command>IfLess,<variable>,<number>,<Command>IfLessOrEqual,<variable>,<number>,<Command>

WillcomparetheDOSvariable<variable>with<number>andbranchdependingontheresult.Iftheparametersarenotnumerictheywillbetreatedasbeingzero.

IfExist,<fileordirectory>,<Command>

IfNotExist,<fileordirectory>,<Command>

Willcausethescripttoexecute<Command>ifthespecifiedfileordirectoryexists/doesn'texists.

e.g.IfExist,C:\\COMMAND.COM,Goto,fileexistExitfileexist:

;ScriptwillgettohereifC:\COMMAND.COMDOESexist.MsgBox,0,AutoIt,Fileexists

IfMsgBox,<returnvalue>,<Command>

UsethistoexecuteacommandbasedonthebuttontheuserpressedintheMsgBoxcommand.ValidreturnvaluesfromMsgBoxare:ABORT,CANCEL,IGNORE,NO,OK,RETRY,YES

e.g.Toputupadialogbox,withOKandCANCELbuttons,thenbranchiftheuserselectsCANCEL:

;ExampleScriptMsgBox,1,AutoIt,ThisisatestmessageIfMsgBox,CANCEL,Goto,cancellabelExitcancellabel:;Ifthescriptgetstohere,userpressedcancelMsgBox,0,AutoIt,Theuserpressedcancel

IniRead,<Variable>,<Filename>,<Section>,<Key>IniWrite,<Value>,<Filename>,<Section>,<Key>IniDelete,<Filename>,<Section>,<Key>

Allowsreadingandwritingofstandardwindows.inifiles.,i.e.thefollowingformat.

[SectionName]KeyName=Value

e.g.Toreadthevalueof"mykey"fromthe"mysection"partofaninifile,intothevariable"%result%":IniRead,result,c:\\mypath\\myfile.ini,mysection,mykey

e.g.Towritethetext"womble"intothesamesectionandkey:IniWrite,womble,c:\\mypath\\myfile.ini,mysection,mykey

e.g.TowritetheDOSpathinformationintothesamesectionandkey:IniWrite,%path%,c:\\mypath\\myfile.ini,mysection,mykey

e.g.TodeletetheDOSpathinformationintothesamesectionandkey:IniDelete,c:\\mypath\\myfile.ini,mysection,mykey

NB.Thefullpathandfilenameofthe.inifilemustbegiven.

InputBox,<variable>,<title>,<message>[,hide]

Willcauseadialogboxwith<message>toappear.Theusercanentertext,pressOK,andthetextwillbestoredintheDOSvariable<variable>.Ifthe"hide"parameterisused,inputwillbemasked(eg.forpasswords).

e.g.InputBox,MyMessage,AutoIt,Please-Entersometexttodisplay!MsgBox,0,AutoIt,%MyMessage%

e.g.InputBox,password,AutoIt,Pleaseenteryourpassword(inputishidden),hide

LeftClick,<x>,<y>RightClick,<x>,<y>

Simulatesaleftorrightmousebuttonclick.TheXandYco-ordinatesarerelativetothecurrentlyactivewindow.RunAutoItinrevealmodetodeterminetherequiredco-ordinatesofawindow.Toperformadouble-click,simplyrunthecommandtwice:)

LeftClickDrag,<x1>,<y1>,<x2>,<y2>RightClickDrag,<x1>,<y1>,<x2>,<y2>

Dragsthemousepointerfromx1,y1tox2,y2withtherelevantmousebuttonhelddown.Theco-ordinatesarerelativetothecurrentactivewindow.

MouseGetPos,<xVariable>,<yVariable>

Thiscommandwillgetthecurrentpositionofthemousecursorintothe'x'and'y'variables.Theco-ordsarerelativetotheactivewindow.

e.g.

MouseGetPos,xpos,yposMsgBox,0,Examples,Themouseisatposition%xpos%%ypos%

MouseMove,<xpos>,<ypos>

Thiscommandwillmovethemousecursortotheposition<xpos>,<ypos>.Theco-ordsarerelativetotheactivewindow.

MsgBox,<displaymode>,<title>,<message>

Displaysadialogboxwiththespecifiedmessage.Differentdisplaymodeswillgivedifferentresults(appearance,numberofbuttons).Alistofmodesisgivenbelow,addupthenumbersofthedisplaymodesyouwant.

e.g.Todisplay"Hello"withjustan"OK"button:MsgBox,0,AutoIt,Hello

e.g.Todisplay"Hello"withanexclamationboxandOKandCancel:MsgBox,49,AutoIt,Hello(1=OKCANCEL,48=Exclamation,=49)

Function AutoItValueMB_OK 0MB_OKCANCEL 1MB_ABORTRETRYIGNORE 2MB_YESNOCANCEL 3MB_YESNO 4MB_RETRYCANCEL 5

MB_ICONHAND 16MB_ICONQUESTION 32MB_ICONEXCLAMATION 48MB_ICONASTERISK 64 MB_APPLMODAL 0MB_SYSTEMMODAL 4096MB_TASKMODAL 8192

Random,<OutputVariable>,<MinValue>,<MaxValue>

Thiscommandproducesarandomnumberbetween<MinValue>and<MaxValue>.(Thesevaluesmustbebetween0and32767).

e.g.Toproducearandomnumberbetween1and200Random,output,1,200MsgBox,0,Result,%output%

(Thiswouldoutputtherandomnumberbetween1and200)

RegRead,Variable,ValueType,RegKey,RegSubkey,ValueName

ThiscommandallowsyoutoreadREG_SZandREG_DWORDvaluesfromtheregsitry.Ifthecommandissuccessful%ERRORLEVEL%issetto0,otherwiseitissetto1.

RegKeymustbeeither"HKEY_LOCAL_MACHINE","HKEY_CURRENT_USER","HKEY_USERS","HKEY_CURRENT_CONFIG"or"HKEY_CLASSES_ROOT".

ValueTypemustbe"REG_DWORD"or"REG_SZ".

e.g.Toreadthelocationofthe"ProgramFiles"directoryintothevariable"TestKey":RegRead,TestKey,REG_SZ,HKEY_LOCAL_MACHINE,Software\\Microsoft\\Windows\\CurrentVersion,ProgramFilesDirMsgBox,0,Example,ProgramFilesarelocatedin%TestKey%

RegWrite,ValueType,RegKey,RegSubKey,ValueName,Value

SimilartotheRegReadcommand,thiscommandwillallowyoutocreateormodifyaregistrykey.Ifthecommandissuccessful%ERRORLEVEL%issetto0,otherwiseitissetto1.

e.g.Tochangethewallpaperofthecurrentuser:RegWrite,REG_SZ,HKEY_CURRENT_USER,ControlPanel\\Desktop,Wallpaper,C:\\Mycrazybitmap.bmp

RegDelete,RegKey,RegSubKey,ValueName

Thiscommandwilldeletearegsitryvalue.Ifthecommandissuccessful%ERRORLEVEL%issetto0,otherwiseitissetto1.

e.g.Todeletethewallpapervalueofthecurrentuser(notparticularlyrecommended:)):RegDelete,HKEY_CURRENT_USER,ControlPanel\\Desktop,Wallpaper

Run,<Programpathandname>[,<Workingdirectory>[,<max|min|hide>]]

Executesagivenprogramandproceedstothenextlineofthescript.N.B.Theprogramtorunandtheworkingdirectoryareseparatedbyacomma','.Theworkingdirectoryisoptional.

>>>>>N.B.Becausethe'\'characterisspecialyoumustuse'\\'whenspecifyingpaths!<<<<<

e.g.Run,notepad.exe,C:\\WINDOWSRun,C:\\ProgramFiles\\MicrosoftOffice\\Office\\WinWord.exe

Thefirstcommandrunsnotepadandsetstheworkingdirectoryto"C:\WINDOWS".ThesecondcommandrunsMSWordinthecurrentdirectory.

YoucanalsoruncommandinterpretercommandslineEcho,Copy,etc.

e.g.Run,COMMAND.COM/CEchoHello>C:\\Hello.txtORRun,%COMSPEC%/CEchoHello>C:\\Hello.txt

CreatesafilecalledC:\Hello.txtcontainingtheword"Hello".

RunWait,<Programpathandname>[,<Workingdirectory>[,<max|min|hide>]]

SameastheRuncommandbutwaitsfortheprogramtofinishbeforecontinuing(recommendedwhenrunningDOScommandssuchascopy,md,del,etc.).

Thiscommandwillalsosetthevariable%ERRORLEVEL%tothereturncodeoftheprogram.

Repeat,<Count>EndRepeat

Thiswillrepeatasectionofthescriptuptothefollowing"EndRepeat"commandatotalof<Count>times.If<Count>iszero,theloopwillbeinfinite.Repeatstatementscanbenested.

e.g.Repeat,10MsgBox,0,Example,Thiswillbeoutputtentimes!EndRepeat

Send,<Seriesofkeypresses>

Sendsasetofkeystrokestothecurrentlyactivewindow.(Thesyntaxofthesekeystrokescanbefoundinthefollowingsection).

e.gSend,Thisisalineoftext#{ENTER}

SetCapslockState,<on|off>

ThiscommandwillcorrectlysetthestateoftheCAPSLOCKkeytoeitheronoroff.

e.g.ToturnontheCAPSLOCKkeySetCapslockState,on

SetEnv,<variable>,<value>

Thiscommandwillsetanenvironmentvariabletothespecifiedvalue.N.B.ThisvariableonlyexistswithinAutoItyouwillnotbeabletoaccessitfromDOS.

e.g.TosettheEnvvariable"ERROR"to"Therehasbeenanerror":SetEnv,ERROR,Therehasbeenanerror.

Tousethisvariable,usethepercentsymbol:

e.g.Afterrunningthepreviouscommand,thiswilloutput"Therehasbeenanerror":MsgBox,1,AutoIt,%ERROR%

SetBatchLines,<lines>

Usually,AutoItexecuteseachlineofascriptduringa10mstimercycle(underNTisit10ms,under9xitcouldbeamuchlargertime).ThiscanmeanthatinscriptswhichdoalotofString/Variableprocessing,thescriptscanbequiteslow.TheSetBatchLinescommandcanbeusedtochangethenumberofscriptlinesthatareprocessedinatimercycle.Thedefaultis1.Themaximumvalueis32767.Note:Forveryhighvalues,AutoItwillstarttoimpacttheavailableCPUtime.ThecurrentvalueofSetBatchLinescanbeobtainedfromthespecialvariable"A_NUMBATCHLINES".

Note:Mostuserswillnotneedtousesthiscommandatall!

e.g.Toexecute100scriptslinespercycleSetBatchLines,100

SetKeyDelay,<milliseconds>

Changesthedelaybetweenkeystrokesinmilliseconds.Maxis32767.Defaultis20ms.1000milliseconds=1second.

SetStoreCapslockMode,<on|off>

Bydefault,atthestartofa"Send"commandAutoItwillstorethestateoftheCAPSLOCKkey;attheendofthe"Send"commandthisstatuswillberestored.Usethiscommandtoturnoffthisbehavior.

e.g.TopreventAutoItfrommodifyingthestateoftheCAPSLOCKkeyduring"Send"commandsSetStoreCapslockMode,off

SetTitleMatchMode,<mode>

Changesthewaythatwindowtitlesarematchedagainstthescript.Validmodesare"1"and"2"-thedefaultis"1".ThismodeaffectsmostofthecommandswithinAutoItthathaveanysortofwindowtitleandtextinthecommand,i.e.WinWait,WinWaitActive,IfWinActive,etc.

e.g.;Scriptusingmode1(default)SetTitleMatchMode,1

;Scriptusingmode2SetTitleMatchMode,2

mode1

Inthescriptyouspecifythestartofawindowtitletomatch.i.e.forthenotepad.exewindow(Untitled-Notepad),validmatcheswouldbe:"Untitled","Untitled-","Unt"and"Untitled-Notepad".

mode2

InthescriptyoucanspecifyANYsubstringofthewindowtitleyouwanttomatch.Againforthenotepad.exewindowvalidmatcheswouldbe:"Untitled","Untitled-Notepad","Notepad","No".

SetWinDelay,<Milliseconds>

ThischangesthetimethatAutoItpausesaftercarryingoutawindowrelatedfunction(waitingfor,minimizing,restoring,etc.)beforecontinuing.Thisisusefulonveryslowmachines,orwhenyouhavethingslikewindowanimationenabled.Thedefaultis500milliseconds.

e.g.SetWinDelay,2000Run,Notepad.exeWinWaitActive,Untitled-NotepadSend,Hello

Inthisexampletherewouldbeapauseof2000milliseconds(2seconds)afternotepadhasstarteduntilthewords"Hello"appear.

Shutdown,<Flag>

Thiscommandallowsyoutoperformvariousformsofshutdown.Thetypeisdeterminedby<Flag>.Theflagcanbeacombinationfromthetablebelow:

Function Flag

Logoffthecurrentuser 0Shutdowntheworkstation 1Reboottheworkstation 2Forceclosingofapplications(mayloseunsavedwork) 4

Shutdownandpoweroff(ifsupported) 8

e.g.Toshutdownandforceapplicationstoclosewithoutsaving=Shutdown+Force=1+4=5:Shutdown,5

Sleep,<milliseconds>

Haltsexecutionofthescriptforthegivennumberofmilliseconds.Maxis2147483647.1000milliseconds=1second.

SplashTextOn,<Width>,<Height>,<Title>,<Message>

Thiscommandbringsupawindowthespecifiedmessageandtitle.Thewindowstaystopmostwithoutinterferingwithwindowsbehindit.Usefulforautomationwhenyoucanbringupa"Don'tTouch"

messagefortheuserwithoutaffectingotherwindows.

SplashTextOff

Removesthesplashtextscreenfromview.

StringCaseSense,<On|Off>

Thiscommandwillturncasesensitivityonoroffforthecommands:IfEqual,IfNotEqual,IfInString,IfNotInString,StringReplaceandStringGetPos.

Defaultisoff(i.e.comparisonsareNOTcasesensitive)

StringLeft,<OutputVariable>,<InputVariable>,<Numberofcharstoextract>StringRight,<OutputVariable>,<InputVariable>,<Numberofcharstoextract>

Thiscommandtakesthecontentsof<InputVariable>,extractsanumberofcharactersandplacestheresultin<OutputVariable>.

e.g.Toextracttheleftmost5charactersofastringSetEnv,test,HellothisisateststringStringLeft,output,test,5MsgBox,0,AutoIt,Theresultingstringis%output%

(Theoutputwouldbe"Hello")

e.g.Toextracttherightmost6charactersofastringSetEnv,test,Hellothisisateststring

StringRight,output,test,6MsgBox,0,AutoIt,Theresultingstringis%output%

(Theoutputwouldbe"string")

StringMid,<OutputVariable>,<InputVariable>,<Startchar>,<Numberofcharstoextract>

Thiscommandtakesthecontentsof<InputVariable>,extractsanumberofcharactersstartingfrom<Startchar>andplacestheresultin<OutputVariable>.

e.g.Toextract4charactersstartingfromcharacter7SetEnv,test,HellothisisateststringStringMid,output,test,7,4MsgBox,0,AutoIt,Theresultingstringis%output%

(Theoutputwouldbe"this")

StringLen,<OutputVariable>,<InputVariable>

Thiscommandtakesthecontentsof<InputVariable>andputsthenumberofcharactersinthestringinto<OutputVariable>.

e.g.SetEnv,test,HellothisisateststringStringLen,output,testMsgBox,0,AutoIt,Thestringlengthis%output%

(Theoutputwouldbe"Thestringlengthis27")

StringReplace,<OutputVariable>,<InputVariable>,<SearchString>,<ReplaceString>

Thiscommandwillsearchforthe<SearchString>inthecontentsofthevariable<InputVariable>.Thesearchstringwillbereplaceby<ReplaceString>andtheresultwillbeplacedinthevariable<OutputVariable>.Ifthesearchstringcannotbefound,thecontentsof<OutputVariable>willbethesameas<InputVariable>.

Ifamatchwasmade,%ERRORLEVEL%willbesetto0.Otherwise,%ERRORLEVEL%willbesetto1.

e.g.SetEnv,teststring,HellothisisateststringStringReplace,output,teststring,test,testingtesting123MsgBox,0,AutoIt,%output%

(Theoutputwouldbe"Hellothisisatestingtesting123string")

StringTrimLeft,<OutputVariable>,<InputVariable>,<Numberofcharstotrim>StringTrimRight,<OutputVariable>,<InputVariable>,<Numberofcharstotrim>

Thiscommandtakesthecontentsof<InputVariable>,trimsanumberofcharactersandplacestheresultin<OutputVariable>.

e.g.Totrimtheleftmost6charactersofastringSetEnv,test,HellothisisateststringStringTrimLeft,output,test,6MsgBox,0,AutoIt,Theresultingstringis%output%

(Theoutputwouldbe"thisisateststring")

e.g.Totrimtherightmost7charactersofastringSetEnv,test,HellothisisateststringStringTrimRight,output,test,7MsgBox,0,AutoIt,Theresultingstringis%output%

(Theoutputwouldbe"Hellothisisatest")

StringGetPos,<OutputVariable>,<InputVariable>,<SearchText>

Thiscommandtakesthecontentsof<InputVariable>,searchesforthestring<SearchText>andreturnsthepositionofthestringin<OutputVariable>.Ifthesearchstringisnotfound,%ERRORLEVEL%issetto1,otherwiseitissetto0.Position"0"isthefirstcharacter.

e.g.TogetthepositioncharacterofastringSetEnv,test,HellothisisateststringStringGetPos,output,test,thisMsgBox,0,AutoIt,Thesearchstringisatposition%output%

(Theoutputwouldbe"Thesearchstringisatposition6")

WinGetActiveStats,<TitleVar>,<WidthVar>,<HeightVar>,<XposVar>,<YposVar>

Thiscommandallowsyoutoreceivemuchinformationfromtheactivewindow,including:Windowstitle,windowwidth,windowheight,windowx-positionandwindowy-position.

e.g.Sleep,2000WinGetActiveStats,titlevar,widthvar,heightvar,xposvar,yposvar

MsgBox,0,AutoIt,Title=%titlevar%Width=%widthvar%Height=%heightvar%Position=%xposvar%,%yposvar%

WinGetActiveTitle,<Variable>

ThiscommandgetsthetitleoftheactivewindowandputsitintheDOSvariable<Variable>

e.g.Sleep,2000WinGetActiveTitle,myvarMsgBox,0,AutoIt,Theactivewindowwas%myvar%

WinKill,<WindowTitle>[,<WindowText>]

SimilartoWinClose,butifthewindowhasnotclosedafteracoupleofseconds(Askingtosave,crashed,etc.)thewindowwillbeforciblyterminated.

WinWait,<WindowTitle>[,<WindowText>[,<Timeout>]]

Stopsscriptexecutionuntilthespecifiedwindowexists.Thewindowdoesnotneedbeactive.

Ifspecifiedthe"Timeout"isinseconds.AfterthelinehasexecutedtheEnvvariable%ERRORLEVEL%willbesetto0ifthefunctioncompletednormally,or1ifthewaittimedout.ThemaximumvalueofTimeoutis32767seconds.

e.g.WaitforeverforthenotepadwindowWinWait,Untitled-Notepad

e.g.WaitforfivesecondsforthenotepadwindowWinWait,Untitled-Notepad,,5

WinWaitClose,<WindowTitle>[,<WindowText>[,<Timeout>]]

Stopsscriptexecutionuntilthespecifiedwindowceasestoexist.

Ifspecifiedthe"Timeout"isinseconds.AfterthelinehasexecutedtheEnvvariable%ERRORLEVEL%willbesetto0ifthefunctioncompletednormally,or1ifthewaittimedout.

e.g.WinWaitClose,Untitled-Notepad

WinWaitActive,<WindowTitle>[,<WindowText>[,<Timeout>]]

Stopsscriptexecutionuntilthespecifiedwindowtoexistsandisactive.

Ifspecifiedthe"Timeout"isinseconds.AfterthelinehasexecutedtheEnvvariable%ERRORLEVEL%willbesetto0ifthefunctioncompletednormally,or1ifthewaittimedout.

WinWaitNotActive,<WindowTitle>[,<WindowText>[,<Timeout>]]

Stopsscriptexecutionuntilthespecifiedwindowceasestobeactive.

Ifspecifiedthe"Timeout"isinseconds.AfterthelinehasexecutedtheEnvvariable%ERRORLEVEL%willbesetto0ifthefunction

completednormally,or1ifthewaittimedout.

WinHide,<WindowTitle>[,<WindowText>]WinShow,<WindowTitle>[,<WindowText>]WinRestore,<WindowTitle>[,<WindowText>]WinMinimize,<WindowTitle>[,<WindowText>]WinMaximize,<WindowTitle>[,<WindowText>]WinActivate,<WindowTitle>[,<WindowText>]WinClose,<WindowTitle>[,<WindowText>]

Ifthewindowexists,therelevantcommand(i.e.minimizing,hiding,activating,etc.)willbeperformed.

WinMove,<WindowTitle>,[<WindowText>],<X>,<Y>,<Width>,<Height>

IfthewindowinTitleandTextexists,itismovedto<X>,<Y>andresizedto<Width>,<Height>

e.g.

Run,notepad.exeWinWaitActive,Untitled-NotepadWinMove,Untitled-Notepad,,0,0,100,100

Thismovesthenotepadwindowto0,0andchangesthesizeofthewindowto100,100

Remembertoincludethecommaifyoudon'tspecifyWindowtext."default"canbeusedinplaceofWidthandHeightifyoudon'twanttochangethesizeofthewindow

e.g.WinMove,Untitled-Notepad,,0,0,default,default

WinSetTitle,<WindowTitle>,[WindowText],<NewTitle>

Usethiscommandtorenameawindow.

e.g.Run,notepad.exeWinWaitActive,Untitled-NotepadWinSetTitle,Untitled-Notepad,,RenamedNotepad!

WinMinimizeAllWinMinimizeAllUndo

The"WinMinimizeAll"commandminimizesallwindows;"WinMinimizeAllUndo"willundothisaction.IfanywindowsaremanipulatedbyAutoItortheuser,then"WinMinimizeAllUndo"willnothaveanyeffectonthese"touched"windows.

ScriptCompiler

AutoItcomeswithtwoprogramstoenablethecomplicationofscriptsintostandaloneexecutables(andbackagainifrequired).

Fromv2.64thefacilitytoaddextrafilesintothecompiledexecutablehasbeenaddedviatheFileInstallcommand.

Aut2Exe-ScriptCompiler

ThisprogramwilltakeanAutoItscriptandconvertittoanexecutable.ThisexecutablecanthenberunwithoutanyoftheoriginalAutoItprogramsbeinginstalled.

Itispossibletodefineaniconfortheresultingexecutable,thismustbeaniconfilethatis32by32pixelsin16colours(thefileshouldhaveafilesizeof766bytes).

Scriptsandfilesaddedtoacompiledexecutablearecompressedandthenencrypted.Duringexecutionofthecompiledscriptthescriptisneverwrittentodisk--alldecompilationofthescriptisperformedinmemoryforsecurity.

N.B.Youcanstillpasscommandlinevariablestotheresultingexefilebyrunning"myscript.exeparam1param2.....".

CommandLineSwitches

Aut2Execanbeusedwithcommandlineswitcheslikeso(all

switchesareoptionalexcept"/in"):

Aut2Exe.exe/in<script.aut>[/out<script.exe>][/icon<icon.ico>][/pass<passphrase>]

Longfilenames(andpassphrasesthatcontainspaces)mustbeenclosedinquotes,forexample:

Aut2Exe.exe/in"C:\myprograms\myscript.aut"/out"script.exe"/pass"Thisismysecret"

Note:Whereaniconisnotspecifiedonthecommandline,thelasticonthatwasusedtocompileascriptisusedbydefault.

Note:Ifadestinationfileisnotspecified,theresultingfilewillbecalledthesameastheinputfile,butwiththetheextensionchangedto".exe".Forexample,"myfile.aut"wouldbecompiledbydefaultto"myfile.exe".

Exe2Aut-ScriptDecompiler

Thisisautilitythatwillconvertandpreviouslycompiled.exebackintoanAutoItscriptfile.Ifapassphrasewasusedtocompilethescript,youwillberequiredtoenterthesamepassphrasetodecompilethe.exe.(Wewouldn'twantpeopledecompilingotherpeoplesscriptsnow,wouldwe?:))

CommandLineSwitches

CommandlineswitchesaresimilartothoseofAut2Exe:

Exe2Aut.exe/in<script.exe>[/out<script.aut>][/pass<passphrase>]

FrequentlyAskedQuestions(FAQ)

ThereisanupdatedFAQonlineatthisaddress:

TheADLIBsection.

DoestheExitcommandworkintheAdLibsection?:Cana"GoSub"beusedinanAdLibstatement?

Check,Dialog,andInputBoxes

Doesanybodyhaveawayoffindingoutwhetheracheckboxiscurrentlyselected?Isitpossibletohaveamessagewindowpopup,typeavalue,thenhavethatvaluere-typedwhencalled?HowdoItakeauserIDandpasswordfromInputBoxesandlatersendittoanotherapplication?

DirectoryManagement

HowdoIcreateadirectoryfromwithinAutoIt?HowdoIdeleteadirectoryfromwithinAutoIt?HowdoIdeleteallofthefilesinadirectory?

DiskManagement

HowdoIformatabootablesystemdiskettefromwithinAutoIt?HowcanIdefragmyharddriveonanightlybasisusingaW2Kscheduler?

DisplayManipulation

HowdoIrunanexternalcommanddependentonthedisplayresolution?HowdoIsaveascreenorsinglewindowforlaterscrutiny?

GeneralAutoItQuestions

DoesAutoItrecordkeystrokes/mouseclicksandcreateascriptordoIneedtowriteitmanually?IsthereawaytohaveautoItrandomlyselectafileoutofadirectoryorlistoffiles?HowdoIemptytherecyclebinfromwithinAutoIt?Whatexactlydoes"Revealmode"do?HowcanIscheduletherunningofanAutoItscript?DoesanyoneknowifanAutoItarchiveexists?HasanyoneusedAutoItXwithinaVisualBasicApplication?

GeneralWindowsQuestions

IsthereasurewaytocommandmyWindowstoreboot?WhatdoIdoifotherusersareconnectedtothesystemaswell?HowdoIshutdownaserverdownwhenusersareconnected?HowdoIshutdownallPC'sonalocalnetworkbyrunningascriptfromaWindows98"server"?IsitpossibletosendkeystrokestoinvisiblewindowswithAutoIt?IstheiranywaytohaveAutoItholdamouseclickdown(forasecondorso)?Isitpossibletobringthecursorbacktoapredefinedpositionafteramousemovementcommand?

IsthereawaytodeterminethatWindowshasfinishedbooting?HowdoIcreateashortcutfromwithinAutoIt?HowcanIdetectawindowwithvaryingtitles?

Networking

IsthereaneasywaytochangetheGatewayIP(inTCP/IP)foranetworkcardusingAutoIt?HowdoIrunanAutoItscriptatorbeforethelogonscreeninWindowsNT?CanIuseAutoIttologinauseronWindowsNTor2000

RegistryManipulation

HowdoIsaveanuninstallstringvalueinavariable,andrunit?HowcanIread/writedefaultentriesto/fromtheregistry?HowdoIdeletearegistrykey?HowdoIdeletearegistrykeywithoutusinganexternalcommand?WhatcanIwriteina.REGfile?IsthereawayfromAutoIttosecureaRegistrykey?

TheRUNandRUNWAITcommandsandtheCOMSPECvariable

HowdoIrunanexternalcommand?IsthereawaytoactivatetheRunbox(Winkey-R)dialoguequickly?HowdoIplayaWAVfilefromwithinAutoIt?Whydoesn'ttheDOScommandwindowcloseautomatically?

TheSendCommand

HowdoIoutputspacesthatareatthebeginningofaline?WithAutoITcanIworkwithexcelcells?

SpecialCharacters

Backslashes

TheSplashTextCommand

HowdoImovetheSplashTextdisplaybox?CanapicturebeputintheSplashTextwindow?

TheStringManipulationCommands

HowdoIremovespacesfromastring?WhatamIdoingwrongwiththeStringLeftcommand?Isthereawaytoreturnthepositionofasubstringwithinastring?Isthereadifferencebetweenreadingalinewithablankspaceandcarriagereturnvs.justacarriagereturn?

VariableResolution

HowdoesvariableresolutionworkinAutoIt?HowdoyouexportanAutoItvariabletoDOS?

History

17/12/2002-v2.64

MoreWindowseysoptionsaddedtotheSendcommand:LWINDOWN,RWINDOWN.Addedcommand:HideAutoItDebugtoturnoffthescriptbeingshownduringexecution.Internalcodeoptimisationsandmodularisation.Fullinstallationaddsregistrykeysforexelocations:HKLM\Software\HiddenSoft\...\InstallDirAddedsimplefileoperationcommands:FileCopy,FileDelete,FileCreateDir,FileRemoveDir.AddednewcompilerdirectiveFileInstallforcompressingandaddingextrafilestoacompiledscript.

04/02/2002-v2.63

WinActivateimprovedunder2000/XP(Hopefully!).

19/01/2002-v2.62

PassphraseaddedtoAut2Exe.Exe2Autaddedforscriptdecompilation.VariousbugsfixedwithSetBatchLines.Somedivision-by-zerobugsfixed.

26/08/2001-v2.61

CAPSLOCKbehaviourchanged.ThestateoftheCAPSLOCKkeyischeckedandstoredatthestartofa"send"commandandrestoredattheendofa"Send"command(youcanstillsendCAPSLOCKkeysfromwithina"Send"commandbutremember

thatitisonlyineffectforthatsingle"Send"command).PreviousbehaviourwasthatAutoItturnedoffCAPSLOCKatstartupwhichcouldleadtounexpectedresultswithusersandtheCAPSkeys.Addedcommand:SetStoreCapslockModetoturnoffanyCAPSLOCKmodifcationasdescribedabove.Addedcommand:SetCapslockStatetocorrectlyallowsettingoftheCAPSLOCKtoonoroff.BugwithSetBatchLinesandRunWaitfixed.BugwithallowingdivisionbyzeroinEnvDivandRandomfixed.Installationpackagerecompiled-hopefullyfixinginstallationbugsunderWinME.

14/05/2001-v2.60

AutoItandAut2Exere-codedinC++.ThankstothebetatestersfortheirhelpinmakingsureIdidn'tbreakeverything.Addedcommands:EnvMult,EnvDiv,WinMinimizeAllUndo,StringGetPos,SetBatchLines,WinGetActiveStats,FileSelectFile.Addedcommand:#include.Operatingsystemversion%A_OSVERSION%variableadded(WIN_XP,WIN_2000,WIN_NT4,WIN_95,WIN_98,WIN_ME).StringReplaceandIfInstringnowsettheERRORLEVELto0ifamatchwasmadeotherwiseERRORLEVELsetto1.StoppedAutoItdetectingit'sownwindowduringWinWaittypecommands.Maxiumcharactersinascriptlineincreasedto16384(shouldenablelargerclipboardrelatedactions).CommandlineparametersandswitcheschangedforbothAutoItandAut2Exe.Errormessagesimproved.Linenumbersandthelinewiththeerrorisnowdisplayed.

Thevariable%0%containsthenumberofcommandlineparameters.Commandline"/c"optionadded.Allowstherunningofasinglescriptlinewithoutascript,e.g.Autoit.exe/c"WinWait,Untitled-Notepad"PreviousdocumentationisincorrectontherangesofnumericvaluesinAutoIt(ouch-sorry).Unlessspecifiedotherwise,numericvaluesare32bitswide,i.e.-2147483648to2147483647.Butstayalittleshortofthemaximum(2147483647)forSleepandtimeoutcommandsasyouwillgetunexpectedresults.Thegoodnewsisthatyoucannow"Sleep"formuchlongerperiodsinasinglecommand(I'dappreciatereportsonyourexperienceswiththis!).SomeiconsandlogoschangedasIfanciedachange:)Optionalexitcodeaddedthethe"Exit"command.(Aut2Exe)lasticonusedbydefault.

03/12/2000-v2.51

InstallationroutinechangedtouseMicrosoftWindowsInstaller.AddedcommandsStringLeft,StringRight,StringMid,StringLen,StringTrimLeft,StringTrimRight,IfInString,IfNotInString,StringReplace.Stringcomparisons(IfEqual,IfNotEqual,IfInString,IfNotInString,StringReplace)canhavecasesensitivitycontrolledbytheStringCaseSensecommand.AddedRandomnumbercommand.FixedbugwithMsgBoxandInputBoxunderNT4(asaresulttheAutoItwindowwillbevisibleinthetaskbarduringthesecommands).FixedADLIBsectionsothatGosubandGotocommandswillworkcorrectly.

07/11/2000-v2.50

FixedaccessrightswithRegRead,RegWriteandRegDeletecommandsfornon-administratoruseunderWindowsNT.AddedcommandsIfLess,IfLessOrEqual,IfGreater,IfGreaterOrEqual.Revealmodeincludesthedimensionsoftheactivewindow.

17/6/2000-v2.42

AddedIniDelete,RegDelete,commands.AddedtheBlockInputcommandtodisablemouseandkeyboardinput.(N.B.onlyworkssatisfactorilyunderWin2000/NT4SP6-bestIcoulddoI'mafraid)The"/p"isnowNOTcasesensitiveforcommandlineparameters.TheWinWaitroutines'"Timeout"isnowaccurate.AddedsimplefileroutinesFileAppendandFileReadLine.Ifyouusethe{CTRLDOWN},{SHIFTDOWN}or{ALTDOWN}keys,thekeyswillbeleft"down"unlessspecifiedotherwisewiththe{CTRLUP},{SHIFTUP}or{ALTUP}keys(evenaftertheendofalineinthescript).Usethesekeyswisely:)

11/02/2000-v2.41

BugwithRegWritefixed.

09/02/2000-v2.4

Problemswithvariablescontainingcommasfixed.Lotsofvariablesaddedtoaccesstimes,dates,currentscriptpath,OS(NTor9x).Canpauseandresumescriptexecutionbyright-clickingonthe

taskbaricon.SIMPLEregistryread/writefunctionsaddedforREG_SZandREG_DWORDtypes.Fixedbugwithcommandlineparametersandquotes.

20/12/99-v2.32

Somequitebrutaloptimizingapplied,bringingtheexecutablesizesdownby12k.Aut2Exeremembersthelastdirectoryusedforthescript,executableandicon.Canspecifycommandlineparameterswithspacesbyusingquotes("....").

12/12/99-v2.31

Maximumlinelengthincreasedto1024characters.Memoryusagewhenrunningscriptsreducedbyafactorof12!(NotthatIeverhadanycomplaints:))

10/12/99-v2.3

VariousbugswithENVvariablesfixed.NowsendscorrectlytoDOS(Ihope:)).OptionalparameteraddedtoInputBoxformaskinginput.Commandlineparameterscanbepassedtothescript.Nowsupportsuser-definediconswhencompilingascripttoan.exe.MouseGetPosandMouseMovecommandsadded.NotusingASPackanymore,althoughfeelfreetouseitonAutoItyourself(http://www.aspack.com).

25/11/99-v2.23

WinActivatetweakedforWin2000RC2.Shutdowncommandadded.WinKillcommandadded.

23/11/99-v2.22

Thevariable%CLIPBOARD%containsthetextualcontentsoftheclipboard.CannowpastetextfromAutoIttotheclipboard.INIFilereadingandwritingaddedwithIniReadandIniWrite.

20/11/99-v2.21

CannowSenddecimalASCIIcodes,likewhenusingusingtheALTkeyandthenumerickeypad(e.g.ALT+65='A').Veryusefulforsendingcharactersthatdon'tusuallywork(e.g.'~'onanItaliankeyboard)

18/11/99-v2.2

CannowRunprogramsaseitherhidden,maximizedorminimized(greatforavoidingblackscreenswhenexecutingDOScommands)RunWaitwillputaprogramsreturncodein%ERRORLEVEL%TheWinWaitgroupoffunctionscanbesettotimeoutafteraperiodoftime(%ERRORLEVEL%canbecheckedtoseeifthefunctiontimedoutornot)WinShowcommandadded(previously,therewasnowayto"undo"aWinHide!!!!)

16/09/99-v2.11

FixedbuginwhichENVvariableswerenotexpandedunderthe"Adlib"section.

InstallationrecreatedunderWin98toresolvesomesetupproblems.

11/09/99-v2.1

Aut2ExeScriptconverteraddedtoinstallation.InternalbuginRunandRunWaitfixed.Addedkeys{CTRLUP},{CTRLDOWN},{SHIFTUP},{SHIFTDOWN},{ALTUP},{ALTDOWN}.

28/08/99-v2.03

AutoIt2.exeandAutoItX.dllnowpackedwithASPackreducingtheexecutablesize.ChangedSplashTextOncommand.YounolongerhavetodoSplashTextOffbeforedoingasecondSplashTextOn.AddedsimplevariableEnvAddandEnvSubcommands."default"canbeusedinplaceofWidthandHeightintheWinMovecommand.AddedcommandsLeftClickDragandRightClickDrag.

26/08/99-v2.02

Changestosomeinternaltimings.Madethesplashwindowslikealittleless"win3.1-ish".AddedAdlibOnandAdlibOffcommands.ChangedinternalhandlingoftheADLIBsection.

18/08/99-v2.01

FixedSendcommandwithmultiplemodifiers(i.e.CTRL+SHIFT+key,CTRL+ALT+key).

16/08/99-v2.0

NB.SomechangesmeanthatoldAutoItscriptsmayneedtobemodifiedslightly-Pleasere-readthedocumentationcarefullyifyouareupgrading!Hencethejumpfromv1.8tov2.0-SORRY,butthingsneededchangingtoeaseimplementationofnewcommandsthathavebeenrequested.Ipersonallyusev1.8foroldscriptsandv2.0foranynewscriptsIwrite.

CannowsendmostkeystrokestoDOSwindows-Finally!Changedthewayinwhich'\',','and'%'aretreated-CAREFUL!ChangedRunandRunWaitcommands.Comma','nowdelimitsworkingdirectory.(therefore'*'isnowvalid-forwildcards,etc.)AddednumerouskeysthatcanbesentincludingWinAppskey.AutoItwindowshowslinenumberandlineofscriptduringexecution.Helpful(?)errormessageswithlinenumbers(can'trunfile,invalidsyntax,etc.)

Addedcommands:HideAutoItWin,WinWaitNotActive,WinMove,WinSetTitle,DetectHiddenText,WinGetActiveTitle,SetWinDelay,Break,WinMinimizeAll,SplashTextOn,SplashTextOff,Repeat,EndRepeat.

ShowsscriptnameasatooltipontheAutoItsystemtrayicon.Followingcommandsnolongerwaitforthewindowtoexistbeforecontinuing:WinRestore,WinHide,WinMaximize,WinClose,WinMinimize.Ifrunwithnoparameters,AutoItwillbringupa"FileOpen"box.Windowin"reveal"modealwaysstaysontop.(Nowonlyonerevealmoderequired).ChangedMsgBoxcommandtoincludeatitle,andtonothangaroundinthebackground.Changedall"If...."commandstoexecuteagivencommandrather

thanjustjumpingtoalabel.ChangedInputBoxtoincludeatitle,andtonothangaroundinthebackground.Invalidcommandswillnowbetreatedaserrorsinsteadofjustignored.'\n','\t'canbeusedinMsgBoxandInputBoxtexttoindicatenewlinesandtabs.Minimizestoasystemtrayicon.IftheHideAutoItWincommandisusednothingisvisibleatall.ChangedAdlib,nowexecutesagivencommandinsteadofjustsendingkeys.ChangedSleep(internal)sothatAutoItwindownowupdatesduringlongSleepfunctions.ChangedGosub/Return.Cannowhavenestedsubroutines,onlylimitedbyfreememory!

02/04/99-v1.8

AddedMsgBoxandIfMsgBoxcommands.(Note,thesehavechangedfrom1.8beta)AddedIfExistandIfNotExistcommandsforfilesanddirectories.AddedDOSenvironmentvariablesupport(e.g.Send,Pathis%PATH%).N.B.Becauseofthis,thepercentsymbol'%'isnowspecial.Ifyoureallywanttousethissymbolyoumustdoittwiceie.%%AddedSetEnvcommand.AddedInputBoxcommand.AddedIfEqualandIfNotEqualcommands.AddedGosubandReturncommands."Page-fault"bugfixed(whenmousecoordsareoutofrange).

14/03/99-v1.7

Added{LWIN}and{RWIN}"Windowkey"keystrokes.AddedSetTitleMatchModecommand.(Altersthewaywindowtitlesarematched).Ablankwindowtitleisnowvalid.(e.g.WinWait,,Windowtext)AutoItexecutablegrowsforthefirsttimeto44KB.

28/02/99-v1.6

AddedIfWinExist,IfWinNotExist,IfWinActive,IfWinNotActivecommands.Addedsupportforlabels(fortheabovecommands).AddedGotocommand.AddedExitcommand.Windowtitlesarenowcasesensitive.i.e."NOTEPAD"and"Notepad"aredifferent.

20/02/99-v1.5

Added{PRINTSCREEN}commandtosimulatethe"PrintScrn"key.Copyandpastefromthe"reveal"mode.(UseCTRL-Ctocopy).Addedcommandlinesyntax-"AutoIt/?".Addedsimulatedmouseclicks(leftandright).Addedmouseco-ordinatesin"reveal"mode.

20/01/99-v1.4

Added{BS},{INSERT},{ESCAPE}and{DELETE}Added"/reveal2"commandlineswitch.CauseAutoIttoupdatetherevealwindoweveryhalfsecond(usefulforcomplexdialogwindows)

18/01/99-v1.3

AddedWinClosecommand.Thetitle"WinWait,Notepad"willnolongermatchthewindow"Untitled-Notepad",but"WinWait,Untitled"will.Youcannowusewhitespaces(spacesandtabs)allovertheplacetomakethescriptfilelookpretty:)

14/01/99-v1.2

Changed"Run"command.Asterisk(*)nowstatesstartofworkingdirectory.Added[ADLIB]sectionsupportOfficiallyreleasedonwinfiles.com

12/01/99-v1.1

FixedWinActivateunderWindows98/NT2000!AddedWinMaximizeAddedexecutableversioninfoAddedicons

12/01/99-v1.0

Initialbuild(beta)

Thanksto

I'vecutthissectiondown-therearejusttoomanypeopletolistnow!Ifyouthinkthatyoushouldbeonthelistthenletmeknow.

TheauthorsofUPXfortheirexcellentfilecompressorusedinAutoItandAutoItcompiledscripts.AlexPetersfortheAutoItscripticon([email protected]).MarkfortheAutoItandAut2ExeLogosusedpriortov2.60ofAutoIt([email protected]).Everyonewhohasdonealanguagetranslationforme(creditsshouldbeintheirtranslatedfiles:)).Everyoneelsewhohassinceemailedmewithsuggestionsandcomments(hundredsofyou!!)-IhopeyouallcontinuetofindAutoItofsomesmalluse!Everyonewhohasmadesuggestions/commentsontheAutoItmailinglists.ThebetatesterswhoalwaysmanagetofindnewandimprovedwaystobreakAutoIt;)

Q#1:DoestheExitcommandworkintheAdLibsection?---------------------------------------------------------------------

A#1:No,theExitcommanddoesnotfunctionfromanADLIBline,asin

;=======ScriptletStartsHere=======[ADLIB]SomeWindow,Sometext,Exit;=======ScriptletStopsHere=======

However,thesamethingcanbeachievedbyreplacing"Exit"with"Goto,ExitLabel"andaddingthelines"ExitLabel:"and"Exit"similartothefollowingscriptlet.

;=======ScriptletStartsHere=======SetTitleMatchMode,2AdLibOn

SetEnv,Count,1Loop:MsgBox,0,TheBeginning,Count=%Count%\nEnvAdd,Count,1IfEqual,Count,5,Run,notepad.exeIfEqual,Count,11,Goto,ExitLabelGoto,Loop

ExitLabel:WinWaitActive,-NotepadWinclose,-NotepadExit

[ADLIB]-Notepad,,Goto,ExitLabel;=======ScriptletEndsHere=======

-----------------------------------------------------------------------------

Q#2:Cana"GoSub"beusedinanAdLibstatement?

---------------------------------------------------------------------

A#1:Yes.Seethescriptbelowforanexample.

;=======ScriptStartsHere=======SetTitleMatchMode,2AdLibOn

SetEnv,C,1SetEnv,Count,11Repeat,%Count%IfEqual,C,5,ExitEnvAdd,C,1Run,Notepad.exeEndRepeat

Exit

Notepad:Send,!fxReturn

[AdLib]-Notepad,,GoSub,Notepad;=======ScriptStopsHere=======

-----------------------------------------------------------------------------

Q#1:Doesanybodyhaveawayoffindingoutwhetheracheckboxiscurrentlyselected?togglingiseasy,butabitpointlessifyoudon'tknowtheinitialstate!

---------------------------------------------------------------------

A#1:Youshouldsend"+"(forenabling)or"-"(disable)tothecheckboxinstead.

Butthisisnotconsistantacrossallprograms.Youshouldtestthiswiththespecificprogramyouareautomatingtomakesureitworks.

-----------------------------------------------------------------------------

Q#2:Isitpossibletohaveamessagewindowpopup,typeavalue,thenhavethatvaluere-typedwhencalled?Iambuildingatoolforouraccountsadmintoremoveallofausersaccounts.Iwanttotrytopreventthemfromtypingintheusernamevalueseveraltimes.

---------------------------------------------------------------------

A#1:Yes,useainputboxandhavethevaluewritten(iniwrite)toafilethenwhenyouneedthevaluehaveitreadinfromthefile(iniread).Likethis:

inputbox,user,EnterUserName,Whatistheuser'sname?iniwrite,%user%,c:\\User.ini,names,username

andthenintheotherscripts

iniread,user,c:\\user.ini,names,usernamesend%user%

---------------------------------------------------------------------

A#2:Ifit'sallinthesamescript,don'tbotherwritingtoafilejustdo:

inputbox,user,EnterUserName,Whatistheuser'sname?

Andlatertosendituse

send,%user%

-----------------------------------------------------------------------------

Q#3:IneedhelpintakingtheinputfromanInputMessageBoxandwhatevertheinputmaybe,writingitasasendcommandintoanactivewindow.Inotherwords,Ineedforausernameandpasswordtobeinputbytheuserandthenwritetheuserinputtoanexistingapplicationasasendfunctionlaterinthescript.IfanyonehasascriptexampleIwouldgreatlyappreciateit.

---------------------------------------------------------------------

A#1:trythis...

;=======ScriptletStartsHere=======InputBox,username,UserNameEntry,\nPleaseenteryourusernameInputBox,password,PasswordEntry,\nPleaseenteryourpassword,hideRun,notepad.exeWinactivate,Untitled-NotepadSend,Usernameis:%username%{ENTER}Send,Passwordis:%password%

;=======ScriptletEndsHere=======

---------------------------------------------------------------------

A#2:InputavalueintoavariablewiththeInputBox,thenSendthevariabletotheapplicationthatneedsit.I'vebeendoingitforayearorso,andworksalmostperfectly;IsayALMOSTbecauseevery

onceinawhilethescriptlosesfocusforwhateverreasonbetweentheWinActivatecommandandtheactualSendcommand,whichmeansoccassionallymySendcommandsendsoutputtothedesktop.

---------------------------------------------------------------------

A#3:TheonlythingI'vebeenabletorelyonwastocreatemyownloginscreen,captureandsendthedataasneeded.I'vetriedspywareandpasswordcaptureprogramsbuttheyaren'treliableorthey'retoobigorthey'reeverywhereorthey'resomethingelse...

---------------------------------------------------------------------

A#4:Tryusingsomethinglikethis:

setenv,WinTitle,<windowtitle>setenv,WinText,<windowtext>

...setenv,keystrokes,<keystrokestring>gosub,loop

...setenv,keystrokes,<nextkeystrokestring>gosub,loop......loop:

;=======ScriptletStartsHere=======IfWinNotActive,%WinTitle%,%WinText%,Winactivate,%WinTitle%,%WinText%

IfWinNotActive,%WinTitle%,%WinText%,goto,loopSend,%keystrokes%Return

;=======ScriptletEndsHere=======

Q#1:HowdoIcreateadirectoryfromwithinAutoIt?

---------------------------------------------------------------------

A#1:ByusingaDOScommand.

Run,%Comspec%/CMDC:\\Temp\\example-----------------------------------------------------------------------------Q#2:HowdoIdeleteadirectoryfromwithinAutoIt?---------------------------------------------------------------------

A#1:AgainbyusingaDOScommand.

Run,%Comspec%/CRDC:\\Temp\\exampleButinthiscasethedirectorymustbeemptybeforeyourunthiscommand.Soacommandlike:Run,%COMSPEC%/cdelC:\\Temp\\example\\*.*Send,y{ENTER}wouldneedtoberunfirst.-----------------------------------------------------------------------------

Q#3:I'mtryingtodeleteallthefilesinC:\TEMPwiththefollowing:

RunWait,delC:\\TEMP\\*.*/q

ButIalwaysgeta'Failedtorunprogram'-error.(TheOSisWindows2000Pro)WhatamIdoingwrong?

---------------------------------------------------------------------

A#1:Youneedsomethinglike:

runwait,%COMSPEC%/cdelc:\\temp\\*.*/q

Because"del"isaDOSinternalcommand.Youneedtospecifythecommandshellthatitisinternalto.Thatiswhatthe%COMSPEC%does.

Q#1:HowdoIformatabootablesystemdiskettefromwithinAutoIt?

---------------------------------------------------------------------

A#1:InWindows9xyoucandothefollowing:

;=======ScriptletStartsHere=======GoSub,MakeTmpFileAppend,Y\nN\n,%TMPFILE%RunWait,%COMSPEC%/cFORMAT.COMA:/S/U<%TMPFILE%RunWait,%COMSPEC%/cdel%TMPFILE%Exit

MakeTmp:SetBatchLines,1000Random,T,1,32767SetEnv,TmpFile,C:\\%T%.txtSetEnv,TMPFILE,C:\\%T%.txtIfExist,%TmpFile%,GoSub,MakeTmpFileAppend,,%TmpFile%Sleep,1000Send,^ZIfExist,%TMPFILE%,Goto,MakeTmp_ENDSetEnv,ERRORLEVEL,1MakeTmp_END:SetBatchLines,1Return;=======ScriptletEndsHere=======

-----------------------------------------------------------------------------

Q#2:HowcanIdefragmyharddriveonanightlybasisusingaW2Kscheduler?Doesanyoneknowhowtorunthedfrg.mscexecutableinascript?

---------------------------------------------------------------------

A#1:IuseO&O'sFreeWareDefragmenterforWin2k.Unfortunately,IremovedtheMSDefragwhenIinstalledthefreewareversion.However,thefollowingcommandinanAutoItscriptallowedmetobringuptheO&ODefragprogramfromanAutoItscript.Note:TheO&ODefragmaynothavecommandlineparametersyoucanpassin,thoughMS'sDefragmight.

Run,C:\\WINNT\\system32\\mmc.exe"C:\\ProgramFiles\\OOD2KFRE\\OOD2KFRE.MSC"/s

Q#1:I'mrunningintoabitofaproblem.WhatI'mwantingtodoisrunaprogramaccordingtothedisplayresolution.Asyou'llseeinthescriptI'vepasted,butwhatIfindisthatitlaunchesall3ofthemnomatterwhat?ProbablysomethingI'veoverlooked!!RegRead,TestKey,REG_SZ,HKEY_CURRENT_CONFIG,Display\\Settings,ResolutionIfEqual,TestKey,"1024,768",GOTO,internetIfEqual,TestKey,"800,600",GOTO,wordIfEqual,TestKey,"640,480",GOTO,excelinternet:run,c:\\programfiles\\internetexplorer\\iexplore.exeword:run,c:\\programfiles\\microsoftoffice\\office\\winword.exeexcel:run,c:\\programfiles\\microsoftoffice\\office\\excel.exe---------------------------------------------------------------------A#1:Firstofall,checktoseetheresultsofyourRegReadbyputtingtheCommandMsgBox,0,RegReadResults,Result=%TestKey%rightaftertheRegRead,Tomakesureyouaregettingtheresultsyouthinkyoushould.Onceyouaresatisfiedwiththat,youcanremovetheMsgBoxcommandInadditionaddthegotocommandsIhaveshownhere:;=======ScriptletStartsHere=======RegRead,TestKey,REG_SZ,HKEY_CURRENT_CONFIG,Display\\Settings,Resolution

IfEqual,TestKey,"1024,768",GOTO,internetIfEqual,TestKey,"800,600",GOTO,wordIfEqual,TestKey,"640,480",GOTO,excelgoto,endinternet:run,c:\\programfiles\\internetexplorer\\iexplore.exegoto,endword:run,c:\\programfiles\\microsoftoffice\\office\\winword.exegoto,endexcel:run,c:\\programfiles\\microsoftoffice\\office\\excel.exeend:;=======ScriptletEndsHere=======-----------------------------------------------------------------------------Q#2:I'vecreatedascriptthatusestheshortcutkeyoptionintheshortcutsproperties(hmm...lemmeexplainthisanotherway,Right-clickonashortcut,selectproperties,see'shortcutkey'youcanassignhotkeyforshortcuts)O.k.Nottoinsultanyone'sintelli-gence,butIwantedeveryoneonthesamepage.)Thisscriptwhencalledupon,willtakeasnapshotofthecurrentlyactivescreen,thenopenmspaint.exe,pasteit,andsavethefileinthe%YEAR%%MONTH%%DAY%....format...itgivesmeascreenshotofeachscreensoIcangobacklateronandwriteascriptthatIwasnotabletospendthetimeduringtheinitialinstall.Sofar,thismethodisstartingtoworkoutgreat,ButI'dlikeawaytoOpenAutoitRevealmode,takeasnapshotofthatwindow,savingit,thenuseitforlaterreviewforscriptmaking.

Problem,youcannot'WinGetAtiveTitle'it,'WinSetTitle',oranyothersimilarsteps.AllAutoitbasedwindowsstay....Autoit,orAut2Exe.Doesanyoneknowofawaytodothis?isthisintheplansforfutureversions?Icannotgetasnapshot(screenshotusingprint-screenkey)oftheAutoitwindow,whichhasallthetextlistedandmousecoordinates,etc...Bybeingabletodothis,ascriptcanbewrittenatalatertime,thatwouldworkfine,asallinfoontheAutoItscreenisintact,buttheinabilitytoprintscreentheAutoItwindowpreventsthiscoolusage.---------------------------------------------------------------------A#1:Iusethiscodetocaptureerrormessagesandprintscreenthem.OpentwoAutoItrevealwindows,togetyourexactAutoItversionandWindowTitle.;=======ScriptletStartsHere=======SetTitleMatchMode,2WinActivate,AutoItv2.41-(C)2000JonathanBennett.WinWaitActive,AutoItv2.41-(C)2000JonathanBennett.SEND,#{ALTDOWN}#{PRINTSCREEN}#{ALTUP}SLEEP,1000WinMinimize,AutoItv2.41-(C)2000JonathanBennett.WinMaximize,untitled-PaintWinWaitActive,untitled-PaintSLEEP,2000SEND,#{CTRLDOWN}#v#{CTRLUP}#{ENTER};=======ScriptletEndsHere=======---------------------------------------------------------------------A#2:Tryusing:send,{PRINTSCREEN}ratherthan:send,!{PRINTSCREEN}thatshouldcapturethewholescreen,notjusttheactivewindow.Thatwouldgetyoutheapplication'sandtheautoitrevealwindow....

Q#1:DoesAutoItrecordmykeystrokesandcreateascriptordoIneedtocreateascriptmanuallyinnotepad?

---------------------------------------------------------------------

A#1:AutoItdoesnotcurrentlyhavearecordingfeature.Ifyouwanttoautomatesomeinstallationorothersetofactions,youmustlearntheexactsequenceofkeystrokesyouwishtosendandwriteit(manually)intoascript.SeetheSendcommandandthesectionthatdescribesthekeystrokecodes(forexample,{ENTER},{ESCAPE},{DOWN},{TAB},etc.)intheAutoItdocumentation.

---------------------------------------------------------------------

A#2:IrecommendnotuseingNotepad,it'sareallypooreditorforwritinganytypeofscript.Therearemanyothereditors,likeUltraEdit,TextPad,NoteTab,etc.whicharemuchbettertoolsforyourtask.HerearetwoeditorsIcouldrecommendfornewbies:1.AutoIteditorhttp://www.lkei.com/downloads/downloadsfreewarerequest.asp?2or2.NoteTabLight(freeware)a)downloadhttp://www.notetab.ch/ftp/ntfree.zipb)installNoteTabLightc)downloadhttp://groups.yahoo.com/group/AutoItList/files/misc/notetab.zipd)puttheuncompressedfileintoNoteTabslibrarypath(usuallyC:\ProgramFiles\NoteTabLight\libraries)

Q#1:HasanyonethoughtofawaytohaveautoItrandomlyselectafileoutofadirectoryorlistoffiles?I'dliketouseitasmywallpapermanager.

---------------------------------------------------------------------

A#1:LetAutoItopenupthedirectoryinExplorerwithallthepicturesthere,then:

;=======ScriptletStartsHere=======Random,numtimes,1,25

;forexampleofhowmanytimestoRepeat,%numtimes%Send,{RIGHT};movesselectionnumtimestoafileandnumtimesisrandom;numberbetween1and25EndRepeat;=======ScriptletEndsHere=======

Fromhereyoucanhavethepicselectedinexploreranddotherest.Therearemoreefficientwaysofdoingthis...becreative

Q#1:HowdoIemptytherecyclebinfromwithinAutoIt?MaybeaRundllcommand?

---------------------------------------------------------------------

A#1:YoucanuseanAutoItscripttoclearitfromthedesktoplikethis:

;=======ScriptletStartsHere=======WinMinimizeAllleftclick,0,0send,recy+{F10}send,b{ENTER}winwaitactive,Confirmsend,!yWinMinimizeAllUndo;=======ScriptletEndsHere=======

ItcanbeputineitheranAutoItscriptfileorcompiledintoanEXE.Ifit'scompiled.Itbecomesalotlikenumber4.

---------------------------------------------------------------------

A#2:Youcanusea3rdpartycommandsuchasERB.Foundat:

http://hjem.get2net.dk/fec/software/erb/index.html

Thiscommandwasspeciallywrittentoemptytherecyclebin.Itcanberunfromsayanetworkdrive(t:)fromwithinAutoItbyusing:Run,%comspec%/ct:\\erb.exe/hide

Itcanalsoberunfromthelogonscriptwiththefollowingcommand:

erb.exe/hide

---------------------------------------------------------------------

A#3:YoucanuseWindowsexplorerandAutoIttodothejoblikethis:

;=======ScriptletStartsHere=======Run,C:\\\\Windows\\\\Explorer.exe\\\\RecycledSend,!fb{ENTER}!fc;=======ScriptletEndsHere=======

---------------------------------------------------------------------

A#4:Youcanrunabatchfile(callitsay:"eraserb.bat")withthefollowingcommandsinit.

;=======BatchFileStartsHere=======C:CD\RECYCLEDATTRIB-h*.*ATTRIB+hdesktop.iniECHOY|DEL*.*>>NUL:;=======BatchFileEndsHere=======

---------------------------------------------------------------------

A#5:YoucanuseasingleDOSinternalcommandlike:

eraseC:\recycled

oranexternalDOScommandlike:deltree/yc:\recycled\

ThesecommandscanberunfromwithinAutoItlikethis:;=======ScriptletStartsHere=======Run,%comspec%/cdeltree/yc:\\recycled\\Run,%comspec%/ceraseC:\\recycled;=======ScriptletEndsHere=======

---------------------------------------------------------------------

A#6:Someothersuggestionscanbefoundontechrepublic.cominanarticlebyBillShadish(whichiswhereIgotthebatchfilefrom).Itstates:

"You’veprobablyheardthePaulSimonsong"FiftyWaystoLeaveYourLover,"whichdescribesanumberoftricksforbreakingfreefromanUndesiredrelationship.Thisarticleplacesaspinontheconceptsusedinthatsong.No,Ican’tguaranteethatsimplybyreadingthisarticleyoullmeetthatspecialperson.ButThisarticlewillprovide40waystosolvesomecommondisk-spaceproblemsunderWindows9xandWindowsNT.

CleanupYoucanuseasmallprogramtoemptytheRecycleBin(29)(itsreallyjustAspecialdirectoryontherootoftheCdrive).TheCheadercodetodoSolookslikethis:

SHEmptyRecycleBinSHSTDAPISHEmptyRecycleBin(HWNDhwnd,LPCTSTRpszRootPath,DWORDdwFlags);

However,youmustinstalltheExplorer4.0xextensions(suchaschannels)Togettherequiredversion4.71oftheShell32.dllfiletomakethecall.I,forone,amnotinterestedininstallingtons(readthat,megabytes)ofglutjusttobeabletodeletefilesfromonedirectory.So,letslookatabatchfilethatdoesthesamething.Notethattherecycledirectorycontainstwospecial,hiddenfiles.InfomapsthenamesoffilesintheRecycleBintotheiroriginalfilenames;youshoulddeletethisfile.TheshellusesDesktop.initorecognizethattheRecycleBinisaspecialfolder;dontremovethisfile.(30)Placethefollowinglineswithinabatchfilecalled,perhaps,Dump.bat:

C:

CD\RECYCLEDATTRIB-h*.*ATTRIB+hdesktop.iniECHOY|DEL*.*>>NUL:

YoucannowemptytheRecycleBinbycallingthisfile."

---------------------------------------------------------------------

A#7:Onepossiblesolutionhasnotbeenprovenornecessarilyshowntobeasolutionasyet.Butthecommentshavebeenincludedhereforcompleteness.ItentailsusingtheRundllcommandandtheshell32.dllfunction"SHEmptyRecycleBin".thegististouseacommandlike:

rundll32shell32,SHEmptyRecycleBin

---------------------------------------------------------------------

Thefunctionexists"SHEmptyRecycleBinA",SomeexamplesofhowtouseitinaVisualBasicprogramcanbefoundat:

http://support.microsoft.com/support/kb/articles/Q164/7/87.ASPhttp://www.TheScarms.com/vbasic/rundll.asp

---------------------------------------------------------------------

Iwouldassumethatitcanbedone,butgettingtherightparametersandusingthemcorrectlyisthekey.IcallapifunctionstoopencertaindialogsorperformotherfunctionswithAutoIt.Somorethanlikelyemptyingtherecyclebinthroughanapicallispossible.Ifoundaninterestingwebsitewithatonofapifunctionsalongwiththeparameters.

http://www.vbapi.com/ref/funca.html

---------------------------------------------------------------------

FortheSHEmptyRecycleBinyouneedatleastShell32V.4.71,butIhavethe4.00versionandIcanemptytherecyclebin,soIthinkthereisawaytodothis,ifyoucreateafolderandnameit:RecycleBin{645FF040-5081-101B-9F08-00AA002F954E}You'llgotanotherrecyclebin.

---------------------------------------------------------------------

Unfortunately,Idon'tthinkyoucandoitwithRundll.TheSHEmptyRecycleBinfunctionisintheSHELL32.DLLfile,butitdoesn'tworkwithRunDll,becauseitneedsaWindowshandle,unlikeSHExitWindowsEx,whichjusttakesasimpleparameter.

---------------------------------------------------------------------

OneavenueyoumaywanttoresearchisMicrosoft'sMSDNsite.I'vefoundthistobeagreatresourceforlocatingthistypeofthing.AfteraquicksearchIwasabletofindthefollowinginformation:TheWindowsAPIprovidestheabilitytoperformacopy,move,rename,ordeleteoperationsonafilesystemobjectusingtheSHFileOperationfunctionthatisexportedbyShell32.DLL.

---------------------------------------------------------------------

Oneotheroption,asadeveloper,wouldbetolumpthefunctionsyouneedintoyourownlibrary(DLLorOCX),andthencallyourownfunctions.

Q#1:Whatexactlydoes"Revealmode"do?Doesitrecordmykeystrokesandmousemovementsandifso,doIcutandpastethecontentsintoatextfiletomakeascript?LetssayIwanttoautomateasoftwareinstallation.WillIneedtostudythecommandsandwriteitinnotepadorwillAutoItassistmeandcreateascriptbyrecordingmykeystrokes?

---------------------------------------------------------------------

A#1:TheAutoIt"Reveal"modeallowsyoutofindouttheexacttitleandtextcontent(ifany)ofanyopenwindowinordertoproperlyspecifythewindowwithinanAutoItscript(seetheWinXXXcommands,e.g.WinWait,WinWaitActive,WinClose,etc.)

TheRevealModewindowshowsinformationaboutsomeotherwindowthatisactive.ForexamplecertainAutoItcommandstakewindowtitlesasanargument.TheRevealModewindowechoesthetitleofthecurrentlyactivewindowwhichyoucancopyandpasteintoyourscript.Inasimilarwaytheotherinformationdisplayedallowsyoutoscripttheclickingofabutton,etc.

---------------------------------------------------------------------

A#2:LetmegiveyouascenarioofhowIgoaboutcreatinganautomationofaprocess.Let'ssayIwantAutoIttoautomaticallybringupthedesktoppropertiesdialogbox.

First,ifyouhaven'tdonesoalready.InstallAutoIt.Itwillmakesomethingseasier.

IwouldstartwithbringingupAutoItinrevealmode.Revealmodeisjustawayofseeinginformationaboutwindowsandthemousepositionwhileyouaregoingthrutheprocess.AllyouneedtodotobringuprevealmodeistoclickonitintheAutoItgroupintheProgramitemontheStartmenu.Oncethat'sdone.startupaneditor(NoteTab,theAutoItScript

Editor,WinVi,etc.)andminimizeit.Thiswillallowyoutowritedownwhatisbeingdisplayedinrevealmode.

ThenIwouldstartuptheprocessIwanttoautomate.InmyexampleIcouldbringupthedisplaydialogboxin2differentways.ButforthisexampleI'llbringitupviathecontrolpanel.

TogettotheStartmenuIwouldnormallypressCNTRL-ESC.SoIwouldputa"Send,^{ESC}"asmy1ststatementintheeditor.

NextIwouldusethearrowkeystogoup6menuitemstothe"Settings"item.SoIwouldput"Send,{UP6}"asthenextline.

NextIwouldpresstherightarrowkeytohighlightthe"ControlPanel"itemandthenpress<ENTER>("Send,{RIGHT}{ENTER}").

NowIhavetolookattherevealmodewindowandseewhatthetitleofthe"ControlPanel"windowis.Obviouslyinthisinstanceit's"ControlPanel"soweneedthescripttowaitforthewindowtocomeupsowe'llputa"WinWaitActive,ControlPanel"asthenextline.

Lastly,weneedtobringuptheDisplaydialogbox.Theeasiestwayistogetthefocusintothemainpartofthewindowbypressinganarrowkeyso"Send,{RIGHT}"comesnext.TheninmyControlPanelwindowIhave3iconsthatstartwitha"D".SoIwouldhavetotype3d'stogettothepropericon("Send,ddd{ENTER}")andthenpressan<ENTER>tobringitup.

Allofthistogetherisinthescriptbelow.Ofcoursethisisacontrivedexample.ButI'msureyougetthedrift.

;===========ScriptletStartsHere===========Send,^{ESC}Send,{UP6}Send,{RIGHT}{ENTER}

WinWaitActive,ControlPanelSend,{RIGHT}Send,ddd{ENTER};===========ScriptjletEndsHere===========

Q#1:HowcanIscheduletherunningofanAutoItscript?

---------------------------------------------------------------------

A#1:Astrategyistousethetimevariableswithacompare(IfEqual)andwaitloopinternaltoyourscript.placingthescriptintothestartupfolderwillstartit.Thismayeatsomeclockcyclesbutinmycasethescriptwillbeonlyoneoftwoapplicationsrunningonthemachineatthetime.

---------------------------------------------------------------------

A#2Ifyou'reusingWin98orabove,youcanscheduleyourscriptthroughtheSystemTaskScheduler.Ican'trememberifWin95hadthis.Also,thereareseveralfreeWaretaskschedulersthathavebeenmodeledafterUnixCron.

---------------------------------------------------------------------

A#3:IuseJustInTimetostartanAutoItscripttocollectcallinformationdataeveryhalfhourfromatelephoneswitch.TheMicrosoftschedulerandmanyothersschedulersruninring3andwillnotinterruptthekernelitahigherprioritytaskisrunning.IftheprogrammedstarttickpassestheMSschedulerdoesnotstartthescheduledprogram.SinceIwenttoJITIhaveonlymissedonestartupbecauseofthe56dayuptimesystembuginMS9xOS.Ascheduledrebooteachweekendbyanotherscript,orJITcandoitforyou,JIT(Version4.xxandbelow)isfreewareandisavailablefrom

http://members.xoom.com/polyakoff/

Version5.0anduphasbeenreleasedasinexpensiveshareware.

Herearesomesmallscripting/scheduling/automatingutilities,thatmaybeusefulforreference:NNCron-http://nemtsev.virtualave.net/Runner-http://home.comset.net/panoff/runner/runner.phtml

ControlAgent-http://www.dg.spb.ru/cgi/index.cgi?ca/default.htm+koi8

Q#1:DoesanyoneknowifanAutoItarchiveexists?

---------------------------------------------------------------------

A#1:AnarchiveoftheAutoItmailinglistfromthelistbotmessageboardhasbeenputintoacompiledHTMLfile.Thiscanbefoundinthefilessectionofhttp://groups.yahoo.com/autoit.ThefilesfromtheAutoItlistonhttp://groups.yahoo.comcanbefoundthere.

---------------------------------------------------------------------

A#2:"swynk.com"hasstartedanAutoITarchive,primarilyforAutoITexposureandhelpwithSMSpackagedistribution.We'vemanagedtobuildaprettystronginterestoverthelastfewweeksandfolkshavestartedsendingintheirscripts.But,wewouldbehappytostartincludinganyscriptsfromthislistifdeemedappropriate.Here'stheAutoITsection:

http://www.swynk.com/trent/Sections/AutoIT.asp

SWYNKisupdatedbi-weeklysothescriptwouldbeavailablefordownloadprettyquickly.Wehaveunlimiteddiskspace,searchengines,etc.

Q#1:HasanyoneusedAutoItXwithinaVisualBasicApplication?Ifyouhave,couldyousendmeasmallsampleofhowtoincludeAutoItinaVisualBasicproject?

---------------------------------------------------------------------

A#1:IuseAutoItXinsomeofmyVBapps.Ifyouareinterested,IcreatedVBModulewhichregisterstheAutoItX.dllautomaticallywhenitisused.ItalsomakesiteasytoreferencetheAutoItXcontrolinyourcode(IhaveonlytesteditonNT4).

SomeofthefunctionsintheModulearenotAutoItXrelated.IalsoaddedfunctionsforREG.EXE,SRVINFO.EXE,andNET.EXEtoreadandwritetoremoteregistry,getserverinfo,andmanipulateNTUserAccounts.LinktotheVBModuleat:

http://chameleonc.com/tfiles/autoitbas.zip

HereisanapplicationwhichutilizestheModule.It'sacoolapp.ItdoesNTUserAccountmaintenanceandreporting.ItonlyworksonNT4.

http://chameleonc.com/tfiles/nttools.zip

Q#1:IsthereasurewaytocommandmyWindowstoreboot?

---------------------------------------------------------------------

A#1:HaveyoutriedtheAutoItshutdowncommand?

fromthemanual:

Shutdown,

Thiscommandallowsyoutoperformvariousformsofshutdown.Thetypeisdeterminedby.Theflagcanbeacombinationfromthetablebelow:

FunctionFlag---------------------------------------------------------------------Logoffthecurrentuser0Shutdowntheworkstation1Reboottheworkstation2Forceclosingofapplications(mayloseunsavedwork)4Shutdownandpoweroff(ifsupported)8

e.g.Toshutdownandforceapplicationstoclosewithoutsaving=Shutdown+Force=1+4=5:Shutdown,5

---------------------------------------------------------------------

A#2:Here'sthepagewhereIfoundthis...

http://www.onecomputerguy.com/desktop.htm#logoff_icon

Andhere'salistofcommandsthattheyshow.It'sbeenalongtimesinceI'vehadWindows9x,soIcan'ttestthis:sorry.Iwouldsuggesttryingthisfromacommandprompt,thenworkingyourway

outwardtowardascript.Isolatewhethertheproblemiswiththescriptorthecommand.

ForShutdown,thecommandisC:\WINDOWS\RUNDLL.EXEuser.exe,exitwindows

ForRestart,thecommandisC:\WINDOWS\RUNDLL.EXEuser.exe,exitwindowsexec

ForLogoff,thecommandisC:\WINDOWS\RUNDLL.EXEshell32.dll,SHExitWindowsEx0

---------------------------------------------------------------------

A#3:WithWindows98,thereareseveralknownshutdownbugs.Idon'tknowspecificallyofshutdownbugsonWindows95,butyoucangetthissamesortofproblemwithbadsoftwareinteractions.ThewaytotestthisistofirstrunanormalshutdownthroughtheStartMenushutdownoption.Ifthatworks,usethestandardcommand"rundll32.exeuser,exitwindows"intheStartMenurunoption.Ifeitheroneofthesefails,itisprobablyaproblemwithyourOS.Iftheybothwork,it'shardertosaywhattheproblemis,butknowingthatthisworkswouldhelpsomeonepointyouclosertotherightdirection.

---------------------------------------------------------------------

A#4:Toremotelyrebootyoumightusethe"Shutgui"utilityfromtheNT-ServerResourceKit.TheNTreskithasa"Shutdown"managerthatallowsyoutoSDaPConyournetwork,butthereisacommandline1"SHUTDOWN"thatcanberunasan"AT"scriptonyourserver.Checkoutthehelpfileforbothoftheaboveforthesyntax...Itshouldbe..

SHUTDOWN\\"Computername"..

Orseethefollowingformoredetails

http://download.mycomputer.com/detail/57/56.html

---------------------------------------------------------------------

A#5:TocurrentlylogoffthecurrentuserfromWINNT4.0,NOT95etcfromthecommandlineorbatchscriptthecommandisthis,

rundll32user32.dll,ExitWindowsEx

Usingthismethodremovesdependenciesonresourcekitutilsetc.whataboutthegoodolddos(useipconfig/release///renew)

-----------------------------------------------------------------------------

Q#2:WhatdoIdoifotherusersareconnectedtothesystemaswell?

---------------------------------------------------------------------

A#1:Try:

Runwait,%COMSPEC%/cnet.exeSTOP

-----------------------------------------------------------------------------

Q#3:I'mtryingtouseShutdowninascripttocreateanexecutabletorebootaPC.ThePCisonaW95network,andaccessedbyothers,soIgettheSharingMessageBoxbeforeshutdown,tellingme"thereare2usersconnectedtoyourPC,etc"andpromptingforY/Ntocontinuewiththereboot.

Thegistofthescriptis:

Shutdown,2;torebootthePC(I'vealsotriedShutdown,6)

WinWaitActive,Sharing

;waitsfortheSharingmessagebox

Send,y;answersYes,tocontinuewithreboot

Itseemsasimpleenoughscript,butitnevergetspasttheSharingbox.HasitshutdownbythentoastatewhereAutoitexecutablescan'tcontinue(theiconisstillinthesystemtray,soIpresumeit'sstillrunning),orhaveIgotsomethingmorefundamentalwrong?Ifso,anysolutions,anyone?

---------------------------------------------------------------------

A#1:Youmaywanttoputthelinethatsendsa!YtotheSharingdialogboxtoa[ADLIB]sectionjustincasetherearenootherusersconnectedtothemachine.becausewiththeWinWaitAcivestatementthescriptwillstoprunninguntilthatwindowappearsandifnooneelseisattachedtotheboxthenthewindowswillnotappearandthescriptwillwait.AlsoyoucantryaIfWinExiststatementonthatlineinsteadofthe[ADLIB]section.

---------------------------------------------------------------------

A#2:There'sanot-normally-installedWindows95accessorycomponent,NetWatcher,ontheW95CDthatallowsyoutodisconnectusers.I'lldoascriptforitonMondaytocleartheconnectionspriortorebooting,thenIcan'tseewhyRestartshouldn'twork.Ican'tfinditonW98athomethough-anyoneknowifit'sbeenreplacedbysomethingdifferentinW98?

---------------------------------------------------------------------

Actually,AutoItquitsstraightafterashutdowncommand,ifit'sstillinthetaskbarafterthiscommandit'sbecausethereisarebootinprogress....So,oncetheshutdowncommandhasbeenissued,noothercommands(ADLIBorotherwise)willbeexecuted.

There'sprobablyawaytostopallnetworkconnectionsbeforerunningthis(on9xandNT).Anyoneseensuchaprogram?

---------------------------------------------------------------------

A#3:ForaWinRebootor(current)UserLogoff/Logon

CreateashortcuttotheRundll.exeortheRundll32.exefileandtypethefollowingPathproperty,egtheSYNTAX:

C:\Windows\RUNDLL.EXEuser,exitwindowsexec

-onesinglespacebetween.EXEanduser-onesinglecommabetweenuserandexitwindowsexecsingle/doubleclickthelink,

---------------------------------------------------------------------

A#4:ThepurposeistoreleaseaclientDHCPIPleasejustbeforesystemshutdownsothatageographicallyroamingnotebookuserwillautomaticallybeservicedwithanewIPaddresswhentheyconnecttoadifferentDHCPserver.Iassumeitwouldlooksomethinglikethis.

;========ScriptStartsHere=======@ECHOOFFIPCONFIG/RELEASERundll32,user,ExitWindowsExec(Iknowthissyntaxisincorrect,ideas?);=======ScriptEndsHere=======

---------------------------------------------------------------------

A#5:Forthoseinterestedintechiestuff....NTisveryeasytoshutdownfromtheAPIanditalsohasthefacilityto"force"shutdowns(i.e.anyopenprogramsanddataaredumped)-ThisiswhythecodeinAutoItwillalwaysworkunderNT.

Differentstoryunder95,internallyI'musingtheExitWindowsAPIbutunder95thereisNOwaytoforceashutdownwiththeAPI(bitofabonkersdecisiononMS'spartinmyopinion).Soeachshutdownutilityfor95willworkinadifferentwaydependingonhowtheauthortriedtoforcetheissue.I'musingsomecodefromMSDNwhichbasicallygetsalistofallprocessesrunningandtriestokillthem.Iftheyhaven't"died"withinacoupleofseconds("Pleasesavedata-blahblahblah")thentheyaregivenakickandreallykilled.Afterthisthenormalwindows"ExitWindows"APIisused-whichusuallysucceedsifallapplicationshavebeenclosed.Thisworksformost95machinesbutI'vealsoseenthe"Pleasewaitforwindowstoshutdown"messageaswell(andI'vealsoseenthatmessagequiteafewtimesonmanualshutdown!)Anyway,that'sjustforinfo,andthat'swhytherearesooooooomany95shutdownapplicationsthatdon'twork100%.

-----------------------------------------------------------------------------

Q#4:IwouldliketoknowhowtorunascriptonalocalnetworkfromaWindows98"server".Forexemple,iwouldliketoshutdownallcomputersofmylocalnetworkinthesameway.isitpossible?

---------------------------------------------------------------------

A#1:Youcouldmakethescriptandthencompileit.Placeitonthenetworkandthenhavealinktoitfortheusers.Ialsoemailthecompiledscriptsasattachmentswhenconvenient.Thisallowsthereceipienttorunthescriptimmediatelyupongettingtheemail.

Q#1:IsitpossibletosendkeystrokestoinvisiblewindowswithAutoIt?---------------------------------------------------------------------A#1:No-----------------------------------------------------------------------------Q#2:IstheiranywaytohaveAutoItholdamouseclickdown(forasecondorso)?ThereasonIaskissomeApplications(AdobeAcrobatinthiscase)have"flyoutmenus"thatareactivatedbyholdingthemousedownoverabuttonforasecondorso.IstheiranywaytodothiswithAutoIt?---------------------------------------------------------------------A#1:Ihaven'ttestedityet,butyoumighttrytheSetKeyDelaycommandbeforetheLeftClickcommand.I'vehadluckdoingthiswithLeftClickDragcommand.Syntaxexamplefrommyscriptfollows.;=======ScriptletStartsHere=======SetKeyDelay,400LeftClickDrag,590,235,247,235SetKeyDelay,20;=======ScriptletEndsHere=======---------------------------------------------------------------------A#2:Ihavenotdonethis,butIbelieveifyourunAutoIT'sRevealModeutility,andthenmimicthemousemovementsyourself,theutilitywillidentifythespecificcoordinatesrelativetothedisplay.Then,tryusingtheMouseMovefunctiontoinitiallypositionthemouseattheappropriatelocation,andthenusetheLeftClickDragfunction,specifyingthesamecoordinatesinboththex1/y1andx2/y2variables.YoumightalsotryusingtheRepeat/EndRepeatfunctionstoextendtheleft-clickoperationtothedesiredlength.

-----------------------------------------------------------------------------Q#3:Itskindofannoyinghavingthemousepositionflyofftosomeoddpositionafterthevariousmouseoperations(LeftClicketc.).Isitpossibletobringitbacktowhereitwasoriginally?---------------------------------------------------------------------A#1:yesyoucandoitwith:;=======ScriptletStartsHere=======WinActivate,ProgramManagerMouseGetPos,X,YWinActivate,[yourapplication][MouseOperation:LeftClicketc...]WinActivate,ProgramManagerMouseMove,%X%,%Y%WinActivate,[your(new)applicationwindow];=======ScriptletEndsHere=======Butit'ssomewhatslow,messyandproblematical,havingtoactivatetheappropriateapplicationwindowattheendetc.-----------------------------------------------------------------------------Q#4:DoesanybodyknowacleanwaytodeterminethatWindowshasfinishedbooting.Iwantanautoitscripttorunafterallprogramsfromthewindowsstartuphavefinished,otherwisesomewindowspoppingupduringthebootprocessinterferewithmyscript.StartingthescriptwithalongSleepisnotvery'clean'.---------------------------------------------------------------------

A#1:MaybetryingWinWaitforalloftheprogramsthataresupposedtobeloading;ifithasn'tloaded,waituntilitdoes.Dothatforalloftheprograms.---------------------------------------------------------------------A#2:I'mnotsureaboutthesequenceofloadingofwindowsprograms,andIknowthisisabitartificial,butcouldyouputnotepad.exeinthestartupgroupandjustwinwaittillitisactive....closeitandstartyourscript?---------------------------------------------------------------------A#3:Idon'tthinkthereisanywaytodothis.Therearesomanyprogramsthatcanstartatbootup,andtheycanstartfromsomanydifferentplaces,thatIdon'tthinktherewilleverbeawaytodothis.Iknowit'sakluge,butIwould:;=======ScriptletStartsHere=======repeat,10sleep,30000endrepeatWinminizeall;=======ScriptletEndsHere=======---------------------------------------------------------------------A#4:Pieceofcake:)WinWait,ProgramManager-----------------------------------------------------------------------------Q#5:HowdoIcreateashortcutfromwithinAutoIt?---------------------------------------------------------------------

A#1:YouhavetousetheShortcutWizardthat'spartoftheDesktopExplorershell(ProgramManager).ThefollowingscriptshouldworkonallWindowsversionsandresolutions,butnoguarantees.;=======ScriptStartsHere=======;Getthescreenresolution.GoSub,FindResolutionEnvDiv,Horizontal,2EnvDiv,Vertical,2;Bringupashortcutcreationwizard.WinActivate,ProgramManagerRightClick,%Horizontal%,%Vertical%Send,ws;SpecifythefullUNC.WinWaitActive,CreateShortcutSend,C:\\autoexec.bat{ENTER};Specifytheshortcuttext.WinWaitActive,SelectaTitlefortheProgramSend,Test1{ENTER}WinMinimizeAllUndoExitFindResolution:;Findoutwhatresolutionthedisplayisat.;FindoutwhatOSwe'reon.IfEqual,A_OSTYPE,WIN32_WINDOWS,goto,Win9xIfEqual,A_OSTYPE,WIN32_NT,goto,WinNTWin9x:;Gettheresolutionfromtheregistry.

RegRead,VideoDevice,REG_SZ,HKEY_CURRENT_CONFIG,Display\\Settings,Resolution

;GettheVerticalresolution.StringGetPos,P,VideoDevice,\,StringLen,L,VideoDeviceSetEnv,L2,%P%EnvAdd,L2,1StringTrimLeft,Vertical,VideoDevice,%L2%;GettheHorizontalresolution.SetEnv,L2,%L%EnvSub,L2,%P%StringTrimRight,Horizontal,VideoDevice,%L2%ReturnWinNT:;Gettheresolutionfromtheregistry.

regread,Videodevice,REG_SZ,HKEY_LOCAL_MACHINE,HARDWARE\\DEVICEMAP\\VIDEO,

\\Device\\Video0StringtrimLeft,Videodevice1,videodevice,48StringtrimRight,videodevice2,videodevice1,8;Putthepropervaluesinthevariables.

RegRead,Horizontal,REG_DWORD,HKEY_CURRENT_CONFIG,System\\CurrentControlSet\\SERVICES\\%videodevice2%\\DEVICE0,DefaultSettings.XResolution

RegRead,Vertical,REG_DWORD,HKEY_CURRENT_CONFIG,System\\CurrentControlSet\\SERVICES\\%videodevice2%\\DEVICE0,DefaultSettings.YResolution

Return;=======ScriptEndsHere=======---------------------------------------------------------------------A#2:YoumightwanttocheckoutaprogramcalledPCUpdater.Itwillcreateshortcuts,etc.Youcanusevariablestosenditexactlywhereyouwant.WorksonNT,and9xboxes.Also,itworksverywellwith

profiles.Agreatprogramforsoftwareinstallsalso.MakesselfextractingEXE's.Iuseitforinstallsifthey'retoocomplicatedforAutoIt.---------------------------------------------------------------------A#3:HereisacommandlineutilityIwrotetocreateashortcut.Youcancreatethe"group"byjustcreatingadirectorywithintheStartMenutree.Attachedisaconsole(DOSwindow)programthatwilltakeatextfileandcreateashortcutfromit.AlsoattachediistheVisualC++sourcefortheprogram.SourceFileFormatLine1-TargetLinkFileLine2-SourceExecutableFileLine3-DescriptionLine4-CommandLineArgsLine5-StartingDirectoryLine6-IconFileLine7-IconIndex---------------------------------------------------------------------A#4:maketheshortcutsreadytoworkinthedirectoryfromwhereyouinstalltheprogramaftertheinstallationisdonecopyitwithlnkcopyintheusersprofile.---------------------------------------------------------------------A#5:WhynotcreateashortcutthathasafilenameofC:\autoexec.batinthe"Target"location,andthenattheendoftheinstallationwhenyouknowwhatthepathisyoumodifytheshortcuttoaddtherealpathandfilenameintothe"Target"and"Startin"locations?Ordowhatmostinstallationprogramsdo.Waituntiltheinstallationiscomplete,andthenmaketheshortcutwhenyouknow

thepathandfilename.---------------------------------------------------------------------A#6:thisiswhereyoucandownloadthescut.exe,http://www.jsiinc.com/TIP0400/rh0422.htmThisprogramhasallthecapabilitiesofthefullMicrosoftshortcut.exeprogramexcepttheabilitytocreatethem.---------------------------------------------------------------------A#7:Haveyouthoughtaboutusinga.piffilefortheshortcut?Idon'tuseAutoIttocreatemyshortcuts-sinceIwrapmyAutoITscriptsineitheranSMSInstallerexecutableoraWiseInstallMasterExecutable.-----------------------------------------------------------------------------

Q#6:InascriptIwanttodetectawindowtobeactive.Theproblemisthatthewindowtextvaries.Thetextis:"A\xxxxxxxxxx\B",whereAandBareconstantandxxxvaries.ThexxxaredependingonProjectnameandpath.

HowcanIsolvethis?

---------------------------------------------------------------------

A#1:IthinkyoucanuseStringRightandStringLefttogetthefirsttwoandthelasttwocharactersfromthetitleintovariablesandthentestIFEqualtoA\\and\\B.

---------------------------------------------------------------------

A#2:CopytheWindowtitleintoavariable,usetheStringfunctionsto

parseitforthepropertext?

---------------------------------------------------------------------

A#3:TrytousethecommandSetTitleMatchMode.

Q#1:IsthereaneasywaytochangetheGatewayIP(inTCP/IP)foranetworkcardusingAutoIt?

---------------------------------------------------------------------

A#1:Ifyoumustautomatethis,Iwouldsuggestusingthebuiltintoolnetsh,ortheresourcekittoolnetset.

Forexampletrythisatthecommandline:

netshinterfaceipsetaddressname="LocalAreaConnection"gateway=10.10.123.2

ForAutoIt,trybelow:Notethat010010123002correspondsto10.10.123.2

;=======ScriptletStartsHere=======send,^{ESC}snWinwaitactive,NetworkandDial-upConnnectionssend,l{ENTER}Winwaitactive,LocalAreaConnectionStatusSleep,250Send,!pWinwaitactive,LocalAreaConnectionPropertiesSleep,500Send,i!rWinwaitactive,InternetProtocol(TCP/IP)PropertiesSleep,250Send,!s!d010010123002{ENTER}Winwaitactive,LocalAreaConnectionPropertiesSleep,250Send,!w!w{TAB}{ENTER}Winactivate,LocalAreaConnectionStatusWinwaitactive,LocalAreaConnectionStatusSend,!cWinactivate,NetworkandDial-upConnnectionsWinwaitactive,NetworkandDial-upConnnections

Send,!fc;=======ScriptletEndsHere=======-----------------------------------------------------------------------------

Q#2:HowdoIrunanAutoItscriptatorbeforethelogonscreeninWindowsNT?

---------------------------------------------------------------------

A#1:UsingtheRunServiceskeyintheregistrywillallowyoutohaveanAutoItprogramrunbeforelogin.

MicrosofthasaKnowledgeBasearticleonthevariousRunkeysintheregistry,andwhatordertheyareexecutedinthestartupprocess:

http://support.microsoft.com/support/kb/articles/Q179/3/65.ASP

Hereissomeofit:

UnderWindows9x,whereallkeysaresupported,thekeysareloadedinthefollowingorder:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices

<LogonPrompt>

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

StartUpFolder

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

WiththeexceptionoftheHKEY_LOCAL_MACHINE\...\RunOncekey,allkeysandtheirentriesareloadedasynchronously.Therefore,allentriesintheRunServicesandRunServicesOncekeyscanpotentiallyrunatthesametime.

EntriesintheHKEY_LOCAL_MACHINE\...\RunOncekeyareloadedsynchronouslyinanundefinedorder.

BecausetheHKEY_LOCAL_MACHINE\...\RunOncekeyisloadedsynchronously,allofitsentriesmustfinishloadingbeforetheHKEY_LOCAL_MACHINE\...\Run,HKEY_CURRENT_USER\...\Run,HKEY_CURRENT_USER\...\RunOnce,andStartupFolderentriescanbeloaded.

TheRunServicesOnceandRunServiceskeysareloadedbeforetheuserlogsintoWindows95.BecausethesetwokeysrunasynchronouslywiththeLogondialogbox,theycancontinuetorunaftertheuserhasloggedon.However,sinceHKEY_LOCAL_MACHINE\...\RunOncemustloadsynchronously,itsentrieswillnotbeginloadinguntilaftertheRunServicesOnceandRunServiceskeyshavefinishedloading.

Becauseofdifferentsystemconfigurations(suchasacomputerthatisconfiguredtoautomaticallylogon),anyapplicationthatisdependantuponotherapplicationsthatareexecutedunderthesekeyshavingcompletedmustbepreparedtowaituntiltheseapplicationsarecomplete.Otherthanthisexception,theabovedescriptionappliestoWindowsNT4.0andWindows2000.

OnethingtorememberaboutNT/2K.Evenifyouhaveanautoitscriptrunning,itcannotdotheCTRL+ALT+DELneededtogettothelogondialog.

anotherpoint

IfyouwanttorunsomethingintheHKEY_LOCAL_MACHINE...RunOncetorunasynchronouslyyoucanusethecommand:

%COMSPEC%/CSTART<path\file.exe>

ThisworksbecausetheRunOnceexecutesthe%COMSPEC%commandsynchronouslywiththeotherRunOncecommands,buttheSTARTcreatesanewprocessthatisnotboundbytheRunOnceconstraints.

-----------------------------------------------------------------------------

Q#3.CanIuseAutoIttologinauseronWindowsNTor2000

---------------------------------------------------------------------

A#1:No.AutoItcannotsendtheCTRL+ALT+DELkeysequencerequiredtobringupthelogondialogboxinNT/2000.ThisisnotalimitationofAutoIt.

However,inWindows2000youcansetthemachinestonotrequireCTRL-ALT-DEL.Goto"UsersandPasswords"anddisableit.Butthis'auto-logon'featurewillnotworkifathirdparyutilityisinstalled(forinstanceNovell'sNovellClient),whichtakesloginprecendenceoverMicrosoft's)andthustheDefaultDomain,DefaultLogin,DefaultPasswordentriesintheRegistrywon'twork.

FromtheAutoItdocumentation:

"Windowsdoesnotallowthesimulationofthe"CTRL-ALT-DEL"

combination!"

Q#1:Howdoyousaveanuninstallstringvalueinavariable,andrunit?Forexample

;Check'sfortheuninstallstringofAcrobat3.01RegRead,Acrobat3,REG_DWORD,HKEY_LOCAL_MACHINE,Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\AdobeAcrobat3.01,UninstallString

;RunstheUninstallforAcrobat3.01Run,Acrobat3

ItriedtorunwiththevariableAcrobat3and%Acrobat3butnonework.

---------------------------------------------------------------------

A#1:IthinkthetypeoftheuninstallentryisREG_SZ

-----------------------------------------------------------------------------

Q#2:HowcanIread/writedefaultentriesto/fromtheregistry?

---------------------------------------------------------------------

A#1:Toread/writeadefaultentryfrom/totheregistryusetheRegReadorRegWritecommandandfillinablank,wheretheValueNameisrequired.Thefollowingiswrongbecausetheword"(Default)"isspecifiedattheend.Useanemptystring("")orsimplynothingatallinsteadof(Default).RegRead,version,REG_SZ,HKEY_LOCAL_MACHINE,SOFTWARE\\Classes\\Classes\\BureauVanDijk\\Promedia\\Version,(Default)

Thelineshouldbe:RegRead,version,REG_SZ,HKEY_LOCAL_MACHINE,SOFTWARE\\Classes\\Classes\\BureauVanDijk\\Promedia\\Version,

""

-OR-

RegRead,version,REG_SZ,HKEY_LOCAL_MACHINE,SOFTWARE\\Classes\\Classes\\BureauVanDijk\\Promedia\\Version,

----------------------------------------------------------------------

Q#3:HowdoIdeletearegistrykey?

---------------------------------------------------------------------

A#1:TodeletearegistryValue,usetheAutoItcommand:RegDelete.TodeletearegistryKey,usereg.exefromtheresourcekit.Forexample,mineisind:\2kreskit:

Run,D:\\2kreskit\\reg.exedeleteHKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer

(BTW,pleasedon'texecutetheaboveline,it'sjustanexample,the'Explorer'keyisprettyusefultokeeparound)

Thecommandsyntaxis:C:\>regdelete/?

RegistryConsoleToolForWindows2000-version2.0Copyright(C)MicrosoftCorp.1981-1999.Allrightsreserved

REGDELETEKeyName[/vValueName|/ve|/va][/f]

KeyName[\\Machine\]FullKeyMachineNameofremotemachine-omittingdefaultstothecurrentmachineOnlyHKLMandHKUareavailableonremotemachinesFullKeyROOTKEY\SubKey

ROOTKEY[HKLM|HKCU|HKCR|HKU|HKCC]SubKeyThefullnameofaregistrykeyundertheselectedROOTKEYValueNameThevaluename,undertheselectedKey,todeleteWhenomitted,allsubkeysandvaluesundertheKeyaredeleted/vedeletethevalueofemptyvaluename<noname>/vadeleteallvaluesunderthiskey/fForcesthedeletionwithoutpropmt

Examples:

REGDELETEHKLM\Software\MyCo\MyApp\TimeoutDeletestheregistrykeyTimeoutandallofitssubkeysandvalues

Note:Withreg.exeyoucandeleteregistrykeysremotely.Thecommand-linesyntaxis:

regdelete[ROOTKEY\]Key[\Value][\\Machine]

Parametersinsquarebracketsareoptional

REGDELETE\\ZODIAC\HKLM\Software\MyCo/vMTUDeletestheregistryvalueMTUunderMyCoonZODIAC

---------------------------------------------------------------------

A#2:thisisn'tpossiblewithoutcallinganexternalprogramfromAutoIt.i.e.useKixtart,

;=======KixtartScriptletStartsHere=======...delkey("HKEY_LOCAL_MACHINE\Software\Something")...;=======KixtartScriptletEndsHere=======andthencallthekixtartscriptfromwithinAutoItlikethis:

runwait,%COMSPEC%/ckix32.exemykixscript.kix,,

-----------------------------------------------------------------------------

Q#4:Ineedawaythatdoesn'tneedanexternalexecutable,WhatcanIwriteina.REGfile

---------------------------------------------------------------------

A#1:IrememberthatIreadthatthisworks:

======Begin.REG-File======

REGEDIT4

[-HKEY_LOCAL_MACHINE\Software\Something]

======End.REG-File========

thencall

runwait,%COMSPEC%/cregedit/sMyRegFile.reg,,

The"-"symbolinfrontofthekeyiswhattelsregedittodeletethekey.-----------------------------------------------------------------------------

Q#5:IsthereawayfromAutoIttosecureaRegistrykey?

---------------------------------------------------------------------

A#1:there'snobuilt-incommandinAutoIt,butyoucandothiswiththecommandlineutilityregini.exefromtheNTResourceKit.At:

http://www.jsiinc.com/subb/tip0700/rh0723.htm

Thefollowingarticlecanbefound.

0723Abetterwaytosetregistrypermissionsonakeyandits'sub-keys,inbatch.SupplementTwooftheNT4.0ServerResourceKitcontainsReginiwhichwillallowyoutosetregistrypermissionsintheHKEY_LOCAL_MACHINEandHKEY_USERShives.Reginireadsascriptfile,whichforourpurposes,containsasinglerecordinthe\Registry\Key[ACL]syntax:

\Registry-Aconstant.

Key:\Machine=HKEY_LOCAL_MACHINE\User=HKEY_USERS

[ACL]-TheACLisalistofnumbers,separatedbyspaces,withinsquarebrackets.Thenumbersrepresentthefollowingpermissions:1.AdministratorFull2.AdministratorR3.AdministratorRW4.AdministratorRWD5.CreatorFull6.CreatorRW7.WorldFull8.WorldR9.WorldRW10.WorldRWD11.PowerUsersFull12.PowerUsersRW13.PowerUsersRWD14.SystemOpFull15.SystemOpRW16.SystemOpRWD17.SystemFull18.SystemRW

19.SystemR20.AdministratorRWX

Examples:\Registry\Machine\System\CurrentControlSet\ENUM[1817]willgrant:1-AdministratorFullControl,8-EveryoneRead,and17-SystemFullControl.

\Registry\User\S-1-5-21-2053067395-480382929-641664369-1001\Software\StrangeSoftwareThingy[1817]-Sameasabove.

\Registry\Machine\System\CurrentControlSet\ENUM[817]-WillremovetheAdministratorgroupfromthefirstexample.

REG(fromtheResourceKitSupplement,notthefreewareattip170)hasaQueryoptionthatwillallowyoutodisplaykeysandsub-keys.TheJSIRegS.batfilewillapplythespecifiedACLtotheKeyandits'sub-keys.Theusageis:

JSIRegSScriptFile1[ScriptFile2ScriptFile3...ScriptFileN]

JSIRegS.batcontains:

@echooff:checkPushD<PathtoResourceKit>ifexist%TEMP%\JSIRegS.logdel/q%TEMP%\JSIRegS.logifexist%TEMP%\JSIRegS.inidel/q%TEMP%\JSIRegS.iniif/i"%1"==""gotosyntaxifexist%1gotoparse:syntax@echoINIfile%1notfoundorcontainsaninvalidentry.gotoend:hkusetreg=%reg:\Registry\User=HKU%

setreg=%reg:\registry\user=HKU%if/i"%reg%"=="%savekey%"gotoSsyntaxgotokey:parsefor/f"Tokens=1-2*Delims=[]"%%iin(%1)dosetreg=%%i!&setsec=%%jsetreg=%reg:!=%setsavekey=%reg%setreg=%reg:\Registry\Machine=HKLM%setreg=%reg:\registry\machine=HKLM%if/i"%reg%"=="%savekey%"gotohku:keyregini%1setreg="%reg%"regquery%reg%/s>>%TEMP%\JSIRegS.logfor/f"Tokens=*"%%iin('findstr/b"["%TEMP%\JSIRegS.log')docall:mkini"%%i"POPDsetreg=setsavekey=setsec=setsub=ifexist%TEMP%\JSIRegS.logdel/q%TEMP%\JSIRegS.logSHIFTif"%1"==""gotoendgotochck:mkinisetsub=%1setsub=%sub:[=%setsub=%sub:]=%setsub=%sub:"=%@echo%savekey%\%sub%[%sec%]>%TEMP%\JSIRegS.iniregini%TEMP%\JSIRegS.inidel%TEMP%\JSIRegS.ini:end

Q#1:HowdoIrunanexternalcommandlikeMSWord?

---------------------------------------------------------------------

A#1:Try:

Run,C:\\ProgramFiles\\MicrosoftOffice\\Office\\Winword.exe

Or

Run,%COMSPEC%/cC:\\ProgramFiles\\MicrosoftOffice\\Office\\Winword.exe

Or

Send,^{ESC}Rwinword{ENTER}

TheRuncommandcanbesubstitutedbyRunWait.TheonlydifferenceisthatRunWaitsuspendstheAutoItscriptuntiltheDOScommandhasfinished,andtheRuncommandallowstheAutoItscripttocontinueatthesametimeastheDOScommand.

-----------------------------------------------------------------------------

Q#2:IsthereawaytoactivatetheRunbox(Winkey-R)dialoguequickly(toexecutethecontentsoftheclipboard).AnyoneknowofsomekindofRundll32sequencethatwilldothis(activatetheRundialoguebox)orotherprogramsthatwilldothis?

IknowtheRundialogueboxonthestartmenuandcanWinkeytoitthatwaybutit'skindofiffyespeciallyifyouhaveotherprogramsstartingwithR.

I'vetriedthe"Run%Clipboard%"etc.,butnothingisaseffectiveastheRundialogueboxforfiguringoutthesyntaxofvariouscommandsandunderstandingspacesetc.

IthinkI'vetriedjustabouteverythingforexecutingtext(specificallyfor"executingtheclipboardtextcontents").NothingworksaseffectivelyforexecutingawidevarietyoftextcommandsasthatRundialoguebox.Asanexampleletmeillustrateasthefollowing2linesoftext:

Notepad"C:\Filewithspacesinit.txt"C:\Filewithspacesinit.txt

ThatRundialogueboxistheonlythingIknowofthatwillruneitherlinewithoutproblems.UsingyoursuggestionitseemsI'dbedoingsomethinglike:

SetEnv,variable,%COMSPEC%/c%CLIPBOARD%Run,%variable%

Orpossiblymoresimply:Run,%COMSPEC%/c%CLIPBOARD%

Thiswillworkforthefirstline:Notepad"C:\Filewithspacesinit.txt"

Butnotthesecond:C:\Filewithspacesinit.txt

Ifonetriestoaddtheextraquotesforthesecondline,thenthefirstlinewon'twork.

---------------------------------------------------------------------

A#1:IfyouwanttodoWinkey+R,try

send,{LWIN}R

{LWIN}R=LeftWindowskey+R(althoughitisn'tthesameasactuallyhittingthewinkeyandRtogether)

---------------------------------------------------------------------

A#2:Whataboutputtingtheapplicationtobeexecutedinan.INIfile,whichcanhavevariablesspecifiedhowyouwantthem(butagaintheymustfollowthespecificcriteriayou'vealreadybuiltintoyourscript(i.e.Aretheygoingtohavequotesornot,Willtheycalltheprogramandthefile,orlettheOSjudgewhichprogramtoopenthefile,etc...)

Ifthevariableof%CLIPBOARD%itselfissuchanuncontrolablefactor(possiblyenteredbytheuser,whichitmayormaynothaveQuotes,ormayormaynothavetheapplicationfollowedbythefilename)Thenperhapsyoushouldputlimitationsintothevariablewhichrejectanyinputgivenbytheuserthatdoesnothavequotesaroundit,orlistsomeexamplesfortheusersotheyknowwhatformatisaccepted,andwhatisnot.

NOTE:AnotherveryinterestingthingI'vefound,isthatIFthevariableyouwantexecutedisinan.INIfile(oranytextfileforthatmatter),thevariableDOESNOTneedtohavetheobligatory'\'preceedinganyspecialcharacter.thescriptreadsthevariablefromthe.INIfileorequiv.,thenthatvariablethenbecomes....'converted'toAuto-Itaccepted-lingo.

trythis;

setenv,variable,%COMSPEC%/cc:\\programfiles\\mydirectory\\myfile.exe\/switch1\/switch2run,%variable%

i.e.

insteadof;youcanhavethis;----------------------------------------------------------------\\\\server\\share\\file.exe\\Server\share\file.exe

c:\\directory\\file.exeC:\directory\file.exe%comspec%\/cc:\\directory\\file.exe%comspec%/cc:\directory\file.exe

etc...Ifanyonefindsanyflawsinthis,pleaseletmeknow...IhaveavariablepathdependingonwhichsystemIplantorunscriptsfrom,andittriesfirstoneofthepaths.Ifitfindsititexecutesit,ifnotittriesthenextpath/filelocation(asspecificedinthe.INIfile)insequence.

-----------------------------------------------------------------------------

Q#3:HowdoIplayaWAVfilefromwithinAutoIt?

---------------------------------------------------------------------

A#1:use:

Run,C:\windows\media\logoff.wav

andtheWAVfilewill"hijack"whateversoundplayeryouusetoplaythesound.IknowthereisasystemcallforthesoundsbutIdon'tknowwhatitis.

---------------------------------------------------------------------

A#2:Thisisthelinethatwindowsusestoplayawavfile.

"C:\ProgramFiles\WindowsMediaPlayer\mplayer2.exe"/Play"%L"

Thewaytogetthisinformationisto:*openanyfolderinwindowsexplorer.*Clickontheviewmenuandchooseoptions,*clickthefiletypestab*scrolldowntothefiletypeyouwant(inthiscase.wav).*Clickontheeditbutton

*Clickplayandeditagain.

Nowyouwillseetheapplicationusedtoperformthisactionandinthatwindowyouwillseetheaboveline.

replace"%L"with"c:\windows\media\hi.wav"orwhateveryourwavfileis.

-----------------------------------------------------------------------------

Q#4:Whydoesn'ttheDOScommandwindowclosewhenIdothis?

Run,"net""user:\\\\hotfurn1\\bin"doesn'twork

---------------------------------------------------------------------

A#1:Tryusing:

Run,%COMSPEC%/cnetuser:\\\\hotfurn1\\bin

Using"%comspec%/C"hastheadvantageofclosingthewindowafterthecommandfinishesinsteadofleavingitopen.-----------------------------------------------------------------------------

Q#5:Usingthescriptbelow,howcanImakesurethatthedefaultbrowseropensthehotmailsite?Iwouldliketohavethisjustforthedefaultbrowser.ItookalookattheOpencommandforHTMLFileintheregistryandithadthis:{Registrykey:

HKEY_CLASSES_ROOT\htmlfile\shell\open\command}"C:\PROGRA~1\Plus!\MICROS~1\iexplore.exe"-nohome

{Registrykey:HKEY_CLASSES_ROOT\http\shell\open\command}"C:\PROGRA~1\Plus!\MICROS~1\iexplore.exe"-nohome

HowwouldIstripthe-nohomefromthevariable?Arethereanystring

manipulationfunctionsinAutoIt?

Usingthislinedoesnotworkwitheitherbrowserasdefault...Run,http://www.hotmail.com,,

;=======ScriptStartsHere=======;============================================================;LogsintoaHotmailaccount;========================={ES11/01/00}======================

;GetthepathtoNetscapefromtheregistry;========================={ES01/11/01}======================;RegRead,NSPath,REG_SZ,HKEY_LOCAL_MACHINE,

SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\AppPaths\\Netscape.exe,;Run,%NSPath%http://www.hotmail.com,,

;GetthepathtoIEfromtheregistry;========================={ES11/01/00}======================;RegRead,IEPath,REG_SZ,HKEY_LOCAL_MACHINE,SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\AppPaths\\IEXPLORE.EXE,;Run,%IEPath%http://www.hotmail.com,,

WinWaitActive,Hotmail;========================={ES11/01/00}======================;Wait5seconds;========================={ES11/01/00}======================Sleep,5000

;========================={ES

11/01/00}======================;NolongerneededasHotmailnowusesjavascriptto;movethecursortotheUserIDfield;========================={ES11/01/00}======================;Youmayhavetochangethesecoordinatesdependinguponyourscreenresolution;LeftClick,260,210

;Replacexxxxxxxxwithyourusername:Send,xxxxxxxxSend,{TAB};========================={ES11/01/00}======================;Extratabisnowneeded;========================={ES11/01/00}======================Send,{TAB}

;Replaceyyyyyyyywithyourpassword:Send,yyyyyyyySend,{TAB}Send,{ENTER};=======ScriptEndsHere=======

---------------------------------------------------------------------

A#1:Trythis:

run,%comspec%/cstarthttp://www.hotmail.com,,min

Q#1:HowdoIoutputspacesthatareatthebeginningofaline?

---------------------------------------------------------------------

A#1:TheSENDcommandgobbleswhitespaceatthebeginningandendoflines.

Forexample:

samplefilesample.txt:

-----thisislineone-----thisislinetwo-----thisislinethree

********************************

;--sample.autfileFileReadLine,line1,C:\\sample.txt,1FileReadLine,line2,C:\\sample.txt,2FileReadLine,line3,C:\\sample.txt,3run,notepad.exewinwaitactive,Untitled

Send,%line1%{ENTER}Send,%line2%{ENTER}Send,%line3%{ENTER}

msgbox,0,test,%line1%\n%line2%\n%line3%

********************************

outputinmsgboxisfineoutputtonotepadis:-----thisislineone

-----thisislinetwo-----thisislinethree

Ifixedbydoingthefollowing:

Send,#%line1%{ENTER}Send,#%line2%{ENTER}Send,#%line3%{ENTER}

Thepoundsigndoesnotgetsent,butitdoesallowyoutodelineatethestartofthestring.

-----------------------------------------------------------------------------

Q#2:WithAutoITcanIworkwithexcelcells,i.e.:canIputvaluesinsidecells

---------------------------------------------------------------------

A#1:Yes.Thesamewayyouwouldnormallydokeystrokesandmouseclicks.Anexamplemightbethefollowingscriptlet.

;=======ScriptletStartsHere=======;PutEXCEL'sPATHintotheEXCELvariable.SetEnv,EXCEL,F:\\Apps\\Office97\\Office\\excel.exe;RuntheExcelprogram.Run,%EXCEL%

;WaitforExceltobereadyforinput.WinWaitActive,MicrosoftExcel

;GotocellsC1-C5andenter#'s&aformula;thatfinds10%ofthe4cellsaboveC5.Send,^Gc1{ENTER}22.5{ENTER}Send,^Gc2{ENTER}55.625{ENTER}Send,^Gc3{ENTER}12.75{ENTER}

Send,^Gc4{ENTER}103.31{ENTER}.Send,^Gc5{ENTER}=sum(C1-C4)/100*10;=======ScriptletEndsHere=======

Q#1:I'vegotascriptwhereIwanttoaddnetworkprinters.ItappearsthatIcan'tgetthebackslash"\"tobeinput.ForexampleIwanttotypein::

\\servername\.sys.vol1.servername

TheoutputIgetis:

\servername.sys.vol1.servername

---------------------------------------------------------------------

A#1:Inordertogetabackslash"\",youmustuseabackslashinfront,Fortwobackslashesinyourscript,usefour.Foronebackslashusetwo.Usingyourexample,youwouldneedtoenterthelineasfollows;

\\\\servername\\.sys.vol1.servername

-----------------------------------------------------------------------------

Q#2:InrelationtostartingtheAddPrinterwizardunderWindows95.Thecommandlineis-

rundll32.exesysdm.cpl,InstallDevice_RundllPrinter

butAutoItthinksthatanythingafterthe','istheworkingdirectory.Anybodyknowaworkaroundforthisone?

---------------------------------------------------------------------

A#1:Tryputtingabackslash(\)infrontofthecomma.

-----------------------------------------------------------------------------

Q#3:Whydoesn't:

run,"net""user:\\hotfurn1\bin"

work?

---------------------------------------------------------------------

A#1:Tryusing

Run,netuser:\\\\hotfurn1\\bin

instead.What'sbeenoverlookedisthatthebackslashisanescapecharacterinAutoIt,soyouhavetoputittwice.

Q#1:IwanttousetheSplashTextcommandtoshowthestatusofmyinstallationprocess.Idon'twantittobeinthemiddleofthescreen,Iwanttoplaceitontheupperleftcorner,Isthereawaytodothat.

---------------------------------------------------------------------

A#1:Displaythesplashtextscreen,andthenmoveittothenewlocation.;=======ScriptletStartsHere=======SplashTextOn,300,300,InstallationinProgress,Part1of10WinMove,InstallationinProgress,,20,20,default,defaultSplashTextOn,300,300,InstallationinProgress,Part2of10WinMove,InstallationinProgress,,20,20,default,defaultSplashTextOn,300,300,InstallationinProgress,Part3of10WinMove,InstallationinProgress,,20,20,default,default...;=======ScriptletEndsHere=======

etc.Yougettheidea.

-----------------------------------------------------------------------------

Q#2:CanapicturebeputintheSplashTextwindow?

---------------------------------------------------------------------

A#1:Unfortunately,no.ThereispresentlynowaytoputapictureintotheSplashTextwindow.

Q#1:HowdoIremovespacesfromastring?IamremovingspacesfromtelephonenumbersasIamusinginifilesasdatastorageforconnection(plusother)informationaboutremotesites.Whilemycurrentmodemwillpausefor5secsonaspacemyISDNTA"see's"aspaceasadelimeteri.e.thenumber01234567890wouldbetodial01234usingsecurityprotocol567890(whichisinvalid)

Ihaveattemptedtousethe

StringReplace,Number,No,,andStringReplace,Number,No,"",

function,butitwon'tfindspaces.IhaveattemptednibblingtheVariable(1charatatime)

;=======ScriptletStartsHere=======Start:StringLeft,TST,No,1StringTrimLeft,No2,No,1SetEnv,No,%No2%IfNotEqual,TST,,SetEnv,%Number%%TST%Goto,Start;=======ScriptletEndsHere=======

butIlosethewholethingthenandIdon'tknowwhyItshouldaddthechars1byonetotheNumbervariableunlessitisaspace.

---------------------------------------------------------------------

A#1:Usethespacetrimmingtoyouradvantage!Thisworksifyoujustwanttoremovespaces.Ifyouwanttoreplacethemwithsomethingelseitdoesn'twork.

;=======ScriptletStartsHere=======;Forageneralremovalofspaces:

SetEnv,test,thisisatestAreallygoodtestSetEnv,Output,loop:StringLeft,dummy,test,1SetEnv,Output,%output%%dummy%StringTrimLeft,test,test,1IfNotEqual,test,,goto,loopMsgBox,0,test,%output%;=======ScriptletEndsHere=======

---------------------------------------------------------------------

A#2:DumpthedatatoainifileandstripallthespaceswithanexternalprogramsuchasGSAR(generalsearchandreplace(DOS)).

;=======ScriptletStartsHere=======FileReadLine,No,numbers.txt,%Ln%IniWrite,%No%,temp.ini,Temp,NumberRunWait,%COMSPEC%/Cgsar-io"-s"-r%S%temp.ini,c:\\temp,MinIniRead,Number,temp.ini,Temp,Number;=======ScriptletEndsHere=======

---------------------------------------------------------------------

A#3:YoucandoascriptwithKiXtart95...Allyouneedisawaytomakethetwoscriptscomunicatewithaninifile.

Firstofall,youneedtofindtheplaceofeachspace,thenyoubegintoremovethemfromendtostart...

you'lldosomethinglike:

;=======KixtartScriptletStartsHere=======$InputStringLen=Len($InputString)$FirstStringChar=$SpaceChar-1$SecondStringChar=$SpaceChar+1$FirstString=SubStr($InputString,0,

$FirstStringChar)$SecondString=SubStr($InputString,$SecondStringChar,$InputStringLen)$CoolString=$FirstString+$SecondString;=======KixtartScriptletEndsHere=======

Thiswayyoucanremovethespa

-----------------------------------------------------------------------------

Q#2:ThisisthefirsttimeIuseastringcommand.Ihavemadethis:;=======ScriptletStartsHere=======WinGetActiveTitle,CLIPBOARDStringLeft,CLIPBOARD,PROGNAME,10IfNotEqual,PROGNAME,EPLAN5.30,Goto,exit;=======ScriptletEndsHere=======Igetanerroronthelinewithstringleft.WhatamIdoingwrong?

---------------------------------------------------------------------

A#1:Changethelineto

StringLeft,PROGNAME,CLIPBOARD,10

Thesyntaxis:

StringLeft,<OutputVar>,<InputVar>,<numberofcharstoextract>

-----------------------------------------------------------------------------

Q#3:Isthereawaytoreturnthepositionofasubstringwithinastring?Iwanttodeletealltextfromthebeginningofalineuptoacolon.

---------------------------------------------------------------------

A#1:Use"StringGetPos".

---------------------------------------------------------------------

A#2:Ifyoudon'thaveversion2.6orabove,thentrysomethinglike

;=======ScriptletStartsHere=======Setenv,test,Thisisastring:TestStringstringlen,strlen,testsetenv,count,1loop:stringmid,strtest,test,%count%,1ifequal,strtest,:,goto,founditenvadd,count,1ifgreater,count,%strlen%,goto,notfoundgoto,loopfoundit:stringmid,output,test,%count%,%strlen%msgbox,0,Result,Theresultingstringis%output%goto,endnotfound:msgbox,0,Error,Nocolonfoundend:;=======ScriptletEndsHere=======

note,ifyoudon'twantthecolon,addonetothecountbeforegettingtheoutputstring

-----------------------------------------------------------------------------

Q#4:Isthereadetecteddifferencebetweenreadingalinewithablankspaceandcarriagereturnvs.justacarriagereturn?

---------------------------------------------------------------------

A:Yes.Foranexampletry:

;=======ScriptletStartsHere=======Filereadline,test1,c:\\testspace.txt,1Setenv,test2,--%test1%--IfEqual,test2,----,Msgbox,0,Test,Thereisaspace!IfEqual,test2,----,Msgbox,0,Test,Thereisnospace!;=======ScriptletEndsHere=======

Q#1:Ihaveascript:

;=======ScriptletStartsHere=======setenv,Sample,AutoItsetenv,a,Samplestringleft,\%a\%,a,1,8MsgBox,0,AutoIt,Sample=%Sample%;a=%a%stringleft,%a%,a,1,8MsgBox,0,AutoIt,Sample=%Sample%;a=%a%;=======ScriptletEndsHere=======

AftersecondstringleftcontentofSample-"AutoIt"convertsinto"S".Why?

--------------------------------------------------------------

A#1:ThesyntaxofStringleftis:

StringLeft,<OutputVariable>,<InputVariable>,<#ofcharstoextract>

sowhydoyouhavethe'1'andthe'8'whenthereissupposedtobeonlyonenumber?

hereiswhatyouareactuallydoing

thefirststringleftcommandissettinganenvironmentvariable'%a%'Not'a'butacompletelydifferentvariable.Unfortunately,youcannotretrievethisvariable.

Inthesecondstringleftcommand:

stringleft,%a%,a,1,8

the%a%isconvertedto'Sample'andgiventhefirstcharacterofthevariable'a'(a=Sample,firstchar=s)

whatyouarereallysayinginPseudoBasicis

%a%=left(a,1)

whichislikesaying

Sample=left("Sample",1)

whichislikesaying

Sample="S"

Whichiswhatyougot.

---------------------------------------------------------------------

IaddedtwolinestocorrectcontentSample:

;=======ScriptletStartsHere=======setenv,Sample,AutoItsetenv,a,Samplestringleft,\%a\%,a,1,8MsgBox,0,AutoIt,Sample=%Sample%;a=%a%stringleft,%a%,a,1,8MsgBox,0,AutoIt,Sample=%Sample%;a=%a%stringreplace,%a%,a,S,AutoItMsgBox,0,AutoIt,Sample=%Sample%;a=%a%;=======ScriptletEndsHere=======

buthave"AutoItample"?

Youaremisunderstandingthecommands

Aftertheline

stringleft,%a%,a,1,8

a=Sample

Sample=S

thenextline:stringreplace,%a%,a,S,AutoIt

becomes

stringreplace,Sample,a,S,AutoIt

whichisequivalentto(inBasic)

Sample=replace(a,"S","AutoIt")

whichevaluatesto

Sample=replace("Sample","S","AutoIt")

whichevaluatesto

Sample=AutoItample

Yourcommandissaying:replaceall"S"inthevariableawiththeword"AutoIt"andputtheresultinthevariableSample.

---------------------------------------------------------------------

Ifthelasttwolinesarechangedto:

;=======ScriptletStartsHere=======setenv,Sample,AutoItsetenv,a,Samplestringleft,\%a\%,a,1,8MsgBox,0,AutoIt,Sample=%Sample%;a=%a%stringleft,%a%,a,1,8MsgBox,0,AutoIt,Sample=%Sample%;a=%a%stringreplace,%a%,%a%,S,AutoItMsgBox,0,AutoIt,Sample=%Sample%;a=%a%

;=======ScriptletEndsHere=======

Thescriptworksthewayitwasintended.

-----------------------------------------------------------------------------

Q#2:IknowitispossibletouseDOSvariablesinAutoitbyreferingtothembetweenpercentagesymbols,buthowdoyouexportanAutoItvariabletoDOS?

I'vetriedthefollowingscripttodiscoverthecurrentlyloggedinuser:

RegRead,AUsername,REG_SZ,HKEY_LOCAL_MACHINE,Network\\Logon,usernamerun,%comspec%/csetusername=%Ausername%

---------------------------------------------------------------------

A#1:Thevariableyouaresettingexistsonlywithinthe%comspec%sessioninwhichitiscreatedanddisappearsimmediatelywhen%comspec%terminates,whichinthiscaseisassoonastheSETcommandisexecuted.Whatyouaretryingtodoiscreatethevariableinthe*global*environment,andthewaytodothatdiffersdependingontheplatform:OnWin9x,youmustusetheWinSetutility(availableontheWin9xCD-ROM).OnWinNT/2000,youmustusetheSetXutilityavailableintheNTor2000ResourceKit.YoucanlaunchbothoftheseutilitiesfromwithinAutoIt(usingRunorRunWait).

---------------------------------------------------------------------

A#2:Youcandiscoverthecurrentlylogged-inIDbyexecutingthecommandNETCONFIGinaDOSbox.

---------------------------------------------------------------------

A#3:InWindowsNT&2000,thereisalreadyavariablewiththeusername

init.Ibelieveitis%username%.