Code:
;Version 1.0
;Autologin sytem using trove saved login hashes
;Version 1.0.1
;Fixing a bug that if you hit delete selected user with out having one selected it would delete them all.
;Fixed when you hit launch acocunt when no account selected. Same error as a above.
;Edited/Fixed the way accounts are saving to give warning to user if the .dat file is not found or unable to get this the hash.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
;#Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
EnvGet, LOCALAPPDATA, LOCALAPPDATA
Global GlyphDataPath ;:= LOCALAPPDATA "\Glyph"
Global GlyphClientPath ;:= "C:\Program Files (x86)\Glyph\"
Global IniFile := "AutoLoginLauncher.ini" ;Save Filename
;Declaring gloabl Var you should not need to change anything below.
Global ConfigWindowToggle := False
Global FoundDat
Global SteamCheckBox := "Button1" ;Don't change this it is used for GUI Checkboss.
Global GUIMainCaption := "Auto Login Launcher by Nipper"
Global GUIConfigCaption := "Auto Login Launcher Config"
;Checking for ini. If not found creates one with default settings.
IfNotExist, %A_ScriptDir%/%IniFile%
{
EnvGet, LOCALAPPDATA, LOCALAPPDATA
GlyphDataPath := LOCALAPPDATA "\Glyph\"
GlyphClientPath := "C:\Program Files (x86)\Glyph\"
IniWrite, 0, %A_ScriptDir%/%IniFile%, AutoLoginSettings, SteamCheckBox
IniWrite, %GlyphDataPath%, %A_ScriptDir%/%IniFile%, AutoLoginSettings, GlyphDataPath
IniWrite, %GlyphClientPath%, %A_ScriptDir%/%IniFile%, AutoLoginSettings, GlyphClientPath
}
;Reading ini for settings.
IniRead, SteamCheckBox, %A_ScriptDir%/%IniFile%, AutoLoginSettings, SteamCheckBox
IniRead, GlyphDataPath, %A_ScriptDir%/%IniFile%, AutoLoginSettings, GlyphDataPath
IniRead, GlyphClientPath, %A_ScriptDir%/%IniFile%, AutoLoginSettings, GlyphClientPath
;Checking for saved users.
GuiControl, Main:, LoginNames,|
Global FolderList :=
loop, %A_ScriptDir%\SavedLogins\*, 2
FolderList .= A_LoopFileName . "|"
Gui, Main: -MaximizeBox -MinimizeBox
Gui, Main:Add, Text, x12 y9 w150 h20 , Saved Account Logins:
Gui, Main:Add, ListBox, x12 y29 w180 h150 vLoginNames gLoginNamesList, %FolderList%
Gui, Main:Add, Button, x12 y179 w180 h20 gRunGlyphNoLogin, Launch Glyph with no login
Gui, Main:Add, Button, x12 y209 w180 h20 gLaunchSelected, Launch Selected Account
Gui, Main:Add, Button, x12 y229 w180 h20 gSaveAddCurrnetLogin, Save/Add Current Login
Gui, Main:Add, Button, x12 y249 w180 h20 gDeleteSelectedAccount, Delete Selected Account
Gui, Main:Add, Button, x12 y279 w80 h20 gConfigToggle, Config
Gui, Main:Add, Button, x102 y279 w90 h20 gMainGuiClose, Exit
Gui, Config:-MaximizeBox -MinimizeBox -Disabled
Gui, Config:Add, Text, x12 y9 w150 h20 , Are you using Steam Version?
Gui, Config:Add, CheckBox, x162 y9 w20 h20 vSteamCheck gSteamSettings
Gui, Config:Add, Text, x12 y39 w260 h20 , Path to GlyphClient.exe
Gui, Config:Add, Edit, x12 y59 w260 h20 vGUIGlyphClientPath, %GlyphClientPath%
Gui, Config:Add, Button, x272 y59 w60 h20 gSelectFolderClient, Browse
Gui, Config:Add, Text, x12 y89 w260 h20 , Path to Glyph Configs
Gui, Config:Add, Edit, x12 y109 w260 h20 vGUIGlyphDataPath, %GlyphDataPath%
Gui, Config:Add, Button, x272 y109 w60 h20 gSelectFolderData, Browse
Gui, Config:Add, Button, x12 y139 w320 h30 gSaveExitConfig, Save and Exit Config
Gui, Config:Show, Hide AutoSize Center h182 w346, %GUIConfigCaption%
if(SteamCheckBox = 1) {
Guicontrol, Config:, SteamCheck, 1
SteamCheck = 1
} else {
SteamCheck = 0
}
Gui, Main:Show, AutoSize Center h314 w205, %GUIMainCaption%
Return
SaveExitConfig:
Gui, Config:Submit, Hide
IniWrite, %SteamCheck%, %A_ScriptDir%/%IniFile%, AutoLoginSettings, SteamCheckBox
IniWrite, %GUIGlyphDataPath%, %A_ScriptDir%/%IniFile%, AutoLoginSettings, GlyphDataPath
IniWrite, %GUIGlyphClientPath%, %A_ScriptDir%/%IniFile%, AutoLoginSettings, GlyphClientPath
return
SelectFolderClient:
FileSelectFolder, Folder, , 3
if Folder =
MsgBox, You didn't select a folder.
else
GuiControl,Config:,GUIGlyphClientPath,%Folder%\
return
SelectFolderData:
FileSelectFolder, Folder, , 3
if Folder =
MsgBox, You didn't select a folder.
else
GuiControl,Config:,GUIGlyphDataPath,%Folder%\
return
SteamSettings:
;Default steam settings.
GuiControlGet, SteamCheck
if(SteamCheck = 1) {
;DefaultSteam Settings
GlyphDataPath := "C:\Program Files (x86)\Steam\steamapps\common\Trove\"
GlyphClientPath := "C:\Program Files (x86)\Steam\steamapps\common\Trove\"
GuiControl,Config:,GUIGlyphClientPath,%GlyphClientPath%
GuiControl,Config:,GUIGlyphDataPath,%GlyphDataPath%
} Else {
;Default Glyph Settings.
EnvGet, LOCALAPPDATA, LOCALAPPDATA
GlyphDataPath := LOCALAPPDATA "\Glyph\"
GlyphClientPath := "C:\Program Files (x86)\Glyph\"
GuiControl,Config:,GUIGlyphClientPath,%GlyphClientPath%
GuiControl,Config:,GUIGlyphDataPath,%GlyphDataPath%
}
Return
RunGlyphNoLogin:
IniDelete, %GlyphDataPath%GlyphClient.cfg, Glyph, Login
FoundDat = 0
Loop, Files, %GlyphDataPath%Cache\*.dat
FoundDat = 1
If (FoundDat = 1)
{
;Deleting and then remake the Cache dir. This is to prevent saving of older or other username hashes.
FileRemoveDir, %GlyphDataPath%Cache, 1
FileCreateDir, %GlyphDataPath%Cache
}
Run, %GlyphClientPath%\GlyphClient.exe
return
LoginNamesList:
if A_GuiControlEvent <> DoubleClick
return
LaunchSelected:
;Sets Var for current selected to LoginNames Var.
Gui, Main:Submit, Nohide
;Warns the user that they need to select a account name first.
if (LoginNames = "")
{
Msgbox, Unable to run selected account. As you forgot to select one. :*(
Return
}
;Sets saved auto login data.
SetAutoLoginData(GlyphDataPath, LoginNames)
;Runs Glyph
Run, %GlyphClientPath%\GlyphClient.exe
Return
SaveAddCurrnetLogin:
;Saves current logged in username/hash data.
SaveLoginData(GlyphDataPath)
;Reloading list
UsernameListReload()
Return
DeleteSelectedAccount:
;Sets Var for current selected to LoginNames Var.
Gui, Main:Submit, Nohide
;This is fix a bug to prevent deleting all your saved logins.
if (LoginNames = "")
{
Msgbox, Unable to delete selected username. As you forgot to select one. :*(
Return
}
;Notify
MsgBox, Deleting all info for %LoginNames%
;Deletes all settings for that user.
FileRemoveDir, %A_ScriptDir%/SavedLogins/%LoginNames%, 1
;Reloading list
UsernameListReload()
Return
ConfigGuiClose:
ConfigToggle:
if !ConfigWindowToggle {
Gui, Config:Show
} else {
Gui, Config:Hide
}
ConfigWindowToggle := !ConfigWindowToggle
Return
MainGuiClose:
;Reload
Exitapp
Return
UsernameListReload()
{
GuiControl, Main:, LoginNames,|
FolderList :=
loop, %A_ScriptDir%\SavedLogins\*, 2
FolderList .= A_LoopFileName . "|"
GuiControl, Main:, LoginNames, %FolderList%
Return
}
;Function to save currnet saved current logged in user.
SaveLoginData(GlyphFolder)
{
;Reading Login name
IniRead, LoginName, %GlyphFolder%GlyphClient.cfg, Glyph, Login
;Warning user if no .dat is not in the folder. And if found copying for later use.
FoundDat = 0
Loop, Files, %GlyphFolder%Cache\*.dat
FoundDat = 1
If (FoundDat = 1)
{
;Creating Saved LoginName Folder
IfNotExist, %A_ScriptDir%/SavedLogins
FileCreateDir, %A_ScriptDir%/SavedLogins
;Creating LoginName Folder
IfNotExist, %A_ScriptDir%/SavedLogins/%LoginName%
FileCreateDir, %A_ScriptDir%/SavedLogins/%LoginName%
;Copying Current .dat files over to new folder by current login name. This will overwrite exsiting files.
FileCopy, %GlyphFolder%Cache\*.dat, %A_ScriptDir%/SavedLogins/%LoginName%, 1
Msgbox Login hash for %LoginName% saved. If the name is on the list already it will overwrite older hashes.
} else {
Msgbox Unable to find login hash for "%LoginName%". Please check to make sure glyph auto logs in and check the pathing to the data folder.
}
return
}
;Function To load Set usernames autologin data.
SetAutoLoginData(GlyphFolder,LoginName)
{
;Checking to see if Glyph is running. If window found it will do nothing.
Process, Exist, GlyphClient.exe
if (ErrorLevel != 0)
{
Process, Close, GlyphClient.exe
Process, WaitClose, GlyphClient.exe
}
LoginToBeUsed := LoginName
;Writing Login name to config file.
IniWrite, %LoginToBeUsed%, %GlyphFolder%GlyphClient.cfg, Glyph, Login
;Deleting and then remake the Cache dir. This is to prevent saving of older or other username hashes.
FoundDat = 0
Loop, Files, %GlyphFolder%Cache\*.dat
FoundDat = 1
If (FoundDat = 1)
{
;Deleting and then remaking the Cache dir. This is to prevent saving of older hashes.
FileRemoveDir, %GlyphFolder%Cache, 1
FileCreateDir, %GlyphFolder%Cache
}
;Checking for .dat file if found copying over.
FoundDat = 0
Loop, Files, %A_ScriptDir%\SavedLogins\%LoginToBeUsed%\*.dat
FoundDat = 1
If (FoundDat = 1)
{
;Copying Current .dat files over to new folder by current login name. This will overwrite exsiting files.
FileCopy, %A_ScriptDir%/SavedLogins/%LoginToBeUsed%\*.dat, %GlyphFolder%Cache, 1
;Msgbox Login hash for %LoginToBeUsed% set.
} else {
Msgbox Unable to find login hash for %LoginToBeUsed%. Please login again and hit save again.
}
;Lauching Glyph
;Run, %GlyphClientPath%\GlyphClient.exe
return
}