Skip to content

Functions and Properties

Kamil edited this page Mar 9, 2018 · 2 revisions

Table of Contents

Memory Manipulation

Reading and writing memory is one of the main methods for hacking games.

lua (Cheat Engine Lua)

GameHaxr uses a Cheat Engine Lua server for executing Cheat Engine Lua code, so you must specify a unique Lua server name using engine.serverName = 'LuaServerNameHere'

The easiest and most powerful way to manipulate memory is Cheat Engine Lua. It has pretty much everything you would need for memory hacking and even more. Take a look at the Cheat Engine Lua documentation for information on how to use it.

Name Description Example
lua.execute(string luaCode) This function allows you to execute raw Cheat Engine Lua code, which gives you access to everything. lua.execute('print("Hello world")')
lua.getVar(string varName) Gets the Lua variable name or return result specified from the engine.serverName environment. lua.getVar('someVar')
lua.setVar(string varName, string varValue) Sets the Lua variable name specified from the engine.serverName environment. lua.setVar('someVar', 'some value')
lua.bool(string luaConditions) Returns a boolean based on the conditions. lua.bool('2 > 1')
lua.runFunc(string funcName, object[] funcParams = null) Runs the function from the engine.serverName environment with the parameters specified. lua.runFunc('someFunc', ['param1', 'param2'])
lua.scanAob(string luaVarAOB, string aob) Uses the AOBScan function and stores the first result in luaVarAOB and returns the amount of results. lua.scanAob('testAob', '01 02 03 ?? 05')

Input Simulation (Macros)

Program key and mouse input to create macros, routines, bots etc.

ahk (AutoHotKey)

The easiest and most powerful way to program artificial input is AutoHotKey. It has pretty much everything you would need for input simulation and even more. Take a look at the AutoHotKey documentation for information on how to use it.

If it's a browser game, you can use the GameHaxr browser functions for direct mouse and key input.

Name Description Example
ahk.execute(string ahkCode) Lets you to execute raw AutoHotKey code, which gives you access to everything. ahk.execute('MsgBox Hello world')
ahk.eval(string ahkCode) Lets you evaluate raw AutoHotKey code (return the result of the ahkCode). ahk.eval('1 + 1')
ahk.getVar(string varName) Gets the AutoHotKey variable name. ahk.getVar('someVar')
ahk.setVar(string varName, string varValue) Sets the AutoHotKey variable name. ahk.setVar('someVar', 'some value')
ahk.execFunc(string funcName, string param1 = null, [...], string param10 = null) Executes the AutoHotKey function with the parameters specified. ahk.execFunc('someFunc', 'param1', 'param2')
ahk.execLabel(string labelName) Executes the AutoHotKey label. ahk.execLabel('SOMELABEL')
ahk.loadFile(string filePath) Load a library or execute scripts in a file. ahk.loadFile('someFile.ahk')

GameHaxr Browser

Functions for the GameHaxr browser, such as screenshot and direct input simulation.

browser

Name Description Example
browser.keyDown(string vkCode) Direct key down input to the browser. browser.keyDown('0x41')
browser.keyUp(string vkCode) Direct key up input to the browser. browser.keyUp('0x41')
browser.mouseDown(int mouseX, int mouseY) Direct mouse down input to the browser. browser.mouseDown(10, 10)
browser.mouseUp(int mouseX, int mouseY) Direct mouse up input to the browser. browser.mouseUp(10, 10)
browser.mouseRightDown(int mouseX, int mouseY) Direct mouse right down input to the browser. browser.mouseRightDown(10, 10)
browser.mouseRightUp(int mouseX, int mouseY) Direct mouse right up input to the browser. browser.mouseRightUp(10, 10)
browser.screenshot(string filename = "BrowserScreenshot.png") Takes a direct screenshot of the GameHaxr browser and saves it to the filename specified. browser.screenshot('b.png')

File IO

File input and output functionality.

engineIO

Name Description Example
engineIO.fileReadText(string path) Reads the text from a file and returns it. engineIO.fileReadText('file.txt')
engineIO.fileReadBytes(string path) Reads the bytes from a file and returns it. engineIO.fileReadBytes('file.txt')
engineIO.fileWriteText(string path, string contents) Writes text to a file. engineIO.fileWriteText('file.txt', 'some text')
engineIO.fileAppendText(string path, string contents) Appends text to a file. engineIO.fileAppendText('file.txt', 'appened text')
engineIO.fileWriteBytes(string path, byte[] bytes) Writes bytes to a file. engineIO.fileWriteBytes('file.txt', byte[] bytes)
engineIO.folderList(string dir, bool safeName = false) Returns the folders in a directory. safeName will make it only return the name and not the full path. engineIO.folderList('SomeFolder', true)

Engine (Core Functions)

Contains functions and properties for core functions.

engine (Important/Core Functions and Properties)

Name Description Example
engine.serverName The name that GameHaxr will use when required, such as the Lua server and named pipe client. engine.serverName = 'SomeName'
engine.scriptDir The directory that will be used when reading from a directory, such as files and folders. engine.scriptDir = 'SomeDir'
engine.loadTrainer(string title = "", string path = "index.html", int width = 500, int height = 500) Opens a new browser window that will apply the parameters provided. engine.loadTrainer('Trainer', 'trainer/index.html', 500, 500)
engine.libraryPath Read only path of where the GameHaxr library folder is. engine.libraryPath
engine.loadLibrary(string name) Loads the specified library from the engine.libraryPath directory. engine.loadLibrary('SomeLibrary')

Engine ('Standard' Functions)

Other useful 'standard' functions

Name Description Example
engine.titleText Directly change the window title. engine.titleText = 'Some Title'
engine.showMsg(string msg, string title = "", string buttons = "OK", string icon = "None", string defaultButton = "Button1") Windows Forms message box. engine.showMsg('Yes or no?', 'Asking You Something', 'YesNo', 'Question', 'Button2')
engine.executeJS(string js) Executes JavaScript on the GameHaxr thread. engine.executeJS('alert("Hello world")')
engine.threadSleep(int sleepMS) Pauses thread. await sleep(int ms) should be used instead. engine.threadSleep(1000)

Engine (String Functions)

String functions.

Name Description Example
engine.strToByte(string str) Converts a string into bytes. engine.strToByte('text')
engine.strToHex(string str) Converts a string into hex. engine.strToHex('text')
engine.strNewLine If \n character is not working use this. engine.strNewLine

Custom C# Code

This feature is experimental and may produce unexpected results.

csharp

Name Description Example
codeObjList Array of unique IDs from compiled code using csharp.compile(...) to identify what code you're referring to. codeObjList
csharp.compile(string nameSpace, string code, object[] dlls = null) Compiles C# code from source code using CompileAssemblyFromSource. csharp.compile('Test.TestClass', engine.fileReadText('code.cs'), ['system.windows.forms.dll'])
csharp.invokeMethod(string codeKey, string method, object[] methodParams = null) Invokes a method from csharp.compile(...) using the unique ID it returned. csharp.invokeMethod('f70e9ddde', 'SomeMethod', ['param1', 'param2'])