Chimaera

AutoIt Snippets

276 posts in this topic

#241 ·  Posted

I agree, this thread is a ridiculous katamari that encourages double posting and creates disjointed conversations about solutions.  snippets are examples.


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites



#242 ·  Posted

i thnk that maybe this should have a section in the example scripts, under snippets, and each one have its own post, otherwise this post will be like the great software thread, cannot remeber name. - a lot of great stuff lost in a 100 pages. 

But I will give my 4 cents this time, as this is the exact definition of examples. Besides the other issue with search for it in our search engine, would be nearly impossible. 

 

Please excuse any spelling mistakes, I am on a cell. 

It's called Examples or wiki.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#243 ·  Posted (edited)

Once everyone was given powers to post on the wiki, I stopped transferring them to the wiki, because you can all do it yourself now.

It even gives you the template to do so in the first post

https://www.autoitscript.com/wiki/AutoIt_Snippets

By the look of the wiki snippets i think it has some formatting issues now prob due to the forum changes.

Edited by Chimaera

Share this post


Link to post
Share on other sites

#244 ·  Posted

Once everyone was given powers to post on the wiki, I stopped transferring them to the wiki, because you can all do it yourself now.

It even gives you the template to do so in the first post

https://www.autoitscript.com/wiki/AutoIt_Snippets

By the look of the wiki snippets i think it has some formatting issues now prob due to the forum changes.

I agree, this thread is a ridiculous katamari that encourages double posting and creates disjointed conversations about solutions.  snippets are examples.

Benefit of posting in the Forum vs in the Wiki: Feedback, Appreciation, Comments, Update Notifications per E-Mail...

IMHO maybe there could be a "Snippets 2015", "Snippets 2015" Thread in the forum,

or maybe even "Snippets November 2015" etc. then it never gets much too long...

Personally I like checking out new posts in this thread. Just wanted to give some counter arguments to the above.

Share this post


Link to post
Share on other sites

#246 ·  Posted

Maybe a Snippets Sub Forum for storing snippet threads? :think:


Spoiler

My contributions to AutoIt Community:

Snippets:

StringTrimLeftUntil & StringTrimRightUntil - Does what it says

StringLeftUntil & StringRightUntil - Does what it says

CalcPercent - Clean calculations

ArraySplit - Simply put, Converts an 1D Array to an 2D Array based on Delimiters (See the example if you want to know what it does clearly)

IsMgcNumPresent - See post for more details :P

 

UDFs:

Process UDF - Get both the output & the exit code of a command with a single line of code :)

Experimental Maps UDF - UDF for Maps (the new alpha datatype)

 

Programs:

Magic Number Calculator - Converts magic numbers to constants

 

Articles:

The Great History of AutoIt - A log (with accurate dates) of major milestones of AutoIt

Arrays 101: All you need to know about them! - A nice documentation of the Array datatype in AutoIt

Maps 101: All you need to know about them! - A nice documentation of the Map (currently in beta) datatype in AutoIt

Chatbox 101: All you need to know about it! - CB 101

 

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me:

I get RSS feeds from my notification list every minute :),So anything which sends me a notification works, I am active most of the time (IST) :)

Or you can have a nice chat with me in the chatbox (If I am online)

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#247 ·  Posted

Maybe a Snippets Sub Forum for storing snippet threads? :think:

In hindsight it would have been better to have a submission sub forum and a discussion sub forum. Oh well, considering no one posts here that much, I don't see it being an issue of leaving it as it is. Ain't broke!


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#248 ·  Posted (edited)

Finally another snippet! :D

I use this little function to check if a number is present in a number (Magic numbers)... Magic numbers are powers of 2 (like 16, 32, 64 etc.) which can be added BitORed together to form a magic number...

; #FUNCTION# ====================================================================================================================
; Name ..........: IsMgcNumPresent
; Description ...: Checks if a number is a present in a number (Magic numbers aka Powers of 2)
; Syntax ........: IsMgcNumPresent($iNumber, $iMagicNumber)
; Parameters ....: $iNumber             - Number to check if it exists in $iMagicNumber.
;                  $iMagicNumber        - The number which might contain $iNumber.
; Return values .: Success: True
;                  Failure: False
; Author ........: Damon Harris (TheDcoder)
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: http://bit.ly/IsMgcNumPresentForAutoIt
; Example .......: Yes, see below.
; ===============================================================================================================================
Func IsMgcNumPresent($iNumber, $iMagicNumber)
    Return BitAND($iMagicNumber, $iNumber) = $iNumber
EndFunc

; Example

Global Const $NUMBER = 32
Global Const $MAGIC_NUMBER = BitOR(32, 64)

ConsoleWrite(@CRLF)
ConsoleWrite('+> Is ' & $NUMBER & ' present in ' & $MAGIC_NUMBER & '?... Its ' & IsMgcNumPresent($NUMBER, $MAGIC_NUMBER) & @CRLF)
ConsoleWrite(@CRLF)

Enjoy, TD :)

Edited by TheDcoder
Added Example & Link, TD :D
1 person likes this

Spoiler

My contributions to AutoIt Community:

Snippets:

StringTrimLeftUntil & StringTrimRightUntil - Does what it says

StringLeftUntil & StringRightUntil - Does what it says

CalcPercent - Clean calculations

ArraySplit - Simply put, Converts an 1D Array to an 2D Array based on Delimiters (See the example if you want to know what it does clearly)

IsMgcNumPresent - See post for more details :P

 

UDFs:

Process UDF - Get both the output & the exit code of a command with a single line of code :)

Experimental Maps UDF - UDF for Maps (the new alpha datatype)

 

Programs:

Magic Number Calculator - Converts magic numbers to constants

 

Articles:

The Great History of AutoIt - A log (with accurate dates) of major milestones of AutoIt

Arrays 101: All you need to know about them! - A nice documentation of the Array datatype in AutoIt

Maps 101: All you need to know about them! - A nice documentation of the Map (currently in beta) datatype in AutoIt

Chatbox 101: All you need to know about it! - CB 101

 

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me:

I get RSS feeds from my notification list every minute :),So anything which sends me a notification works, I am active most of the time (IST) :)

Or you can have a nice chat with me in the chatbox (If I am online)

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#249 ·  Posted (edited)

; EG---------------------------------------------- -
Local $sString = StringBetween("<test>C</test><test>B</test><test>A</test>", "<test>", "</test>")
MsgBox(0, "StringBetween", "Strings between <test> and </test>" & @CRLF & "Is: " & $sString & @CRLF & "In text: <test>C</test><test>B</test><test>A</test>")
; ------------------------------------------------ -

; #FUNCTION# ====================================================================================================================
; Name ..........: StringBetween
; Description ...: Find strings between two string delimiters
; Syntax ........: StringBetween($sString, $sStart, $sEnd)
; Parameters ....: $sString         - The string to search.
; Parameters ....: $sStart          - The beginning of the string to find.
;                  $sEnd            - The end of the string to find.
; Return values .: Success: a found string
;                  Failure: sets the @error flag to non-zero.
;                  @error: 1 - No strings found.
; Author ........: Trong
; Related .......: _StringBetween
; Example .......: Yes
; ===============================================================================================================================

Func StringBetween($sString, $sStart, $sEnd)
    $sString = StringReverse(StringTrimLeft($sString, StringInStr($sString, $sStart) + StringLen($sStart) - 1))
    $sString = StringReverse(StringTrimLeft($sString, StringInStr($sString, StringReverse($sEnd)) + StringLen($sEnd) - 1))
    Return SetError(StringLen($sString) < 1, 0, $sString)
EndFunc   ;==>StringBetween

 

Edited by Trong

Please do not create multiple accounts, that it only to ask.trong_cf.png

Share this post


Link to post
Share on other sites

#250 ·  Posted

StringLen($sString) = ""

No, this is awful, as you are relying on type coercion.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#251 ·  Posted

Sorry I forgot to fix it here, I thought I had to fix it :(
Thanks for your reminder!


Please do not create multiple accounts, that it only to ask.trong_cf.png

Share this post


Link to post
Share on other sites

#252 ·  Posted

This might seem stupid to put here, but in the absence of a shortcut key for past and go in chrome, I always have this running of late.

HotKeySet("^b", _Go)

While 3
    Sleep(333)
WEnd

Func _Go()
    Send("^v")
    Send("{Enter}")
EndFunc

 


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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#253 ·  Posted (edited)

Hello everyone!

I want to add 2-3 simple functions, very very stupid, but because I'm very lazy I'd like them to be included in official AutoIt ;-)

They are for writing messages in a simple & concise way, without bothering if you have to deal with strings or arrays. They are mostly for debug pourpose.
 

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

#include <Array.au3>

; Functions for writing messages in the most concise way (be it strings or array)

Local $simpleMsg="Hey you!"
Local $aMsg[3]=["Hey you!", "Not you", "You!!"]

_showAnyMsg($simpleMsg, "_showAnyMsg example", 0)
_msg($simpleMsg, "_msg example")
_msg("simplest way")
_msg($aMsg, "_msg example with array")
_bye("I'm gone!")
_msg("I had something else to say...")


;====================================================================================================================
;Function that displays a message to the user, :
;  Parameters
;    message_IN: (long) text of the message
;    title_IN  : (short) title of the message
;    msgFlag_IN: tipe of message display (see MsgBox standard function)
Func _showAnyMsg (ByRef $message_IN, $title_IN, $msgFlag_IN)
    If IsArray($message_IN) Then
        _ArrayDisplay($message_IN, $title_IN)
    Else
        MsgBox($msgFlag_IN, $title_IN, $message_IN)
    EndIf
EndFunc ;==>_showAnyMsg


;====================================================================================================================
;Function that displays a message to the user, using the simplest form:
;  Parameters
;    message_IN: (long) text of the message
;    title_IN  : (short) title of the message, default is "Message".
;    msgFlag_IN: tipe of message display (see MsgBox standard function), default is 0.
Func _msg (ByRef $message_IN, $title_IN = "Message", $msgFlag_IN = 0)
    _showAnyMsg($message_IN, $title_IN, $msgFlag_IN)
EndFunc ;==>_msg


;====================================================================================================================
;Function that displays a message to the user, using the simplest form:
;  Parameters
;    message_IN: (long) text of the message
;    title_IN  : (short) title of the message, default is "Message".
;    msgFlag_IN: tipe of message display (see MsgBox standard function), default is 0.
Func _bye (ByRef $message_IN, $title_IN = "Terminate", $msgFlag_IN = 0)
    _showAnyMsg($message_IN, $title_IN, $msgFlag_IN)
    Exit
EndFunc ;==>_bye

 

Edited by NotAviable

Share this post


Link to post
Share on other sites

#254 ·  Posted

5 minutes ago, NotAviable said:

I want to add 2-3 simple functions, very very stupid, but because I'm very lazy I'd like them to be included in official AutoIt ;-)

Won't happen because we are lazy too! ;)
Just add them in your own include file.

Jos

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#255 ·  Posted

I'm even too lazy to post here ... ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2016-05-02 - Version 1.4.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-05-09 - Version 1.2.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#256 ·  Posted (edited)

EDITED: REMOVED

I prefer to keep it

EDIT:
Edited by gil900

Share this post


Link to post
Share on other sites

#258 ·  Posted

Here an alternative to the _StringRepeat() function:

; returns the passed char (or a whole string) replicated n times
; Example1: ConsoleWrite(_StringReplicate('*', 5) & @CRLF)
; Example2: ConsoleWrite(_StringReplicate('<->', 15) & @CRLF)
;
Func _StringReplicate($sChars = "", $iRepeats = 0)
    $sChars = String($sChars)
    $iRepeats = Int(Abs(Number($iRepeats)))
    Return StringReplace(StringFormat('%' & $iRepeats & 's', ""), " ", $sChars)
EndFunc   ;==>_StringReplicate

 


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

#259 ·  Posted (edited)

EnvParse - for passing strings (paths) with environment variables (e.g.: %TEMP%\test):

Func EnvParse($str)
    $vars = StringRegExp($str, "%([^%]+)%", 3)
    For $var In $vars
        $get = EnvGet($var)
        If $get Then
            $str = StringReplace($str, "%" & $var & "%", $get)
        EndIf
    Next
    Return $str
EndFunc

Example: EnvParse("%TEMP%\test") will return something like C:\Windows\Temp\test.

Edited by Jefrey

My UDFs and functions

Spoiler

UDF (lib):

JSONgen JSON generator

_TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do

_TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do

_CmdLine UDF easily parse command line parameters, keys or flags

AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP

(Un)Serialize Convert arrays and data into a storable string (PHP compatible)

RTTL Plays and exports Nokia-format monophonic ringtones (for very old cellphones)

I18n library Simple and easy to use localization library

Scripting.Dictionary OOP and OOP-like approach

Buffer/stack limit arrays to N items by removing the last one once the limit is reached

NGBioAPI UDF to work with Nitgen fingerprint readers

Classes (objects):

_WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...)

Projects:

Serial/Licensing system require license key based on unique machine ID from your users

 

Standalone functions/snippets:

_Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit)

rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5")

EnvParser parse strings/paths with environment variables and get full path

 

Random stuff:

Super Mario beep sound your ears will hurt

Share this post


Link to post
Share on other sites

#260 ·  Posted

also:

$sPath = "%TEMP%\test\subfolder1\subfolder2"
msgbox(0, '' , EnvGet(stringtrimleft(stringtrimright(stringsplit($sPath, "\" , 2)[0] , 1) , 1)) & stringmid($sPath , stringinstr($sPath , "\" , 0 , 1)))

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
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