Samatter

2ch-tf.au3

Jan 23rd, 2022 (edited)
2,188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.88 KB | None | 0 0
  1. #pragma compile(Console, True)
  2. #NoTrayIcon
  3.  
  4. If (Not @Compiled) Then
  5.     MsgBox(0, "Error", "This script must be compiled to run correctly.")
  6.     Exit
  7. EndIf
  8.  
  9. Global $sConfigPath = @ScriptDir & "\" & StringTrimRight(@ScriptName, 3) & "ini"
  10. Global $sHotKey = IniRead($sConfigPath, "General", "sHotKey", "{Insert}")
  11.  
  12. If HotKeySet($sHotKey, "RunScript") Then
  13.     ConsoleWrite("HotKeySet() called and """ & $sHotKey & """ key registered" & @CRLF)
  14. Else
  15.     ConsoleWrite("HotKeySet() called but """ & $sHotKey & """ key not registered" & @CRLF)
  16. EndIf
  17.  
  18. Global $bActive = False
  19.  
  20. Func RunScript()
  21.     $bActive = Not $bActive
  22.     If $bActive Then
  23.         ConsoleWrite("RunScript() called, bActive is TRUE" & @CRLF)
  24.         Local $iLinesCount = IniRead($sConfigPath, "General", "iLinesCount", 0)
  25.         If ($iLinesCount > 0) Then
  26.             ConsoleWrite("iLinesCount is " & $iLinesCount & ", triforce started" & @CRLF)
  27.             DrawTF($iLinesCount)
  28.         EndIf
  29.         $bActive = False
  30.         ConsoleWrite("Triforce completed, you can use """ & $sHotKey & """ key again" & @CRLF)
  31.     Else
  32.         ConsoleWrite("RunScript() called, bActive is FALSE, triforce canceled" & @CRLF)
  33.         HotKeySet($sHotKey)
  34.         Run(@ScriptFullPath)
  35.         Exit
  36.     EndIf
  37. EndFunc
  38.  
  39. Func DrawTF($iCount)
  40.     ; read settings
  41.     Local $sPrefixSpaceB64 = IniRead($sConfigPath, "Symbols", "sPrefixSpaceB64", "")
  42.     Local $sMainSymbolB64 = IniRead($sConfigPath, "Symbols", "sMainSymbolB64", "")
  43.     Local $sMainSpaceB64 = IniRead($sConfigPath, "Symbols", "sMainSpaceB64", "")
  44.     ; decode from base64
  45.     Local $sPrefixSpace = Base64ToUTF8($sPrefixSpaceB64)
  46.     Local $sMainSymbol = Base64ToUTF8($sMainSymbolB64)
  47.     Local $sMainSpace = Base64ToUTF8($sMainSpaceB64)
  48.     ; combine main chunk
  49.     Local $sMainChunk = $sMainSpace & $sMainSymbol
  50.     ; send text into lines
  51.     For $iLineIndex = 1 To $iCount Step 1
  52.         Local $sPrefix = TextMult($sPrefixSpace, $iCount - $iLineIndex)
  53.         Local $sMain = $sMainSymbol & TextMult($sMainChunk, $iLineIndex - 1)
  54.         Send($sPrefix & $sMain & "{ENTER}")
  55.     Next
  56.     Send("{BACKSPACE}")
  57. EndFunc
  58.  
  59. Func TextMult($sText, $iMult)
  60.     Local $sResult = ""
  61.     For $iIndex = 1 To $iMult Step 1
  62.         $sResult = $sResult & $sText
  63.     Next
  64.     Return $sResult
  65. EndFunc
  66.  
  67. Func Base64ToUTF8($Input)
  68.     If (Not $Input) Then
  69.         Return ""
  70.     EndIf
  71.     Local $Struct = DllStructCreate("int")
  72.     $Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $Input, "int", 0, "int", 1, "ptr", 0, "ptr", DllStructGetPtr($Struct, 1), "ptr", 0, "ptr", 0)
  73.     If @error Or (Not $Call[0]) Then
  74.         Return ""
  75.     EndIf
  76.     Local $A = DllStructCreate("byte[" & DllStructGetData($Struct, 1) & "]")
  77.     $Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $Input, "int", 0, "int", 1, "ptr", DllStructGetPtr($A), "ptr", DllStructGetPtr($Struct, 1), "ptr", 0, "ptr", 0)
  78.     If @error Or (Not $Call[0]) Then
  79.         Return ""
  80.     EndIf
  81.     Return BinaryToString(DllStructGetData($A, 1), 4)
  82. EndFunc
  83.  
  84. While True
  85.     Sleep(1000)
  86. WEnd
  87.  
Add Comment
Please, Sign In to add comment