Read-bot . fic username - last_name

Read-bot . fic username - last_name

#region init
	#NoTrayIcon
	#include <Misc.au3>
	If _Singleton(@ScriptName, 1) = 0 Then ; allow only one instance
		MsgBox(0, "Warning", "An occurence of " & @ScriptName & " is already running")
		Exit
	EndIf

	#include <includes\includesJS.au3>
	_ConfigInitial()
#endregion init

;~ new user
;~ local $s='{"ok":true,"result":[{"update_id":566511565,"message":{"message_id":340,"from":{"id":205102520,"is_bot":false,"first_name":"Marcelo","last_name":"Saied","language_code":"en-US"},"chat":{"id":205102519,"first_name":"Marcelo","last_name":"Saied","type":"private"},"date":1507310174,"text":"/start","entities":[{"offset":0,"length":6,"type":"bot_command"}]}}]}'
;~ mensages
;~ local $s='{"ok":true,"result":[{"update_id":566511562,"message":{"message_id":35,"from":{"id":205102519,"is_bot":false,"first_name":"Marcelo","last_name":"Saied","language_code":"en-US"},"chat":{"id":205102519,"first_name":"Marcelo","last_name":"Saied","type":"private"},"date":1506834706,"text":"msg 1"}}  ]}'

;~ Local $s='{"ok":true,"result":[{"update_id":566511567,"message":{"message_id":453,"from":{"id":205102520,"is_bot":false,"first_name":"Marcelo","last_name":"Saied","language_code":"en-US"},"chat":{"id":205102519,"first_name":"Marcelo","last_name":"Saied","type":"private"},"date":1507501930,"text":"hello there"}},{"update_id":566511568,"message":{"message_id":454,"from":{"id":205102521,"is_bot":false,"first_name":"Marcelo","last_name":"Saied","language_code":"en-US"},"chat":{"id":205102521,"first_name":"Marcelo","last_name":"Saied","type":"private"},"date":1507507372,"text":"msg1"}},{"update_id":566511569,"message":{"message_id":455,"from":{"id":205102522,"is_bot":false,"first_name":"Marcelo","last_name":"Saied","language_code":"en-US"},"chat":{"id":205102519,"first_name":"Marcelo","last_name":"Saied","type":"private"},"date":1507513642,"text":"mensage2 , coma, mensage3"}}]}'

local $s=GetBotUpdates()
$s=StringReplace($s,'"username":','"last_name":')
if $s then
	$oJSON = _OO_JSON_Init()
	$jsonObj = $oJSON.parse($s)
	$type = $jsonObj.type($jsonObj)
	ConsoleWrite("$jsonObj.type($jsonObj  ->" & $type & @CR) ;
	if $jsonObj.ok  then
		if $jsonObj.jsonPath( "$.result").stringify() = "[[]]" then
			ConsoleWrite(' No Bot data ' & @crlf)
		Else
;~ 			ConsoleWrite("=2==result==================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result").stringify() &  @CR )
;~ 			ConsoleWrite("=3=update_id================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..update_id").stringify() &  @CR )
;~ 			ConsoleWrite("=3==message_id==============================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message_id").stringify() &  @CR )
;~ 			ConsoleWrite("=3==FROM====================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from.id").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from.is_bot").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from.first_name").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from.last_name").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from.language_code").stringify() &  @CR )
;~ 			ConsoleWrite("=3==CHAT====================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.chat").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.chat.id").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.chat.first_name").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.chat.last_name").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.chat.type").stringify() &  @CR )
;~ 			ConsoleWrite("=4===DATE===================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.date").stringify() &  @CR )
;~ 			ConsoleWrite("=5===TEXT==================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.text").stringify() &  @CR )

			$UserIDArr = StripIntJS($jsonObj.jsonPath( "$.result..message.from.id").stringify())
			_printFromArray($UserIDArr)
			$FnameArr = StripStrJS($jsonObj.jsonPath( "$.result..message.from.first_name").stringify())
			_printFromArray($FnameArr)
			$LnameArr = StripStrJS($jsonObj.jsonPath( "$.result..message.from.last_name").stringify())
			_printFromArray($LnameArr)
			$epochArr = StripIntJS($jsonObj.jsonPath( "$.result..message.date").stringify())
			_printFromArray($epochArr)
			$menssageJSArr = StripStrJS($jsonObj.jsonPath( "$.result..message.text").stringify())
			_printFromArray($menssageJSArr)

			for $i=1 to $UserIDArr[0]
				SQLregister($UserIDArr[$i],$FnameArr[$i],$LnameArr[$i],$epochArr[$i])
			next
		endif
	endif

endif

#region init
	#NoTrayIcon
	#include <Misc.au3>
	If _Singleton(@ScriptName, 1) = 0 Then ; allow only one instance
		MsgBox(0, "Warning", "An occurence of " & @ScriptName & " is already running")
		Exit
	EndIf

	#include <includes\includesJS.au3>
	_ConfigInitial()
#endregion init

;~ new user
;~ local $s='{"ok":true,"result":[{"update_id":566511565,"message":{"message_id":340,"from":{"id":205102520,"is_bot":false,"first_name":"Marcelo","last_name":"Saied","language_code":"en-US"},"chat":{"id":205102519,"first_name":"Marcelo","last_name":"Saied","type":"private"},"date":1507310174,"text":"/start","entities":[{"offset":0,"length":6,"type":"bot_command"}]}}]}'
;~ mensages
;~ local $s='{"ok":true,"result":[{"update_id":566511562,"message":{"message_id":35,"from":{"id":205102519,"is_bot":false,"first_name":"Marcelo","last_name":"Saied","language_code":"en-US"},"chat":{"id":205102519,"first_name":"Marcelo","last_name":"Saied","type":"private"},"date":1506834706,"text":"msg 1"}}  ]}'

;~ Local $s='{"ok":true,"result":[{"update_id":566511567,"message":{"message_id":453,"from":{"id":205102520,"is_bot":false,"first_name":"Marcelo","last_name":"Saied","language_code":"en-US"},"chat":{"id":205102519,"first_name":"Marcelo","last_name":"Saied","type":"private"},"date":1507501930,"text":"hello there"}},{"update_id":566511568,"message":{"message_id":454,"from":{"id":205102521,"is_bot":false,"first_name":"Marcelo","last_name":"Saied","language_code":"en-US"},"chat":{"id":205102521,"first_name":"Marcelo","last_name":"Saied","type":"private"},"date":1507507372,"text":"msg1"}},{"update_id":566511569,"message":{"message_id":455,"from":{"id":205102522,"is_bot":false,"first_name":"Marcelo","last_name":"Saied","language_code":"en-US"},"chat":{"id":205102519,"first_name":"Marcelo","last_name":"Saied","type":"private"},"date":1507513642,"text":"mensage2 , coma, mensage3"}}]}'

local $s=GetBotUpdates()
if $s then
	$oJSON = _OO_JSON_Init()
	$jsonObj = $oJSON.parse($s)
	$type = $jsonObj.type($jsonObj)
	ConsoleWrite("$jsonObj.type($jsonObj  ->" & $type & @CR) ;
	if $jsonObj.ok  then
		if $jsonObj.jsonPath( "$.result").stringify() = "[[]]" then
			ConsoleWrite(' No Bot data ' & @crlf)
		Else
;~ 			ConsoleWrite("=2==result==================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result").stringify() &  @CR )
;~ 			ConsoleWrite("=3=update_id================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..update_id").stringify() &  @CR )
;~ 			ConsoleWrite("=3==message_id==============================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message_id").stringify() &  @CR )
;~ 			ConsoleWrite("=3==FROM====================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from.id").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from.is_bot").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from.first_name").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from.last_name").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.from.language_code").stringify() &  @CR )
;~ 			ConsoleWrite("=3==CHAT====================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.chat").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.chat.id").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.chat.first_name").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.chat.last_name").stringify() &  @CR )
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.chat.type").stringify() &  @CR )
;~ 			ConsoleWrite("=4===DATE===================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.date").stringify() &  @CR )
;~ 			ConsoleWrite("=5===TEXT==================================="  & @CR)
;~ 			ConsoleWrite("-> " & $jsonObj.jsonPath( "$.result..message.text").stringify() &  @CR )

			$UserIDArr = StripIntJS($jsonObj.jsonPath( "$.result..message.from.id").stringify())
			_printFromArray($UserIDArr)
			$FnameArr = StripStrJS($jsonObj.jsonPath( "$.result..message.from.first_name").stringify())
			_printFromArray($FnameArr)
			$LnameArr = StripStrJS($jsonObj.jsonPath( "$.result..message.from.last_name").stringify())
			_printFromArray($LnameArr)
			$epochArr = StripIntJS($jsonObj.jsonPath( "$.result..message.date").stringify())
			_printFromArray($epochArr)
			$menssageJSArr = StripStrJS($jsonObj.jsonPath( "$.result..message.text").stringify())
			_printFromArray($menssageJSArr)

			for $i=1 to $UserIDArr[0]
				SQLregister($UserIDArr[$i],$FnameArr[$i],$LnameArr[$i],$epochArr[$i])
			next
		endif
	endif

endif


Files includes for json parsing

Files includes for json parsing

#region File includes
;~ 	FileInstall("helper\SendTelegramSubteBA/SendTelegramSubteBA.exe", @TempDir & "\SendTelegramSubteBA.exe", 1)

	if not @Compiled then
		FileCopy("secret\"&$dbfile, $dbfullPath,0)
		FileCopy("sqlite\System.Data.SQLite.32.2012.dll", $FolderBin&"\"&$sqliteDLLfile,0)
	else
		FileInstall("secret\SubteBA.db", $dbfullPath, 0)
		FileInstall("secret\config.ini", "config.ini", 1)
		FileInstall("sqlite\System.Data.SQLite.32.2012.dll", $FolderBin&"\System.Data.SQLite.32.2012.dll", 1)
		FileInstall("resources\json2.txt",$FolderResources & "\json2.txt", 1)
		ConsoleWrite('@@(' & @ScriptName & '-' & @ScriptLineNumber & ') : $FolderResources = ' & $FolderResources & @crlf )
		FileInstall("resources\jsonpath-0.8.0.js",$FolderResources & "\jsonpath-0.8.0.js", 1)
		FileInstall("resources\Keys_polyfill.txt",$FolderResources & "\Keys_polyfill.txt", 1)
	endif
#endregion File includes

#region File includes
	FileInstall("helper\SendTelegramSubteBA/SendTelegramSubteBA.exe", @TempDir & "\SendTelegramSubteBA.exe", 1)

	if not @Compiled then
		FileCopy("secret\"&$dbfile, $dbfullPath,0)
		FileCopy("sqlite\System.Data.SQLite.32.2012.dll", $FolderBin&"\"&$sqliteDLLfile,0)
	else
		FileInstall("secret\"&$dbfile, $dbfullPath, 0)
		FileInstall("sqlite\System.Data.SQLite.32.2012.dll", $FolderBin&"\"&$sqliteDLLfile, 1)
	endif
#endregion File includes


Update Example.au3

Update Example.au3

;~ #AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
;~ #Tidy_Parameters=/sf
#include-once
#include <BackEffect.au3>

; #INDEX# =======================================================================================================================
; Title .........: BackEffect Example
; AutoIt Version : 3.3.14.2
; Description ...:
; Source.........: https://github.com/chechelaky/AutoIt/edit/master/BackEffect/Example.au3
; Author(s) .....: Luismar Chechelaky (Luigi)
; ===============================================================================================================================

OnAutoItExitRegister("OnExit")

Opt("GUIOnEventMode", 1)
Opt("GUIEventOptions", 1)
Opt("MustDeclareVars", 1)

Global $aGui[9] = [0, "BackEfect", 520, 360, -1, -1, Default, $WS_EX_COMPOSITED, 0]

Global $aMouse, $hGui, $OVER

$aGui[0] = GUICreate($aGui[1], $aGui[2], $aGui[3], $aGui[4], $aGui[5], $aGui[6], $aGui[7], $aGui[8])
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")

Local $hControlLabel = GUICtrlCreateLabel("Label", 10, 10, 90, 30)
Local $hControlButton = GUICtrlCreateButton("Button", 110, 10, 90, 30)
Local $hControlRadio = GUICtrlCreateRadio("Radio", 210, 10, 90, 30)
Local $hControlGroup = GUICtrlCreateGroup("Group", 310, 10, 90, 30)
Local $hControlCheckBox = GUICtrlCreateCheckbox("CheckBox", 410, 10, 90, 30)
Local $hControlCheckBox = GUICtrlCreateCombo("Combo", 10, 60, 90, 30)
Local $hControlInput = GUICtrlCreateInput("Input", 110, 60, 90, 30)
Local $hControlList = GUICtrlCreateList("List", 210, 60, 90, 90)

GUISetState(@SW_SHOW, $hGui)

;__BackEffectStart($aGui[0])
__BackEffectStart($aGui[0], 0xFFFF00)

AddBack_Effect($aGui[0], $hControlLabel, 2)
AddBack_Effect($aGui[0], $hControlButton, 4)
AddBack_Effect($aGui[0], $hControlRadio, 6)
AddBack_Effect($aGui[0], $hControlGroup)
AddBack_Effect($aGui[0], $hControlCheckBox)
AddBack_Effect($aGui[0], $hControlCheckBox)
AddBack_Effect($aGui[0], $hControlInput)
AddBack_Effect($aGui[0], $hControlList)

While Sleep(10)
WEnd

Func Quit()
	Exit
EndFunc   ;==>Quit

Func OnExit($sInput = 0)
	If IsDeclared("sInput") Then ConsoleWrite("_exit[ " & $sInput & " ]" & @LF)
	GUIDelete($aGui[0])
EndFunc   ;==>OnExit

;~ #AutoIt3Wrapper_AU3Check_Parameters= -q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
;~ #Tidy_Parameters=/sf
#include-once
#include <BackEffect.au3>

OnAutoItExitRegister("OnExit")

Opt("GUIOnEventMode", 1)
Opt("GUIEventOptions", 1)
Opt("MustDeclareVars", 1)

Global $aGui[9] = [0, "BackEfect", 520, 360, -1, -1, Default, $WS_EX_COMPOSITED, 0]

Global $aMouse, $hGui, $OVER

$aGui[0] = GUICreate($aGui[1], $aGui[2], $aGui[3], $aGui[4], $aGui[5], $aGui[6], $aGui[7], $aGui[8])
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")

Local $hControlLabel = GUICtrlCreateLabel("Label", 10, 10, 90, 30)
Local $hControlButton = GUICtrlCreateButton("Button", 110, 10, 90, 30)
Local $hControlRadio = GUICtrlCreateRadio("Radio", 210, 10, 90, 30)
Local $hControlGroup = GUICtrlCreateGroup("Group", 310, 10, 90, 30)
Local $hControlCheckBox = GUICtrlCreateCheckbox("CheckBox", 410, 10, 90, 30)
Local $hControlCheckBox = GUICtrlCreateCombo("Combo", 10, 60, 90, 30)
Local $hControlInput = GUICtrlCreateInput("Input", 110, 60, 90, 30)
Local $hControlList = GUICtrlCreateList("List", 210, 60, 90, 90)

GUISetState(@SW_SHOW, $hGui)

;__BackEffectStart($aGui[0])
__BackEffectStart($aGui[0], 0xFFFF00)

AddBack_Effect($aGui[0], $hControlLabel, 2)
AddBack_Effect($aGui[0], $hControlButton, 4)
AddBack_Effect($aGui[0], $hControlRadio, 6)
AddBack_Effect($aGui[0], $hControlGroup)
AddBack_Effect($aGui[0], $hControlCheckBox)
AddBack_Effect($aGui[0], $hControlCheckBox)
AddBack_Effect($aGui[0], $hControlInput)
AddBack_Effect($aGui[0], $hControlList)

While Sleep(10)
WEnd

Func Quit()
	Exit
EndFunc   ;==>Quit

Func OnExit($sInput = 0)
	If IsDeclared("sInput") Then ConsoleWrite("_exit[ " & $sInput & " ]" & @LF)
	GUIDelete($aGui[0])
EndFunc   ;==>OnExit


Fix one click login accessing/generating wrong folders

; Remove the ; from the next line if you get script errors
; Or you can add a ; to disable it (i.e: ;#RequireAdmin)
#RequireAdmin

#include <String.au3>
#include <File.au3>
#include <Array.au3>

Global $string, $password, $email, $data, $path, $search, $file, $root
$root = "HKEY_CLASSES_ROOT\muledump"
$title = "Muledump One Click Login Installer"
$adminRightsError = "Error - Requires Admin Privileges" & @CRLF & @CRLF & "Edit mulelogin.au3 in a text editor to enable admin rights at the top" & @CRLF & @CRLF & "For more help see:" & @CRLF & "https://github.com/jakcodex/muledump/wiki/One-Click-Login"

Func _write()
	RegWrite($root,"","REG_SZ","URL: muledump Protocol")
	RegWrite($root,"URL Protocol","REG_SZ","")
	RegWrite($root & "\shell")
	RegWrite($root & "\shell\open")
	RegWrite($root & "\shell\open\command","","REG_SZ", @AutoItExe & ' "' & @ScriptFullPath & '" %1')
	If RegRead("HKEY_CLASSES_ROOT\muledump","") Then
		MsgBox(64,$title,"One Click Login: installed" & @CRLF & @CRLF & "You should open mulelogin.au3 in a text editor and disable:" & @CRLF & "#RequireAdmin")
	Else
		MsgBox(16,$title,$adminRightsError)
	EndIf
	Exit
EndFunc

Func _install()
	Local $k
	$k = RegEnumKey($root, 1)
	If @error == 2 Then
		MsgBox(16,$title,$adminRightsError)
		Exit
	EndIf
	If @error == 1 Then _write()
	$k = MsgBox(6 + 32, $title, _
		'One Click Login is already installed. What would you like to do?' & @CRLF & @CRLF & _
		'"Cancel" to do nothing' & @CRLF & _
		'"Try Again" to reinstall' & @CRLF & _
		'"Continue" to uninstall')
	If $k == 10 Then _write()
	If $k == 11 Then
		RegDelete($root)
		if @error <> 0 Then
			MsgBox(16,$title,$adminRightsError)
		Else
			MsgBox(64,$title,"One Click Login: uninstalled")
		EndIf
	EndIf
	Exit
EndFunc

Func _length($string)
	Local $binlength, $declength, $array, $result
	$declength = StringLen($string)/2
    While $declength > 0
        $binlength &= Mod($declength,2)
        $declength = Floor($declength/2)
    WEnd
	$binlength = StringReverse($binlength)
	if @error <> 0 Then
		$binlength = _StringReverse($binlength)
	EndIf
	$binlength = $binlength & "1"
	$array = StringSplit($binlength,"")
	For $i = 1 To $array[0]
        $array[0] -= 1
        If $array[$i] = "1" Then $result += 2 ^ ($array[0])
	Next
	Return Hex(Int($result),2)
EndFunc

Func _build()
	;header
	$string  = "0x 00 BF" 						;Magic Number		 2 bytes
	$string &= "?? ?? ?? ??"					;Size				 4 bytes
	$string &= "54 43 53 4F 00 04 00 00 00 00"	;Marker				10 bytes
	$string &= "00 05"							;Name Size			 2 bytes
	$string &= "52 6F 74 4D 47"					;"RotMG"			 5 bytes
	$string &= "00 00 00"						;Padding			 3 bytes
	$string &= "03"								;AMF Version		 1 byte

	;data
	$string &= "11"								;Length				 1 byte
	$string &= "50 61 73 73 77 6F 72 64"		;"Password"			 8 bytes
	$string &= "06"								;Type (string) 		 1 byte
	$string &= _length($password)				;Length				 1 byte
	$string &= $password						;Actual Password	 ? bytes
	$string &= "00"								;AMF Padding		 1 byte

	$string &= "09"								;Length				 1 byte
	$string &= "47 55 49 44"					;"GUID"				 4 bytes
	$string &= "06"								;Type (string)		 1 byte
	$string &= _length($email)					;Length				 1 byte
	$string &=  $email							;Email				 ? bytes
	$string &= "00"								;AMF Padding		 1 byte

	$string = StringReplace($string," ","")
	$string = StringRegExpReplace($string,"\?{8}",Hex(Int(StringLen(StringMid($string,15))/2)))
EndFunc

If $CmdLine[0] = 0 Then _install()

$data = StringReplace($CmdLine[1],"muledump:","")
$data = StringSplit($data,"-")
$email = $data[1]
$password = $data[2]

_build()

Local $paths_base[2] = [ _
	@AppDataDir & "\Macromedia\Flash Player\#SharedObjects\", _
	@LocalAppDataDir & "\Google\Chrome\User Data\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\" _
]
Local $paths[4] = [ _
	"localhost", _
	"realmofthemadgodhrd.appspot.com", _
	"www.realmofthemadgod.com", _
	"#localWithNet" _
]
For $path_base In $paths_base
	$search = FileFindFirstFile($path_base & "*")

	; flash was never run from this application,
	; prevent generating degenerate folder stucture
	if @error Then ContinueLoop

	While 1
		$sandbox = FileFindNextFile($search)

		; no more sandboxes
		If @error Then ExitLoop

		; verify that the folder name corresponds to a sandbox id (8 uppercase chars)
		if StringLen($sandbox) = 8 And StringUpper($sandbox) == $sandbox Then
			For $gameDir In $paths
				$gameFilePath = $path_base & $sandbox & "\" & $gameDir & "\RotMG.sol"
				$file = FileOpen($gameFilePath,26)
				FileWrite($file,$string)
				FileClose($file)
			Next
		EndIf
	WEnd
Next
FileClose($search)

;;
; launch one-click login
;;

; run one-click login thru the browser
ShellExecute("https://www.realmofthemadgod.com/")

;;
; replace the line above with one of the following if you're using a projector
;;

; run one-click login thru flash projector
; update the path to your flash projector exe
; https://www.adobe.com/support/flashplayer/debug_downloads.html
;ShellExecute('C:\flashplayer_28_sa.exe', 'https://www.realmofthemadgod.com/client')

; run one-click login thru totalcmd + swfview
; https://www.ghisler.com/
;ShellExecute('C:\Program Files\Total Commander\Totalcmd.exe', '/S=L:Pswfview e:\temp\rotmg\loader.swf')

; Remove the ; from the next line if you get script errors
; Or you can add a ; to disable it (i.e: ;#RequireAdmin)
#RequireAdmin

#include <String.au3>
#include <File.au3>
#include <Array.au3>

Global $string, $password, $email, $data, $path, $search, $file, $root
$root = "HKEY_CLASSES_ROOT\muledump"
$title = "Muledump One Click Login Installer"
$adminRightsError = "Error - Requires Admin Privileges" & @CRLF & @CRLF & "Edit mulelogin.au3 in a text editor to enable admin rights at the top" & @CRLF & @CRLF & "For more help see:" & @CRLF & "https://github.com/jakcodex/muledump/wiki/One-Click-Login"

Func _write()
	RegWrite($root,"","REG_SZ","URL: muledump Protocol")
	RegWrite($root,"URL Protocol","REG_SZ","")
	RegWrite($root & "\shell")
	RegWrite($root & "\shell\open")
	RegWrite($root & "\shell\open\command","","REG_SZ", @AutoItExe & ' "' & @ScriptFullPath & '" %1')
	If RegRead("HKEY_CLASSES_ROOT\muledump","") Then
		MsgBox(64,$title,"One Click Login: installed" & @CRLF & @CRLF & "You should open mulelogin.au3 in a text editor and disable:" & @CRLF & "#RequireAdmin")
	Else
		MsgBox(16,$title,$adminRightsError)
	EndIf
	Exit
EndFunc

Func _install()
	Local $k
	$k = RegEnumKey($root, 1)
	If @error == 2 Then
		MsgBox(16,$title,$adminRightsError)
		Exit
	EndIf
	If @error == 1 Then _write()
	$k = MsgBox(6 + 32, $title, _
		'One Click Login is already installed. What would you like to do?' & @CRLF & @CRLF & _
		'"Cancel" to do nothing' & @CRLF & _
		'"Try Again" to reinstall' & @CRLF & _
		'"Continue" to uninstall')
	If $k == 10 Then _write()
	If $k == 11 Then
		RegDelete($root)
		if @error <> 0 Then
			MsgBox(16,$title,$adminRightsError)
		Else
			MsgBox(64,$title,"One Click Login: uninstalled")
		EndIf
	EndIf
	Exit
EndFunc

Func _length($string)
	Local $binlength, $declength, $array, $result
	$declength = StringLen($string)/2
    While $declength > 0
        $binlength &= Mod($declength,2)
        $declength = Floor($declength/2)
    WEnd
	$binlength = StringReverse($binlength)
	if @error <> 0 Then
		$binlength = _StringReverse($binlength)
	EndIf
	$binlength = $binlength & "1"
	$array = StringSplit($binlength,"")
	For $i = 1 To $array[0]
        $array[0] -= 1
        If $array[$i] = "1" Then $result += 2 ^ ($array[0])
	Next
	Return Hex(Int($result),2)
EndFunc

Func _build()
	;header
	$string  = "0x 00 BF" 						;Magic Number		 2 bytes
	$string &= "?? ?? ?? ??"					;Size				 4 bytes
	$string &= "54 43 53 4F 00 04 00 00 00 00"	;Marker				10 bytes
	$string &= "00 05"							;Name Size			 2 bytes
	$string &= "52 6F 74 4D 47"					;"RotMG"			 5 bytes
	$string &= "00 00 00"						;Padding			 3 bytes
	$string &= "03"								;AMF Version		 1 byte

	;data
	$string &= "11"								;Length				 1 byte
	$string &= "50 61 73 73 77 6F 72 64"		;"Password"			 8 bytes
	$string &= "06"								;Type (string) 		 1 byte
	$string &= _length($password)				;Length				 1 byte
	$string &= $password						;Actual Password	 ? bytes
	$string &= "00"								;AMF Padding		 1 byte

	$string &= "09"								;Length				 1 byte
	$string &= "47 55 49 44"					;"GUID"				 4 bytes
	$string &= "06"								;Type (string)		 1 byte
	$string &= _length($email)					;Length				 1 byte
	$string &=  $email							;Email				 ? bytes
	$string &= "00"								;AMF Padding		 1 byte

	$string = StringReplace($string," ","")
	$string = StringRegExpReplace($string,"\?{8}",Hex(Int(StringLen(StringMid($string,15))/2)))
EndFunc

If $CmdLine[0] = 0 Then _install()

$data = StringReplace($CmdLine[1],"muledump:","")
$data = StringSplit($data,"-")
$email = $data[1]
$password = $data[2]

_build()

Local $paths_base[2] = [ _
	@AppDataDir & "\Macromedia\Flash Player\#SharedObjects\", _
	_PathFull("../Local", @AppDataDir) & "\Google\Chrome\User Data\Default\Pepper Data\Shockwave Flash\WritableRoot\#SharedObjects\" _
]
Local $paths[3] = [ _
	"localhost", _
	"realmofthemadgodhrd.appspot.com", _
	"www.realmofthemadgod.com" _
]
For $path_base In $paths_base
	$search = FileFindFirstFile($path_base & "*")
	$searchPath = FileFindNextFile($search)
	For $gameDir In $paths
		$gameFilePath = $path_base & $searchPath & "\" & $gameDir & "\RotMG.sol"
		$file = FileOpen($gameFilePath,26)
		FileWrite($file,$string)
		FileClose($file)
	Next
Next
FileClose($search)

;;
; launch one-click login
;;

; run one-click login thru the browser
ShellExecute("https://www.realmofthemadgod.com/")

;;
; replace the line above with one of the following if you're using a projector
;;

; run one-click login thru flash projector
; update the path to your flash projector exe
; https://www.adobe.com/support/flashplayer/debug_downloads.html
;ShellExecute('C:\flashplayer_28_sa.exe', 'https://www.realmofthemadgod.com/client')

; run one-click login thru totalcmd + swfview
; https://www.ghisler.com/
;ShellExecute('C:\Program Files\Total Commander\Totalcmd.exe', '/S=L:Pswfview e:\temp\rotmg\loader.swf')


usage edit

usage edit

;;  Copyright 2008 Nokia Siemens Networks Oyj
;;
;;  Licensed under the Apache License, Version 2.0 (the "License");
;;  you may not use this file except in compliance with the License.
;;  You may obtain a copy of the License at
;;
;;      http://www.apache.org/licenses/LICENSE-2.0
;;
;;  Unless required by applicable law or agreed to in writing, software
;;  distributed under the License is distributed on an "AS IS" BASIS,
;;  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;;  See the License for the specific language governing permissions and
;;  limitations under the License.

;; Robot Framework One Click Installer for Windows
;;
;; This installer installs Robot Framework and its preconditions Python and
;; Jython (optional). If installer is executed without arguments, it opens a
;; dialog explaining the options and asking the user to enter the installation
;; directory. If a command line options is given, it must be a path to an
;; existing directory and it is used as installation directory.
;;
;; For more information about this script see $USAGE below. To learn more
;; about silent Python installation, see url [1]. Silent Jython installation
;; options can be seen with command [2].
;;
;; [1] http://www.python.org/download/releases/2.5/msi/#automated
;; [2] java -jar jython_installer-2.2.x.jar --help

;;
;; Config
;;

; Expected patterns for installer names and target directory names.
$PYTHON_DIR_NAME = "Python"
$JYTHON_DIR_NAME = "Jython"
$PYTHON_PATTERN = "python-2.*.msi"
$ROBOT_PATTERN = "robotframework-2.*.exe"
$JYTHON_PATTERN = "jython_installer-2.*.jar"

$USAGE = "One Click Installer installs Robot Framework and its " & _
         "preconditions Python and Jython (optional)." & @CRLF & @CRLF & _
         "Please specify the directory where you want software to be " & _
         "installed. Also make sure that you have required Robot Framework " & _
         "and Python installers, and optionally Jython installer, in the " & _
         "same directory as this installer." & @CRLF & @CRLF & _
         "For more information see http://robotframework.org/."

;;
;; Main
;;

$base_dir = GetBaseDirectory()
$python_installer = GetRequiredInstaller($PYTHON_PATTERN, "Python")
$robot_installer = GetRequiredInstaller($ROBOT_PATTERN, "Robot Framework")
$jython_installer = GetOptionalInstaller($JYTHON_PATTERN)
$python_dir = GetPythonDir($base_dir & $PYTHON_DIR_NAME)
$jython_dir = GetJythonDir($base_dir & $JYTHON_DIR_NAME, $jython_installer)
InstallPython($python_installer, $python_dir)
InstallJython($jython_installer, $jython_dir)
SetPath($python_dir, $jython_dir)  ; This must be done before InstallRobot to always have msvcrt71.dll in PATH
InstallRobot($robot_installer)
Exit

;;
;; Functions
;;

Func GetBaseDirectory()
    If $CmdLine[0] == 0 Then
        $base = InputBox("Robot Framework One Click Installer", $USAGE, "C:\", "", 500, 470)
    ElseIf $CmdLine[0] == 1 Then
        $base = $CmdLine[1]
    Else
        Cancel("Usage: " & @ScriptName & " [basedir]")
    EndIf
    If $base == "" Then
        Cancel("Installation cancelled by user.")
    ElseIf FileExists($base) == 0 Then
        Cancel("Given directory doesn't exist.")
    ElseIf StringRight($base, 1) <> "\" Then
        $base = $base & "\"
    EndIf
    Return $base
EndFunc

Func Cancel($msg)
    MsgBox(0, "Installation Cancelled", $msg)
    Exit
EndFunc

Func GetRequiredInstaller($pattern, $name)
    $installer = GetOptionalInstaller($pattern)
    If $installer == "" Then
        Cancel("Could not find " & $name & " installer with pattern '" & $pattern & "'")
    Endif
    return $installer
EndFunc

Func GetOptionalInstaller($pattern)
    $found = FileFindFirstFile($pattern)
    If $found == -1 Then
        $installer = ""
    Else
        $installer = FileFindNextFile($found)
    EndIf
    FileClose($found)
    return $installer
EndFunc

Func GetPythonDir($dir)
    VerifyInstallationDir($dir, "Python")
    return $dir
EndFunc

Func GetJythonDir($dir, $installer)
    If $installer == "" Then
        return ""
    EndIf
    VerifyInstallationDir($dir, "Jython")
    return $dir
EndFunc

Func VerifyInstallationDir($dir, $name)
    If FileExists($dir) == 1 Then
        Cancel($name & " installation directory '" & $dir & "' already exists.")
    EndIf
EndFunc

Func InstallPython($installer, $dir)
    $cmd = "msiexec /i " & $installer & " TARGETDIR=" & $dir & " /qb!"
    RunWait($cmd)
EndFunc

Func InstallJython($installer, $dir)
    If $installer == "" Then
        return
    EndIf
    $cmd = "java -jar " & $installer & " -s -d " & $dir
    RunWait($cmd)
EndFunc

Func InstallRobot($installer)
    Run($installer)
    WaitSetupWindowAndClickEnter("This Wizard will install")
    WaitSetupWindowAndClickEnter("Select python installation")
    WaitSetupWindowAndClickEnter("Ready to install")
    WaitSetupWindowAndClickEnter("Postinstall script finished")
EndFunc

Func WaitSetupWindowAndClickEnter($exp_text)
    WinWaitActive("Setup", $exp_text)
    Send("{ENTER}")
EndFunc

Func SetPath($python, $jython)
    $update = $python & ";" & $python & "\Scripts;" & $jython
    $orig = RegRead("HKCU\Environment", "PATH")

    If $orig == "" Then
        $new = $update
    ElseIf StringRight($orig, 1) == ";" Then
        $new = $orig & $update
    Else
        $new = $orig & ";" & $update
    EndIf

    RegWrite("HKCU\Environment", "PATH", "REG_EXPAND_SZ", $new)
    EnvUpdate()
EndFunc

;;  Copyright 2008 Nokia Siemens Networks Oyj
;;
;;  Licensed under the Apache License, Version 2.0 (the "License");
;;  you may not use this file except in compliance with the License.
;;  You may obtain a copy of the License at
;;
;;      http://www.apache.org/licenses/LICENSE-2.0
;;
;;  Unless required by applicable law or agreed to in writing, software
;;  distributed under the License is distributed on an "AS IS" BASIS,
;;  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;;  See the License for the specific language governing permissions and
;;  limitations under the License.

;; Robot Framework One Click Installer for Windows
;;
;; This installer installs Robot Framework and its preconditions Python and
;; Jython (optional). If installer is executed without arguments, it opens a
;; dialog explaining the options and asking the user to enter the installation
;; directory. If a command line options is given, it must be a path to an
;; existing directory and it is used as installation directory.
;;
;; For more information about this script see $USAGE below. To learn more
;; about silent Python installation, see url [1]. Silent Jython installation
;; options can be seen with command [2].
;;
;; [1] http://www.python.org/download/releases/2.5/msi/#automated
;; [2] java -jar jython_installer-2.2.x.jar --help

;;
;; Config
;;

; Expected patterns for installer names and target directory names.
$PYTHON_DIR_NAME = "Python"
$JYTHON_DIR_NAME = "Jython"
$PYTHON_PATTERN = "python-2.*.msi"
$ROBOT_PATTERN = "robotframework-2.*.exe"
$JYTHON_PATTERN = "jython_installer-2.*.jar"

; Usage to show to the user. If major versions of installed software are changed update them also here!!
; Patterns and directory names above are used in the usage so that they don't need to be updated.
$USAGE = "One Click Installer installs Robot Framework and its preconditions Python and Jython (optional)." & @CRLF & @CRLF & _
         "Please specify the directory where you want to install the software. Make also sure you have the " & _
         "required Robot Framework and Python installers, optionally Jython installer, in the directory " & _
         "where you have this installer." & @CRLF & @CRLF & _
         "See more information from robotframework.org."

;;
;; Main
;;

$base_dir = GetBaseDirectory()
$python_installer = GetRequiredInstaller($PYTHON_PATTERN, "Python")
$robot_installer = GetRequiredInstaller($ROBOT_PATTERN, "Robot Framework")
$jython_installer = GetOptionalInstaller($JYTHON_PATTERN)
$python_dir = GetPythonDir($base_dir & $PYTHON_DIR_NAME)
$jython_dir = GetJythonDir($base_dir & $JYTHON_DIR_NAME, $jython_installer)
InstallPython($python_installer, $python_dir)
InstallJython($jython_installer, $jython_dir)
SetPath($python_dir, $jython_dir)  ; This must be done before InstallRobot to always have msvcrt71.dll in PATH
InstallRobot($robot_installer)
Exit

;;
;; Functions
;;

Func GetBaseDirectory()
    If $CmdLine[0] == 0 Then
        $base = InputBox("Robot Framework One Click Installer", $USAGE, "C:\", "", 500, 470)
    ElseIf $CmdLine[0] == 1 Then
        $base = $CmdLine[1]
    Else
        Cancel("Usage: " & @ScriptName & " [basedir]")
    EndIf
    If $base == "" Then
        Cancel("Installation cancelled by user.")
    ElseIf FileExists($base) == 0 Then
        Cancel("Given directory doesn't exist.")
    ElseIf StringRight($base, 1) <> "\" Then
        $base = $base & "\"
    EndIf
    Return $base
EndFunc

Func Cancel($msg)
    MsgBox(0, "Installation Cancelled", $msg)
    Exit
EndFunc

Func GetRequiredInstaller($pattern, $name)
    $installer = GetOptionalInstaller($pattern)
    If $installer == "" Then
        Cancel("Could not find " & $name & " installer with pattern '" & $pattern & "'")
    Endif
    return $installer
EndFunc

Func GetOptionalInstaller($pattern)
    $found = FileFindFirstFile($pattern)
    If $found == -1 Then
        $installer = ""
    Else
        $installer = FileFindNextFile($found)
    EndIf
    FileClose($found)
    return $installer
EndFunc

Func GetPythonDir($dir)
    VerifyInstallationDir($dir, "Python")
    return $dir
EndFunc

Func GetJythonDir($dir, $installer)
    If $installer == "" Then
        return ""
    EndIf
    VerifyInstallationDir($dir, "Jython")
    return $dir
EndFunc

Func VerifyInstallationDir($dir, $name)
    If FileExists($dir) == 1 Then
        Cancel($name & " installation directory '" & $dir & "' already exists.")
    EndIf
EndFunc

Func InstallPython($installer, $dir)
    $cmd = "msiexec /i " & $installer & " TARGETDIR=" & $dir & " /qb!"
    RunWait($cmd)
EndFunc

Func InstallJython($installer, $dir)
    If $installer == "" Then
        return
    EndIf
    $cmd = "java -jar " & $installer & " -s -d " & $dir
    RunWait($cmd)
EndFunc

Func InstallRobot($installer)
    Run($installer)
    WaitSetupWindowAndClickEnter("This Wizard will install")
    WaitSetupWindowAndClickEnter("Select python installation")
    WaitSetupWindowAndClickEnter("Ready to install")
    WaitSetupWindowAndClickEnter("Postinstall script finished")
EndFunc

Func WaitSetupWindowAndClickEnter($exp_text)
    WinWaitActive("Setup", $exp_text)
    Send("{ENTER}")
EndFunc

Func SetPath($python, $jython)
    $update = $python & ";" & $python & "\Scripts;" & $jython
    $orig = RegRead("HKCU\Environment", "PATH")

    If $orig == "" Then
        $new = $update
    ElseIf StringRight($orig, 1) == ";" Then
        $new = $orig & $update
    Else
        $new = $orig & ";" & $update
    EndIf

    RegWrite("HKCU\Environment", "PATH", "REG_EXPAND_SZ", $new)
    EnvUpdate()
EndFunc