Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma compile(Console, True)
- #NoTrayIcon
- #include <Misc.au3>
- If (Not @Compiled) Then
- MsgBox(0, "Error", "This script must be compiled to run correctly.")
- Exit
- EndIf
- Global $sConfigPath = @ScriptDir & "\" & StringTrimRight(@ScriptName, 3) & "ini"
- Global $sHotKey = IniRead($sConfigPath, "General", "sHotKey", "{Insert}")
- If HotKeySet($sHotKey, "RunScript") Then
- ConsoleWrite("HotKeySet called and """ & $sHotKey & """ key registered" & @CRLF)
- Else
- ConsoleWrite("HotKeySet called but """ & $sHotKey & """ key not registered" & @CRLF)
- EndIf
- Global $hU32 = DllOpen("user32.dll")
- Global $bActive = False
- While True
- Sleep(1000)
- WEnd
- Func RunScript()
- $bActive = Not $bActive
- If $bActive Then
- ConsoleWrite("RunScript called, bActive is TRUE" & @CRLF)
- Local $iLinesCount = IniRead($sConfigPath, "General", "iLinesCount", 0)
- If ($iLinesCount > 0) Then
- ConsoleWrite("iLinesCount is " & $iLinesCount & ", triforce started" & @CRLF)
- DrawTF($iLinesCount)
- EndIf
- $bActive = False
- ConsoleWrite("Triforce completed, you can use """ & $sHotKey & """ key again" & @CRLF)
- EndIf
- EndFunc
- Func StopScript()
- If $bActive Then
- ConsoleWrite("StopScript called, bActive is TRUE, triforce canceled" & @CRLF)
- DllClose($hU32)
- $bActive = False
- HotKeySet($sHotKey)
- Run(@ScriptFullPath)
- Exit
- Else
- ConsoleWrite("StopScript called, but bActive is FALSE, do nothing" & @CRLF)
- EndIf
- EndFunc
- Func DrawTF($iCount)
- ; read settings
- Local $sPrefixSpaceB64 = IniRead($sConfigPath, "Symbols", "sPrefixSpaceB64", "")
- Local $sMainSymbolB64 = IniRead($sConfigPath, "Symbols", "sMainSymbolB64", "")
- Local $sMainSpaceB64 = IniRead($sConfigPath, "Symbols", "sMainSpaceB64", "")
- ; decode from base64
- Local $sPrefixSpace = Base64ToUTF8($sPrefixSpaceB64)
- Local $sMainSymbol = Base64ToUTF8($sMainSymbolB64)
- Local $sMainSpace = Base64ToUTF8($sMainSpaceB64)
- ; combine main chunk
- Local $sMainChunk = $sMainSpace & $sMainSymbol
- ; send text into lines
- For $iLineIndex = 1 To $iCount Step 1
- If IsEscPressed($hU32) Then
- StopScript()
- Else
- Local $sPrefix = TextMult($sPrefixSpace, $iCount - $iLineIndex)
- Local $sMain = $sMainSymbol & TextMult($sMainChunk, $iLineIndex - 1)
- Send($sPrefix & $sMain & "{ENTER}")
- EndIf
- Next
- Send("{BACKSPACE}")
- EndFunc
- Func TextMult($sText, $iMult)
- Local $sResult = ""
- For $iIndex = 1 To $iMult Step 1
- $sResult = $sResult & $sText
- Next
- Return $sResult
- EndFunc
- Func Base64ToUTF8($sInput)
- If (Not $sInput) Then Return ""
- ; 1st pass - calculate size
- Local $StructA = DllStructCreate("int")
- Local $StructA_PTR = DllStructGetPtr($StructA)
- Local $CallA = DllCall("crypt32.dll", "int", "CryptStringToBinary", "str", $sInput, "int", 0, "int", 1, "ptr", 0, "ptr", $StructA_PTR, "ptr", 0, "ptr", 0)
- If @error Or (Not $CallA[0]) Then Return ""
- ; 2nd pass - perform conversion
- Local $StructB = DllStructCreate("byte[" & DllStructGetData($StructA, 1) & "]")
- Local $StructB_PTR = DllStructGetPtr($StructB)
- Local $CallB = DllCall("crypt32.dll", "int", "CryptStringToBinary", "str", $sInput, "int", 0, "int", 1, "ptr", $StructB_PTR, "ptr", $StructA_PTR, "ptr", 0, "ptr", 0)
- If @error Or (Not $CallB[0]) Then Return ""
- ; return result
- Return BinaryToString(DllStructGetData($StructB, 1), 4)
- EndFunc
- Func IsEscPressed($hDLL)
- Local $Call = DllCall($hDLL, "short", "GetAsyncKeyState", "int", "0x1B")
- If @error Then Return SetError(@error, @extended, False)
- Return BitAND($Call[0], 0x8000) <> 0
- EndFunc
Add Comment
Please, Sign In to add comment