AHK_H v2 beta
-
- Posts: 941
- Joined: 30 Sep 2017, 03:59
- Location: Romania
- Contact:
AHK_H v2 beta
Hello!
I'm wondering when will the next version of AHK_H v2 be available... Is it planned?
Thank you.
I'm eager to migrate to v2.
Best regards, Marius.
I'm wondering when will the next version of AHK_H v2 be available... Is it planned?
Thank you.
I'm eager to migrate to v2.
Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
KeyPress OSD v4: GitHub or forum. (presentation video)
Quick Picto Viewer: GitHub or forum.
AHK GDI+ expanded / compilation library (on GitHub)
My home page.
Re: AHK_H v2 beta
This is my AHK_H V2 Beta.1 (https://github.com/thqby/autohotkey_h), but there is a little change with Hotkeyit's AHK_H.
Re: AHK_H v2 beta
It will be available soon, I need to decide and adapt a few features.
Re: AHK_H v2 beta
I cannot using ExeThread or ThreadObj in this fork, only thread function NewThread can be use, but this func is very useless, only run child thread and dont have some method for thread manager like exethread or threadobj. Can you fix it?thqby wrote: ↑31 Jul 2021, 19:30This is my AHK_H V2 Beta.1 (https://github.com/thqby/autohotkey_h), but there is a little change with Hotkeyit's AHK_H.
Re: AHK_H v2 beta
@DuyMinh
exethread is a simple wrapper for NewThread. You can try to modify it.
But I don't recommend old H users to use thqby's version, he forced L2-H2 merge with L2 as the main one, which causes some H functions not to work properly, and it seems that thqby has no intention to fix these problems.
exethread is a simple wrapper for NewThread. You can try to modify it.
Code: Select all
exethread(s:="",p:="",t:="",w:=0){
static lib
if !lib
lib:=GetModuleHandle(),ahkFunction:=GetProcAddress(lib,"ahkFunction"),ahkPostFunction:=GetProcAddress(lib,"ahkPostFunction"),addFile:=GetProcAddress(lib,"addFile"),addScript:=GetProcAddress(lib,"addScript")
,ahkExec:=GetProcAddress(lib,"ahkExec"),ahkExecuteLine:=GetProcAddress(lib,"ahkExecuteLine"),ahkFindFunc:=GetProcAddress(lib,"ahkFindFunc"),ahkFindLabel:=GetProcAddress(lib,"ahkFindLabel")
,ahkgetvar:=GetProcAddress(lib,"ahkgetvar"),ahkassign:=GetProcAddress(lib,"ahkassign"),ahkLabel:=GetProcAddress(lib,"ahkLabel"),ahkPause:=GetProcAddress(lib,"ahkPause")
,ahkIsUnicode:=GetProcAddress(lib,"ahkIsUnicode"),ahkReady:=GetProcAddress(lib,"ahkReady")
thread:={(""):ThreadID:=s=""?GetCurrentThreadId():NewThread((w?"SetEvent(" hEvent:=CreateEvent() ")`n":"") s,p,t)
,_ahkFunction:DynaCall(ahkFunction,"s==sttttttttttui","",0,0,0,0,0,0,0,0,0,0,ThreadID)
,_ahkPostFunction:DynaCall(ahkPostFunction,"i==sttttttttttui","",0,0,0,0,0,0,0,0,0,0,ThreadID)
,ahkFunction:DynaCall(ahkFunction,"s==sssssssssssui","","","","","","","","","","","",ThreadID)
,ahkPostFunction:DynaCall(ahkPostFunction,"i==sssssssssssui","","","","","","","","","","","",ThreadID)
,addFile:DynaCall(addFile,"ut==siui","",0,ThreadID)
,addScript:DynaCall(addScript,"ut==siui","",0,ThreadID)
,ahkExec:DynaCall(ahkExec,"ut==sui","",ThreadID)
,ahkExecuteLine:DynaCall(ahkExecuteLine,"ut==utuiuiui",0,0,0,ThreadID)
,ahkFindFunc:DynaCall(ahkFindFunc,"ut==sui","",ThreadID)
,ahkFindLabel:DynaCall(ahkFindLabel,"ut==sui","",ThreadID)
,ahkgetvar:DynaCall(ahkgetvar,"s==suiui","",0,ThreadID)
,ahkassign:DynaCall(ahkassign,"i==ssui","","",ThreadID)
,ahkLabel:DynaCall(ahkLabel,"ui==suiui","",0,ThreadID)
,ahkPause:DynaCall(ahkPause,"ui==sui","",ThreadID)
,ahkIsUnicode:DynaCall(ahkIsUnicode,"ui==")
,ahkReady:DynaCall(ahkReady,"ui==ui",ThreadID)}
thread.ahkterminate:=Func("Exethread_exit").Bind(ThreadID)
if w
WaitForSingleObject(hEvent,w),CloseHandle(hEvent)
return thread
}
Exethread_exit(ThreadID){
static pExitApp:=NumGet(GetProcAddress(0,"g_ThreadExitApp"),"PTR"),Exethread_CloseWindows:=CallbackCreate("Exethread_CloseWindows")
if hThread:=OpenThread(THREAD_ALL_ACCESS:=2032639,true,ThreadID)
success:=QueueUserAPC(pExitApp,hThread,0),CloseHandle(hThread),PostThreadMessage(ThreadID, 0, 0, 0),EnumThreadWindows(ThreadID,Exethread_CloseWindows,0)
return success
}
Exethread_CloseWindows(hwnd,value){
If (WinGetClass("ahk_id " hwnd)!="AutoHotkey")
SendMessage_(hwnd,16,0,0) ;WM_CLOSE:=16
return true
}
Re: AHK_H v2 beta
Most of the missing functions are implemented by AHK and can #include library files.
Re: AHK_H v2 beta
@arcticir
@thqby
Thank you, I find some thread function in HotkeyIt github, i will try it with your version...
@thqby
Thank you, I find some thread function in HotkeyIt github, i will try it with your version...
Re: AHK_H v2 beta
@DuyMinh Did you run the thread lib functions? This is ThreadObj, but I failed to compile with ahk2exe because A_LineFile did not parse correctly.
Code: Select all
;@Ahk2Exe-AddResource %A_LineFile%, THREADOBJ
class ThreadObj {
static Call(script, cmdLine := "", title := "") {
ThreadID := NewThread("#include '" (A_IsCompiled ? "*THREADOBJ" : A_LineFile) "'`nNumPut(`"PTR`",ObjShare({base:ThreadObj.Prototype})," GetVar(pObjShare := 0) ")`nSetEvent(" hEvent := CreateEvent() ")`n" script, cmdLine, title)
WaitForSingleObject(hEvent, 1000), CloseHandle(hEvent)
return pObjShare ? ObjShare(pObjShare) : ""
}
__Get(k, p) => p.Length ? %k%[p*] : %k%
__Set(k, p, v) {
global
return p.Length ? (%k%[p*] := v) : (%k% := v)
}
PostCall(func, p*) => SetTimer(%func%.Bind(p*), -1)
Call(func, p*) => %func%(p*)
__Delete() {
if (A_MainThreadID != A_ThreadID)
SetTimer(ExitApp, -1)
}
FuncPtr(func) {
static FindFunc := DynaCall(GetProcAddress(0, "ahkFindFunc"), "ut==sui", , A_ThreadID)
return FindFunc(func)
}
LabelPtr(label) {
static FindLabel := DynaCall(GetProcAddress(0, "ahkFindLabel"), "ut==sui", , A_ThreadID)
return FindLabel(label)
}
Exec(code) {
static ahkExec := DynaCall(GetProcAddress(0, "ahkExec"), "i==sui", , A_ThreadID)
ahkExec(code)
}
AddScript(script, execute := 0) {
static addScript := DynaCall(GetProcAddress(0, "addScript"), "ut==siui", , , A_ThreadID)
return addScript(script, execute)
}
AddFile(file, execute := 0) {
static addFile := DynaCall(GetProcAddress(0, "addFile"), "ut==siui", , , A_ThreadID)
return addFile(file, execute)
}
}
ObjShare(ObjorLresult) {
static IDispatch := Buffer(16), init := NumPut("int64", 0x20400, "int64", 0x46000000000000c0, IDispatch)
if IsObject(ObjorLresult)
return LresultFromObject(IDispatch.Ptr, 0, ObjPtr(ObjorLresult))
else if ObjectFromLresult(ObjorLresult, IDispatch.Ptr, 0, getvar(com := 0))
throw Error("LResult Object could not be created", -1)
return ComValue(9, com, 1)
}
Re: AHK_H v2 beta
I try but dont success to run cuz many syntax error from hotkeyit lib function. I try to fix, but so diffcult with me...thqby wrote: ↑18 Aug 2021, 07:36@DuyMinh Did you run the thread lib functions? This is ThreadObj, but I failed to compile with ahk2exe because A_LineFile did not parse correctly.Code: Select all
;@Ahk2Exe-AddResource %A_LineFile%, THREADOBJ class ThreadObj { static Call(script, cmdLine := "", title := "") { ThreadID := NewThread("#include '" (A_IsCompiled ? "*THREADOBJ" : A_LineFile) "'`nNumPut(`"PTR`",ObjShare({base:ThreadObj.Prototype})," GetVar(pObjShare := 0) ")`nSetEvent(" hEvent := CreateEvent() ")`n" script, cmdLine, title) WaitForSingleObject(hEvent, 1000), CloseHandle(hEvent) return pObjShare ? ObjShare(pObjShare) : "" } __Get(k, p) => p.Length ? %k%[p*] : %k% __Set(k, p, v) { global return p.Length ? (%k%[p*] := v) : (%k% := v) } PostCall(func, p*) => SetTimer(%func%.Bind(p*), -1) Call(func, p*) => %func%(p*) __Delete() { if (A_MainThreadID != A_ThreadID) SetTimer(ExitApp, -1) } FuncPtr(func) { static FindFunc := DynaCall(GetProcAddress(0, "ahkFindFunc"), "ut==sui", , A_ThreadID) return FindFunc(func) } LabelPtr(label) { static FindLabel := DynaCall(GetProcAddress(0, "ahkFindLabel"), "ut==sui", , A_ThreadID) return FindLabel(label) } Exec(code) { static ahkExec := DynaCall(GetProcAddress(0, "ahkExec"), "i==sui", , A_ThreadID) ahkExec(code) } AddScript(script, execute := 0) { static addScript := DynaCall(GetProcAddress(0, "addScript"), "ut==siui", , , A_ThreadID) return addScript(script, execute) } AddFile(file, execute := 0) { static addFile := DynaCall(GetProcAddress(0, "addFile"), "ut==siui", , , A_ThreadID) return addFile(file, execute) } } ObjShare(ObjorLresult) { static IDispatch := Buffer(16), init := NumPut("int64", 0x20400, "int64", 0x46000000000000c0, IDispatch) if IsObject(ObjorLresult) return LresultFromObject(IDispatch.Ptr, 0, ObjPtr(ObjorLresult)) else if ObjectFromLresult(ObjorLresult, IDispatch.Ptr, 0, getvar(com := 0)) throw Error("LResult Object could not be created", -1) return ComValue(9, com, 1) }
Re: AHK_H v2 beta
@thqby
Can you explain the two new functions MinHookEnable and MinHookDisable, or add some examples? Thanks.
Can you explain the two new functions MinHookEnable and MinHookDisable, or add some examples? Thanks.
Re: AHK_H v2 beta
@crocodile
Code: Select all
MinHookEnable := DynaCall(A_AhkPath '\MinHookEnable', 't==ttt*')
MinHookDisable := DynaCall(A_AhkPath '\MinHookDisable', 'ui==t')
pMessageBox := GetProcAddress(GetModuleHandle('user32'), 'MessageBoxW')
pHook := MinHookEnable(pMessageBox, CallbackCreate(hook_msgbox), &true_messagebox := 0)
MsgBox('hello world', 'ahk')
MinHookDisable(pHook)
MsgBox('hello world', 'ahk')
hook_msgbox(hwnd,text,title,opts) {
DllCall(true_messagebox, 'ptr', 0, 'str', 'hook msgbox`n' StrGet(text), 'str', 'hook msgbox', 'uint', 0)
}