Code: Select all
#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.
class ImGui
{
__New(){
bitness := A_PtrSize == 8 ? "x64" : "x86"
dllName := "imgui.dll"
if (A_IsCompiled){
dllFile := "Lib\" bitness "\" dllName
FileCreateDir, Lib
FileInstall, Lib\imgui.dll, Lib\imgui.dll
if (bitness == "x86"){
FileCreateDir, Lib\x86
FileInstall, Lib\x86\imgui.dll, Lib\x86\imgui.dll
} else {
FileCreateDir, Lib\x64
FileInstall, Lib\x64\imgui.dll, Lib\x64\imgui.dll
}
} else {
dllFile := "Lib\" bitness "\" dllName
}
if (!FileExist(dllFile)) {
MsgBox % "Unable to find " dllFile ", exiting...`nYou should extract both x86 and x64 folders from the library folder in interception.zip into AHI's lib folder."
ExitApp
}
hModule := DllCall("LoadLibrary", "Str", dllFile, "Ptr")
if (hModule == 0) {
this_bitness := A_PtrSize == 8 ? "64-bit" : "32-bit"
other_bitness := A_PtrSize == 4 ? "64-bit" : "32-bit"
MsgBox % "Bitness of " dllName " does not match bitness of AHK.`nAHK is " this_bitness ", but " dllName " is " other_bitness "."
ExitApp
}
DllCall("FreeLibrary", "Ptr", hModule)
dllName := "imgui.dll"
if (A_IsCompiled){
dllFile := "Lib\" dllName
} else {
dllFile := dllName
}
hintMessage := "Try right-clicking " dllFile ", select Properties, and if there is an 'Unblock' checkbox, tick it`nAlternatively, running Unblocker.ps1 in the lib folder (ideally as admin) can do this for you."
if (!FileExist(dllFile)) {
MsgBox % "Unable to find " dllFile ", exiting..."
ExitApp
}
try {
; this.Instance := asm.CreateInstance("AutoHotInterception.Manager")
DllCall("LoadLibrary", "Str", dllFile, "Ptr")
}
catch {
MsgBox % dllName " failed to load`n`n" hintMessage
ExitApp
}
; if (this.Instance.OkCheck() != "OK") {
; MsgBox % dllName " loaded but check failed!`n`n" hintMessage
; ExitApp
; }
}
Initialization(){
DllCall(this.Funcs.Initialization)
}
SetRenderFunc(function){
if (this.RenderFunc)
DllCall("Kernel32.dll\GlobalFree", "Uint", this.RenderFunc)
if (this.RenderFunc := RegisterCallback("function"))
DllCall(this.Funcs.SetRenderFunc, "Uint", this.RenderFunc)
}
Begin(name, p_open, flags:= 0){
return DllCall(this.Funcs.Begin, "Str", name, "UInt", p_open, "Int", flags)
}
End(){
return DllCall(this.Funcs.End)
}
Text(text){
return DllCall(this.Funcs.Text, "Str", text)
}
class System
{
GetProcAdress(hModule, lpProcName)
{
return DllCall("Kernel32.dll\GetProcAdress", "Uint", hModule, "AStr", lpProcName)
}
}
}
Msgbox, % IsObject(ImGui)
global ImGui := new ImGui()
ImGui.SetRenderFunc("ImGuiRender")
ImGui.Initialization()
ImGuiRender()
{
static isOpen:= True
Imgui.Begin("Test", &isOpen)
ImGui.Text("Test text")
ImGui.End()
}
Or with CLR?