-
Notifications
You must be signed in to change notification settings - Fork 49
support AHK version 2.0 and up #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Here is the docs on changes between v1.1 and v2.0: |
@hklene Where should I put the code if AHK v2 is supported ? |
I only stumbled over this today, so haven't put much thought into it. Therefor without trying this first, I share my thoughts:
Hope this helps ... |
@hklene I don't think there's conditional import in AHK, supporting both would require omitting statements and directives, and probably more But here's the v2 branch: https://github.com/FuPeiJiang/VD.ahk/tree/v2_port |
Hi. The https://github.com/FuPeiJiang/VD.ahk/blob/v2_port/README.md doesn't explain how to use it. I figured out the include, so in my script I try: ` numpad1::VD.goToDesktopNum(1) But loading that gives an error from line #1 in vd.ah2: Has anyone got this port working? Any help appreciated. |
@boardtc I think you will only get this error when you have v1 installed and you are trying to run this v2 script, you should add |
Are you able to run |
Thanks, @FuPeiJiang. I have ahk & ah2 installed in C:\Program Files\AutoHotkey and C:\Program Files\AutoHotkey\v2 retrospectively.
If I double-click VD examples.ah2 it opens a modal win titled: I can then press numpad2, and this modal moves to the second virtual. I guess that's what you mean by my running! I tried moving #Requires AutoHotkey v2.0 to the first line and adding `;#SETUP START ProcessSetPriority "H" SetWinDelay -1 ;include the library ;#SETUP END` This is the only include I use. At the bottom of my file, I use: ` ` I now get the message: Error: Hotkeys/hotstrings are not allowed inside functions or classes. Can the readme provide a simple example of the minimum to add to one's ah2 file to move windows with a shortcut? |
@boardtc if
;#SETUP START
#SingleInstance force
ListLines 0
SendMode "Input"
SetWorkingDir A_ScriptDir
KeyHistory 0
#WinActivateForce
ProcessSetPriority "H"
SetWinDelay -1
SetControlDelay -1
;include the library
#Include %A_LineFile%\..\VD.ah2
;#SETUP END
numpad1::VD.goToDesktopNum(1)
numpad2::VD.goToDesktopNum(2)
numpad3::VD.goToDesktopNum(3) note the: I don't think it's the autohotkey interpreter version, since |
@FuPeiJiang, thanks for that and for finding my error with the slash; my bad. That's working now. I am using: #Requires AutoHotkey v2.0
;#SETUP START
#SingleInstance force
ListLines 0
SendMode "Input"
SetWorkingDir A_ScriptDir
KeyHistory 0
#WinActivateForce
ProcessSetPriority "H"
SetWinDelay -1
SetControlDelay -1
;include the library
#Include %A_LineFile%\..\VD.ah2
;#SETUP END
VD.createUntil(3) ;create until we have at least 3 VD
return
;#useful stuff
numpad1::VD.goToDesktopNum(1)
numpad2::VD.goToDesktopNum(2)
numpad3::VD.goToDesktopNum(3)
;follow your window
numpad4::VD.MoveWindowToDesktopNum("A",1).follow()
numpad5::VD.MoveWindowToDesktopNum("A",2).follow()
numpad6::VD.MoveWindowToDesktopNum("A",3).follow()
;just move window
numpad7::VD.MoveWindowToDesktopNum("A",1)
numpad8::VD.MoveWindowToDesktopNum("A",2)
numpad9::VD.MoveWindowToDesktopNum("A",3)
; wrapping / cycle back to first desktop when at the last
^+#left::VD.goToRelativeDesktopNum(-1)
^+#right::VD.goToRelativeDesktopNum(+1)
; move window to left and follow it
#!left::VD.MoveWindowToRelativeDesktopNum("A", -1).follow()
; move window to right and follow it
#!right::VD.MoveWindowToRelativeDesktopNum("A", 1).follow()
;getters and stuff
f1::Msgbox VD.getCurrentDesktopNum()
f2::Msgbox VD.getCount()
f3::Exitapp |
AI summary of above I found useful: Desktop Management:
Window Management:
Getters:
Exit:
|
Note that numpad5 gives the error: Error: Target window not found. Specifically: ahk_id 266236
▶ 556: WinActivate("ahk_id " this.hwnd) |
@boardtc I've made "Target window not found" fail silently, this happened for me when the VD failed to switch |
Thanks for your help again. I'll test again if possible. Right now, even though I've restarted my script a bunch of times, hitting the numpad keys types the number rather than moving the window 😭 I can't see what's changed (numlock is on), not the script anyway, which shows last changed 90 minutes ago., |
I have no idea what changed, but the above script (#77 (comment)) is no longer working. Numpad leys are no longer intercepted, and I've run out of debugging ideas... |
@boardtc does F1::MsgBox 1
Numpad1::MsgBox 11 If not, then check if your Antivirus (if any), is silently blocking autohotkey If anything works, then add stuff or remove stuff from it until you get what you want |
I updated to recent version 2.0.18 of AHK
https://www.autohotkey.com/download/
and cannot load your VD-Lib anymore:
The text was updated successfully, but these errors were encountered: