Snippets ( AutoIt ): Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
(Converted all snippets to the Template:Snippet Header)
mNo edit summary
Line 3: Line 3:
{{Snippet Credit Header}}
{{Snippet Credit Header}}


{{Snippet Header|AutoItWinShow|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=AutoItWinShow|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
#include <GUIConstantsEx.au3>
#include <GUIConstantsEx.au3>


Line 29: Line 29:
}}
}}


{{Snippet Header|AutoItWinGetText|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=AutoItWinGetText|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
Example()
Example()


Line 74: Line 74:
}}
}}


{{Snippet Header|_DockToWindow|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_DockToWindow|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
#include <GUIConstantsEx.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WinAPI.au3>
Line 126: Line 126:
}}
}}


{{Snippet Header|_FuncExists|52-geosoft|GEOSoft|||1|AutoItCode=
{{Snippet Header|UDFName=_FuncExists|52-geosoft|GEOSoft|ReturnToTop=1|AutoItCode=
MsgBox(0, "TEST", "Function Exists = " & _FuncExists("_FuncExists", @ScriptFullPath))
MsgBox(0, "TEST", "Function Exists = " & _FuncExists("_FuncExists", @ScriptFullPath))


Line 139: Line 139:
}}
}}


{{Snippet Header|_FunctionSort|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_FunctionSort|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
; Get the list of Functions in a script and sort by alphabetical order.
; Get the list of Functions in a script and sort by alphabetical order.


Line 175: Line 175:
}}
}}


{{Snippet Header|_IsButton|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_IsButton|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
#include <ButtonConstants.au3>
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <Constants.au3>
Line 223: Line 223:
}}
}}


{{Snippet Header|_IsControlID|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_IsControlID|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
; Check if a Control ID is a native AutoIt control.
; Check if a Control ID is a native AutoIt control.


Line 258: Line 258:
}}
}}


{{Snippet Header|_GetAutoItIncludesFromSciTE|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_GetAutoItIncludesFromSciTE|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
#include <WinAPIEx.au3>
#include <WinAPIEx.au3>


Line 274: Line 274:
}}
}}


{{Snippet Header|_GetAutoItInstall|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_GetAutoItInstall|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
; Get the AutoIt installation folder.
; Get the AutoIt installation folder.


Line 284: Line 284:
}}
}}


{{Snippet Header|_GetAutoItInstallEx|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_GetAutoItInstallEx|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
ConsoleWrite(_GetAutoItInstallEx() & @CRLF)
ConsoleWrite(_GetAutoItInstallEx() & @CRLF)


Line 305: Line 305:
}}
}}


{{Snippet Header|_GetAutoItInstallFromSciTE|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_GetAutoItInstallFromSciTE|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
ConsoleWrite(_GetAutoItInstallFromSciTE() & @CRLF)
ConsoleWrite(_GetAutoItInstallFromSciTE() & @CRLF)


Line 318: Line 318:
}}
}}


{{Snippet Header|_GetClasses|24-cyberslug|CyberSlug|||1|AutoItCode=
{{Snippet Header|UDFName=_GetClasses|AuthorURL=24-cyberslug|CyberSlug|ReturnToTop=1|AutoItCode=
; Get ALL Controls Info
; Get ALL Controls Info


Line 374: Line 374:
}}
}}


{{Snippet Header|_GetFile|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_GetFile|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
; FileRead Alternative
; FileRead Alternative


Line 388: Line 388:
}}
}}


{{Snippet Header|_GetTitle|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_GetTitle|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
; Get the title of your program.
; Get the title of your program.


Line 401: Line 401:
}}
}}


{{Snippet Header|_GetXML|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_GetXML|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
; Simple Way Of Parsing XML Data.
; Simple Way Of Parsing XML Data.


Line 423: Line 423:
}}
}}


{{Snippet Header|Include Source With Exe|54985-jlogan3o13|JLogan3o13|||1|AutoItCode=
{{Snippet Header|UDFName=Include Source With Exe|54985-jlogan3o13|AuthorName=JLogan3o13|ReturnToTop=1|AutoItCode=
;recover source .au3 file with /Extract switch
;recover source .au3 file with /Extract switch
; The above code would be copied into the top of your script. The source location (C:\Test.au3 in my example) is the full path to your script file.
; The above code would be copied into the top of your script. The source location (C:\Test.au3 in my example) is the full path to your script file.
Line 433: Line 433:
}}
}}


{{Snippet Header|_IsANSIFile|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_IsANSIFile|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
#include <FileConstants.au3>
#include <FileConstants.au3>


Line 443: Line 443:
}}
}}


{{Snippet Header|_IsUnicodeFile|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_IsUnicodeFile|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
#include <FileConstants.au3>
#include <FileConstants.au3>


Line 453: Line 453:
}}
}}


{{Snippet Header|_IsAu3File|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_IsAu3File|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
ConsoleWrite(_IsAu3File(@AutoItExe) & @CRLF)
ConsoleWrite(_IsAu3File(@AutoItExe) & @CRLF)
ConsoleWrite(_IsAu3File(@ScriptFullPath) & @CRLF)
ConsoleWrite(_IsAu3File(@ScriptFullPath) & @CRLF)
Line 463: Line 463:
}}
}}


{{Snippet Header|_IsDefault|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_IsDefault|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
If _IsDefault(Default) Then
If _IsDefault(Default) Then
     MsgBox(0, "_IsDefault() - 1", "This was a Default variable.")
     MsgBox(0, "_IsDefault() - 1", "This was a Default variable.")
Line 481: Line 481:
}}
}}


{{Snippet Header|_IsInTrial|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_IsInTrial|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
#include <Date.au3> ; Required for _DateDiff()
#include <Date.au3> ; Required for _DateDiff()


Line 495: Line 495:
}}
}}


{{Snippet Header|_IsVisible|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_IsVisible|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
; Check if the Notepad Window is visible.
; Check if the Notepad Window is visible.


Line 524: Line 524:
}}
}}


{{Snippet Header|Open help file to desired page|1967-garyfrost|GaryFrost|||1|AutoItCode=
{{Snippet Header|UDFName=Open help file to desired page|AuthorURL=1967-garyfrost|AuthorName=GaryFrost|ReturnToTop=1|AutoItCode=
; Open help file / Open a desired page
; Open help file / Open a desired page


Line 532: Line 532:
}}
}}


{{Snippet Header|_RunAU3|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_RunAU3|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
_RunAU3("AU3_Example.txt", '"This is a commandline example!"')
_RunAU3("AU3_Example.txt", '"This is a commandline example!"')


Line 549: Line 549:
}}
}}


{{Snippet Header|Run Any Au3 File From Your Program|4920-valuater|Valuater|||1|AutoItCode=
{{Snippet Header|UDFName=Run Any Au3 File From Your Program|AuthorURL=4920-valuater|AuthorName=Valuater|ReturnToTop=1|AutoItCode=
; Run Any Au3 File From Your Program
; Run Any Au3 File From Your Program


Line 563: Line 563:
}}
}}


{{Snippet Header|_ScriptName|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_ScriptName|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
ConsoleWrite(_ScriptName() & @CRLF)
ConsoleWrite(_ScriptName() & @CRLF)


Line 572: Line 572:
}}
}}


{{Snippet Header|_ScriptVersion|31149-milesahead|MilesAhead|||1|AutoItCode=
{{Snippet Header|UDFName=_ScriptVersion|AuthorURL=31149-milesahead|AuthorName=MilesAhead|ReturnToTop=1|AutoItCode=
#NoTrayIcon
#NoTrayIcon


Line 624: Line 624:
}}
}}


{{Snippet Header|_SetFile|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_SetFile|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
; FileWrite Alternative
; FileWrite Alternative


Line 641: Line 641:
}}
}}


{{Snippet Header|_ShowHelp|60350-chimaera|Chimaera|||1|AutoItCode=
{{Snippet Header|UDFName=_ShowHelp|AuthorURL=60350-chimaera|AuthorName=Chimaera|ReturnToTop=1|AutoItCode=
HotKeySet("{F1}", "_ShowHelp")
HotKeySet("{F1}", "_ShowHelp")


Line 649: Line 649:
}}
}}


{{Snippet Header|_SingletonPID|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_SingletonPID|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
Local $iSingleton = _SingletonPID('RandomName', 1)
Local $iSingleton = _SingletonPID('RandomName', 1)


Line 690: Line 690:
}}
}}


{{Snippet Header|_Sort|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_Sort|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
#include <Constants.au3>
#include <Constants.au3>


Line 713: Line 713:
}}
}}


{{Snippet Header|Speak Object and Save to WAV File|52278-solidsnake26|SolidSnake26|||1|AutoItCode=
{{Snippet Header|UDFName=Speak Object and Save to WAV File|AuthorURL=52278-solidsnake26|AuthorName=SolidSnake26|ReturnToTop=1|AutoItCode=
; Speak Object and save to wav file
; Speak Object and save to wav file


Line 731: Line 731:
}}
}}


{{Snippet Header|_VariableSwap|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_VariableSwap|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
Global $sString_1 = 'This is string 1.'
Global $sString_1 = 'This is string 1.'
Global $sString_2 = 'This is string 2.'
Global $sString_2 = 'This is string 2.'
Line 751: Line 751:
}}
}}


{{Snippet Header|_WinAPI_CharLower|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_WinAPI_CharLower|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
;Convert characters to upper or lower case
;Convert characters to upper or lower case


Line 766: Line 766:
}}
}}


{{Snippet Header|_WinAPI_CharUpper|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_WinAPI_CharUpper|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
;Convert characters to upper or lower case
;Convert characters to upper or lower case


Line 781: Line 781:
}}
}}


{{Snippet Header|_WinAPI_PathFileExists|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_WinAPI_PathFileExists|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
; An API Alternative To FileExist.
; An API Alternative To FileExist.


Line 798: Line 798:
}}
}}


{{Snippet Header|_WinActiveByExe|4813-smoke-n|SmOke_N|||1|AutoItCode=
{{Snippet Header|UDFName=_WinActiveByExe|AuthorURL=4813-smoke-n|AuthorName=SmOke_N|ReturnToTop=1|AutoItCode=
; Window Active/Activate by Exe, Open Notepad whilst script is running
; Window Active/Activate by Exe, Open Notepad whilst script is running


Line 827: Line 827:
}}
}}


{{Snippet Header|_WindowShake|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_WindowShake|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
; Shake a window left to right.
; Shake a window left to right.


Line 867: Line 867:
}}
}}


{{Snippet Header|_WinGetDetails|35302-guinness|guinness|||1|AutoItCode=
{{Snippet Header|UDFName=_WinGetDetails|AuthorURL=35302-guinness|AuthorName=guinness|ReturnToTop=1|AutoItCode=
#include <Array.au3>
#include <Array.au3>


Line 908: Line 908:
}}
}}


{{Snippet Header|_WinGetNumeratedClassList|20477-mrcreator|MrCreatoR|||1|AutoItCode=
{{Snippet Header|UDFName=_WinGetNumeratedClassList|AuthorURL=20477-mrcreator|AuthorName=MrCreatoR|ReturnToTop=1|AutoItCode=
; Description: Retrieves the numerated classes from a window.
; Description: Retrieves the numerated classes from a window.


Line 941: Line 941:
}}
}}


{{Snippet Header|_WinGetHandleByPID|4813-smoke-n|SmOke_N|||1|AutoItCode=
{{Snippet Header|UDFName=_WinGetHandleByPID|AuthorURL=4813-smoke-n|AuthorName=SmOke_N|ReturnToTop=1|AutoItCode=
; Get Window Handle by PID
; Get Window Handle by PID



Revision as of 04:20, 12 November 2012


Please always credit an author in your script if you use their code. It is only polite.


Author: guinness








Author: guinness








Author: guinness








{{{AuthorName}}}








Author: guinness








Author: guinness








Author: guinness








Author: guinness








Author: guinness








Author: guinness








Author: guinness








Author: {{{AuthorName}}}








Author: guinness








Author: guinness








Author: guinness








JLogan3o13








Author: guinness








Author: guinness








Author: guinness








Author: guinness








Author: guinness








Author: guinness








Author: GaryFrost








Author: guinness








Author: Valuater








Author: guinness








Author: MilesAhead








Author: guinness








Author: Chimaera








Author: guinness








Author: guinness








Author: SolidSnake26








Author: guinness








Author: guinness








Author: guinness








Author: guinness








Author: SmOke_N








Author: guinness








Author: guinness








Author: MrCreatoR








Author: SmOke_N