hjf

Wednesday, March 30, 2016

Torchlight Launcher [and cheat/hotkey trainer] V2.2 [ Updated ]


Torchlight Launcher [and cheat/hotkey trainer +10] V2.2



[UPDATED - V2.2]

Update Notes:
This runs fine on medium-high end machines, but on slower machines this doesn't always execute the whole command.
  • Added BlockInput during cheat execution to reduce lag.
  • Added slight wait intervals during key Send.
  • Created a function to send keys: reduced file size and speed up send keys execution to reduce lag even more.

I cheat sometimes. Not all of the time, but I cheat when replaying a game or on games that I am just going to test for hacking/modding. I cheat because I am getting old and I have a life with children; which are, of course, more important... So in everything I do I create automation to speed up gaming and any other processes so I can spend more time with my family. I am a techy and gamer, I can't help doing what I love so I can do both with the help of automation.

So I have created Torchlight Launcher V2.2. This is my first official online release, but I have several working personal releases that work well for me so I'll keep the version sequence going. This is a launcher//cheat trainer/hotkey helper in one. Unlike traditional cheat trainers this is written in the Autohotkey scripting language and uses no coding hacks other than using Windows libraries and modules themselves to automate all functions.

This launcher adds hotkeys for 10 different cheats and adds item slots 1 & 2 to the XButtons 1 & 2 on any gaming mouse. It also adds ascend and decend level to the + and - number pad keys. This trainer uses then normal in-game console to use cheats that can already be found on the internet, but makes it so you only have to press one button for very quick access. The in-game console can only be accessed by enabling it in Torchlights 'settings.txt' file found in your users AppData folder. This launcher provides the ability to enable it with the click of a button (creates a backup of the original settings file) or if that fails for some reason helps you edit the file manually.

Usage

This is a compiled ahk script for use in any x86 (I can compile for anything else) system From Windows Vista on up. Just run the trainer and view the Help. There is a system tray icon where you can access any function that have buttons in the gui, view the help window, enable cheats, run the game, and exit the launcher. This can be used with any version of Torchlight on PC as long as it installed in it's default location (even GOG).

Downloads

Screenshots

Launcher text and hotkey list background and slight editing by me:
In custom Windows 10 build:
 photo tllss_zpsiqjzlnxp.png
In Windows 7 Build:
 photo tllss2_zpsvudvkmrf.png

Source Code

; Torchlight Helper
; Torchlight Helper
#SingleInstance, Force
Menu, Tray, NoStandard
Menu, Tray, Add, Run Torchlight, gsRunTl
Menu, Tray, Add, Enable Cheats, gsEnblChts
Menu, Tray, Add, Help, ButtonHelp
Menu, Tray, Add
Menu, Tray, Add, E&xit Launcher, ExitSub
if not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"
   ExitApp
}
OnExit, ExitSub
DetectHiddenWindows, On

; Variables
Global _varTit
ahkexe := "\AutoHotkey\AutoHotkey.exe"
settfl := A_AppData . "\runic games\torchlight\settings.txt"
ProgramFilesX86 := A_ProgramFiles . (A_PtrSize=8 ? " (x86)" : "")
ahkroot86 := ProgramFilesX86 . ahkexe
ahkroot := "C:\Program Files" . ahkexe
bgpic := A_Temp . "\tllogo.png"
; Auto-execute begin
FileInstall, C:\GOG Games\Torchlight\tllogo.png, %bgpic%, 1
IfExist, %ahkroot86%
 {
  exepath := ahkroot86 
 }
IfExist, %ahkroot%
 {
  exepath := ahkroot
 }
 
IfExist, %exepath%
 {
  _funcGetAhk(_varTit, _varThis)
  _funcKillAhk()
 }
IfExist, C:\GOG Games\Torchlight\Torchlight.exe
 {
  _vExePath := "C:\GOG Games\Torchlight\Torchlight.exe"
 }
IfExist, C:\Program Files\Torchlight\Torchlight.exe
 {
  _vExePath := "C:\Program Files\Torchlight\Torchlight.exe"
 }
IfExist, C:\Program Files (x86)\Torchlight\Torchlight.exe
 {
  _vExePath := "C:\Program Files (x86)\Torchlight\Torchlight.exe"
 }
Gui, Add, Pic, w300 h288 y20 x20 vPic, % bgpic
Gui, Font, s14, Arial
_funcTextGlow("5","96", "298", "24", "White", "DD4B1B", "Center BackgroundTrans", "Cheat Hotkeys")
Gui, Font, s12, Arial
_funcTextGlow("5","120", "145", "24", "White", "DD4B1B", "BackgroundTrans", "F5  = God")
_funcTextGlow("5","144", "145", "24", "White", "DD4B1B", "BackgroundTrans", "F6  = Identify All")
_funcTextGlow("5","168", "145", "24", "White", "DD4B1B", "BackgroundTrans", "F7  = Stash")
_funcTextGlow("5","192", "145", "24", "White", "DD4B1B", "BackgroundTrans", "F8  = Level Up")
_funcTextGlow("5","216", "145", "24", "White", "DD4B1B", "BackgroundTrans", "-      = Decend Lvl")
Gui, Add, Button,x5 y238 w145 h20 ggsRunTl ,Run Torchlight
Gui, Add, Button, x152 y238 w143 h20 ggsEnblChts , Enable Cheats
_funcTextGlow("150","120", "145", "24", "White", "DD4B1B", "BackgroundTrans", "F9    = Kill All")
_funcTextGlow("150","144", "145", "24", "White", "DD4B1B", "BackgroundTrans", "F10  = Critical Hits")
_funcTextGlow("150","168", "145", "24", "White", "DD4B1B", "BackgroundTrans", "F11  = AI Freeze")
_funcTextGlow("150","192", "145", "24", "White", "DD4B1B", "BackgroundTrans", "F12  = 1 Million Gold")
_funcTextGlow("150","216", "145", "24", "White", "DD4B1B", "BackgroundTrans", "+       = Ascend Lvl")
Gui, Add, Button,x5 y264 w70 h20 ,E&xit
Gui, Add, Button,x79 y264 w70 h20 ,&Help
GuiControl, Move, Pic, x0 y0
Gui, Show, w300 h288 Center, Torchlight Launcher V2.1

OnMessage(0x200, "WM_MOUSEMOVE")

;Auto-execute end
SetTimer, chkTlRun, 1000
Return

; Hotkeys
#IfWinActive, ahk_exe Torchlight.exe
XButton1::Send, {1}
XButton2::Send, {2}
F5::Send, {LShift Down}``{LShift Up}god{Enter}{Esc}
F6::Send, {LShift Down}``{LShift Up}identifyall{Enter}{Esc}
F7::Send, {LShift Down}``{LShift Up}stash{Enter}{Esc}
F8::Send, {LShift Down}``{LShift Up}levelup{Enter}{Esc}
F9::Send, {LShift Down}``{LShift Up}killall{Enter}{Esc}
F10::Send, {LShift Down}``{LShift Up}alwayscrit{Enter}{Esc}
F11::Send, {LShift Down}``{LShift Up}aifreeze{Enter}{Esc}
F12::Send, {LShift Down}``{LShift Up}money 1000000{Enter}{Esc}
NumPadSub::Send, {LShift Down}``{LShift Up}decend{Enter}{Esc}
NumPadAdd::Send, {LShift Down}``{LShift Up}ascend{Enter}{Esc}
^+s::Gosub, gsEnblChts
#IfWinActive

;Gosubs
chkTlRun:
 IfWinExist, ahk_exe Torchlight.exe
  {
   Sleep, 1000
   SetTimer, chkTlRun, Off
   SetTimer, gsChckT, 3000
  }
Return
gsChckT:
 IfWinNotExist, ahk_exe Torchlight.exe
  Gosub, ExitSub
Return

gsRunTl:
 Sleep, 2000
 IfWinNotExist, ahk_exe Torchlight.exe
  Run, "%_vExePath%"
 Else
  WinActivate
Return
gsEnblChts:
 c := "CONSOLE"
 bk := settfl . ".bak"
 FileRead, _vChtFl, % settfl
 IfNotExist, % bk
  {
   FileAppend, % _vChtFl, % bk, UTF-16
  }
 StringReplace, _vRplcChtFl,_vChtFl, %c% :0, %c% :1
 IfExist, % bk
  {
   FileDelete, % settfl
   FileAppend, % _vRplcChtFl, % settfl, UTF-16
   MsgBox, 64, Torchlight Launcher Info, Cheats should be enabled!`nYou can run Torchlight from this launcher but`nit is not neccesary as long as this launcher is running.
  }
 Else
  {
   MsgBox,4, Torchlight Launcher Error, % ("Backup file:" . bk . "`n`nwas not created, please edit:"
   . "`n`n" . settfl 
   . "`n`nyourself and change CONSOLE :0 to CONSOLE :1"
   . "`n`nWould you like to edit the file manually now?")
   IfMsgBox Yes
    Run, notepad "%settfl%"
  }
 ;MsgBox % _vRplcChtFl
Return

; Functions
_funcTextGlow(_vXPos,_vYPos, _vWPos, _vHPos, _vTxtClr, _vGlwClr, _vOpt, _vTxt){
 xa := _vXPos - 1
 xb := _vXPos + 1
 ya := _vYPos - 1
 yb := _vYPos + 1
 Gui, Add, Text, x%xa% y%ya% w%_vWPos% h%_vHPos% c%_vGlwClr% %_vOpt%,%_vTxt%
 Gui, Add, Text, x%xb% y%ya% w%_vWPos% h%_vHPos% c%_vGlwClr% %_vOpt%,%_vTxt%
 Gui, Add, Text, x%xa% y%yb% w%_vWPos% h%_vHPos% c%_vGlwClr% %_vOpt%,%_vTxt%
 Gui, Add, Text, x%xb% y%yb% w%_vWPos% h%_vHPos% c%_vGlwClr% %_vOpt%,%_vTxt%
 Gui, Add, Text, x%_vXPos% y%_vYPos% w%_vWPos% h%_vHPos% c%_vTxtClr% %_vOpt%,%_vTxt%
}
_funcGetAhk(ByRef _varTit, ByRef _varThis){
 WinGet,_varThis, List, ahk_class AutoHotkey
 WinGetTitle, _varTit, ahk_id %_varThis1%
}

_funcKillAhk(_varCnt:=1){
 WinGet,_varAhkList, List, ahk_class AutoHotkey
 lCnt := _varAhkList
 Loop, %_varAhkList%
  {
   _pr := _varAhkList%A_Index%
   WinGetTitle, _varTt, ahk_id %_pr%
   If (_varTt  != _varTit)
    {
     WinClose, ahk_id %_pr%
     lCnt := lCnt - 1
    }
  }
 ;MsgBox, 64,Start AHK, Start AHK manually for test.
 _funcGetAhk(_varTit, _varThis)
 If (_varThis != "1")
  {
   MsgBox, 5, Something went wrong, All AHK scripts were not closed.`nPlease exit them manually and`nclick [Retry].
    {
     IfMsgBox, Retry
      {
       Reload
      }
     Else IfMsgBox, Cancel
      {
       MsgBox, 64, AutoHotkey Error, Please resolve your issue and try again.
       Gosub, ExitSub      
      }      
    }
  }
}

WM_MOUSEMOVE() {
}
ButtonHelp:
 MsgBox, 64, Torchlight Launcher & Trainer +10 V2.1, % ( "Torchlight Launcher & Trainer +10 V2.1 by Lateralus138."
 . "`n`nThis cheat trainer is written completely in AutoHotkey &"
 . "`nunlike traditional trainers this does not use any hacks,"
 . "`nonly normal cheats that can also be accessed from the"
 . "`nin-game console. To use cheats in Torchlight you must"
 . "`nfirst enable the console in the games settings config file:"
 . "`n`n""settings.txt"" Found in:"
 . "`n" . A_AppData . "\runic games\torchlight\"
 . "`n`nOpen the settings file and change CONSOLE: 0 to CONSOLE: 1"
 . "`nand then run this trainer."
 . "`n`nThis trainer adds 10 of the more commonly used cheats to"
 . "`nhotkeys & adds item slots 1 & 2 to XButton1 & XButton2 on"
 . "`na gaming mouse."
 . "`n`nTorchlight Launcher can be used with any version of the"
 . "`ngame (GOG & regular) as long as it is installed in the"
 . "`ndefault directory.") 
Return
ButtonExit:
GuiClose:
ExitSub:
 IfExist, %exepath%
  {
   Run, AutoHotkey
  }
 Sleep, 1000
ExitApp

No comments: