quickies Posted December 21, 2013 Posted December 21, 2013 I often find myself resorting to these forums for help with various questions I have and most of the time a quick search is able to give me the answer I need. Mounds of examples, explanations, and definitions. For me personally I find myself copying and pasting examples time and time again downloading archived UDF's and so on. What I would like to do is some parsing of the example scripts in the topic post of the forum. It would be nice to directly extract the examples and say I don't know run them. Some grabbing of any required .zip's or attached files for examples would be nice. I do not know if any of you have done or thought about doing this, or if it would even be useful but for me it is so I want to figure out how to accomplish this task. I'm not so worried about the latter of two, for now downloading the zip's and such, just grabbing some of the example scripts from post within code tags will suffice. My understanding of regular expressions is mediocre, but improving as the days go on. My overall understanding of programming is laughable since I've been working solidly with this language for about a month now. I have a general understanding of concepts and can pick up on things rather quickly. Where I am at so far is full of errors I know. The arrays have been hacked together to work since figuring out how to do something is much easier than figuring out how to do it right, but that is why I am here. Where I am at so far. Feed the thing a URL and return back the first 20 post example scripts on the 1st page kind of... The URL = ?do=embed' frameborder='0' data-embedContent> Func _HTML_StripTags($sHTMLData) If $sHTMLData = "" Then Return SetError(1, 0, $sHTMLData) Local $oHTML = ObjCreate("HTMLFILE") If @error Then Return SetError(1, 0, $sHTMLData) $oHTML.Open() $oHTML.Write($sHTMLData) Return SetError(0, 0, $oHTML.Body.InnerText) EndFunc ;==>_HTML_StripTags Func _ForumGetPostExScript($sURLSrc, $iPstNum) ; get post number and some of a general description (?:\A|\#\d+\h).* Local $sRetHtmlSrc, $sRetHtmlStrpd, $sRetCodePost $sRetHtmlSrc = _InetGetSource($sURLSrc) $sRetHtmlStrpd = _HTML_StripTags($sRetHtmlSrc) Local $x = 2 Local $arr[1] $sRetCodePost = StringRegExp($sRetHtmlStrpd, '(?:\A|\#\d+\h)', 3) For $i = 1 to Ubound($sRetCodePost, 1) - 1 If $i = 20 then $sRetCode = _StringBetween($sRetHtmlStrpd, $sRetCodePost[$i], 'Back to top') _ArrayAdd($arr, $sRetCode[0]) ExitLoop 1 Else For $x = $x to Ubound($sRetCodePost, 1) - 1 $sRetCode = _StringBetween($sRetHtmlStrpd, $sRetCodePost[$i], $sRetCodePost[$x]) _ArrayAdd($arr, $sRetCode[0]) $x = $x+1 ExitLoop 1 Next EndIf _ArrayInsert($arr, 0, $i+2) _ArrayDelete($arr, 1) Next _ArrayDisplay($arr) EndFunc ;==> _GetPostNumber The output looks like this expandcollapse popup[0]21 [1] Chimaera Chimaera Sorry .. Where am i again? Active Members 1,722 posts Posted 04 April 2012 - 03:32 PM 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. 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 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 === 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 Chimaera, 27 March 2013 - 11:38 AM. Jon and JScript like this If Ive just helped you ... miracles do happen. Chimaera _CopyRobo() * H [2] water water ? MVPs 13,551 posts Posted 23 June 2012 - 12:07 PM AutoIt expandcollapse popup#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, 23 June 2012 - 12:21 PM. BrewManNH likes this UDFs: Active Directory (2012-10-12 - Version 1.3.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX (NEW: 2013-11-10 - Version 0.10.0.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2013-01-21 - Version 0.3.1.1) - Download - General Help & Support - Example Scripts WordEX (2012-12-29 - Version 1.3) - Download (no longer needed - is now part of the latest beta version) Excel Rewrite (NEW: 2013-10-31 - Beta 3) - Download - Example Scripts Back to top [3] czardas czardas Active Members 6,119 posts Posted 09 July 2012 - 08:03 AM 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, 09 July 2012 - 08:45 AM. Back to top [4] BrewManNH BrewManNH ב×ָבקעס מיט קודוצ׳ה MVPs 8,676 posts Posted 11 July 2012 - 05:50 PM UDFs to write and/or remove comments from an INI file. AutoIt expandcollapse popup#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_In [5] guinness guinness Twerking my code Developers 14,169 posts Posted 24 July 2012 - 08:40 AM 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) BrewManNH likes this Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasswordValid • PasteBin • Posts Per Day • PreExpand • SciTE Jump • SHELLHOOK • Signature Creator • StringAddLF()/StringStripLF() • StringEOLToCRLF() • WM_COPYDATA • More Examples... Updated: 25/10/2013 Back to top [6] BrewManNH BrewManNH ב×ָבקעס מיט קודוצ׳ה MVPs 8,676 posts Posted 24 July 2012 - 01:38 PM 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. AutoIt expandcollapse popup#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. How to ask questions the smart way!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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator Back to top [7] guinness guinness Twerking my code Developers 14,169 posts Posted 24 July 2012 - 02:11 PM 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. AutoIt expandcollapse popup#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 ..........: <a href='http://www.autoitscript.com/forum/topic/131832-getoslanguage-retrieve-the-language-of-the-os/' class='bbc_url' title=''>http://www.autoitscript.com/forum/topic/131832-getoslanguage-retrieve-the-language-of-the-os/</a> ; 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 Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex [8] BrewManNH BrewManNH ב×ָבקעס מיט קודוצ׳ה MVPs 8,676 posts Posted 24 July 2012 - 08:03 PM My contribution #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, 24 July 2012 - 08:11 PM. How to ask questions the smart way!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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips. Latin Square password generator Back to top [9] guinness guinness Twerking my code Developers 14,169 posts Posted 24 July 2012 - 08:12 PM My contribution #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 ;==>_StringEqualSplitAnd 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 ;==>_StringEqualSplitExWould be interested to see the differences in time. Edited by guinness, 24 July 2012 - 08:20 PM. Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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()/_USToUKDa [10] guinness guinness Twerking my code Developers 14,169 posts Posted 26 July 2012 - 07:21 PM ; 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 Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasswordValid • PasteBin • Posts Per Day • PreExpand • SciTE Jump • SHELLHOOK • Signature Creator • StringAddLF()/StringStripLF() • StringEOLToCRLF() • WM_COPYDATA • More Examples... Updated: 25/10/2013 Back to top [11] guinness guinness Twerking my code Developers 14,169 posts Posted 26 July 2012 - 07:41 PM #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 Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasswordValid • PasteBin • Posts Per Day • PreExpand • SciTE Jump • SHELLHOOK • Signature Creator • StringAddLF()/StringStripLF() • StringEOLToCRLF() • WM_COPYDATA • More Examples... Updated: 25/10/2013 Back to top [12] guinness guinness Twerking my code Developers 14,169 posts Posted 28 July 2012 - 01:09 AM AutoIt expandcollapse popup#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, 06 May 2013 - 10:14 PM. Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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() • [13] guinness guinness Twerking my code Developers 14,169 posts Posted 28 July 2012 - 09:39 PM 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 Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasswordValid • PasteBin • Posts Per Day • PreExpand • SciTE Jump • SHELLHOOK • Signature Creator • StringAddLF()/StringStripLF() • StringEOLToCRLF() • WM_COPYDATA • More Examples... Updated: 25/10/2013 Back to top [14] guinness guinness Twerking my code Developers 14,169 posts Posted 29 July 2012 - 08:41 PM 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 Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasswordValid • PasteBin • Posts Per Day • PreExpand • SciTE Jump • SHELLHOOK • Signature Creator • StringAddLF()/StringStripLF() • StringEOLToCRLF() • WM_COPYDATA • More Examples... Updated: 25/10/2013 Back to top [15] guinness guinness Twerking my code Developers 14,169 posts Posted 30 July 2012 - 08:25 AM 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 Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasswordValid • PasteBin • Posts Per Day • PreExpand • SciTE Jump • SHELLHOOK • Signature Creator • StringAddLF()/StringStripLF() • StringEOLToCRLF() • WM_COPYDATA • More Examples... Updated: 25/10/2013 Back to top [16] guinness guinness Twerking my code Developers 14,169 posts Posted 30 July 2012 - 08:26 AM #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, 30 July 2012 - 08:28 AM. Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasswordValid • PasteBin • Posts Per Day • PreExpand • SciTE Jump • SHELLHOOK • Signature Creator • StringAddLF()/StringStripLF() • StringEOLToCRLF() • WM_COPYDATA • More Examples... Updated: 25/10/2013 Back to top [17] guinness guinness Twerking my code Developers 14,169 posts Posted 30 July 2012 - 09:23 AM AutoIt expandcollapse popup#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 Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasswordValid • PasteBin • Posts Per Day • PreExpand • SciTE Jump • SHELLHOOK • Signature Creator • StringAddLF()/StringStripLF() • StringEOLToCRLF() • WM_COPYDATA • More Examples... Updated: 25/10/2013 Back to top [18] guinness guinness Twerking my code Developers 14,169 posts Posted 30 July 2012 - 12:25 PM 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.8.1 ; Rerieve the TinyURL of a 'LongURL.' Please read the 'terms of usage' on TinyURL's site [<a href='http://tinyurl.com/#terms].' class='bbc_url' title='External link' rel='nofollow external'>http://tinyurl.com/#terms].</a> Func _GetTinyURLFromURL($sURL) Local $sRead = StringStripWS(BinaryToString(InetRead('http://tinyurl.com/api-create.php?url=' & $sURL)), 8) Return SetError(Number($sRead = ''), 0, $sRead) EndFunc ;==>_GetTinyURLFromURL ; Version: 1.00. AutoIt: V3.3.8.1 ; Rerieve the 'LongURL' from a TinyURL. Please read the 'terms of usage' on TinyURL's site [<a href='http://tinyurl.com/#terms].' class='bbc_url' title='External link' rel='nofollow external'>http://tinyurl.com/#terms].</a> Func _GetURLFromTinyURL($sURL) Local $sRead = BinaryToString(InetRead('http://preview.tinyurl.com/' & StringRegExpReplace($sURL, '^V*/', ''))) Local $aReturn = StringRegExp($sRead, 'redirecturl"shref="(V+)"', 3) If @error Then Return SetError(1, 0, '') EndIf Return StringStripWS($aReturn[0], 8) EndFunc ;==>_GetURLFromTinyURL Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _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_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasswordValid • PasteBin • Posts Per Day • PreExpand • SciTE Jump • SHELLHOOK • Signature Creator [19] guinness guinness Twerking my code Developers 14,169 posts Posted 30 July 2012 - 01:24 PM AutoIt expandcollapse popup#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 Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _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() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • [20] JohnOne JohnOne John Active Members 10,120 posts Posted 30 July 2012 - 02:33 PM 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, 30 July 2012 - 02:36 PM. AutoIt Absolute Beginners Require a serial Ukraine News
quickies Posted December 22, 2013 Author Posted December 22, 2013 I don't understand is this question not worthy?
l3ill Posted December 22, 2013 Posted December 22, 2013 What Question? Looks lore like an example.... My Contributions... Reveal hidden contents SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
mikell Posted December 22, 2013 Posted December 22, 2013 Do you mean something like this ? looks a bit like reinventing the wheel And such a solution can be not very reliable... #include <Inet.au3> _ForumGetPostExScript("http://www.autoitscript.com/forum/topic/139260-autoit-snippets/", 10) ;========================================= Func _ForumGetPostExScript($sURLSrc, $iPstNum) Local $sRetHtmlSrc, $p, $txt = "" $sRetHtmlSrc = _InetGetSource($sURLSrc) $p = StringRegExp($sRetHtmlSrc, '(?s)#\d+\s+.+?</pre>', 3) If $iPstNum>UBound($p)-1 Then $iPstNum=UBound($p)-1 For $i = 0 to $iPstNum-1 $p[$i] = StringReplace($p[$i], '<div class="autoit">', '----------------------------------------------------------'&@crlf) $p[$i] = _HTML_StripTags($p[$i]) $p[$i] = StringRegExpReplace($p[$i], '(?s)(#\d+)\s+(\S+).+?(AM|PM)', "$1" &@crlf& "$2" &@crlf) $p[$i] = StringRegExpReplace($p[$i], '(AutoIt\h+expandcollapse\h+popup)', "") $txt &= $p[$i] &@crlf& '----------------------------------------------------------' &@crlf&@crlf&@crlf Next FileWrite("result.txt", $txt) EndFunc ;==> _GetPostNumber Func _HTML_StripTags($sHTMLData) If $sHTMLData = "" Then Return SetError(1, 0, $sHTMLData) Local $oHTML = ObjCreate("HTMLFILE") If @error Then Return SetError(1, 0, $sHTMLData) $oHTML.Open() $oHTML.Write($sHTMLData) Return SetError(0, 0, $oHTML.Body.InnerText) EndFunc ;==>_HTML_StripTag
quickies Posted December 22, 2013 Author Posted December 22, 2013 On 12/22/2013 at 9:53 AM, l3ill said: What Question? Looks lore like an example.... lerfect! Thanks sooo much for your haelp, just the answer I was looking for.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now