Page 1 of 1

Help to make a wrapper for IMGUI

Posted: 21 Jul 2021, 10:52
by Noblish
Hello, I use AHK for some years now, I'm not an expert, but I understand many things. I don't know why, no one has ever made a wrapper for IMGGUI, all I found on Google was on a Russian site, someone succeeded. I need someone to explain to me, what functions on Visual Studio, or where the functions are or needed (imgui project), to make the wrapper in AHK. I have an approach, but cant make it work, also below is a screenshot from the guy that I found. If someone could be kind and patient to explain to me, I would really appreciate. It is a project I wanted to make for a long time, and I am willing to do a full wrapper and post it here later on, I mean… imgui is useful and clean, I'm sure many people would want.

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?

Image

Re: Help to make a wrapper for IMGUI

Posted: 21 Jul 2021, 11:06
by gregster
Never heard of ImGUI before, but what has AutoHotInterception to do with it (in your second code box) - isn't that a working project (for remapping keys) by our forum member evilC ?
My guess is that a ImGUI wrapper would be a lot more complex, and that you can't just replace a few lines in the AHI wrapper to make it work.

Re: Help to make a wrapper for IMGUI

Posted: 21 Jul 2021, 11:31
by Noblish
Hello , thanks for your reply,

yea that autohotkeyinterception was just an example, with imggui we can create cool guis

https://github.com/ocornut/imgui

someone did it for autoit: https://github.com/thedemons/imgui-autoit/

Re: Help to make a wrapper for IMGUI

Posted: 22 Jul 2021, 04:44
by Noblish
bump

Re: Help to make a wrapper for IMGUI

Posted: 22 Jul 2021, 07:47
by malcev
You seriously think that somebody will write wrapper for about 2500 lines of autoit code? :)))
You need to learn autoit and then convert this functions to ahk.
As I see it seems not difficult.

Code: Select all

DllCall("LoadLibrary", "Str", "imgui.dll")
hwnd := DllCall("imgui\GUICreate", "wstr", "AHK ImGui", "int", 300, "int", 300, "int", 100, "int", 100, "Cdecl ptr")
winshow ahk_id %hwnd%
loop
{
   DllCall("imgui\BeginFrame", "Cdecl")
   DllCall("imgui\Begin", "wstr", "Another window", "ptr", 0, "int", 0, "Cdecl")
   DllCall("imgui\Text", "wstr", "Hello there..", "Cdecl")
   DllCall("imgui\End", "Cdecl")
   DllCall("imgui\EndFrame", "uint", 0xFF738C99, "Cdecl")
}

Re: Help to make a wrapper for IMGUI

Posted: 22 Jul 2021, 09:38
by Noblish
malcev wrote:
22 Jul 2021, 07:47
You seriously think that somebody will write wrapper for about 2500 lines of autoit code? :)))
You need to learn autoit and then convert this functions to ahk.
As I see it seems not difficult.

Hi, it's not about converting the autoit script to ahk, IMGUI is actually C++. It might seem like many functions, I dont need it all, but I know a way to automate it.

Btw your example does not work..

Re: Help to make a wrapper for IMGUI

Posted: 22 Jul 2021, 09:44
by malcev
My example works.
You need download dll with the same bitness as ahk and unblock it.

Re: Help to make a wrapper for IMGUI

Posted: 22 Jul 2021, 09:47
by Noblish
malcev wrote:
22 Jul 2021, 09:44
My example works.
You need download dll with the same bitness as ahk and unblock it.
Ohhh gotchaa, hey thank you. It is all I needed, to start.

Re: Help to make a wrapper for IMGUI

Posted: 23 Jul 2021, 13:44
by thedemons
malcev wrote:
22 Jul 2021, 07:47
You seriously think that somebody will write wrapper for about 2500 lines of autoit code? :)))
You need to learn autoit and then convert this functions to ahk.
As I see it seems not difficult.
Hello guys, I'm the creator of that imgui-autoit wrapper, just wonder around on the internet and found this topic.
Yes in fact I didn't write that line by line, I wrote a script to convert c++ code to autoit, but it's still a tremendous amount of works and took me like a week to finish.

If you want, I can help you with it, even tho I don't know AutoHotkey, I can give you the source for the imgui.dll and maybe help you write some script that converts the already-written autoit code to AutoHotkey, that would be easier.

Re: Help to make a wrapper for IMGUI

Posted: 23 Jul 2021, 23:35
by SOTE
@Noblish

What exactly are you looking for or what particular advantage is IMGUI giving you, over the present way that AutoHotkey creates GUIs?

I say this, because there are many scripts that expand abilities of AutoHotkey GUIs (like add color buttons) or integrate with JavaScript.

Re: Help to make a wrapper for IMGUI

Posted: 24 Jul 2021, 15:12
by Noblish
SOTE wrote:
23 Jul 2021, 23:35
@Noblish

What exactly are you looking for or what particular advantage is IMGUI giving you, over the present way that AutoHotkey creates GUIs?

I say this, because there are many scripts that expand abilities of AutoHotkey GUIs (like add color buttons) or integrate with JavaScript.
IMGUI is more advanced, has different styling options, and it's the perfect GUI to use with big tools like editing software or game creating tools. And many other advanced things. I don't know everything about it, but you can really create creative tools with it. I feel that it would be a game changer for AHK users, since AHK is easy to use, for me, I use AHK at my personal PC and at work, I feel that having an easy GUI, can boost my productivity (my needs). From buttons, sliders, multiple GUIs in some clicks, advanced graphics, it draws with DirectX, so it's direct. If i could have a little help with the community, i would push to make a full wrapper and post it.

Re: Help to make a wrapper for IMGUI

Posted: 24 Jul 2021, 18:23
by DuyMinh
thedemons wrote:
23 Jul 2021, 13:44
malcev wrote:
22 Jul 2021, 07:47
You seriously think that somebody will write wrapper for about 2500 lines of autoit code? :)))
You need to learn autoit and then convert this functions to ahk.
As I see it seems not difficult.
Hello guys, I'm the creator of that imgui-autoit wrapper, just wonder around on the internet and found this topic.
Yes in fact I didn't write that line by line, I wrote a script to convert c++ code to autoit, but it's still a tremendous amount of works and took me like a week to finish.

If you want, I can help you with it, even tho I don't know AutoHotkey, I can give you the source for the imgui.dll and maybe help you write some script that converts the already-written autoit code to AutoHotkey, that would be easier.
I'm DuyMinh from AutoIt Guru, can you send me source of this dll. I can try to compile and convert it to AutoHotkey...
Btw, tiếng anh của iêm yếu lắm thím à... Thím cho iêm xin cái source dll nhé, iêm sẽ thử convert nó qua AHK cho. Sẵn cho iêm xin cách nào để liên hệ với thím nhé, facebook không thấy thím online.

Re: Help to make a wrapper for IMGUI

Posted: 24 Jul 2021, 20:20
by malcev
what particular advantage is IMGUI giving you, over the present way that AutoHotkey creates GUIs?
I think that it will be easier to inject imgui guis into directx fullscreen games.

Re: Help to make a wrapper for IMGUI

Posted: 25 Jul 2021, 01:01
by thedemons
DuyMinh wrote:
24 Jul 2021, 18:23
I'm DuyMinh from AutoIt Guru, can you send me source of this dll. I can try to compile and convert it to AutoHotkey...
Btw, tiếng anh của iêm yếu lắm thím à... Thím cho iêm xin cái source dll nhé, iêm sẽ thử convert nó qua AHK cho. Sẵn cho iêm xin cách nào để liên hệ với thím nhé, facebook không thấy thím online.
Just send me a message on facebook, I can't find you in the group, or just dm me in discord, my tag name is in the imgui-autoit github repository

Re: Help to make a wrapper for IMGUI

Posted: 25 Jul 2021, 03:42
by Noblish
thedemons wrote:
23 Jul 2021, 13:44
malcev wrote:
22 Jul 2021, 07:47
You seriously think that somebody will write wrapper for about 2500 lines of autoit code? :)))
You need to learn autoit and then convert this functions to ahk.
As I see it seems not difficult.
Hello guys, I'm the creator of that imgui-autoit wrapper, just wonder around on the internet and found this topic.
Yes in fact I didn't write that line by line, I wrote a script to convert c++ code to autoit, but it's still a tremendous amount of works and took me like a week to finish.

If you want, I can help you with it, even tho I don't know AutoHotkey, I can give you the source for the imgui.dll and maybe help you write some script that converts the already-written autoit code to AutoHotkey, that would be easier.
Hello, thanks for your reply. I really would love if we could help each other here, since I am stuck with some functions

Re: Help to make a wrapper for IMGUI

Posted: 25 Jul 2021, 03:44
by Noblish
DuyMinh wrote:
24 Jul 2021, 18:23
thedemons wrote:
23 Jul 2021, 13:44
malcev wrote:
22 Jul 2021, 07:47
You seriously think that somebody will write wrapper for about 2500 lines of autoit code? :)))
You need to learn autoit and then convert this functions to ahk.
As I see it seems not difficult.
Hello guys, I'm the creator of that imgui-autoit wrapper, just wonder around on the internet and found this topic.
Yes in fact I didn't write that line by line, I wrote a script to convert c++ code to autoit, but it's still a tremendous amount of works and took me like a week to finish.

If you want, I can help you with it, even tho I don't know AutoHotkey, I can give you the source for the imgui.dll and maybe help you write some script that converts the already-written autoit code to AutoHotkey, that would be easier.
I'm DuyMinh from AutoIt Guru, can you send me source of this dll. I can try to compile and convert it to AutoHotkey...
Btw, tiếng anh của iêm yếu lắm thím à... Thím cho iêm xin cái source dll nhé, iêm sẽ thử convert nó qua AHK cho. Sẵn cho iêm xin cách nào để liên hệ với thím nhé, facebook không thấy thím online.
https://github.com/thedemons/imgui-autoit

Re: Help to make a wrapper for IMGUI

Posted: 25 Jul 2021, 04:40
by thedemons
Noblish wrote:
25 Jul 2021, 03:42
Hello, thanks for your reply. I really would love if we could help each other here, since I am stuck with some functions
Do you have discord? My discord is at the end of the github repos, please contact me

Re: Help to make a wrapper for IMGUI

Posted: 25 Jul 2021, 06:08
by Noblish
thedemons wrote:
25 Jul 2021, 04:40
Noblish wrote:
25 Jul 2021, 03:42
Hello, thanks for your reply. I really would love if we could help each other here, since I am stuck with some functions
Do you have discord? My discord is at the end of the github repos, please contact me
Added

Re: Help to make a wrapper for IMGUI

Posted: 27 Jul 2021, 11:54
by Noblish
Just wanting to give you all an update, things are working well, it's handling smooth and fast

Image

Re: Help to make a wrapper for IMGUI

Posted: 16 Aug 2021, 00:39
by kazhafeizhale
hi, i am interesting about this, (imgui->ahk),do you have github repository address 8-) ?