I don't know much about Class, so I hope it's not too much of a problem
Test in AutoHotkey v2 2.0-beta.1
Copy the DLL to your script directory or set dllPath
Test in this dll ahkdll-v1-release-master\x64w\AutoHotkey.dll
Thanks to HotKeyIt for their help! viewtopic.php?f=67&t=95612#p425193
Supports up to 10 params
Code: Select all
; Test in AutoHotkey v2 2.0-beta.1
; Copy the DLL to your script directory or set dllPath
; Test in this dll ahkdll-v1-release-master\x64w\AutoHotkey.dll
; Need V1 AutoHotkey.dll https://hotkeyit.github.io/v1/
; Download dll https://github.com/HotKeyIt/ahkdll-v1-release/archive/master.zip
; Sample need copy func and save in D:\OSDTIP.ahk https://www.autohotkey.com/boards/viewtopic.php?f=6&t=76881
; Thanks to HotKeyIt for their help! https://www.autohotkey.com/boards/viewtopic.php?f=67&t=95612#p425193
; Supports up to 10 params
; Persistent
; test := IncludeLib("D:\OSDTIP.ahk") ;(v1 libs path, AutoHotkey.dll path)
; test.do("OSDTIP_Pop","Notification","Message", "-2000")
; Sleep(2000)
; test.do("OSDTIP_Pop","Notification","Message", "0", "C11 zh7 w160 CW101010 CTD3D3D3 U1 U2",,,"0x00FFFF", "0x808080", "30")
; Sleep(2000)
; test.do("OSDTIP_KBLeds","CapsLock", "", "-2000")
; Sleep(2000)
; test.do("OSDTIP_Volume","+1", "", "-2000")
; Sleep(2000)
; test.do("OSDTIP_Desktop",A_UserName,A_Hour ":" A_Min ":" A_Sec ,"-2000") ;Variables dont need ""
; Sleep(2000)
; test.do("OSDTIP_Alert","MainText","SubText")
; Sleep(2000)
; test := ""
; ExitApp
Class IncludeLib
{
__New(libPath, dllPath := "")
{
if !FileExist(dllPath := dllPath ? dllPath : A_ScriptDir "\AutoHotkey.dll")
MsgBox("Miss AutoHotkey.dll file"), ExitApp()
This.hDll := DllCall("LoadLibrary", "Str", dllPath, "Ptr")
DllCall("AutoHotkey.dll\ahktextdll", "Str", "#Persistent `n#NoTrayIcon `n#include " libPath, "Str", "", "Str", "")
This.hahkFunction := DllCall("GetProcAddress", "Ptr", This.hDll, "AStr", "ahkFunction", "PTR")
}
__Delete()
{
DllCall("AutoHotkey.dll\ahkExec", "Str", "ExitApp", "CDecl")
DllCall("FreeLibrary", "Ptr", This.hDll)
}
do(FuncNmae, v*)
{
p := []
Loop 10
p.Push(v.Has(A_Index) ? v[A_Index] : "")
ahkFunction := DllCall.Bind(this.hahkFunction, "Str", , "Str", p[1], "Str", p[2], "Str", p[3], "Str", p[4], "Str", p[5], "Str", p[6], "Str", p[7], "Str", p[8], "Str", p[9], "Str", p[10], "CDecl Str")
return ahkFunction(FuncNmae)
}
}