-
Notifications
You must be signed in to change notification settings - Fork 48
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
Error #48
Comments
You need to check that |
copy
what is your windows version ? what is the value of MsgBox % Clipboard:=A_OSVersion
what is the code for LButton::
??? |
I moved SetForeGroundWindow.exe to where VD.ahk is, same issue. I'm actually using _VD.ahk, but I renamed it as VD.ahk, could that be a problem? My version is 10.0.22621. As for LButton, there is no code for it. It's just when you click on an application, it activates that window. So I was thinking once I activated it, I can just go to another virtual desktop, and middle click on the desktop to bring that previously activated window to the new virtual desktop. Thanks for trying to help. |
VD.ahk does exist in C:\Ahk\Library, and the scripts I have included previously have been working just fine. So I doubt that was the problem. But just in case, below is how I included my scripts:
|
then you need to add 1 line: VD.init() so it becomes (please don't rename it, keep it as _VD.ahk): #Include %A_LineFile%\..\..\_VD.ahk
VD.init()
foundProcesses := ""
; Make sure to get all windows from all virtual desktops
DetectHiddenWindows On
WinGet, id, List
Loop %id%
{
hwnd := id%A_Index%
;VD.getDesktopNumOfWindow will filter out invalid windows
desktopNum_ := VD.getDesktopNumOfWindow("ahk_id" hwnd)
If (desktopNum_ > -1) ;-1 for invalid window, 0 for "Show on all desktops", 1 for Desktop 1
{
WinGet, exe, ProcessName, % "ahk_id" hwnd
foundProcesses .= desktopNum_ " " exe "`n"
}
}
MsgBox % foundProcesses if you #Include |
Thank you so much, this fixed it! |
VD.MoveWindowToCurrentDesktop("A") when you go to another virtual desktop, the active window changes to a window on the VD you go to, (the active windows is literally what you are seeing in front of you), so this will bring the current active window to the current desktop, doing nothing so you will have to save the last active window in another VD somehow, (save the hwnd of that window) VD.MoveWindowToCurrentDesktop("ahk_id " savedHwnd) @TaroDumpling
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance force
ListLines Off
SetBatchLines -1
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#KeyHistory 0
#WinActivateForce
Process, Priority,, H
#Include %A_LineFile%\..\..\VD.ahk
SetWinDelay -1
SetControlDelay -1
DllCall("RegisterShellHookWindow","Ptr",A_ScriptHwnd)
OnMessage(DllCall("RegisterWindowMessage",Str,"SHELLHOOK"), "ShellMessage")
VD.RegisterDesktopNotifications()
VD.CurrentVirtualDesktopChanged:=Func("CurrentVirtualDesktopChanged")
CurrentVirtualDesktopChanged(desktopNum_Old, desktopNum_New) {
global other_VD_hwnd, current_VD_Hwnd
other_VD_hwnd:=current_VD_Hwnd
current_VD_Hwnd:=false
}
current_VD_Hwnd:=WinExist("A")
#If MouseIsOver("ahk_class Progman ahk_exe explorer.exe")
MButton::
if (other_VD_hwnd) {
VD.MoveWindowToCurrentDesktop("ahk_id " other_VD_hwnd)
}
return
#If
MouseIsOver(WinTitle) {
MouseGetPos,,, Win
return WinExist(WinTitle) == Win
}
Return
ShellMessage(wParam,lParam) {
global current_VD_Hwnd
switch wParam {
case 2, 4, 32772:
; WinGetTitle, title, ahk_id %lParam%
; ToolTip WinActivated`n%Title%
if (lParam) {
current_VD_Hwnd:=lParam
}
; default:
; ToolTip % wParam
}
}
f3::Exitapp |
I figured out an easier and more practical solution. I want to do the same thing using hotkey 1 through 9. Are there ways to make my code shorter instead of write the code for hotkey 1, hotkey 2, hotkey 3, and so forth? I wanted to not send numbers when I'm long pressing, one downside of my code is that I'm able to notice latency with typing numbers. Thanks!
|
I can think of 2 ways: *1::
*2::
*3::
*4::
*5::
*6::
*7::
*8::
*9::
numeric:=SubStr(A_ThisHotkey,2,1)
KeyWait % numeric, T0.5
If ErrorLevel = 1
{
Soundbeep, 1500
VD.MoveWindowToDesktopNum("A", numeric)
KeyWait % numeric
}
Else Send % numeric
Return *1::foo("1")
*2::foo("2")
*3::foo("3")
*4::foo("4")
*5::foo("5")
*6::foo("6")
*7::foo("7")
*8::foo("8")
*9::foo("9")
foo(numeric) {
KeyWait % numeric, T0.5
If ErrorLevel = 1
{
Soundbeep, 1500
VD.MoveWindowToDesktopNum("A", numeric)
KeyWait % numeric
}
Else Send % numeric
}
numbers are sent on KeyUp, instead of the default: on KeyDown if any other key is pressed while a number is down(like when typing), you might want to send the number immediately, but I don't immediately know how to code that |
I really appreciate the advice, thank you so much! |
I'm using _VD.ahk. My goal is to create a code when I activate a window with mouse left click, I can just go to the virtual desktop I desire, and mouse middle click on desktop, then it will bring the previously activated window to this new virtual desktop. But I'm not sure what went wrong, nothing happens when I middle-click on a different virtual desktop.
I tried the following code to see if other function works, but I got an error message.
When I run the folloinwg code, it returns empty message box.
The text was updated successfully, but these errors were encountered: