#include-once ; #INDEX# ======================================================================================================================= ; Title .........: Frankenstein ; AutoIt Version : v3.3.16.1 ; UDF Version....: v1.2 ; Language ......: English ; Description ...: IRC Functions ; Time Conversion Functions ; Token String Functions ; Other Misc Functions ; Includes _IsPressed and _FileCreate (modified to run without constants) ; Author(s) .....: Neo_ (aka coderusa) - OTHERS: [ _IsPressed --> ezzetabi and Jon ] - [ _FileCreate --> Brian Keene ] ; Dll(s) ........: UxTheme.dll, User32.dll ; Remarks .......: Version 1.2, added some new IRC functions, refined Token String functions, added Time Conversion functions. ; =============================================================================================================================== ; #CURRENT IRC Functions# ======================================================================================================= ; IRC_Change_Nick ; IRC_Chanserv ; IRC_Command ; IRC_Join_Channel ; IRC_Kick_User ; IRC_Nickserv ; IRC_Send_Action ; IRC_Send_CTCP ; IRC_Send_Notice ; IRC_Send_PrivMsg ; IRC_Server_Connect ; IRC_Server_Disconnect ; IRC_Server_Ping ; IRC_Set_ChanMode ; IRC_Set_ChanTopic ; IRC_Set_UserMode ; IRC_Part_Channel ; =============================================================================================================================== ; #CURRENT Time Conversion Functions# =========================================================================================== ; MilSecConvertMsg ; MilSecToHour ; MilSecToMin ; MilSecToSec ; MinToHour ; SecToHour ; SecToMilSec ; SecToMin ;================================================================================================================================ ; #CURRENT Token String Functions# ============================================================================================== ; AddTok ; DelTok ; GetTok ; NumTok ; PutTok ; RemTok ; RepTok ; =============================================================================================================================== ; #CURRENT Misc Functions# ====================================================================================================== ; Cons ; _FileCreate ; Ini_Prc ; _IsPressed ; Parity ; UxTheme ; =============================================================================================================================== ; #IRC FUNCTIONS#================================================================================================================ ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Change_Nick ; Description.....: Change IRC username ; Syntax..........: IRC_Change_Nick($socket, $nick) ; Parameters......: $socket - main socket identifier ; $nick - new nickname ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Change_Nick($socket, $nick) TCPSend($socket, "NICK :" & $nick & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Change_Nick ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Chanserv ; Description.....: Send PRIVMSG to Chanserv ; Syntax..........: IRC_Chanserv($socket, $data) ; Parameters......: $socket - main socket identifier ; $data - data to be sent to chanserv ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Chanserv($socket, $data) TCPSend($socket, "PRIVMSG Chanserv :" & $data & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Command ; Description.....: Send IRC protocol commands ; Syntax..........: IRC_Command($socket, $data) ; Parameters......: $socket - main socket identifier ; $data - "COMMAND :TEXT" -basic irc protocols ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Command($socket, $data) TCPSend($socket, $data & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Command ; #FUNCTION# ===================================================================================================================== ; Name............: IRC_Join_Channel ; Description.....: Join to IRC Channel ; Syntax..........: IRC_Join_Channel($socket, $chan) ; Parameters......: $socket - main socket identifier ; $chan - Channel name ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Join_Channel($socket, $chan) TCPSend($socket, "JOIN " & $chan & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Join_Channel ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Kick_User ; Description.....: KICK user from channel ; Syntax..........: IRC_Kick_User($socket, $channel, $user, $msg) ; Parameters......: $socket - main socket identifier ; $channel - channel name ; $user - user name to be kicked ; $msg - kick message ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Kick_User($socket, $channel, $user, $msg) TCPSend($socket, "KICK " & $channel & " " & $user & " :" & $msg & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Kick_User ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Nickserv ; Description.....: Send PRIVMSG to Nickserv ; Syntax..........: IRC_Nickserv($socket, $data) ; Parameters......: $socket - main socket identifier ; $data - data to be sent to nickserv ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Nickserv($socket, $data) TCPSend($socket, "PRIVMSG Nickserv :" & $data & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Send_Action ; Description.....: Send ACTION message ; Syntax..........: IRC_Send_Action($socket, $target, $msg) ; Parameters......: $socket - main socket identifier ; $target - #Channel or Username ; $message - ACTION text ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Send_Action($socket, $target, $msg) TCPSend($socket, "PRIVMSG " & $target & " :ACTION " & $msg & "" & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Send_Action ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Send_CTCP ; Description.....: Sends CTCP information ; Syntax..........: IRC_Send_CTCP($socket, $user, $data) ; Parameters......: $socket - main socket identifier ; $user - username to send CTCP ; $data - CTCP data/message ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Send_CTCP($socket, $user, $data) TCPSend($socket, "NOTICE " & $user & " :" & $data & "" & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Send_CTCP ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Send_Notice ; Description.....: Send PRIVMSG ; Syntax..........: IRC_Send_Notice($socket, $target, $msg) ; Parameters......: $socket - main socket identifier ; $target - #Channel or Username ; $message - NOTICE text ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Send_Notice($socket, $target, $msg) TCPSend($socket, "NOTICE " & $target & " :" & $msg & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Send_Notice ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Send_PrivMsg ; Description.....: Send PRIVMSG ; Syntax..........: IRC_Send_PrivMsg($socket, $target, $msg) ; Parameters......: $socket - main socket identifier ; $target - #Channel or Username ; $message - PRIVMSG text ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Send_PrivMsg($socket, $target, $msg) TCPSend($socket, "PRIVMSG " & $target & " :" & $msg & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Send_PrivMsg ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Server_Connect ; Description.....: Connect to IRC Server ; Syntax..........: IRC_Server_Connect($server, $port, $user) ; Parameters......: $server - Plain text server name "irc.server.net" ; $port - Numeric server port "6667" ; $user - User name ; Return Values...: Returns main socket identifier ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Server_Connect($server, $port, $user) $socket = TCPConnect(TCPNameToIp($server), $port) Sleep(100) If $socket = -1 Then Cons("No response from server.") Exit EndIf TCPSend($socket, "NICK " & $user & @CRLF) TCPSend($socket, "USER " & $user & " 0 0 " & $user & @CRLF) Return $socket EndFunc ;===> IRC_Server_Connect ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Server_Disconnect ; Description.....: QUIT from server ; Syntax..........: IRC_Server_Disconnect($socket, $msg) ; Parameters......: $socket - main socket identifier ; $msg - Quit message ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Server_Disconnect($socket, $msg) TCPSend($socket, "QUIT :" & $msg & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Server_Disconnect ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Server_Ping ; Description.....: Sends PONG reply to server for Ping? Pong! ; Syntax..........: IRC_Server_Ping($socket, $msg) ; Parameters......: $socket - main socket identifier ; $msg - Ping message ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Server_Ping($socket, $msg) TCPSend($socket, "PONG " & $msg & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Server_Ping ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Set_ChanMode ; Description.....: Set IRC channel modes ; Syntax..........: IRC_Set_ChanMode($socket, $channel, $mode) ; Parameters......: $socket - main socket identifier ; $channel - IRC channel ; $mode - channel mode(s) ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Set_ChanMode($socket, $channel, $mode) TCPSend($socket, "MODE " & $channel & " " & $mode & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Set_ChanMode ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Set_ChanTopic ; Description.....: Set's channel topic ; Syntax..........: IRC_Set_ChanTopic($socket, $channel, $topic) ; Parameters......: $socket - main socket identifier ; $channel - channel name ; $topic - TOPIC text ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Set_ChanTopic($socket, $channel, $topic) TCPSend($socket, "TOPIC " & $channel & " :" & $topic & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Set_ChanTopic ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Set_UserMode ; Description.....: Set user mode on channel ; Syntax..........: IRC_Set_UserMode($socket, $channel, $mode, $user) ; Parameters......: $socket - main socket identifier ; $channel - channel name ; $mode - mode to be set ; $user - username for mode ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Set_UserMode($socket, $channel, $mode, $user) TCPSend($socket, "MODE " & $channel & " " & $mode & " " & $user & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Set_UserMode ; #FUNCTION# ==================================================================================================================== ; Name............: IRC_Part_Channel ; Description.....: Leaave IRC Channel ; Syntax..........: IRC_Part_Channel($socket, $chan) ; Parameters......: $socket - main socket identifier ; $chan - Channel name ; Return Values...: Failure: -1 ; Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func IRC_Part_Channel($socket, $chan, $msg = "") TCPSend($socket, "PART " & $chan & " :" & $msg & @CRLF) If @error Then Cons("Server connection lost.") Return -1 EndIf Return 1 EndFunc ;===> IRC_Part_Channel ; #TIME CONVERSION FUNCTIONS# ==================================================================================================== ; #FUNCTION# ===================================================================================================================== ; Name............: MilSecConvertMsg($mseconds) ; Description.....: Converts miliseconds into a Hours, Minutes and Seconds statement ; Syntax..........: MilSecConvertMsg($mseconds) ; Parameters......: $mseconds - number of milliseconds to be converted ; Return Values...: Returns a statement " X hours X minutes X seconds " in whole numbers ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: MilSecConvertMsg(86388000) - Returns "23 hours 59 minutes 48 seconds" ; MilSecConvertMsg(86400000) - Returns "24 hours 0 minutes 0 seconds" ; Remarks ........: Based on _TicksToTime by Marc ; ================================================================================================================================ Func MilSecConvertMsg($mseconds) $time = Int($mseconds / 1000) $hours = Int($time / 3600) $time = Mod($time, 3600) $minutes = Int($time / 60) $seconds = Mod($time, 60) Return $hours & " hours " & $minutes & " minutes " & $seconds & " seconds" EndFunc ;===> MilSecConvertMsg ; #FUNCTION# ===================================================================================================================== ; Name............: MilSecToHour ; Description.....: Converts milliseconds to hours ; Syntax..........: MilSecToHour($mseconds) ; Parameters......: $mseconds - number of milliseconds to be convrted ; Return Values...: Returns the hours value (up to two decimal places) ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: MilSecToHour(3600000) - Returns 1 ; MilSecToHour(5400000) - Returns 1.5 ; ================================================================================================================================ Func MilSecToHour($mseconds) $time = $mseconds / 1000 Return Round($time / 3600, 2) EndFunc ;===> MilSecToHour ; #FUNCTION# ===================================================================================================================== ; Name............: MilSecToMin ; Description.....: Converts milliseconds to minutes ; Syntax..........: MilSecToMin($mseconds) ; Parameters......: $mseconds - number of milliseconds to be convrted ; Return Values...: Returns the minutes value (up to two decimal places) ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: MilSecToMin(60000) - Returns 1 ; MilSecToMin(60500) - Returns 1.5 ; ================================================================================================================================ Func MilSecToMin($mseconds) $time = $mseconds / 1000 Return Round($time / 60, 2) EndFunc ;===> MilSecToMin ; #FUNCTION# ===================================================================================================================== ; Name............: MilSecToSec ; Description.....: Converts milliseconds to seconds ; Syntax..........: MilSecToSec($mseconds) ; Parameters......: $mseconds - number of milliseconds to be convrted ; Return Values...: Returns the seconds value (up to two decimal places) ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: MilSecToSec(1000) - Returns 1 ; MilSecToSec(1500) - Returns 1.5 ; ================================================================================================================================ Func MilSecToSec($mseconds) Return Round($mseconds / 1000, 2) EndFunc ;===> MilSecToSec ; #FUNCTION# ===================================================================================================================== ; Name............: MinToHour ; Description.....: Converts minutes to hours ; Syntax..........: MinToHour($minutes) ; Parameters......: $minutes - number of minutes to be converted ; Return Values...: Returns the hour value of specified minutes (up to two decimal places) ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: MinToHour(30) - Returns 0.5 ; MinToHour(120) - Returns 2 ; ================================================================================================================================ Func MinToHour($minutes) Return Round($minutes / 60, 2) EndFunc ;===> MinToHour ; #FUNCTION# ===================================================================================================================== ; Name............: SecToHour ; Description.....: Converts seconds into hours ; Syntax..........: SecToHour($seconds) ; Parameters......: $seconds - number of seconds to be converted ; Return Values...: Returns the hour value of specified seconds (up to two decimal places) ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: SecToHour(3600) - Returns 1 ; SecToHour(5400) - Returns 1.5 ; ================================================================================================================================ Func SecToHour($seconds) Return Round($seconds / 3600, 2) EndFunc ;===> SecToHour ; #FUNCTION# ===================================================================================================================== ; Name............: SecToMilSec ; Description.....: Converts seconds into milliseconds ; Syntax..........: SecToMilSec($seconds) ; Parameters......: $seconds - number of seconds to be converted ; Return Values...: Returns the millisecond value ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: SecToMilSec(1) - Returns 1000 ; ================================================================================================================================ Func SecToMilSec($seconds) Return Int($seconds * 1000) EndFunc ;===> SecToMilSec ; #FUNCTION# ===================================================================================================================== ; Name............: SecToMin ; Description.....: Converts seconds into minutes ; Syntax..........: SecToMin($seconds) ; Parameters......: $seconds - number of seconds to be converted ; Return Values...: Returns the minute value of specified seconds (up to two decimal places) ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: SecToMin(60) - Returns 1 ; ================================================================================================================================ Func SecToMin($seconds) Return Round($seconds / 60, 2) EndFunc ;===> SecToMin ; #TOKEN STRING FUNCTIONS#======================================================================================================= ; #FUNCTION# ==================================================================================================================== ; Name............: AddTok ; Description.....: Adds a token to end of a token string. ; Syntax..........: AddTok($string, $token, $chr) ; Parameters......: $string - The token string ; $token - The token to be added ; $chr - ascii value of the character separating the tokens ; Return Values...: Returns the token string with the new token added to the end ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: AddTok("A,B,C,D", "E", "44") - Returns A,B,C,D,E ; AddTok("1?2?3?4", "5", "63") - Returns 1?2?3?4?5 ; ================================================================================================================================ Func AddTok($string, $token, $chr) Return $string & Chr($chr) & $token EndFunc ;===> AddTok ; #FUNCTION# ===================================================================================================================== ; Name............: DelTok ; Description.....: Removes all matching tokens from string. ; Syntax..........: DelTok($string, $token, $chr) ; Parameters......: $string - The token string ; $token - Token match criteria, no wildcards. ; $chr - ascii value of the character separating the tokens ; Return Values...: Returns token string with specified token matches removed ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: DelTok("A,B,E,C,D,E" "E", "44") - Returns "A,B,C,D" ; ================================================================================================================================ Func DelTok($string, $token, $chr) $tok = StringSplit($string, Chr($chr)) $NewString = " " For $x = 1 To $tok[0] Step 1 If $token = $tok[$x] Then ContinueLoop Else If $NewString = " " Then $NewString = $tok[$x] ContinueLoop Else $NewString = $NewString & Chr($chr) & $tok[$x] ContinueLoop EndIf EndIf Next Return $NewString EndFunc ;===> DelTok ; #FUNCTION# ===================================================================================================================== ; Name............: GetTok ; Description.....: Retreives a token from specified position in token string ; Syntax..........: GetTok($string, $x, $chr) ; Parameters......: $string - The token string ; $x - Location of token to be retreived ; $chr - ascii value of the character separating the tokens ; Return Values...: Returns a token from specified position ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: GetTok("A,B,C,D", "2", "44") - Returns B ; ================================================================================================================================ Func GetTok($string, $x, $chr) $tok = StringSplit($string, Chr($chr)) return $tok[$x] EndFunc ;===> GetTok ; #FUNCTION# ===================================================================================================================== ; Name............: NumTok ; Description.....: Counts the total number of tokens in the string ; Syntax..........: NumTok($string, $chr) ; Parameters......: $string - The token string ; $chr - ascii value of the character separating the tokens ; Return Values...: Returns the total number of tokens in the string ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: NumTok("A,B,C,D", "44") - Returns 4 ; ================================================================================================================================ Func NumTok($string, $chr) $NumTok = StringSplit($string, Chr($chr)) Return $NumTok[0] EndFunc ;===> NumTok ; #FUNCTION# ===================================================================================================================== ; Name............: PutTok ; Description.....: Places token in specified location in token string ; Syntax..........: PutTok($string, $token, $chr, $x) ; Parameters......: $string - The token string ; $token - The token to be added ; $chr - ascii value of the character separating the tokens ; $x - Location to put into token string ; Return Values...: Returns the token string with token put into position ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: PutTok("A,B,D,E", "C", "44", "3") - Returns "A,B,C,D,E" ; ================================================================================================================================ Func PutTok($string, $token, $chr, $x) $splt = StringSplit($string, Chr($chr)) $newstring = " " For $n = 1 To $splt[0] Step 1 If $n = $x Then If $newstring = " " Then $newstring = $token & Chr($chr) & $splt[$n] ContinueLoop Else $newstring = $newstring & Chr($chr) & $token & Chr($chr) & $splt[$n] ContinueLoop EndIf Else If $newstring = " " Then $newstring = $splt[$n] ContinueLoop Else $newstring = $newstring & Chr($chr) & $splt[$n] ContinueLoop EndIf EndIf Next Return $newstring EndFunc ;===> PutTok ; #FUNCTION# ===================================================================================================================== ; Name............: RemTok ; Description.....: Removes specified token from string ; Syntax..........: RemTok($string, $x, $chr) ; Parameters......: $string - The token string ; $x - Location of token to be removed ; $chr - ascii value of the character separating the tokens ; Return Values...: Returns token string with specified token removed ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: RemTok("A,B,T,C,D", "3", "44") - Returns "A,B,C,D" ; ================================================================================================================================ Func RemTok($string, $x, $chr) $tok = StringSplit($string, Chr($chr)) $NewString = " " For $t = 1 To $tok[0] Step 1 If $t = $x Then ContinueLoop Else If $NewString = " " Then $NewString = $tok[$t] ContinueLoop Else $NewString = $NewString & Chr($chr) & $tok[$t] ContinueLoop EndIf EndIf Next Return $NewString EndFunc ;===> RemTok ; #FUNCTION# ===================================================================================================================== ; Name............: RepTok ; Description.....: Replaces specified token in token string with new token ; Syntax..........: RepTok($string, $token, $chr, $x) ; Parameters......: $string - The token string ; $token - The token to be added ; $chr - ascii value of the character separating the tokens ; $x - Location of token to be replaced ; Return Values...: Returns the token string with replaced token in position ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: RepTok("A,B,D,D", "C", "44", "3") - Returns "A,B,C,D" ; ================================================================================================================================ Func RepTok($string, $token, $chr, $x) $TokenString = " " For $tk = 1 To NumTok($string, $chr) Step 1 If $TokenString = " " Then If $x = $tk Then $TokenString = $token Else $TokenString = GetTok($string, $tk, $chr) EndIf ContinueLoop Else If $x = $tk Then $TokenString = $TokenString & Chr($chr) & $token ContinueLoop Else $TokenString = $TokenString & Chr($chr) & GetTok($string, $tk, $chr) ContinueLoop EndIf EndIf Next Return $TokenString EndFunc ;===> RepTok ; #OTHER MISC FUNCTIONS# ========================================================================================================= ; #FUNCTION# ===================================================================================================================== ; Name............: Cons ; Description.....: ConsoleWrite that includes @CRLF and only works if script is not compiled, for SciTE debugging ; Syntax..........: Cons($data) ; Parameters......: $data - Info to be written to STDOUT stream ; Return Values...: Success (Not Compiled): 1 ; Failure (Compiled): -1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func Cons($data) If Not @Compiled Then ConsoleWrite($data & @CRLF) Return 1 EndIf Return -1 EndFunc ;===> Cons ; #FUNCTION# ===================================================================================================================== ; Name...........: _FileCreate ; Description ...: Creates or zero's out the length of the file specified. ; Syntax.........: _FileCreate($sFilePath) ; Parameters ....: $sFilePath - Path and filename of the file to be created. ; Return values .: Success - Returns a 1 ; Failure - Returns a 0 ; @Error - 0 = No error. ; |1 = Error opening specified file ; |2 = File could not be written to ; Author ........: Brian Keene ; Modified.......: Neo_ (aka coderusa) ; Remarks .......: Copied from File.au3 and modified for Frankenstein.au3 (replaced $FO_OVERWRITE with raw value "2") ; Related .......: .FileOpen ; Link ..........: ; Example .......: Yes ; ================================================================================================================================ Func _FileCreate($sFilePath) Local $hOpenFile = FileOpen($sFilePath, 2) If $hOpenFile = -1 Then Return SetError(1, 0, 0) Local $hWriteFile = FileWrite($hOpenFile, "") FileClose($hOpenFile) If $hWriteFile = -1 Then Return SetError(2, 0, 0) Return 1 EndFunc ;===> _FileCreate ; #FUNCTION# ==================================================================================================================== ; Name............: Ini_Prc ; Description.....: Basic combination of reading/writing to ini files ; Syntax..........: Ini_Prc($filename, $section, $key, $prm, $data) ; Parameters......: $filename - File path and name of Ini file. ; $section - Ini file section ; $key - Ini file section key ; $prm - Parameter for (R)ead or (W)rite (Can also specify "O" for "W", same result - (O)verwrite) ; Return Values...: Writes to file, or returns specified section key ; Author..........: Neo_ (aka coderusa) ; Modified........: ; Example.........: Ini_Prc("File.ini", "Section1", "Key1", "R") - Returns specified section key value (same as IniRead) ; Ini_Prc("File.ini", "Section1", "Key1", "W", "NewData") - Writes "NewData" to specified section key. ; Ini_Prc("File.ini", "Section1", "Key1", "O", "NewData") - Same as "W" ; ================================================================================================================================= Func Ini_Prc($filename, $section, $key, $prm, $data = " ") ;Overwrites specified section key with $data If $prm = "O" or $prm = "W" Then IniWrite($filename, $section, $key, $data) Return 1 EndIf ;Returns the specified section key value If $prm = "R" Then Return IniRead($filename, $section, $key, "None") EndIf Return -1 EndFunc ;===> Ini_Prc ; #FUNCTION# ==================================================================================================================== ; Name...........: _IsPressed ; Description ...: Check if key has been pressed ; Syntax.........: _IsPressed($sHexKey[, $vDLL = 'user32.dll']) ; Parameters ....: $sHexKey - Key to check for ; $vDLL - Handle to dll or default to user32.dll ; Return values .: True - 1 ; False - 0 ; Author ........: ezzetabi and Jon ; Copied.........: Neo_ (aka coderusa) ; Remarks .......: Copied from Misc.au3 for Frankenstein.au3 ; If calling this function repeatidly, should open 'user32.dll' and pass in handle. ; Make sure to close at end of script ; 01 Left mouse button ; 02 Right mouse button ; 04 Middle mouse button (three-button mouse) ; 05 Windows 2000/XP: X1 mouse button ; 06 Windows 2000/XP: X2 mouse button ; 08 BACKSPACE key ; 09 TAB key ; 0C CLEAR key ; 0D ENTER key ; 10 SHIFT key ; 11 CTRL key ; 12 ALT key ; 13 PAUSE key ; 14 CAPS LOCK key ; 1B ESC key ; 20 SPACEBAR ; 21 PAGE UP key ; 22 PAGE DOWN key ; 23 END key ; 24 HOME key ; 25 LEFT ARROW key ; 26 UP ARROW key ; 27 RIGHT ARROW key ; 28 DOWN ARROW key ; 29 SELECT key ; 2A PRINT key ; 2B EXECUTE key ; 2C PRINT SCREEN key ; 2D INS key ; 2E DEL key ; 30 0 key ; 31 1 key ; 32 2 key ; 33 3 key ; 34 4 key ; 35 5 key ; 36 6 key ; 37 7 key ; 38 8 key ; 39 9 key ; 41 A key ; 42 B key ; 43 C key ; 44 D key ; 45 E key ; 46 F key ; 47 G key ; 48 H key ; 49 I key ; 4A J key ; 4B K key ; 4C L key ; 4D M key ; 4E N key ; 4F O key ; 50 P key ; 51 Q key ; 52 R key ; 53 S key ; 54 T key ; 55 U key ; 56 V key ; 57 W key ; 58 X key ; 59 Y key ; 5A Z key ; 5B Left Windows key ; 5C Right Windows key ; 60 Numeric keypad 0 key ; 61 Numeric keypad 1 key ; 62 Numeric keypad 2 key ; 63 Numeric keypad 3 key ; 64 Numeric keypad 4 key ; 65 Numeric keypad 5 key ; 66 Numeric keypad 6 key ; 67 Numeric keypad 7 key ; 68 Numeric keypad 8 key ; 69 Numeric keypad 9 key ; 6A Multiply key ; 6B Add key ; 6C Separator key ; 6D Subtract key ; 6E Decimal key ; 6F Divide key ; 70 F1 key ; 71 F2 key ; 72 F3 key ; 73 F4 key ; 74 F5 key ; 75 F6 key ; 76 F7 key ; 77 F8 key ; 78 F9 key ; 79 F10 key ; 7A F11 key ; 7B F12 key ; 7C-7F F13 key - F16 key ; 80H-87H F17 key - F24 key ; 90 NUM LOCK key ; 91 SCROLL LOCK key ; A0 Left SHIFT key ; A1 Right SHIFT key ; A2 Left CONTROL key ; A3 Right CONTROL key ; A4 Left MENU key ; A5 Right MENU key ; BA ; ; BB = ; BC , ; BD - ; BE . ; BF / ; C0 ` ; DB [ ; DC \ ; DD ] ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _IsPressed($sHexKey, $vDLL = 'user32.dll') ; $hexKey must be the value of one of the keys. ; _Is_Key_Pressed will return 0 if the key is not pressed, 1 if it is. Local $a_R = DllCall($vDLL, "short", "GetAsyncKeyState", "int", '0x' & $sHexKey) If @error Then Return SetError(@error, @extended, False) Return BitAND($a_R[0], 0x8000) <> 0 EndFunc ;===> _IsPressed ; #FUNCTION# ===================================================================================================================== ; Name............: Parity ; Description.....: Determines if $number is even or odd ; Syntax..........: Parity($number) ; Parameters......: $number - Number to be analyzed ; Return Values...: Even Number returns 0 ; Odd Number returns 1 ; Failure/Error returns -1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func Parity($number) If ($number/2)=Round($number/2) Then Return 0 Else Return 1 EndIf Return -1 EndFunc ;===> Parity ; #FUNCTION# ===================================================================================================================== ; Name............: UxTheme ; Description.....: For use in coloring GUI controls (like groups etc.) ; Syntax..........: UxTheme($controlID) ; Parameters......: $controlID - GUI Control ID ; Return Values...: Success: 1 ; Author..........: Neo_ (aka coderusa) ; Modified........: ; ================================================================================================================================ Func UxTheme($controlID) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($controlID), "wstr", 0, "wstr", 0) Return 1 EndFunc ;===> UxTheme