JSThePatriot Posted June 7, 2005 Share Posted June 7, 2005 Here are two more fuctions that may be useful.1. Converts String to Hex String2. Converts Hex String to StringThe files are attached below.Thanks,JSStrToHex.zipHexToStr.zip<{POST_SNAPBACK}>I have updated the old code to use less line and possibly a bit optimized for speed.Old Codeexpandcollapse popupFunc _StrToHex($strChar) Local $aryChar, $i, $iDec, $hChar, $file, $strHex $aryChar = StringSplit($strChar, "") For $i = 1 To $aryChar[0] $iDec = Asc($aryChar[$i]) $hChar = Hex($iDec, 2) $strHex = $strHex & $hChar Next If $strHex = "" Then SetError(1) Return -1 Else Return $strHex EndIf EndFunc Func _HexToStr($strHex) Local $strChar, $aryHex, $i, $iDec, $Char, $file, $strHex $aryHex = StringSplit($strHex, "") For $i = 1 To $aryHex[0] $iOne = $aryHex[$i] $i = $i + 1 $iTwo = $aryHex[$i] $iDec = Dec($iOne & $iTwo) $Char = Chr($iDec) $strChar = $strChar & $Char Next If $strChar = "" Then SetError(1) Return -1 Else Return $strChar EndIf EndFuncNew CodeFunc _StringToHex($strChar) Local $aryChar, $i, $iDec, $hChar, $file, $strHex $aryChar = StringSplit($strChar, "") For $i = 1 To $aryChar[0] $strHex = $strHex & Hex(Asc($aryChar[$i]), 2) Next If $strHex = "" Then SetError(1) Return -1 Else Return $strHex EndIf EndFunc Func _HexToString($strHex) Local $strChar, $aryHex, $i, $iDec, $Char, $file, $strHex, $iOne, $iTwo $s_Length = StringLen($strHex) For $i = 1 To $s_Length Step 2 $strChar = $strChar & Chr(Dec(StringMid($strHex, $i, 2))) Next If $strChar = "" Then SetError(1) Return -1 Else Return $strChar EndIf EndFuncI have re uploaded the files so that they would be in proper format, and updated.StrToHex.zipHexToStr.zipThanks,JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
doucment Posted June 17, 2005 Share Posted June 17, 2005 Thanks u for the job Link to comment Share on other sites More sharing options...
myredeemerlives Posted June 17, 2005 Share Posted June 17, 2005 To get UDF's added to the standard library you will have to follow the standards as defined in the first post in this threat...Its also better to publish your UDF's in the Scripts and Scraps forum first so people can comment/test them so we can see if people like to have them included in the standard library and if they find bugs or have ideas about changes. <{POST_SNAPBACK}>You could get arrested for threatning people.I think I am gona go convert all my UDFs into a format suitable for publishment. Link to comment Share on other sites More sharing options...
erifash Posted June 26, 2005 Share Posted June 26, 2005 (edited) I have just created a UDF for Math.au3. It converts degrees into radians and can be used in conjunction with the Sin(), Cos(), and Tan() functions because they require radians, not degrees. I searched the helpfile and noticed AutoIt doesn't have a function to convert degrees into radians so I made one. Math.zip EDIT: Added a _Degree() function. EDIT2: Updated. Proper format. Edited July 18, 2005 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
w0uter Posted June 26, 2005 Share Posted June 26, 2005 read this: http://www.autoitscript.com/autoit3/scite/...F_Standards.htmalso i would like a _Degrees function to convert it back. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
erifash Posted August 1, 2005 Share Posted August 1, 2005 (edited) This UDF will print a file using the ShellExecute function of shell32.dll. I have included a global constants list that defines the error codes. Thanks to ezzetabi for making the _ShellExecute function! The code helped me make this.Here's the function documentation:;=============================================================================== ; ; Function Name: _FilePrint() ; ; Description: Prints a plain text file. ; ; Syntax: _FilePrint ( $s_File [, $i_Show] ) ; ; Parameter(s): $s_File = The file to print. ; $i_Show = The state of the window. (default = @SW_HIDE) ; ; Requirement(s): External: = shell32.dll (it's already in system32). ; Internal: = None. ; ; Return Value(s): On Success: = Returns 1. ; On Failure: = Returns 0 and sets @error according to the global constants list. ; ; Author(s): erifash <erifash [at] gmail [dot] com> ; ; Note(s): Uses the ShellExecute function of shell32.dll. ; ; Example(s): ; _FilePrint("C:\file.txt") ; ;===============================================================================The zip is attached. You can find the topic here.File.zip Edited August 2, 2005 by erifash My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
w0uter Posted August 7, 2005 Share Posted August 7, 2005 what can it print other then .txt ? My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
peethebee Posted August 8, 2005 Share Posted August 8, 2005 Hi!If somebody has time to look at it:I created some functions to animate text in controls. It's still in development, but ideas are welcome and there's still a little display problem.Link: http://www.autoitscript.com/forum/index.php?showtopic=14409peethebee vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvGerman Forums: http://www.autoit.deGerman Help File: http://autoit.de/hilfe vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv Link to comment Share on other sites More sharing options...
MSLx Fanboy Posted August 8, 2005 Share Posted August 8, 2005 I would like to request that ProcessGetPriority() be added to the includes files. The code has been cleaned up from the previous version I had posted.ProcessGetPriority.zip Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate()) Link to comment Share on other sites More sharing options...
svennie Posted August 11, 2005 Share Posted August 11, 2005 I have writed some scripts to enchance the Inet functions get it here:http://www.autoitscript.com/forum/index.php?showtopic=14594 Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF Link to comment Share on other sites More sharing options...
erifash Posted August 13, 2005 Share Posted August 13, 2005 what can it print other then .txt ?<{POST_SNAPBACK}>It can print any plain text file type that has an editor associated with it that has a print option. I have only tested it with txt files but I am certain it will work with other types. To print a plain text file that has no editor associated with it, you would simply need to do this:FileMove("textfile.extention", "textfile.txt") _FilePrint("textfile.txt") FileDelete("textfile.txt") My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
w0uter Posted August 13, 2005 Share Posted August 13, 2005 to bad it cant print like doc or html My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
erifash Posted November 9, 2005 Share Posted November 9, 2005 With w0uter's help, I have created a UDF that returns a process name out of a given PID. I believe this could be quite useful. Here is the documentation:;=============================================================================== ; ; Description - Returns a string containing the process name that belongs to a given PID. ; ; Syntax - _ProcessGetName( $iPID ) ; ; Parameters - $iPID - The PID of a currently running process ; ; Requirements - None. ; ; Return Values - Success - The name of the process ; Failure - Blank string and sets @error ; 1 - Process doesn't exist ; 2 - Error getting process list ; 3 - No processes found ; ; Author(s) - Erifash <erifash [at] gmail [dot] com>, Wouter van Kesteren. ; ; Notes - Supplementary to ProcessExists(). ; ;===============================================================================The topic can be found here. The zip is attached. Thanks for your time! process.zip My UDFs:_FilePrint() | _ProcessGetName() | _Degree() and _Radian()My Scripts:Drive Lock - Computer Lock Using a Flash DriveAU3Chat - Simple Multiuser TCP ChatroomStringChunk - Split a String Into Equal PartsAutoProxy - Custom Webserver Link to comment Share on other sites More sharing options...
CatchFish Posted November 14, 2005 Share Posted November 14, 2005 A small correction to _GUICtrlListViewDeleteItemsSelected() UDF in AutoIt v3.1.1.87 Func _GUICtrlListViewDeleteItemsSelected($h_listview, $s_WindowTitle = "", $s_WindowText = "") Local $i, $ItemCount If (StringLen($s_WindowTitle) == 0) Then $s_WindowTitle = WinGetTitle("") EndIf $ItemCount = _GUICtrlListViewGetItemCount($h_listview) If (_GUICtrlListViewGetSelectedCount($h_listview) == $ItemCount) Then _GUICtrlListViewDeleteAllItems($h_listview) Else Local $items = _GUICtrlListViewGetSelectedIndices($h_listview, 1, $s_WindowTitle, $s_WindowText) ;************* added by CatchFish *********** If Not IsArray($items) Then Return ;******* without this, an error will occur when no item is selected ;******************************************** ControlListView($s_WindowTitle, $s_WindowText, $h_listview, "SelectClear") For $i = $items[0] To 1 Step - 1 ;~ ConsoleWrite($items[$i] & @LF) ;commented by CatchFish _GUICtrlListViewDeleteItem($h_listview, $items[$i]) Next EndIf EndFunc ;==>_GUICtrlListViewDeleteItemsSelected Link to comment Share on other sites More sharing options...
Guest Darksoul71 Posted November 18, 2005 Share Posted November 18, 2005 May be my filename proccessing UDF´s are also something you are interested, -D$ Straight from the readme: Purpose: Filename.au3 is a small set of UDF´s (=User defined functions) which I developed for my own little scripts. Freel free to use the source code as you like. I just would like to encourage everyone to release his sources under GPL whenever you distribute a script as binary. My UDF´s are depending on the file.au3 script from the latest beta as I´m using some of the included functions. Functions included and what the do: *Func _FileExtractPath ($FileName) This function extracts the file path with trailing "\" for a filename with path. Example: _FileExtractPath("C:\MyPath\MyFile.TXT") returns "C:\MyPath\" * Func _FileExtractFilename ($FileName) This function extracts the file name for a filename with path. Example: _FileExtractFilename("C:\MyPath\MyFile.TXT") returns "MyFile.TXT" * Func _FileGetExt ($FileName) This function returns the extension for a filename with path with "." Example: _FileGetExt ("C:\MyPath\MyFile.TXT") returns ".TXT" * Func _FileChangeExt ($FileName, $Extension) This function changes the extension for a filename with path. Example: _FileChangeExt ("C:\MyPath\MyFile.TXT", "doc") returns "C:\MyPath\MyFile.doc" * Func _FileStripExt ($FileName) This function strips the extension for a filename with path. Example: _FileStripExt ("C:\MyPath\MyFile.TXT") returns "C:\MyPath\MyFile" * Func _FileIncrementFileName ($FileName) This function generates a unique filename for a filename with path if the file exists. Example: _FileIncrementFileName ("C:\MyPath\MyFile.TXT") returns "C:\MyPath\MyFile.TXT" when "C:\MyPath\MyFile.TXT" does not exist "C:\MyPath\MyFile (1).TXT" when "C:\MyPath\MyFile.TXT" does exist "C:\MyPath\MyFile (2).TXT" when "C:\MyPath\MyFile (1).TXT" does exist "C:\MyPath\MyFile (3).TXT" when "C:\MyPath\MyFile (2).TXT" does exist and so on. I´ve provided a little sample script called "MoveFileUnique.au3" as example for what you can use this function. * Func _GenerateIncrementedFileNames ($FullPath, $Count, byRef $myArray) This function is intended to be a "counterpart" for _FileIncrementFileName and generates a directory which keeps up to $Count filenames with the same naming scheme as _FileIncrementFileName produces. This enables you to search for incremental filnames based on the "base name" without dealing with FileFindFirstFile. In one of my scripts I use _FileIncrementFileName to store multiple setting files under unique names. Afterwards I generate an array with _GenerateIncrementedFileNames with 10000 filenames and do a simple "FileExists" loop for each of those filenames stored in the array. Note: If $myArray isn´t initialized, the function will do a DIM by itself. Example: _GenerateIncrementedFileNames ("C:\MyPath\MyFile.TXT", 4, $myArr) would return the following array $myArr[0] = "C:\MyPath\MyFile.TXT" $myArr[1] = "C:\MyPath\MyFile (1).TXT" $myArr[2] = "C:\MyPath\MyFile (2).TXT" $myArr[3] = "C:\MyPath\MyFile (3).TXT" * Func _DrivePercentFree ($FullPath) This function return the available diskspace on a drive in % Example: _DrivePercentFree ("C:\") would return 50 if your HD has a size of 8 GB and 4 GB are still free. * Func _IsSearchedType ($FullPath, $Types) This function return "1" it the filename in $FullPath matches one of the extension defined by $Types and returns "0" if it doesn´t match any of the defined extensions. $Types can be a single extension without any separator (e.g. $Types = "txt") or multiple extensions using one of the following separators "|,;:", e.g. $Types = "avi,mpg,mpeg" is similar to $Types = "avi|mpg|mpeg" or $Types = "avi:mpg:mpeg" The dot for the extension is optional and will be added if missing, e.g. both $Types = ".avi,.mpg" and $Types = "avi,mpg" are valid. Extensions are NOT casesensitive and will be converted to uppercase prior comparison. Example: _IsSearchedType ("C:\This is a file.txt", "txt,doc,rtf") would return 1 as one of the specified extensions is txt. * Func _FileSearchForText ($SearchFile, $SearchString, $CaseSensitive) This function searches for a searchstring within a textfile. The search can be casesensitive or not. Example: _FileSearchForText ("C:\myTextfile.txt", "myString", 1) returns 1 if "myString" is found within "C:\myTextfile.txt" or returns 0 if it´s not found. Setting $CaseSensitive to 0 will deactivate casesensitive search. In other words "myString" equals "MYSTRING", "mySTRING", MyStRiNG", etc. * Func _FileSearchAndReplaceText ($SearchFile, $SearchString, $ReplaceString, $CaseSensitive) This function does nearly the same as _FileSearchForText but instead of only searching for a searchstring within a textfile, it will replace any instance of the found string by $ReplaceString. The search and replace process can be casesensitive or not. Examples: _FileSearchAndReplaceText ("C:\myTextfile.txt", "myString", "Replace", 1) will replace any instance of "myString" within "C:\myTextfile.txt" by the String "Replace". Setting $CaseSensitive to 0 will deactivate casesensitive search and replace. In other words "myString" equals "MYSTRING", "mySTRING", MyStRiNG", etc. and will be replaced by the String "Replace". * Func _FileAppendTextfile ($ToAppend, $FromAppend) This function appends the content of the textfile specified under $FromAppend to the textfile specified under $ToAppend. Example: _FileAppendTextfile ("C:\myFile.txt", "C:\myAppendFile.txt") would append all the content from "C:\myAppendFile.txt" at the end of "C:\myFile.txt".dsfile.zip Link to comment Share on other sites More sharing options...
Confuzzled Posted December 18, 2005 Share Posted December 18, 2005 Could we squeeze in a small addition to the standard date.au3 UDF functions? I've called it _MonthStringToNumberThis is the opposite function of _DateMonthOfYear($iMonthNum, $iShort). It takes a month name as a string parameter and returns it as the numeric value of the month.Very useful when date is extracted from text to convert it into usable format for manipulation by other functions within date.au3, especially when screen scraping from other applications and the Internet.Note: Logically it follows just after the _DateMonthOfYear function in date.au3expandcollapse popup;=============================================================================== ; ; Description: Returns the month in two digit number from alpha month name ; Parameter(s): $MonthString - Input month code in format where first three characters are valid months ; irrespective of case or rest of spelling ; Requirement(s): None ; Return Value(s): On Success - Returns two digit numeric month code ; On Failure - 0 and Sets @ERROR to: 1 - Invalid $MonthString ; Author(s): Confuzzled ; Note(s): Assumes English spelling of Months ; ;=============================================================================== Func _MonthStringToNumber($MonthString);Returns month in two digit number from alpha month name ;============================================== ; Local Constant/Variable Declaration Section ;============================================== Local $MonthNum ;Convert supplied month string by stripping the left three characters and changing them to uppercase $MonthString=StringUpper(StringLeft($MonthString,3)) Select Case $MonthString = "JAN" $MonthNum = "01" Case $MonthString = "FEB" $MonthNum = "02" Case $MonthString = "MAR" $MonthNum = "03" Case $MonthString = "APR" $MonthNum = "04" Case $MonthString = "MAY" $MonthNum = "05" Case $MonthString = "JUN" $MonthNum = "06" Case $MonthString = "JUL" $MonthNum = "07" Case $MonthString = "AUG" $MonthNum = "08" Case $MonthString = "SEP" $MonthNum = "09" Case $MonthString = "OCT" $MonthNum = "10" Case $MonthString = "NOV" $MonthNum = "11" Case $MonthString = "DEC" $MonthNum = "12" ; Allow for non-valid entries if got to here Case Else $MonthNum = "00" SetError(1) Return (0) EndSelect ;Send back the month in numeric format Return $MonthNum EndFunc ;==>_MonthStringToNumberExample of usage would be to call it as _MonthStringToNumber("JaNUary") and get "01" returned. Note the input case and spelling are not an issue if the first three letters are valid month prefixes.I can't say it's bulletproof, but it does include some workarounds for common corrupt input data. Any suggestions, changes, additions welcome. Link to comment Share on other sites More sharing options...
w0uter Posted December 18, 2005 Share Posted December 18, 2005 (edited) why not like this Func _MonthStringToNumber($MonthString) Switch StringLeft($MonthString, 3) Case "JAN" Return "01" Case "FEB" Return "02" Case "MAR" Return "03" Case "APR" Return "04" Case "MAY" Return "05" Case "JUN" Return "06" Case "JUL" Return "07" Case "AUG" Return "08" Case "SEP" Return "09" Case "OCT" Return "10" Case "NOV" Return "11" Case "DEC" Return "12" EndSwitch SetError(1) Return "00" EndFunc ;==>_MonthStringToNumber Edited December 18, 2005 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
dragonrider Posted December 18, 2005 Share Posted December 18, 2005 I agree with changing it from the "Select" to the "Switch" statement, but you forgot to make the string uppercase. So you need to replace: Switch StringLeft($MonthString, 3) with: Switch StringUpper( StringLeft($MonthString, 3) ) Regards Dragonrider why not like this Func _MonthStringToNumber($MonthString) Switch StringLeft($MonthString, 3) Case "JAN" Return "01" Case "FEB" Return "02" Case "MAR" Return "03" Case "APR" Return "04" Case "MAY" Return "05" Case "JUN" Return "06" Case "JUL" Return "07" Case "AUG" Return "08" Case "SEP" Return "09" Case "OCT" Return "10" Case "NOV" Return "11" Case "DEC" Return "12" EndSwitch SetError(1) Return "00" EndFunc ;==>_MonthStringToNumber Link to comment Share on other sites More sharing options...
w0uter Posted December 18, 2005 Share Posted December 18, 2005 nope, the comapre is case INsensitive. try mine and you will see My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Walkabout Posted December 18, 2005 Share Posted December 18, 2005 DIRECT eMail UDFThis udf will send an email using TCP rather than an external mail client.Link to threadLatest version and associated UDF files attached.INetSmtpMail.au3INetSmtpMail.txtINetSmtpMail_Example.au3 My Stuff:AutoIt for the MassesWait until Oracle Apps is readySend email natively from Autoit3 Link to comment Share on other sites More sharing options...
Recommended Posts