Jump to content

AutoIt Snippets


Chimaera
 Share

Recommended Posts

Once tested and validated OK for all, what I feel would be nice is to change the standard functions, without creating a bunch of separate functions. Of course this would require attention of Jon or whoever gets his/her hands on the code.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

3 hours ago, Andreik said:

@jchd couldn't agree more

@UEZ Thank you. I saw you updated the code and get rid of the global dll handle, which is much better. After all it's a single function not a UDF to require such a strategy.

Well, if I want to draw a line in GDI+, I don't need all the GDI+ functions. The idea was simply to implement the other functions as well, in case you need them at some point.
I admit that it is oversized for the "Snippet" topic and would actually fit better in the "Example Scripts" section as its own topic, but the code is not ready for that. Actually, the plan was not to implement many DPI WinAPI functions, but one thing led to another.
If the functions are to be included in the next release, then I would welcome that if there are no bugs.

 

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I changed the code from here

into a single call and removed all other functions that are not needed. Maybe one day the DPI WinAPI functions will find their way into the next Autoit release...

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

The replacement function for DirMove()

Func _DirMove($SourceDir, $DestDir, $flag = 0)
    Local $Show_Debug = 1, $SourceDir_Exists = FileExists($SourceDir)
    If $Show_Debug Then ConsoleWrite("> Move folder '" & $SourceDir & "' [To> '" & $DestDir & "'" & @CRLF)
    If ($SourceDir_Exists < 1) Then
        If $Show_Debug Then ConsoleWrite("! ERROR - The source directory does not exist at: " & $SourceDir & @CRLF)
        Return SetError(1, -1, 0)
    EndIf
    Local $file_Move = '', $file_Moved = 0, $Move_Error = 0
    $SourceDir = StringReplace($SourceDir, "/", '\')
    $DestDir = StringReplace($DestDir, "/", '\')
    If StringRight($SourceDir, 1) == '\' Then $SourceDir = StringTrimRight($SourceDir, 1)
    If StringRight($DestDir, 1) == '\' Then $DestDir = StringTrimRight($DestDir, 1)
    If Not FileExists($DestDir) Then
        If $Show_Debug Then ConsoleWrite("> Found folder: " & $SourceDir & @CRLF)
        If $Show_Debug Then ConsoleWrite("> Moving to: " & $DestDir & " (with Flag=" & $flag & ")" & @CRLF)
        DirCopy($SourceDir, $DestDir, $flag)
    Else
        If $Show_Debug Then ConsoleWrite("- Getting a list of files... " & @CRLF)
        Local $aFileList = _FileListToArrayRec($SourceDir & "\", "*", 1, 1, 1, 1)
        If (@error < 1) And IsArray($aFileList) Then
            If $Show_Debug Then ConsoleWrite("> Found files in: " & $SourceDir & @CRLF)
            If $Show_Debug Then ConsoleWrite("> Moving to: " & $DestDir & " (with Flag=" & $flag & ")" & @CRLF)
            For $I = 1 To $aFileList[0]
                $file_Move = $SourceDir & "\" & $aFileList[$I]
                $SourceDir_Exists = FileExists($file_Move)
                $file_Moved = FileMove($file_Move, $DestDir & "\" & $aFileList[$I], $flag < 1 ? 0 : 1 + 8)
                $Move_Error = @error
                If $Show_Debug Then ConsoleWrite("- Move file: " & $file_Move & " [" & $SourceDir_Exists & "] To> " & $DestDir & "\" & $aFileList[$I] & " [" & FileExists($DestDir & "\" & $aFileList[$I]) & "] > [Moved:" & $file_Moved & "-E:" & $Move_Error & "] " & (FileExists($file_Move) ? "Error" : "OK") & @CRLF)
                $file_Move = ''
                $SourceDir_Exists = 0
                $file_Moved = 0
            Next
        Else
            If $Show_Debug Then ConsoleWrite("! No files found at: " & $SourceDir & @CRLF)
        EndIf
    EndIf
    If $Show_Debug Then
        If FileExists($DestDir) Then ConsoleWrite("> Copied " & $SourceDir & " [To> " & $DestDir & @CRLF)
    EndIf
    If $Show_Debug Then ConsoleWrite("- Removing the source folder: " & $SourceDir & @CRLF)
    If FileExists($SourceDir) Then
        DirRemove($SourceDir, $flag)
        If FileExists($SourceDir) Then
            FileSetAttrib($SourceDir, "-RASH", $flag)
            DirRemove($SourceDir)
            If FileExists($SourceDir) And $flag Then
                RunWait(@ComSpec & ' /c takeown /f "' & $SourceDir & '" /r /d y', '', @SW_HIDE)
                RunWait(@ComSpec & ' /c Echo y|icacls "' & $SourceDir & '" /grant EveryOne:F /t /q', '', @SW_HIDE)
                RunWait(@ComSpec & ' /c RD /s /q "' & $SourceDir & '"', '', @SW_HIDE)
                DirRemove($SourceDir)
            EndIf
        EndIf
    EndIf
    If FileExists($SourceDir) Then
        If $Show_Debug Then ConsoleWrite("! FAILURE ! Folder " & $SourceDir & " has not been moved to: " & $DestDir & @CRLF)
        Return SetError(1, 0, 0)
    Else
        If $Show_Debug Then ConsoleWrite("+ SUCCESS ! Folder " & $SourceDir & " has been moved to: " & $DestDir & @CRLF)
        Return SetError(0, 0, 1)
    EndIf
EndFunc   ;==>_DirMove

 

Regards,
 

Link to comment
Share on other sites

  • 4 weeks later...

Awesome solver for Tweaking Round() to return with trailing zeros like a currency.

On 8/12/2018 at 4:47 PM, lpduy said:

A fure AutoIt function to display number with group!

It good for me. and not sure for any one, please test before use

Func num($num, $round = 0, $group = ",", $negative = "-", $decimal = ".")
    If $num = 0 Then Return "0" 
    Local $sign = ""    
    $num = StringReplace($num, $group, "")
    If StringInStr($num, $negative) Then
        $num = StringReplace($num, $negative, "")
        $sign = "-"
    EndIf
    $split = StringSplit($num, $decimal, 2)
    $int = $split[0]
    $tail = ""
    If UBound($split) >= 2 Then
        $tail = $split[1]
    Else
        $mod = Mod(StringLen($int), 3)
        If $mod = 0 Then
            $int = StringRegExpReplace($int, "(\d{1,3})", ".$1")
            $int = StringRight($int, StringLen($int) - 1)
            If $round = 0 Then
                Return $sign & $int
            Else
                Return $sign & $int & "," & StringFormat("%0" & $round & "s", "0")
            EndIf
        ElseIf $mod = 2 Or $mod = 1 Then
            $int1 = StringLeft($int, $mod)
            $int2 = StringRight($int, StringLen($int) - $mod)
            If $round = 0 Then
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1")
            Else
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1") & "," & StringFormat("%0" & $round & "s", "0")
            EndIf
        EndIf
    EndIf
    $tail = Round("0." & $tail, $round)
    If $tail = 1 Then
        $int = $int + 1
        $tail = StringFormat("%0" & $round & "s", "0")
        $mod = Mod(StringLen($int), 3)
        If $mod = 0 Then
            $int = StringRegExpReplace($int, "(\d{1,3})", ".$1")
            If $round = 0 Then
                Return $sign & StringRight($int, StringLen($int) - 1)
            Else
                Return $sign & StringRight($int, StringLen($int) - 1) & "," & StringMid(StringFormat("%f", $tail), 3, $round)
            EndIf
        ElseIf $mod = 2 Or $mod = 1 Then
            $int1 = StringLeft($int, $mod)
            $int2 = StringRight($int, StringLen($int) - $mod)
            If $round = 0 Then
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1")
            Else
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1") & "," & StringMid(StringFormat("%f", $tail), 3, $round)
            EndIf
        EndIf
    Else
        $mod = Mod(StringLen($int), 3)
        If $mod = 0 Then
            $int = StringRegExpReplace($int, "(\d{1,3})", ".$1")
            $int = StringRight($int, StringLen($int) - 1)
            If $round = 0 Then
                Return $sign & $int
            Else
                Return $sign & $int & "," & StringMid(StringFormat("%f", $tail), 3, $round)
            EndIf
        ElseIf $mod = 2 Or $mod = 1 Then
            $int1 = StringLeft($int, $mod)
            $int2 = StringRight($int, StringLen($int) - $mod)
            If $round = 0 Then
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1")
            Else
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1") & "," & StringMid(StringFormat("%f", $tail), 3, $round)
            EndIf
        EndIf
    EndIf
EndFunc   ;==>num

 

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

15 minutes ago, mLipok said:

Awesome solver for Tweaking Round() to return with trailing zeros like a currency.

my modified version:

Example(0)
Example(1)
Example(0.2)
Example(10234.2)
Example(300200100.45)

Func Example($i)
    Local $sTest = Round($i, 2)
    ConsoleWrite("! $sTest = " & $sTest & @CRLF)
    ConsoleWrite("+ $sTest = " & _RoundAsCurrency($sTest, 2, ',', '-', '.') & @CRLF)
EndFunc   ;==>Example

; #FUNCTION# ====================================================================================================================
; Name ..........: _RoundAsCurrency
; Description ...: Awesome solver for Tweaking Round() to return with trailing zeros like a currency.
; Syntax ........: _RoundAsCurrency($s_Number[, $i_Round = 0[, $s_DecimalSeparator = "[, $s_NegativeMark = "-"[, $s_ThousandsSeparator = "."]]]])
; Parameters ....: $s_Number            - a string value that represents number/value
;                  $i_Round             - [optional] an integer value. Default is 0.
;                  $s_DecimalSeparator  - [optional] a string value. Default is '.
;                  $s_NegativeMark      - [optional] a string value. Default is '-'.
;                  $s_ThousandsSeparator- [optional] a string value. Default is '.'.
; Return values .: $s_Number formated like a currency
; Author ........: lpduy
; Modified ......: mLipok
; Remarks .......:
; Related .......:
; Link ..........: https://www.autoitscript.com/forum/topic/139260-autoit-snippets/page/18/#comment-1400209
; Link ..........: https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1523211
; Example .......: No
; ===============================================================================================================================
Func _RoundAsCurrency($s_Number, $i_Round = 0, $s_DecimalSeparator = ",", $s_NegativeMark = "-", $s_ThousandsSeparator = ".")
;~     If $s_Number = 0 Then Return "0"
    Local $sign = ""
    $s_Number = StringReplace($s_Number, $s_DecimalSeparator, "")
    If StringInStr($s_Number, $s_NegativeMark) Then
        $s_Number = StringReplace($s_Number, $s_NegativeMark, "")
        $sign = "-"
    EndIf
    Local $split = StringSplit($s_Number, $s_ThousandsSeparator, 2)
    Local $int = $split[0]
    Local $tail = ""
    If UBound($split) >= 2 Then
        $tail = $split[1]
    Else
        Local $mod = Mod(StringLen($int), 3)
        If $mod = 0 Then
            $int = StringRegExpReplace($int, "(\d{1,3})", ".$1")
            $int = StringRight($int, StringLen($int) - 1)
            If $i_Round = 0 Then
                Return $sign & $int
            Else
                Return $sign & $int & "," & StringFormat("%0" & $i_Round & "s", "0")
            EndIf
        ElseIf $mod = 2 Or $mod = 1 Then
            Local $int1 = StringLeft($int, $mod)
            Local $int2 = StringRight($int, StringLen($int) - $mod)
            If $i_Round = 0 Then
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1")
            Else
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1") & "," & StringFormat("%0" & $i_Round & "s", "0")
            EndIf
        EndIf
    EndIf
    $tail = Round("0." & $tail, $i_Round)
    If $tail = 1 Then
        $int = $int + 1
        $tail = StringFormat("%0" & $i_Round & "s", "0")
        $mod = Mod(StringLen($int), 3)
        If $mod = 0 Then
            $int = StringRegExpReplace($int, "(\d{1,3})", ".$1")
            If $i_Round = 0 Then
                Return $sign & StringRight($int, StringLen($int) - 1)
            Else
                Return $sign & StringRight($int, StringLen($int) - 1) & "," & StringMid(StringFormat("%f", $tail), 3, $i_Round)
            EndIf
        ElseIf $mod = 2 Or $mod = 1 Then
            $int1 = StringLeft($int, $mod)
            $int2 = StringRight($int, StringLen($int) - $mod)
            If $i_Round = 0 Then
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1")
            Else
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1") & "," & StringMid(StringFormat("%f", $tail), 3, $i_Round)
            EndIf
        EndIf
    Else
        $mod = Mod(StringLen($int), 3)
        If $mod = 0 Then
            $int = StringRegExpReplace($int, "(\d{1,3})", ".$1")
            $int = StringRight($int, StringLen($int) - 1)
            If $i_Round = 0 Then
                Return $sign & $int
            Else
                Return $sign & $int & "," & StringMid(StringFormat("%f", $tail), 3, $i_Round)
            EndIf
        ElseIf $mod = 2 Or $mod = 1 Then
            $int1 = StringLeft($int, $mod)
            $int2 = StringRight($int, StringLen($int) - $mod)
            If $i_Round = 0 Then
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1")
            Else
                Return $sign & $int1 & StringRegExpReplace($int2, "(\d{1,3})", ".$1") & "," & StringMid(StringFormat("%f", $tail), 3, $i_Round)
            EndIf
        EndIf
    EndIf
EndFunc   ;==>_RoundAsCurrency

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

  • 2 weeks later...

 

_LCID_Language_GetInfo()

Func _LCID_Language_GetInfo($iType=-1, $iLCID=-1)
    $iType=Number($iType)
    $iLCID=Number($iLCID)
    If ($iLCID<1 Or $iLCID==Default) Then
        Local $aCall = DllCall('kernel32.dll', 'dword', 'GetUserDefaultLCID')
        If @error Then Return SetError(@error, @extended, 0)
        $iLCID=$aCall[0]
    EndIf
    If ($iType < 0 Or $iType==Default) Then $iType=0
    If $iType<1 Then Return $iLCID
    Local $aCall = DllCall('kernel32.dll', 'int', 'GetLocaleInfoW', 'dword', $iLCID, 'dword', $iType, 'wstr', '', 'int', 2048)
    If @error Or Not $aCall[0] Then Return SetError(@error + 10, @extended, '')
    Return $aCall[3]
EndFunc

; -- BEGIN eg
ConsoleWrite('_LCID_Language_GetInfo Type 2: => ' & _LCID_Language_GetInfo() & @CRLF)
ConsoleWrite('_LCID_Language_GetInfo LCID 1033: => ' & _LCID_Language_GetInfo(2,1033)& @CRLF)

For $i=0 to 129
    ConsoleWrite('_LCID_Language_GetInfo Type '&$i&': => ' & _LCID_Language_GetInfo($i) & @CRLF)
Next

; --- ENG EG

Output Eg:

_LCID_Language_GetInfo Type 2 UserDefaultLCID: => 1066
_LCID_Language_GetInfo LCID 1033: => English (United States)

_LCID_Language_GetInfo Type 0: => 1066
_LCID_Language_GetInfo Type 1: => 042a
_LCID_Language_GetInfo Type 2: => Vietnamese (Vietnam)
_LCID_Language_GetInfo Type 3: => VIT
_LCID_Language_GetInfo Type 4: => Tiếng Việt
_LCID_Language_GetInfo Type 5: => 84
_LCID_Language_GetInfo Type 6: => Vietnam
_LCID_Language_GetInfo Type 7: => VNM
_LCID_Language_GetInfo Type 8: => Việt Nam
_LCID_Language_GetInfo Type 9: => 042a
_LCID_Language_GetInfo Type 10: => 84
_LCID_Language_GetInfo Type 11: => 1258
_LCID_Language_GetInfo Type 12: => ,
_LCID_Language_GetInfo Type 13: => 0
_LCID_Language_GetInfo Type 14: => ,
_LCID_Language_GetInfo Type 15: => .
_LCID_Language_GetInfo Type 16: => 3;0
_LCID_Language_GetInfo Type 17: => 2
_LCID_Language_GetInfo Type 18: => 1
_LCID_Language_GetInfo Type 19: => 0123456789
_LCID_Language_GetInfo Type 20: =>_LCID_Language_GetInfo Type 21: => VND
_LCID_Language_GetInfo Type 22: => ,
_LCID_Language_GetInfo Type 23: => .
_LCID_Language_GetInfo Type 24: => 3;0
_LCID_Language_GetInfo Type 25: => 2
_LCID_Language_GetInfo Type 26: => 2
_LCID_Language_GetInfo Type 27: => 3
_LCID_Language_GetInfo Type 28: => 8
_LCID_Language_GetInfo Type 29: => /
_LCID_Language_GetInfo Type 30: => :
_LCID_Language_GetInfo Type 31: => dd/MM/yyyy
_LCID_Language_GetInfo Type 32: => dd MMMM yyyy
_LCID_Language_GetInfo Type 33: => 1
_LCID_Language_GetInfo Type 34: => 1
_LCID_Language_GetInfo Type 35: => 0
_LCID_Language_GetInfo Type 36: => 1
_LCID_Language_GetInfo Type 37: => 0
_LCID_Language_GetInfo Type 38: => 1
_LCID_Language_GetInfo Type 39: => 1
_LCID_Language_GetInfo Type 40: => SA
_LCID_Language_GetInfo Type 41: => CH
_LCID_Language_GetInfo Type 42: => Thứ Hai
_LCID_Language_GetInfo Type 43: => Thứ Ba
_LCID_Language_GetInfo Type 44: => Thứ Tư
_LCID_Language_GetInfo Type 45: => Thứ Năm
_LCID_Language_GetInfo Type 46: => Thứ Sáu
_LCID_Language_GetInfo Type 47: => Thứ Bảy
_LCID_Language_GetInfo Type 48: => Chủ Nhật
_LCID_Language_GetInfo Type 49: => T2
_LCID_Language_GetInfo Type 50: => T3
_LCID_Language_GetInfo Type 51: => T4
_LCID_Language_GetInfo Type 52: => T5
_LCID_Language_GetInfo Type 53: => T6
_LCID_Language_GetInfo Type 54: => T7
_LCID_Language_GetInfo Type 55: => CN
_LCID_Language_GetInfo Type 56: => Tháng Giêng
_LCID_Language_GetInfo Type 57: => Tháng Hai
_LCID_Language_GetInfo Type 58: => Tháng Ba
_LCID_Language_GetInfo Type 59: => Tháng Tư
_LCID_Language_GetInfo Type 60: => Tháng Năm
_LCID_Language_GetInfo Type 61: => Tháng Sáu
_LCID_Language_GetInfo Type 62: => Tháng Bảy
_LCID_Language_GetInfo Type 63: => Tháng Tám
_LCID_Language_GetInfo Type 64: => Tháng Chín
_LCID_Language_GetInfo Type 65: => Tháng Mười
_LCID_Language_GetInfo Type 66: => Tháng Mười Một
_LCID_Language_GetInfo Type 67: => Tháng Mười Hai
_LCID_Language_GetInfo Type 68: => Thg1
_LCID_Language_GetInfo Type 69: => Thg2
_LCID_Language_GetInfo Type 70: => Thg3
_LCID_Language_GetInfo Type 71: => Thg4
_LCID_Language_GetInfo Type 72: => Thg5
_LCID_Language_GetInfo Type 73: => Thg6
_LCID_Language_GetInfo Type 74: => Thg7
_LCID_Language_GetInfo Type 75: => Thg8
_LCID_Language_GetInfo Type 76: => Thg9
_LCID_Language_GetInfo Type 77: => Thg10
_LCID_Language_GetInfo Type 78: => Thg11
_LCID_Language_GetInfo Type 79: => Thg12
_LCID_Language_GetInfo Type 80: => 
_LCID_Language_GetInfo Type 81: => -
_LCID_Language_GetInfo Type 82: => 1
_LCID_Language_GetInfo Type 83: => 1
_LCID_Language_GetInfo Type 84: => 0
_LCID_Language_GetInfo Type 85: => 1
_LCID_Language_GetInfo Type 86: => 0
_LCID_Language_GetInfo Type 87: => 1
_LCID_Language_GetInfo Type 88: => � 
_LCID_Language_GetInfo Type 89: => vi
_LCID_Language_GetInfo Type 90: => VN
_LCID_Language_GetInfo Type 91: => 251
_LCID_Language_GetInfo Type 92: => vi-VN
_LCID_Language_GetInfo Type 93: => h:mm:ss
_LCID_Language_GetInfo Type 94: => 042a:{C2CB2CF0-AF47-413E-9780-8BC3A3C16068}{5FB02EC5-0A77-4684-B4FA-DEF8A2195628};042a:{C2CB2CF0-AF47-413E-9780-8BC3A3C16068}{591AE943-56BE-48F6-8966-06B43915CC5A};042a:0000042a;0409:00000409
_LCID_Language_GetInfo Type 95: => 
_LCID_Language_GetInfo Type 96: => H
_LCID_Language_GetInfo Type 97: => B
_LCID_Language_GetInfo Type 98: => T
_LCID_Language_GetInfo Type 99: => N
_LCID_Language_GetInfo Type 100: => S
_LCID_Language_GetInfo Type 101: => B
_LCID_Language_GetInfo Type 102: => C
_LCID_Language_GetInfo Type 103: => vie
_LCID_Language_GetInfo Type 104: => VNM
_LCID_Language_GetInfo Type 105: => NaN
_LCID_Language_GetInfo Type 106: =>_LCID_Language_GetInfo Type 107: => -_LCID_Language_GetInfo Type 108: => Latn;
_LCID_Language_GetInfo Type 109: => vi
_LCID_Language_GetInfo Type 110: => en
_LCID_Language_GetInfo Type 111: => Vietnamese
_LCID_Language_GetInfo Type 112: => 0
_LCID_Language_GetInfo Type 113: => 0
_LCID_Language_GetInfo Type 114: => Vietnamese (Vietnam)
_LCID_Language_GetInfo Type 115: => Tiếng Việt (Việt Nam)
_LCID_Language_GetInfo Type 116: => 1
_LCID_Language_GetInfo Type 117: => 1
_LCID_Language_GetInfo Type 118: => %
_LCID_Language_GetInfo Type 119: =>_LCID_Language_GetInfo Type 120: => dd MMMM
_LCID_Language_GetInfo Type 121: => h:mm tt
_LCID_Language_GetInfo Type 122: => VIT 
_LCID_Language_GetInfo Type 123: => vi-VN
_LCID_Language_GetInfo Type 124: => dddd, dd MMMM
_LCID_Language_GetInfo Type 125: => 0
_LCID_Language_GetInfo Type 126: => s
_LCID_Language_GetInfo Type 127: => c
_LCID_Language_GetInfo Type 128: => 8
_LCID_Language_GetInfo Type 129: => k0-windows-vietnam;k0-windows-vietnam-telex;k0-windows-vietnam-vni

 

 

Edited by Trong

Regards,
 

Link to comment
Share on other sites

  • 3 weeks later...

Tonight, I wanted to be able to add a tab to my GUI like some programs allow with a plus sign on the end. I couldn't find any examples in my search (although I did see a cool UDF that was more complicated than I wanted - and still no plus sign). So, here's what I came up with (oh, right click the tab to be able to delete the current tab that you are on):

#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#include <Array.au3>

$sAddTabSymbol = "   +"
Global $aTabs[100] ; make whatever you want or with more code, it can be dynamic

$Form1 = GUICreate("My Tabbed Form", 625, 442)
$aTabs[0] = GUICtrlCreateTab(16, 24, 585, 385)
$Tab1 = $aTabs[0]

$aTabs[1] = _GUICtrlTab_InsertItem($Tab1, 0, "TabSheet1")
$aTabs[2] = _GUICtrlTab_InsertItem($Tab1, 1, $sAddTabSymbol)

$Menu1 = GUICtrlCreateContextMenu($aTabs[0])
$MenuDelTab = GUICtrlCreateMenuItem("Delete Current Tab", $Menu1)

GUICtrlSetState(-1,$GUI_SHOW)
GUICtrlCreateTabItem("")
_GUICtrlTab_SetCurSel($Tab1, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Tab1
            $iPos = GUICtrlRead($Tab1)
            $sTabText = _GUICtrlTab_GetItemText($Tab1, $iPos)
            If $sTabText = $sAddTabSymbol Then
                $sAns = InputBox("Create New Tab", "Enter new tab name: ", "New Tab")
                If $sAns <> "" Then
                    _GUICtrlTab_InsertItem($Tab1, $iPos, $sAns)
                    _GUICtrlTab_SetCurSel($Tab1, $iPos)
                EndIf
            EndIf
        Case $MenuDelTab
            $iPos = GUICtrlRead($Tab1)
            $sTabText = _GUICtrlTab_GetItemText($Tab1, $iPos)
            $iAns = MsgBox(4, "Delete Current Tab", "Do you really want to delete the current tab:" & @CRLF & @CRLF & $sTabText)
            If $iAns = 6 Then
                _GUICtrlTab_DeleteItem($Tab1, $iPos)
                _GUICtrlTab_SetCurSel($Tab1, $iPos - 1)
            EndIf
    EndSwitch
WEnd

 

Link to comment
Share on other sites

  • 1 month later...

I needed a simple way to display the content of a map so I made this simple snippet:

#include <Array.au3>

; Prepare some data
Local $iRows = 10
Local $iCols = 20
Local $aData[$iRows][$iCols]

; Create a map and assign some data
Local $mMap[]
$mMap['Rows'] = $iRows
$mMap['Cols'] = $iCols
$mMap['Data'] = $aData

; Display the content of the map
MapDisplay($mMap)

Func MapDisplay(Const ByRef $mMap, $sTitle = 'MapDisplay')
    If Not IsMap($mMap) Then Return SetError(1, 0, Null)
    Local $aMapKeys = MapKeys($mMap)
    Local $aDisplay[UBound($aMapKeys) + 1][3] = [['Key', 'Type', 'Value']]
    Local $Index = 1
    For $vKey In $aMapKeys
        $aDisplay[$Index][0] = $vKey
        $aDisplay[$Index][1] = VarGetType($mMap[$vKey])
        $aDisplay[$Index][2] = $mMap[$vKey]
        $Index += 1
    Next
    _ArrayDisplay($aDisplay, $sTitle)
EndFunc

I could have made a GUI to display the content of the map but I preferred to keep it minimal and use the existing _ArrayDisplay() to present the data.

When the words fail... music speaks.

Link to comment
Share on other sites

  • 2 weeks later...

This is my Window List checker:

#RequireAdmin
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <Process.au3>
#include <WinAPISysWin.au3>

Example()

Func Example()
    ; Retrieve a list of window handles using a regular expression. The regular expression looks for titles that contain the word SciTE or Internet Explorer.
    Local $aWinList
    Local $iPID = 0
    Local $iThread
    Local $s_Process_Name_current

    While 1
        $aWinList = WinList()

        _ArrayColInsert($aWinList, 2) ; ProcessName
        _ArrayColInsert($aWinList, 3) ; PID
        _ArrayColInsert($aWinList, 4) ; Thread
        _ArrayColInsert($aWinList, 5) ; TEXT
        For $IDX = 1 To $aWinList[0][0]
            $iThread = _WinAPI_GetWindowThreadProcessId($aWinList[$IDX][1], $iPID)
            $s_Process_Name_current = _ProcessGetName($iPID)
            $aWinList[$IDX][2] = $s_Process_Name_current
            $aWinList[$IDX][3] = $iPID
            $aWinList[$IDX][4] = $iThread
            $aWinList[$IDX][5] = WinGetText($aWinList[$IDX][0])
        Next

        _ArrayDisplay($aWinList, 'WinList - originall ordering')

        _ArraySort($aWinList, 0, 1, 0, 0)
        _ArrayDisplay($aWinList, 'WinList - ordering by Title')

        _ArraySort($aWinList, 0, 1, 0, 1)
        _ArrayDisplay($aWinList, 'WinList - ordering by HWND')

        _ArraySort($aWinList, 0, 1, 0, 2)
        _ArrayDisplay($aWinList, 'WinList - ordering by ProcessName')

        _ArraySort($aWinList, 0, 1, 0, 3)
        _ArrayDisplay($aWinList, 'WinList - ordering by PID')

        If $IDNO = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON2, "Question", _
                "Check again ?") Then ExitLoop

    WEnd

EndFunc   ;==>Example

 

Edited by mLipok
fixed code, and not Sort 0th element

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

  • 2 weeks later...
Func HotKey2Words($sHotkey)
    $sHotkey = StringReplace($sHotkey, "+", "Shift+")
    $sHotkey = StringReplace($sHotkey, "^", "Ctrl+")
    $sHotkey = StringReplace($sHotkey, "!", "Alt+")
    $sHotkey = StringReplace($sHotkey, "#", "Win+")
    $sHotkey = StringReplace($sHotkey, "{", "")
    Return StringReplace($sHotkey, "}", "")
EndFunc

( shamelessly taken from AutoIt3Wrapper )

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

  • 1 month later...
; https://www.autoitscript.com/forum/topic/139260-autoit-snippets/page/25/#comment-1529091
;----------------------------------------------------------------------------------------
; Title...........: ShellTrayRefresh.au3
; Description.....: Refreshes ShellTray to remove leftover zombie icons
; AutoIt Version..: 3.3.16.1   Author: ioa747
; Note............: Testet in Win10 22H2
;----------------------------------------------------------------------------------------
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#NoTrayIcon

Sleep(1000)

ShellTrayRefresh()

;----------------------------------------------------------------------------------------
Func ShellTrayRefresh()
    Local $aStartPos = MouseGetPos()
    Local $hTrayWnd = WinGetHandle("[CLASS:Shell_TrayWnd]")
    Local $hTlb = ControlGetHandle($hTrayWnd, "", "ToolbarWindow323")
    Local $hBtn = ControlGetHandle($hTrayWnd, "", "Button2")
    Local $aPos = ControlGetPos($hTrayWnd, "", $hBtn)
    Local $aTPos = ControlGetPos($hTrayWnd, "", $hTlb)
    For $i = ($aPos[0] - 1) + ($aPos[2] / 2) To $aPos[0] + $aPos[2] + $aTPos[2] Step $aPos[2]
        MouseMove($i, @DesktopHeight - 3, 1)
        ConsoleWrite("$i=" & $i & @CRLF)
    Next
    MouseMove($aStartPos[0], $aStartPos[1], 1)
EndFunc   ;==>ShellTrayRefresh
;----------------------------------------------------------------------------------------

 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

#include <Array.au3>

; From https://www.autoitscript.com/forum/topic/211337-_filelisttoarrayrec-but-each-subfolder-is-returned-in-separate-array-dimension/#comment-1529413
;----------------------------------------------------------------------------------------
; Title...........: FileListRecToMap.au3
; Description.....: List all files from a folder recursively into a map
;                 : Key of map = Folder name
;                 : Map value = array of file names within the folder (subfolders names excluded)
; AutoIt Version..: 3.3.16.1
; Author..........: Nine
; Date............: 2024-01-23
;----------------------------------------------------------------------------------------

Opt("MustDeclareVars", True)

Global $mList[]

FileListRecToMap($mList, "C:\Apps\AutoIt\Files")
For $sKey In MapKeys($mList)
  _ArrayDisplay($mList[$sKey], $sKey)
Next

Func FileListRecToMap(ByRef $mList, $sFolder, $sFileFilter = "*", $sFolderFilter = "*")
  Local Static $oShell = ObjCreate("Shell.Application")
  Local $oFolder = $oShell.NameSpace($sFolder)
  If Not IsObj($oFolder) Then Return 1
  Local $oFolderItems = $oFolder.Items()
  $oFolderItems.Filter(0x40, $sFileFilter) ; SHCONTF_NONFOLDERS
  Local $aList[$oFolderItems.count], $i = 0
  For $oFile In $oFolderItems
    $aList[$i] = $oFile.name
    $i += 1
  Next
  $mList[$sFolder] = $aList
  $oFolderItems.Filter(0x20, $sFolderFilter) ; SHCONTF_FOLDERS
  For $oFolderItem In $oFolderItems
    FileListRecToMap($mList, $oFolderItem.path, $sFileFilter, $sFolderFilter)
  Next
EndFunc   ;==>FileListRecToMap

 

Link to comment
Share on other sites

  • 1 month later...
RunApp('wordpad') ;this will Launch wordpad
ConsoleWrite(" next" & @CRLF)


Func RunApp($appName)
    For $app In ObjCreate('Shell.Application').NameSpace('shell:AppsFolder').Items
        If $app.Name = $appName Then RunWait('explorer shell:appsFolder\' & $app.Path)
        ConsoleWrite("$app.Name=" & $app.Name & @CRLF)
    Next
EndFunc   ;==>runApp

 

I know that I know nothing

Link to comment
Share on other sites

1 hour ago, ioa747 said:
RunApp('wordpad') ;this will Launch wordpad
ConsoleWrite(" next" & @CRLF)


Func RunApp($appName)
    For $app In ObjCreate('Shell.Application').NameSpace('shell:AppsFolder').Items
        If $app.Name = $appName Then RunWait('explorer shell:appsFolder\' & $app.Path)
        ConsoleWrite("$app.Name=" & $app.Name & @CRLF)
    Next
EndFunc   ;==>runApp

 

Am I missing something?

ShellExecute('wordpad')

When the words fail... music speaks.

Link to comment
Share on other sites

Quote

Am I missing something?

Yes:

ShellExecute('Visual Studio 2022') does not work.

and

RunApp('Visual Studio 2022') does

But for me there is no use to start "named" applications with RunApp.

Edited by Sascha
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...