Hi,
I found this 12 year old thread were someone had the same question:
https://autohotkey.com/board/topic/1091 ... ahk-class/
When I compile a script (e.g. one which creates an AHK gui), the class id is always:
ahk_class AutoHotkeyGUI
Is there a newer way to change the class id rather than using any hex tools?
I create guis for different applications.
If all guis have the same class id, there might be some problems.
because I often work with #if WinActive("ahk_class ...")
Regards
Create own class id for ahk gui?
Create own class id for ahk gui?
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Re: Create own class id for ahk gui?
Try this code, it is for AHKv2 because AHKv1 is MUCH slower. Create a copy of AutoHotkey.exe and select it in the dialog box.
Anyway, this is a VERY bad idea. You should look for a smarter alternative to ahk_class.
Edit: You can try this for v1.
Code: Select all
ahkexe := FileSelect()
if (!ErrorLevel)
MsgBox SetAHKClassName(ahkexe, InputBox(,,,"FlipeadorGUI"))
ExitApp
SetAHKClassName(File, Name)
{
local f := FileOpen(File, "rw-wd", "UTF-16-RAW")
if (!f)
return FALSE
local Buffer := ""
VarSetCapacity(Buffer, 28)
while (!f.AtEOF)
{
f.RawRead(&Buffer, 26)
if (StrGet(&Buffer, 13, "UTF-16") == "AutoHotkeyGUI")
{
f.pos := f.pos - 2*13, f.Write(Name)
loop 13 - StrLen(Name)
f.WriteUShort(0)
return TRUE
}
f.Seek(A_Index+1)
}
return FALSE
}
Edit: You can try this for v1.
Spoiler
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Create own class id for ahk gui?
Interesting, how can I do this manually? when I try to open the exe in txt I do not find AutoHotkeyGUI
Re: Create own class id for ahk gui?
Open it in a hexadecimal editor like HxD.AHKStudent wrote:Interesting, how can I do this manually? when I try to open the exe in txt I do not find AutoHotkeyGUI
Edit: I tried doing it in a running script with GetAddressOfData (v2) but it did not work
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Create own class id for ahk gui?
I tried HxD, I select my exe, I do a search for the word AutoHotkeyGUI and it finds nothing, but your script works. I tried with a exe that did not have the changed name yet.Flipeador wrote:Open it in a hexadecimal editor like HxD.AHKStudent wrote:Interesting, how can I do this manually? when I try to open the exe in txt I do not find AutoHotkeyGUI
Edit: I tried doing it in a running script with GetAddressOfData (v2) but it did not work
Re: Create own class id for ahk gui?
- Here's a script I wrote to change 'AutoHotkeyGUI' to something else, live, while the exe is open, rather than editing the exe file.
test whether another script's hotkeys are still working (trigger hotkeys in another script) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 92#p132392
- But I agree, it ought to be possible to choose a custom class name for GUIs, and I mentioned it in my Wish List 2.0.
Wish List 2.0 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13&t=36789
test whether another script's hotkeys are still working (trigger hotkeys in another script) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 92#p132392
- But I agree, it ought to be possible to choose a custom class name for GUIs, and I mentioned it in my Wish List 2.0.
Wish List 2.0 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 13&t=36789
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Re: Create own class id for ahk gui?
AHKStudent wrote:I tried HxD, I select my exe, I do a search for the word AutoHotkeyGUI and it finds nothing
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Create own class id for ahk gui?
worksFlipeador wrote:AHKStudent wrote:I tried HxD, I select my exe, I do a search for the word AutoHotkeyGUI and it finds nothing
Re: Create own class id for ahk gui?
Hi, thanks for the many replies!
Very interesting indeed.
A question:
Let's say I create a bigger script which contains single scripts (for different applications for example).
If I have several Guis and compile the big script to an Exe, will a hex editor show me several AutoHotKeyGui class ids?
If yes, I assume that the first found will be the first gui, the second the second gui etc.
So I guess I could simply rename those IDs even though they are in 1 big script?
Regards
Very interesting indeed.
A question:
Let's say I create a bigger script which contains single scripts (for different applications for example).
If I have several Guis and compile the big script to an Exe, will a hex editor show me several AutoHotKeyGui class ids?
If yes, I assume that the first found will be the first gui, the second the second gui etc.
So I guess I could simply rename those IDs even though they are in 1 big script?
Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Who is online
Users browsing this forum: Descolada and 83 guests