Jump to content

AutoIt Snippets


Chimaera
 Share

Recommended Posts

Welcome to the AutoIt Snippets thread

This section is dedicated to small reusable pieces of AutoIt code i.e. Snippets

They can be added to your script to give extra functionality without writing extra code. they are varied and cover many subjects like GUI's, Maths, Networking and many others.

Posted Image Autoit Snippets

Please visit the link above and you will find many examples to help you.

Many thanks for all the work from everybody who contributed to the original Autoit Wrappers thread created by Valuater which gave us the starting point for the Wiki, and those who added their code to it like Valuater, guinness, SmOke_N, GEOSoft, Zedna, Mhz, GaryFrost and many others.

Submitting Code Instructions

We would also like you to have a look through your saved code and if you have examples that would be usefull to others then submit them so they can be added to the wiki for the benefit of all.

After you have submitted one they will remain on the thread for a short while and after it has been added to the Wiki it will be removed from the thread shortly afterwards to keep the submissions current.

Take this example by guinness

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7

; Checks To See If The Internet Is Connected

ConsoleWrite("Internet Is Connected" & " = " & _IsInternetConnected() & @CRLF) ; ( Returns "True" Or "False" )

Func _IsInternetConnected()
    Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected')
    If @error Then
        Return SetError(1, 0, False)
    EndIf
    Return $aReturn[0] = 0
EndFunc ;==>_IsInternetConnected

This is how we would like them submitted so that whoever uses the example can paste it in SciTE and it gives a result [MsgBox / ConsoleWrite Etc] that the user can see and understand.

They don't have to be in a Function like the above example (Although that will be the preferred option), but they must have a way of calling the code so it gives a reproducible result.

A few points to note for submissions:

1: All code to be submitted must be run with this line and have no errors or warnings.

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7

2: Please use Tidy on your scripts before you submit them

3: Although it is our aim to transfer all posted scripts into the Wiki listings, the final decision to do so is entirely at the discretion of the editorial panel.

Remember this is NOT a UDF thread, Snippets are small functions pieces of code not large ones, if your code has more than 2-3 functions in it, you may be better looking at making a UDF.

Instructions on how to make one are to be found here. UDF Standards

I hope you will make use of this section and add too it to make it better for all who use AutoIt

Many thanks to guinness and Melba23 for their help and advice whilst the section was being made Posted Image

As the Wiki is now open for editing this is the template ive used to add the sections so far In the Snippets Section

This code is for adding to the Wiki only it will not work in AutoIt

Quote

=== Your Title Goes Here ===

{{Snippet Header

| AuthorURL=35302-guinness <<<<< Change To Your Name Here ( Copy User Name Link Location to get the entry number e.g. forum/user/35302-guinness)

| AuthorName=guinness <<<<< Change To Your Name Here

}}

<syntaxhighlight lang="autoit">

Your AutoIt Snippet Code goes here between the syntax highlights so it shows like AutoIt would show it.

</syntaxhighlight>

[[#top | ReturnToContents]]

Leave the rest unchanged so they are similar and uniform.

Note:

Can we keep conversation in this thread to a minimum please, as this sections posts are deleted as they are added to the wiki, so if your chatting about a piece of code it will deleted as well.

Better to discuss elsewhere, Thanks.

Enjoy your coding

Edited by Melba23
Link to comment
Share on other sites

  • 2 months later...

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7

; Dumps a string in three lines as character, hex and decimal. A new output block is started after $iLength characters

_StringDump("1234567890" & @CRLF & "abcdefghij", 5)
Exit

Func _StringDump($sString, $iLength)

    Local $sStringAsc, $sStringDec, $sStringHex, $sChar, $iIndex, $iPos = 1
    For $iIndex = 1 To StringLen($sString)
        $sChar = StringMid($sString, $iIndex, 1)
        If Asc($sChar) >= 32 Then
            $sStringAsc = $sStringAsc & "  " & $sChar & " "
        Else
            $sStringAsc = $sStringAsc & "  . "
        EndIf
        $sStringHex = $sStringHex & " " & Hex(Asc(StringMid($sString, $iIndex, 1)), 2) & " "
        $sStringDec = $sStringDec & StringRight("00" & Asc(StringMid($sString, $iIndex, 1)), 3) & " "
    Next
    While $iPos < StringLen($sString)
        ConsoleWrite(StringStripWS(StringMid($sStringAsc, ($iPos * 4) - 3, $iLength * 4), 2) & @LF)
        ConsoleWrite(StringStripWS(StringMid($sStringHex, ($iPos * 4) - 3, $iLength * 4), 2) & @LF)
        ConsoleWrite(StringStripWS(StringMid($sStringDec, ($iPos * 4) - 3, $iLength * 4), 2) & @LF & @LF)
        $iPos += $iLength
    WEnd

EndFunc   ;==>_StringDump

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 3 weeks later...

A couple of small tweaks to the function Random()

MsgBox(0, "", _Random(-1)) ; Example

Func _Random($nNum1 = 0, $nNum2 = 0, $iFlag = 0)
    If Not IsNumber($nNum1) Then Return SetError(1, 0, 0) ; Invalid 1st parameter
    Switch @NumParams
        Case 0
            Return Random()
        Case 1
            If $nNum1 < 0 Then Return -Random(-$nNum1)
            Return Random($nNum1)
        Case Else
            If Not IsNumber($nNum1) Or ($iFlag <> 0 And $iFlag <> 1) Then Return SetError(2, 0, 0) ; Invalid 2nd or 3rd parameter
            If $nNum1 = $nNum2 Then Return $nNum1
            If $nNum2 > $nNum1 Then Return Random($nNum1, $nNum2, $iFlag)
            Return Random($nNum2, $nNum1, $iFlag)
    EndSwitch
EndFunc

One parameter returns a value between that number and zero. Two parameters return a random number between the two numbers - the order they appear is irrelevant. Two equal parameters return the actual number. The flag behaves exactly as it does with the native AutoIt function.

Edited by czardas
Link to comment
Share on other sites

UDFs to write and/or remove comments from an INI file.

#include-once
#include <File.au3>
#include <array.au3>
;Test function to write comments to an ini file
Global $IniFile = @ScriptDir & "\Test.ini"
FileOpen($IniFile, 2)
IniWrite($IniFile, "Test1", 1, 1)
IniWrite($IniFile, "Test1", 2, 2)
IniWrite($IniFile, "Test1", 3, 3)
IniWrite($IniFile, "Test1", 4, 4)
IniWrite($IniFile, "Test2", 1, 1)
IniWrite($IniFile, "Test2", 2, 2)
IniWrite($IniFile, "Test2", 3, 3)
IniWrite($IniFile, "Test3", 1, 1)
IniWrite($IniFile, "Test3", 2, 2)
IniWrite($IniFile, "Test3", 3, 3)
Global $Test = _IniWriteSectionComment($IniFile, "Test1", "This is a comment that comes before a section name", 1)
$Test = _IniWriteSectionComment($IniFile, "Test2", "This is a comment that comes after a section name", 0)
$Test = _IniWriteSectionComment($IniFile, "Test3", "This is a multi-line comment|that comes after a section name", 0)
$Test = _IniWriteSectionComment($IniFile, "Test4", "This will cause an error by referencing a non-existent section name", 0)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Test = ' & $Test & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$Test = _IniWriteSectionComment($IniFile, "Test3", "This is a NEW multi-line comment|that comes after a section name", 0)
$Test = _IniWriteSectionComment($IniFile, "Test3", "This is a multi-line comment|that comes before a section name", 1)
;~ $Test = _IniStripComments($IniFile, 0, "Test3", 1) ; This will strip the comments from before the section Test3
; #FUNCTION# ====================================================================================================================
; Name...........: _IniWriteSectionComment
; Description ...: Writes comment(s) to an .ini file
; Syntax.........: _IniWriteSectionComment($IWSC_FileName, $IWSC_SectionName, $IWSC_Comment[, $IWSC_ForeAft = 1])
; Parameters ....: $IWSC_FileName      - String path of the file to write to.
;                 $IWSC_SectionName    - The section of the ini file to comment.
;                 $IWSC_Comment     - String that contains the comment for the section name.
;                 $IWSC_ForeAft     - Optional: Specifies where to put the comment in relation to the section name
;                                        default is before the section name.
; Return values .: Success - Returns a 1
;                 Failure - Returns a 0
;                 @Error  - 0 = No error.
;                 |1 = file not found
;                 |2 = Could not read/split file
;                 |3 = Not an .ini file
;                 |4 = Section Name not found
; Author ........: Bob Marotte (BrewManNH)
; Modified.......:
; Remarks .......: $IWSC_ForeAft specifies whether to put the comments before or after the section name, 1 = before/0 = after
;                 To write multiline comments, separate the lines with the "|" (pipe) character, see example below.
; Related .......:
; Link ..........:
; Example .......: $Test = _IniWriteSectionComment($IniFile, "Settings", "Now is the time for all good|men to come to the aid of their country", 1)
; ===============================================================================================================================
Func _IniWriteSectionComment($IWSC_FileName, $IWSC_SectionName, $IWSC_Comment, $IWSC_ForeAft = 1)
 Local $aFileRead
 If FileExists($IWSC_FileName) Then
  Local $IWSC_fHnd = FileOpen($IWSC_FileName, 0)
  If $IWSC_fHnd = -1 Then
   Return SetError(2, 0, 0)
  EndIf
  Local $Return = _FileReadToArray($IWSC_FileName, $aFileRead)
  If $Return = 0 Then
   Return SetError(2, 0, 0)
  EndIf
  Local $aSectionNames = IniReadSectionNames($IWSC_FileName)
  If @error Then
   Return SetError(3, 0, 0)
  EndIf
  If _ArraySearch($aSectionNames, $IWSC_SectionName) < 0 Then
   Return SetError(4, 0, 0)
  EndIf
  Local $aTempArray = StringSplit($IWSC_Comment, "|")
  Local $IWSC_Index = _ArraySearch($aFileRead, "[" & $IWSC_SectionName & "]")
  Local $aHolder[UBound($aFileRead) + UBound($aTempArray) - 1]
  If $IWSC_ForeAft Then
   For $I = 0 To $IWSC_Index - 1
    $aHolder[$I] = $aFileRead[$I]
   Next
   For $I = $IWSC_Index To $aTempArray[0] + $IWSC_Index - 1
    $aHolder[$I] = "; " & $aTempArray[$I - ($IWSC_Index - 1)]
   Next
   For $I = $IWSC_Index To $aFileRead[0]
    $aHolder[$I + $aTempArray[0]] = $aFileRead[$I]
   Next
  Else
   For $I = 0 To $IWSC_Index
    $aHolder[$I] = $aFileRead[$I]
   Next
   For $I = $IWSC_Index + 1 To $aTempArray[0] + $IWSC_Index
    $aHolder[$I] = "; " & $aTempArray[$I - ($IWSC_Index)]
   Next
   For $I = $IWSC_Index + 1 To $aFileRead[0]
    $aHolder[$I + $aTempArray[0]] = $aFileRead[$I]
   Next
  EndIf
  _ArrayDelete($aHolder, 0)
  _FileWriteFromArray($IWSC_FileName, $aHolder)
 Else
  Return SetError(1, 0, 0)
 EndIf
 Return SetError(0, 0, 1)
EndFunc   ;==>_IniWriteSectionComment
; #FUNCTION# ====================================================================================================================
; Name...........: _IniStripComments
; Description ...: Strips comment(s) from an .ini file
; Syntax.........: _IniStripComments($ISC_FileName[, $ISC_All = 1[, $ISC_SectionName=""[, $ISC_ForeAft = 1]]])
; Parameters ....: $ISC_FileName        - String path of the file to work with
;                 $ISC_All           - Strip all comments in the ini file (default is yes)
;                 $ISC_SectionName   - The section of the ini file to strip comments from, can not be left blank.
;                 $ISC_ForeAft       - Optional: Specifies where to strip the comments in relation to the section name
;                                        default is before the section name.
; Return values .: Success - Returns a 1
;                 Failure - Returns a 0
;                 @Error  - 0 = No error.
;                 |1 = file not found
;                 |2 = Could not read/split file
;                 |3 = Not an .ini file
;                 |4 = Section Name not found or not specified
; Author ........: Bob Marotte (BrewManNH)
; Modified.......:
; Remarks .......: $ISC_ForeAft specifies whether to strip the comments before or after the section name, 1 = before/0 = after
;                 If you use the $ISC_All = 1 option, then the other parameters after it are ignored.
; Related .......:
; Link ..........:
; Example .......: $Test = _IniWriteSectionComment($IniFile, "Settings", "Now is the time for all good|men to come to the aid of their country", 1)
; ===============================================================================================================================
Func _IniStripComments($ISC_FileName, $ISC_All = 1, $ISC_SectionName="", $ISC_ForeAft = 1)
 Local $aFileRead
 If FileExists($ISC_FileName) Then
  Local $ISC_fHnd = FileOpen($ISC_FileName, 0)
  If $ISC_fHnd = -1 Then
   Return SetError(2, 0, 0)
  EndIf
  Local $Return = _FileReadToArray($ISC_FileName, $aFileRead)
  If $Return = 0 Then
   Return SetError(2, 0, 0)
  EndIf
  Local $aSectionNames = IniReadSectionNames($ISC_FileName)
  If @error Then
   Return SetError(3, 0, 0)
  EndIf
  If $ISC_All = 1 Then
   For $I = $aFileRead[0] To 1 Step -1
    If StringLeft($aFileRead[$I], 1) = ";" Then
     _ArrayDelete($aFileRead, $I)
    EndIf
   Next
   _ArrayDelete($aFileRead, 0)
   _FileWriteFromArray($ISC_FileName, $aFileRead)
   Return 1
  EndIf
  If _ArraySearch($aSectionNames, $ISC_SectionName) < 0 Or $ISC_SectionName = "" Then
   Return SetError(4, 0, 0)
  EndIf
  Local $aSectionNames = IniReadSectionNames($ISC_FileName)
  If @error Then
   Return SetError(3, 0, 0)
  EndIf
  If _ArraySearch($aSectionNames, $ISC_SectionName) < 0 Then
   Return SetError(4, 0, 0)
  EndIf
  Local $ISC_Index = _ArraySearch($aFileRead, "[" & $ISC_SectionName & "]")
  Local $aHolder[$aFileRead[0] + 1]
  If $ISC_ForeAft Then
   For $I = 0 To $ISC_Index - 1
    $aHolder[$I] = $aFileRead[$I]
   Next
   For $I = $ISC_Index - 1 To 0 Step -1
    If StringLeft($aHolder[$I], 1) = ";" Then
     _ArrayDelete($aHolder, $I)
     _ArrayDelete($aFileRead, $I)
     $aFileRead[0] = $aFileRead[0] - 1
     $ISC_Index -= 1
    Else
     ExitLoop
    EndIf
   Next
   For $I = $ISC_Index To $aFileRead[0]
    $aHolder[$I] = $aFileRead[$I]
   Next
  Else
   Local $tmpIndex = $ISC_Index
   For $I = 0 To $ISC_Index
    $aHolder[$I] = $aFileRead[$I]
   Next
   For $I = $ISC_Index + 1 To $aFileRead[0]
    If StringLeft($aFileRead[$I], 1) = ";" Then
     $ISC_Index += 1
    Else
     ExitLoop
    EndIf
   Next
   For $I = $ISC_Index + 1 To $aFileRead[0]
    $aHolder[$I] = $aFileRead[$I]
   Next
   For $I = $aFileRead[0] To $tmpIndex Step -1
    If $aHolder[$I] = "" Then
     _ArrayDelete($aHolder, $I)
    EndIf
   Next
  EndIf
  _ArrayDelete($aHolder, 0)
  _FileWriteFromArray($ISC_FileName, $aHolder)
 Else
  Return SetError(1, 0, 0)
 EndIf
 Return SetError(0, 0, 1)
EndFunc   ;==>_IniStripComment

This script will create an INI file and then insert comments into it. There is a commented out line that will also demonstrate the removal of comments from an INI file. The headers for both function should tell you all you need to know in how to use it. Everything after the last #include line and the first comment line, for the first function, are only needed as a demo of how it works and should be removed if you're going to use this.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • 2 weeks later...

Those who post vague questions are not only wasting their own time but also the time of those replying. So please provide the following to help those who help you.

#include <Misc.au3>

; Version: 1.00. AutoIt: V3.3.8.1
; Retrieve the recommended information of the current system when posting a support question.
Local $sSystemInfo = 'I have a valid AutoIt support question and kindly provide the details of my system:' & @CRLF & @CRLF & _
        'AutoIt Version: V' & @AutoItVersion & ' [' & _Iif(@AutoItX64, 'X64', 'X32') & ']' & @CRLF & _
        'Windows Version: ' & @OSVersion & ' [' & @OSArch & ']' & @CRLF & _
        'Language: ' & @OSLang & @CRLF & @CRLF & _
        'The following information has been copied to the clipboard. Use Ctrl + V to retrieve the following information.'
MsgBox(4096, 'System Info', $sSystemInfo)
ClipPut($sSystemInfo)

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

A minor modification of the above snippet, which by the way is excellent. It moves the instructions about CTRL-V to the title of the MsgBox and translates the language code. I borrowed the language code conversion function from the help file. The reason I moved the line about CTRL-V to the title is because that was also being sent to the clipboard when generating the information, now only the relevant info is being sent to it.

#include 

; Version: 1.00. AutoIt: V3.3.8.1
; Retrieve the recommended information of the current system when posting a support question.
Local $sSystemInfo = 'I have a valid AutoIt support question and kindly provided the details of my system:' & @CRLF & @CRLF & _
          'AutoIt Version: V' & @AutoItVersion & ' [' & _Iif(@AutoItX64, 'X64', 'X32') & ']' & @CRLF & _
          'Windows Version: ' & @OSVersion & ' [' & @OSArch & ']' & @CRLF & _
          'Language: ' & _Language() & ' (' & @OSLang & ')' & @CRLF & @CRLF
MsgBox(4096, 'This info has been copied to the clipboard. Use Ctrl + V to retrieve it.', $sSystemInfo)
ClipPut($sSystemInfo)

Func _Language()
     Select
          Case StringInStr("0413 0813", @OSLang)
               Return "Dutch"
          Case StringInStr("0409 0809 0c09 1009 1409 1809 1c09 2009 2409 2809 2c09 3009 3409", @OSLang)
               Return "English"
          Case StringInStr("040c 080c 0c0c 100c 140c 180c", @OSLang)
               Return "French"
          Case StringInStr("0407 0807 0c07 1007 1407", @OSLang)
               Return "German"
          Case StringInStr("0410 0810", @OSLang)
               Return "Italian"
          Case StringInStr("0414 0814", @OSLang)
               Return "Norwegian"
          Case StringInStr("0415", @OSLang)
               Return "Polish"
          Case StringInStr("0416 0816", @OSLang)
               Return "Portuguese"
          Case StringInStr("040a 080a 0c0a 100a 140a 180a 1c0a 200a 240a 280a 2c0a 300a 340a 380a 3c0a 400a 440a 480a 4c0a 500a", @OSLang)
               Return "Spanish"
          Case StringInStr("041d 081d", @OSLang)
               Return "Swedish"
          Case Else
               Return "Other (can't determine with @OSLang directly)"
     EndSelect
EndFunc   ;==>_Language

I hope you don't mind the modifications. :)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I hope you don't mind the modifications. :)

I don't mind at all, I did think about posting something similar using _GetOSLanguage (see signature) but didn't bother.

Thanks for the comments, I just realised today those that post generally lack the basic information required to help them.

#include <Misc.au3>

; Version: 1.00. AutoIt: V3.3.8.1
; Retrieve the recommended information of the current system when posting a support question.
Local $sSystemInfo = 'I have a valid AutoIt support question and kindly provide the details of my system:' & @CRLF & @CRLF & _
        'AutoIt Version: V' & @AutoItVersion & ' [' & _Iif(@AutoItX64, 'X64', 'X32') & ']' & @CRLF & _
        'Windows Version: ' & @OSVersion & ' [' & _GetOSLanguage() & ']' & @CRLF & _
        'Language: ' & @OSLang & @CRLF & @CRLF
MsgBox(4096, 'This info has been copied to the clipboard. Use Ctrl + V to retrieve it.', $sSystemInfo)
ClipPut($sSystemInfo)

; #FUNCTION# ====================================================================================================================
; Name ..........: _GetOSLanguage
; Description ...: Retrieves the language of the OS, this supports 19 of the most popular languages.
; Syntax ........: _GetOSLanguage()
; Parameters ....: None
; Return values .: None
; Author ........: guinness
; Link ..........: http://www.autoitscript.com/forum/topic/131832-getoslanguage-retrieve-the-language-of-the-os/
; Example .......: No
; ===============================================================================================================================
Func _GetOSLanguage()
    Local $aString[20] = [19, "0409 0809 0c09 1009 1409 1809 1c09 2009 2409 2809 2c09 3009 3409", "0404 0804 0c04 1004 0406", "0406", "0413 0813", "0425", _
            "040b", "040c 080c 0c0c 100c 140c 180c", "0407 0807 0c07 1007 1407", "040e", "0410 0810", _
            "0411", "0414 0814", "0415", "0416 0816", "0418", _
            "0419", "081a 0c1a", "040a 080a 0c0a 100a 140a 180a 1c0a 200a 240a 280a 2c0a 300a 340a 380a 3c0a 400a 440a 480a 4c0a 500a", "041d 081d"]

    Local $aLanguage[20] = [19, "English", "Chinese", "Danish", "Dutch", "Estonian", "Finnish", "French", "German", "Hungarian", "Italian", _
            "Japanese", "Norwegian", "Polish", "Portuguese", "Romanian", "Russian", "Serbian", "Spanish", "Swedish"]
    For $i = 1 To $aString[0]
        If StringInStr($aString[$i], @OSLang) Then
            Return $aLanguage[$i]
        EndIf
    Next
    Return $aLanguage[1]
EndFunc   ;==>_GetOSLanguage

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

:D My contribution :D

#include <Array.au3>
Local $aArray = _StringEqualSplit('abcdefghijklmnopqrstuvwxyz', 5)
_ArrayDisplay($aArray)
$aArray = _StringEqualSplit(1234567890, 5)
_ArrayDisplay($aArray)

; By czardas & modified by guinness >> [url="http://www.autoitscript.com/forum/topic/139260-autoit-snippets/page__st__20#entry992149"]http://www.autoitscript.com/forum/topic/139260-autoit-snippets/page__st__20#entry992149[/url]
; Version: 1.00. AutoIt: V3.3.8.1
; Splits a string into an equal number of characters. The 0th index returns the number of items.
Func _StringEqualSplit($sString, $iNumChars)
     Local $aArray = StringRegExp($sString, '(?s).{1,' & $iNumChars & '}', 3)
     Local $aArray1[UBound($aArray) + 1]
     For $I = 1 To UBound($aArray)
         $aArray1[$I] = $aArray[$I - 1]
     Next
     $aArray1[0] = UBound($aArray) 
     Return SetError(@error, 0, $aArray1)
EndFunc ;==>_StringEqualSplit

EDIT: Typo in the script.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

:D My contribution :D

#include <Array.au3>
Local $aArray = _StringEqualSplit('abcdefghijklmnopqrstuvwxyz', 5)
_ArrayDisplay($aArray)
$aArray = _StringEqualSplit(1234567890, 5)
_ArrayDisplay($aArray)

; By czardas & modified by guinness >> [url="http://www.autoitscript.com/forum/topic/139260-autoit-snippets/page__st__20#entry992149"]http://www.autoitscript.com/forum/topic/139260-autoit-snippets/page__st__20#entry992149[/url]
; Version: 1.00. AutoIt: V3.3.8.1
; Splits a string into an equal number of characters. The 0th index returns the number of items.
Func _StringEqualSplit($sString, $iNumChars)
     Local $aArray = StringRegExp($sString, '(?s).{1,' & $iNumChars & '}', 3)
     Local $aArray1[UBound($aArray) + 1]
     For $I = 1 To UBound($aArray)
          $aArray1[$I] = $aArray[$I - 1]
     Next
     $aArray1[0] = UBound($aArray) - 1
     Return SetError(@error, 0, $aArray1)
EndFunc   ;==>_StringEqualSplit

And this too...

#include <Array.au3>

Local $aArray = _StringEqualSplitEx('abcdefghijklmnopqrstuvwxyz', 5)
_ArrayDisplay($aArray)

$aArray = _StringEqualSplitEx(1234567890, 5)
_ArrayDisplay($aArray)

; By czardas & modified by guinness >> [url="http://www.autoitscript.com/forum/topic/139260-autoit-snippets/page__st__20#entry992149"]http://www.autoitscript.com/forum/topic/139260-autoit-snippets/page__st__20#entry992149[/url]
; Version: 1.00. AutoIt: V3.3.8.1
; Splits a string into an equal number of characters. The 0th index returns the number of items.
Func _StringEqualSplitEx($sString, $iNumChars)
     Local $aArray = StringRegExp(String($sString), '(?s).{1,' & $iNumChars & '}', 3)
     Local $aReturn[UBound($aArray) + 1] = [UBound($aArray)]
     For $i = 1 To $aReturn[0]
          $aReturn[$i] = $aArray[$i - 1]
     Next
     Return SetError(@error, 0, $aReturn)
EndFunc   ;==>_StringEqualSplitEx
Would be interested to see the differences in time. Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

; WARNING: This will erase the contents of the drive.
; Version: 1.00. AutoIt: V3.3.8.1
; Format a drive.
Func _FormatDrive($sDrive, $sLabel = '', $iIsNTFS = 1, $iQuickFormat = 0)
    Local $aFileSystem[2] = ['FAT', 'NTFS'], $sQuickFormat = ''
    If $iQuickFormat Then
        $sQuickFormat = ' /Q'
    EndIf
    If StringStripWS($sLabel, 8) <> '' Then
        $sLabel = ' /V:' & StringStripWS($sLabel, 3)
    Else
        $sLabel = ''
    EndIf
    Return RunWait(@ComSpec & ' /c format ' & StringLeft($sDrive, 1) & ' /FS:' & $aFileSystem[$iIsNTFS] & $sLabel & $sQuickFormat & ' /X /Y', @SystemDir, @SW_HIDE)
EndFunc   ;==>_FormatDrive

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

#include <Date.au3>

ConsoleWrite(_IsDateOrAbove(@YEAR & @MON & '29') & @CRLF) ; Returns false if the date is less than the 29th of the month.
ConsoleWrite(_IsDateOrAbove(@YEAR & @MON & '3') & @CRLF) ; Returns true if the date is greater than the 3rd of the month.

; Version: 1.00. AutoIt: V3.3.8.1
; Check if a date is equal to/or has passed the current date. Pass the string YYYYMMDD e.g. 20121225.
Func _IsDateOrAbove($sDateString)
    Local $aArray = StringRegExp($sDateString, '(d{4})(d{2})(d{2})', 3)
    If @error = 0 Then
        $sDateString = $aArray[0] & '/' & $aArray[1] & '/' & $aArray[2]
    EndIf
    Return (_DateDiff('D', $sDateString, @YEAR & '/' & @MON & '/' & @MDAY) >= 0)
EndFunc   ;==>_IsDateOrAbove

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

#include <GDIPlus.au3>

_ConvertImage(@ScriptDir & '\Example.jpg', 4) ; Pass an integer as the file format you would like to convert to.
_ConvertImage(@ScriptDir & '\Example.jpg', '4') ; Pass an integer string as the file format you would like to convert to.
_ConvertImage(@ScriptDir & '\Example.jpg', 'PNG') ; Pass a valid CLSID as the file format you would like to convert to.

; Version: 1.01. AutoIt: V3.3.8.1
; Convert an image to a different file format.
Func _ConvertImage($sFilePath, $vFileType = 1)
    Local $aFileType[6][2] = [[5, 2], _
            ['BMP', 'bmp;dib;rle'],['GIF', 'gif'],['JPEG', 'jpg;jpeg;jpe;jfif'],['PNG', 'png'],['TIFF', 'tif;tiff']]
    If FileExists($sFilePath) = 0 Then
        Return SetError(1, 0, 0)
    EndIf
    If IsInt($vFileType) = 0 And StringIsInt($vFileType) = 0 Then
        For $i = 1 To $aFileType[0][0]
            If $aFileType[$i][0] = $vFileType Then
                $vFileType = $i
                ExitLoop
            EndIf
        Next
    Else
        $vFileType = Int($vFileType)
    EndIf
    If IsInt($vFileType) = 0 Or $vFileType < 1 Or $vFileType > $aFileType[0][0] Then
        Return SetError(2, 0, 0)
    EndIf
    If Not _GDIPlus_Startup() Then
        Return SetError(@error, @extended, 0)
    EndIf
    Local $iExtension = StringInStr($sFilePath, '.', 2, -1), $sFileString = StringLeft($sFilePath, $iExtension - 1)
    If StringInStr($aFileType[$vFileType][1], StringMid($sFilePath, $iExtension + 1), 2) = 0 Then
        Local $hImage = _GDIPlus_ImageLoadFromFile($sFilePath)
        Local $sCLSID = _GDIPlus_EncodersGetCLSID($aFileType[$vFileType][0])
        _GDIPlus_ImageSaveToFileEx($hImage, $sFileString & '.' & StringMid($aFileType[$vFileType][1], 1, StringInStr($aFileType[$vFileType][1], ';', 2) - 1), $sCLSID)
        _GDIPlus_ImageDispose($hImage)
    EndIf
    _GDIPlus_Shutdown()
EndFunc   ;==>_ConvertImage

Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

ConsoleWrite(_NameCount('Example') & @CRLF) ; Returns 76 as e = 5, x = 24, a = 1, m = 13, p = 16, l = 12 and e = 5.
ConsoleWrite(_NameCount('A') & @CRLF) ; Returns 1 as 'A' or 'a' is the 1st letter of the alphabet.
ConsoleWrite(_NameCount('Qwerty') & @CRLF) ; Returns 108.

; Version: 1.00. AutoIt: V3.3.8.1
; Find the value of a string where a = 1, b = 2, c = 3 etc.
Func _NameCount($sData)
    $sData = StringStripWS(StringLower($sData), 8)
    Local $aStringSplit = StringSplit($sData, ''), $iReturn = 0
    For $i = 1 To $aStringSplit[0]
        For $j = 97 To 122
            If $aStringSplit[$i] == Chr($j) Then
                $iReturn += ($j - 96)
                ExitLoop
            EndIf
        Next
    Next
    Return $iReturn
EndFunc   ;==>_NameCount

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

ConsoleWrite(_StripQuotes('"' & @ScriptDir & '"') & @CRLF)
ConsoleWrite(_StripQuotes("'" & @ScriptFullPath & "'") & @CRLF)
ConsoleWrite(_StripQuotes(@ScriptDir) & @CRLF)

; Version: 1.00. AutoIt: V3.3.8.1
; Strip quotation marks from a filepath.
Func _StripQuotes($sFilePath)
    Return StringRegExpReplace($sFilePath, '^("|'')*([^"'']+)("|'')*$', '2')
EndFunc   ;==>_StripQuotes

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

ConsoleWrite(_GetExchangeRate('1', 'GBP', 'EUR') & @CRLF) ; Returns the same value in Euros.
ConsoleWrite(_GetExchangeRate('1', 'EUR', 'GBP') & @CRLF) ; Returns the same value in British pounds.

; Version: 1.00. AutoIt: V3.3.8.1
; Convert from one currency to the other using Google's Calculator API.
Func _GetExchangeRate($iAmount, $sFromExchange, $sToExchange)
    Local $sData = BinaryToString(InetRead('http://www.google.com/ig/calculator?hl=en&q=' & $iAmount & $sFromExchange & '=?' & $sToExchange))
    Local $aArray = StringRegExp($sData, 'rhs:s"(d+(?:.d*)?s+[w.s]*)', 3)
    If @error Then
        Return SetError(1, 0, '')
    EndIf
    Return StringStripWS($aArray[0], 3)
EndFunc   ;==>_GetExchangeRate

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

#include <Array.au3>

Local $aCodes = _GetExhangeRateCodes()
_ArrayDisplay($aCodes)

; Version: 1.00. AutoIt: V3.3.8.1
; Display an array of exhange rate codes.
Func _GetExhangeRateCodes()
    Local $aArray[95] = [94, _
            'AED', 'ANG', 'ARS', 'AUD', 'BDT', 'BGN', 'BHD', 'BND', 'BOB', 'BRL', _
            'BWP', 'CAD', 'CHF', 'CLP', 'CNY', 'COP', 'CRC', 'CZK', 'DKK', 'DOP', _
            'DZD', 'EEK', 'EGP', 'EUR', 'FJD', 'GBP', 'HKD', 'HNL', 'HRK', 'HUF', _
            'IDR', 'ILS', 'INR', 'ISK', 'JMD', 'JOD', 'JPY', 'KES', 'KRW', 'KWD', _
            'KYD', 'KZT', 'LBP', 'LKR', 'LTL', 'LVL', 'MAD', 'MDL', 'MKD', 'MUR', _
            'MVR', 'MXN', 'MYR', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR', 'NZD', 'OMR', _
            'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG', 'QAR', 'RON', 'RSD', 'RUB', _
            'SAR', 'SCR', 'SEK', 'SGD', 'SKK', 'SLL', 'SVC', 'THB', 'TND', 'TRY', _
            'TTD', 'TWD', 'TZS', 'UAH', 'UGX', 'USD', 'UYU', 'UZS', 'VEF', 'VND', _
            'XOF', 'YER', 'ZAR', 'ZMK']
    Return $aArray
EndFunc   ;==>_GetExhangeRateCodes

Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

#NoTrayIcon ; So no icon is displayed in the trayicon menu.
#include <GUIConstants.au3>

Example()

Func Example()
    Local $hGUI = _GUICreateNoTaskBar('Example of a GUI with no TaskBar icon/button', 500, 500, -1, -1)
    Local $iClose = GUICtrlCreateButton('Close', 410, 470, 85, 25)
    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $iClose
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc   ;==>Example

; Version: 1.00. AutoIt: V3.3.8.1
; Create a GUI without a taskbar icon/button, this uses AutoIt's internal hidden window as the parent GUI.
Func _GUICreateNoTaskBar($sTitle, $iWidth, $iHeight = Default, $iLeft = Default, $iTop = Default, $bStyle = Default, $bStyleEx = Default)
    Return GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iTop, $bStyle, $bStyleEx, WinGetHandle(AutoItWinGetTitle()))
EndFunc   ;==>_GUICreateNoTaskBar

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

#include <StringConstants.au3>

Local $sTinyURL = _GetTinyURLFromURL('http://www.google.com/') ; Retrieve the TinyURL of google.com.
ConsoleWrite('TinyURL: ' & $sTinyURL & @CRLF) ; Display the TinyURL.
ConsoleWrite('LongURL: ' & _GetURLFromTinyURL($sTinyURL) & @CRLF) ; Retrieve the 'LongURL' of the TinyURL. This should be the same URL from before.

; Version: 1.00. AutoIt: V3.3.10.2
; Rerieve the TinyURL of a 'LongURL.' Please read the 'terms of usage' on TinyURL's site http://tinyurl.com/#terms.
Func _GetTinyURLFromURL($sURL)
    Return StringStripWS(BinaryToString(InetRead('http://tinyurl.com/api-create.php?url=' & $sURL)), $STR_STRIPALL)
EndFunc   ;==>_GetTinyURLFromURL

; Version: 1.00. AutoIt: V3.3.10.2
; Rerieve the 'LongURL' from a TinyURL. Please read the 'terms of usage' on TinyURL's site http://tinyurl.com/#terms.
Func _GetURLFromTinyURL($sURL)
    Local $sRead = BinaryToString(InetRead('http://preview.tinyurl.com/' & StringRegExpReplace($sURL, '^\V*\/', '')))
    Return StringStripWS(StringRegExp($sRead & @CRLF & _
            'id="redirecturl" href=" "', '(?:id="redirecturl"\s*href="(.*?)")', $STR_REGEXPARRAYGLOBALMATCH)[0], $STR_STRIPALL)
EndFunc   ;==>_GetURLFromTinyURL

Edited by guinness

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

#include <File.au3> ; For demonstration purposes only.
#include <WinAPIEx.au3>

Example()

Func Example() ; To demonstrate there is very little difference in terms of execution time.
    Local $hTimer = TimerInit()
    For $i = 1 To 5000
        _TempFile()
    Next
    ConsoleWrite(TimerDiff($hTimer) / 5000 & @CRLF)

    $hTimer = TimerInit()
    For $i = 1 To 5000
        _TempFileEx(Default, Default, 'tmp')
    Next
    ConsoleWrite(TimerDiff($hTimer) / 5000 & @CRLF)

    ConsoleWrite('Example Output: ' & _TempFileEx(@TempDir & '', Default, 'temp.file') & @CRLF) ; The $sFileExtension doesn't have to have the dot (.) at the start of the file extension.
    ConsoleWrite('Example Output: ' & _TempFileEx(@TempDir & '', ';', '.....prefix') & @CRLF) ; The $sFileExtension doesn't have to have the dot (.) at the start of the file extension, but in this example there are many!
EndFunc   ;==>Example

; Version: 1.00. AutoIt: V3.3.8.1
; A different approach to creating a temporary file. See the documentation for _TempFile.
Func _TempFileEx($sDirectoryName = @TempDir, $sFilePrefix = '~', $sFileExtension = '.tmp')
    If $sDirectoryName = Default Or FileExists($sDirectoryName) = 0 Then
        $sDirectoryName = @TempDir
    EndIf
    If FileExists($sDirectoryName) = 0 Then
        $sDirectoryName = @ScriptDir
    EndIf
    If $sFileExtension = Default Then
        $sFileExtension = '.tmp'
    EndIf
    If $sFilePrefix = Default Then
        $sFilePrefix = '~'
    EndIf
    $sDirectoryName = StringRegExpReplace($sDirectoryName, '+$', '') ; Remove the backslash from the file path - Or _WinAPI_PathRemoveBackslash in WinAPIEx.
    $sFileExtension = '.' & StringRegExpReplace($sFileExtension, '^.+', '') ; Remove the initial dot (.) from the file extension.
    $sFilePrefix = StringRegExpReplace($sFilePrefix, '[/:*?"<>|]', '') ; Remove any non-supported characters in the file prefix.
    Local $sReturn = ''
    Do
        $sReturn = FileGetShortName($sDirectoryName & '' & $sFilePrefix & StringRegExpReplace(_WinAPI_CreateGUID(), 'V*(w{12})}', '1') & $sFileExtension)
    Until FileExists($sReturn) = 0
    Return $sReturn
EndFunc   ;==>_TempFileEx

UDF List:

 
_AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Here's one for simply create a unique tmp file

MsgBox(0, 0, _CreateUniqueTmpFile())

; Create a unique tmp file, optional path and prefix
Func _CreateUniqueTmpFile($sPath = @TempDir, $sPreFix = '999')
    Local Const $ERROR_PATH_LENGTH = 6

    If StringLen($sPath) > 256 - 14 Then ;MAX_PATH - 14
        Return SetError($ERROR_PATH_LENGTH)
    EndIf

    Local $Struct = DllStructCreate("char[256]") ; MAX_PATH
    Local $StructPointer = DllStructGetPtr($Struct)

    Local $aRtn = DllCall("Kernel32.dll", 'uint', 'GetTempFileName', 'str', $sPath, 'str', $sPreFix, 'uint', 0, 'ptr', $StructPointer)
    If @error Then
        Return SetError(@error)
    EndIf

    Return DllStructGetData($Struct, 1)
EndFunc   ;==>_CreateUniqueTmpFile
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...