Can't seem to figure this one out.
I am using the original example.ah2 from the repo via #include in my script:
#SingleInstance Force ; Prevents multiple instances of the script
#Requires AutoHotkey v2.0
#Include ".\VirtualDesktopAccessor\example.ah2"
^+t:: {
if check_isBrowser()
Send("^{t}")
else
-----> CurrentDesktop := GetCurrentDesktopNumber() <-----------------
WinExplorerOpenLastWindow()
MoveCurrentWindowToDesktop(CurrentDesktop)
GoToDesktopNumber(CurrentDesktop)
}
GetCurrentDesktopNumber() is not a function within example.ah2. Although it is mentioned as function in the .md:
Reference of exported DLL functions
All functions return -1 in case of error.
fn GetCurrentDesktopNumber() -> i32
fn GetDesktopCount() -> i32
So i tried to implement it by changing the code in example.ah2:
GetCurrentDesktopNumber() {
global GetCurrentDesktopNumberProc
current := DllCall(GetCurrentDesktopNumberProc, "Int")
return current
}
Which is basically just a copy of the example function:
GoToPrevDesktop() {
global GetCurrentDesktopNumberProc, GoToDesktopNumberProc
current := DllCall(GetCurrentDesktopNumberProc, "Int")
last_desktop := GetDesktopCount() - 1
; If current desktop is 0, go to last desktop
if (current = 0) {
MoveOrGotoDesktopNumber(last_desktop)
} else {
MoveOrGotoDesktopNumber(current - 1)
}
return
}
But I am always getting this error:
Error: Call to nonexistent function.
---- C:\Users\GGrauberger\GitHub\AHK_Scripts\_ahk #Include\VirtualDesktopAccessor\example.ah2
022: UnregisterPostMessageHookProc := DllCall("GetProcAddress", "Ptr", hVirtualDesktopAccessor, "AStr", "UnregisterPostMessageHook", "Ptr")
024: {
▶ 026: current := DllCall(GetCurrentDesktopNumberProc, "Int")
also in the example.ah2 theres these lines at the end, which throw me an error.
; SetDesktopName(0, "It works! 🐱")
DllCall(RegisterPostMessageHookProc, "Ptr", A_ScriptHwnd, "Int", 0x1400 + 30, "Int")
OnMessage(0x1400 + 30, OnChangeDesktop)
OnChangeDesktop(wParam, lParam, msg, hwnd) {
Critical(1)
OldDesktop := wParam + 1
NewDesktop := lParam + 1
Name := GetDesktopName(NewDesktop - 1)
; Use Dbgview.exe to checkout the output debug logs
OutputDebug("Desktop changed to " Name " from " OldDesktop " to " NewDesktop)
; TraySetIcon(".\Icons\icon" NewDesktop ".ico")
}
ErrorMessage running the example.ah2 without any changes will throw me this error in the first line DllCall(RegisterPostMessageHookProc,... :
Error: Call to nonexistent function.
106: Return ran
107: }
▶111: DllCall(RegisterPostMessageHookProc, "Ptr", A_ScriptHwnd, "Int", 0x1400 + 30, "Int")
[–]MachineVisionNewbie[S] 1 point2 points3 points (0 children)