Comments (17)
OK, I meant to post the issue to https://github.com/phazei/Win11AutoHotKeyFixes. But does this ring a bell?
from vd.ahk.
this is the minimum to reproduce it:
#SingleInstance force
ListLines 0
SendMode "Input"
SetWorkingDir A_ScriptDir
KeyHistory 0
#WinActivateForce
ProcessSetPriority "H"
SetWinDelay -1
SetControlDelay -1
keybd_eventDown("LWin")
keybd_eventDown("LCtrl")
keybd_eventDown("LShift")
WinActivate "ahk_class Progman ahk_exe explorer.exe" ;office 365 bug
;WinActivate "ahk_class WorkerW ahk_exe explorer.exe" ;no bug
;WinActivate "ahk_exe notepad.exe" ;no bug
keybd_eventDown(key)
{
DllCall("keybd_event","UChar",GetKeyVK(key),"UChar",GetKeySC(key),"Uint",0,"Ptr",0)
}
keybd_eventUp(key)
{
DllCall("keybd_event","UChar",GetKeyVK(key),"UChar",GetKeySC(key),"Uint",2,"Ptr",0)
}
f3::Exitapp
the above is v2 code
___
Office
OfficeApp-Frame
WebViewHost.exe
0x16CF0000
0x00000100
___
@christodoulos does this bug only happen when the destination virtual desktop is empty ?
from vd.ahk.
@christodoulos does this bug only happen when the destination virtual desktop is empty ?
After a reboot, when I manually start, say, a Windows explorer in both Virtual Desktop 1 and Virtual Desktop 2, and then start a terminal in Virtual Desktop 1, when I move it using WinCtrlShift-> then the terminal window moves just fine, and nothing else is happening (i.e., the bug does not happen).
Keeping both explorer windows open at Virtual Desktop 1 and Virtual Desktop 2, I can use WinCtrlShift-> and WinCtrlShift<-, and the terminal window keeps moving between the virtual desktops without any Office 365 window popping up. But if I close the Explorer Window before moving the terminal window from Virtual Desktop 2 to Virtual Desktop 1 using WinCtrlShift<-, the Office 365 setup window starts popping up again!
The Windows OS never stops to amaze me with awkward behaviors!
from vd.ahk.
this even happens on Windows 10
Help disabling Office hotkey of Ctrl + Win + Alt + Shift that leads to Office 365 Login Page
this makes me suspect that WinActivate
of AHK sends !{Tab}
KeyEvent(KEYDOWNANDUP, VK_MENU);
KeyEvent(KEYDOWNANDUP, VK_MENU);
VK_MENU | 0x12 | ALT key
That's only ALT, but not ALT+TAB, I'm not even sure if the code execution reaches that line
from vd.ahk.
@christodoulos does this fix it ?
from vd.ahk.
Hello, thanks for your suggestions. I pulled your last repository update:
C:\Users\christodoulos\VD.ahk>git log
commit 3cb24e3ea6c0223bed08c9c335d34b5c658da706 (HEAD -> class_VD, origin/class_VD, origin/HEAD)
Author: FuPeiJiang <[email protected]>
Date: Mon May 15 18:02:42 2023 -0400
_activateDesktopBackground(); #40
and uninstalled the Office 365 application. Using your latest commit, the problem remains with a different nature:
- I boot my laptop and have no windows opened.
- I start a Terminal on Virtual Desktop 1
- By pressing WinCtrlShift->, the Terminal is moved to Virtual Desktop 2, and a Browser Window flashes and disappears.
- Moving to Virtual Desktop 1 using WinCtrl<- I see a Browser Window that I didn't open myself with a new tab opened at https://www.office.com/?from=OfficeKey
- I manually close the browser window and move to Virtual Desktop 2 using WinCtrl->. There I find the Terminal window from step 3, and using WinCtrlShift-> I move it to Virtual Desktop 3. The browser window flashes again and immediately disappears. Moving to Virtual Desktop 1 by pressing two times WinCtrl<-, I find the browser window with two tabs opened at https://www.office.com/?from=OfficeKey
Of course, the new behavior is much more tolerable as I can live with using Virtual Desktops 2 and 3 and letting the browser windows pop up at Virtual Desktop 1.
from vd.ahk.
before I bring in a proper fix, does this work ?
; move window to left and follow it
^#+left::
keybd_eventUp("LShift")
VD.goToDesktopNum(VD.MoveWindowToRelativeDesktopNum("A", -1))
Send % "{LShift down}"
return
; move window to right and follow it
^#+right::
keybd_eventUp("LShift")
VD.goToDesktopNum(VD.MoveWindowToRelativeDesktopNum("A", 1))
Send % "{LShift down}"
return
;functions
keybd_eventUp(key)
{
DllCall("keybd_event","UChar",GetKeyVK(key),"UChar",GetKeySC(key),"Uint",2,"Ptr",0)
}
so in "VD-move-window-with-desktop.ahk", you replace the 2 hotkeys with the above
^#+Left::
n := VD.getCurrentDesktopNum()
if n = 1 ;at begining, can't go left
Return
n -= 1
active := "ahk_id" WinExist("A")
VD.MoveWindowToDesktopNum(active,n), VD.goToDesktopNum(n)
WinActivate active ;once in a while it's not active
Return
^#+Right::
n := VD.getCurrentDesktopNum()
if n = % VD.getCount() ;at end, can't go right
Return
n += 1
active := "ahk_id" WinExist("A")
VD.MoveWindowToDesktopNum(active,n), VD.goToDesktopNum(n)
WinActivate active
Return
from vd.ahk.
which version of AHK are you using ?
MsgBox % Clipboard:=A_AhkVersion
maybe the implementation for WinActivate has changed
from vd.ahk.
Using your script above:
But in Apps > Installed apps:
My D-move-window-with-desktop.ahk
:
;FROM https://superuser.com/questions/1685845/moving-current-window-to-another-desktop-in-windows-11-using-shortcut-keys
;#SETUP START
#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
SetWinDelay -1
SetControlDelay -1
;include the library
#Include ../VD.ahk/VD.ahk
; VD.init() ;COMMENT OUT `static dummyStatic1 := VD.init()` if you don't want to init at start of script
;you should WinHide invisible programs that have a window.
WinHide, % "Microsoft 365 App Host"
;#SETUP END
VD.createUntil(3) ;create until we have at least 3 VD
return
^#+Left::
n := VD.getCurrentDesktopNum()
if n = 1 ;at begining, can't go left
Return
n -= 1
active := "ahk_id" WinExist("A")
VD.MoveWindowToDesktopNum(active,n), VD.goToDesktopNum(n)
WinActivate active ;once in a while it's not active
Return
^#+Right::
n := VD.getCurrentDesktopNum()
if n = % VD.getCount() ;at end, can't go right
Return
n += 1
active := "ahk_id" WinExist("A")
VD.MoveWindowToDesktopNum(active,n), VD.goToDesktopNum(n)
WinActivate active
Return
from vd.ahk.
I don't know if it is relevant but I installed AutoHotkey using scoop:
C:\Users\christodoulos>scoop list
Installed apps:
Name Version Source Updated Info
---- ------- ------ ------- ----
autohotkey 2.0.2 extras 2023-01-02 20:11:29
from vd.ahk.
try this script, I added keybd_eventUp("LShift")
;#SETUP START
#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
SetWinDelay -1
SetControlDelay -1
;include the library
#Include ../VD.ahk/VD.ahk
; VD.init() ;COMMENT OUT `static dummyStatic1 := VD.init()` if you don't want to init at start of script
VD.createUntil(3) ;create until we have at least 3 VD
return
^#+Left::
n := VD.getCurrentDesktopNum()
if n = 1 ;at begining, can't go left
Return
n -= 1
active := "ahk_id" WinExist("A")
keybd_eventUp("LShift")
VD.MoveWindowToDesktopNum(active,n)
VD.goToDesktopNum(n)
WinActivate active ;once in a while it's not active
keybd_eventDown("LShift")
Return
^#+Right::
n := VD.getCurrentDesktopNum()
if n = % VD.getCount() ;at end, can't go right
Return
n += 1
active := "ahk_id" WinExist("A")
keybd_eventUp("LShift")
VD.MoveWindowToDesktopNum(active,n)
VD.goToDesktopNum(n)
WinActivate active
keybd_eventDown("LShift")
Return
;functions
keybd_eventDown(key)
{
DllCall("keybd_event","UChar",GetKeyVK(key),"UChar",GetKeySC(key),"Uint",0,"Ptr",0)
}
keybd_eventUp(key)
{
DllCall("keybd_event","UChar",GetKeyVK(key),"UChar",GetKeySC(key),"Uint",2,"Ptr",0)
}
I'm pretty sure it will work, but it's not the correct way to fix it
, I'll need your help to test/debug a bit more because I can't reproduce the issue anymore
from vd.ahk.
in order to debug, checkout the branch https://github.com/FuPeiJiang/VD.ahk/tree/tooltip-debug, use your unedited D-move-window-with-desktop.ahk
script, not the ones I sent
there are 3 possible ToolTips:
1.
ToolTip % "WinActivate % ""ahk_class WorkerW ahk_exe explorer.exe"""
2.
ToolTip % "WinActivate % ""ahk_class Progman ahk_exe explorer.exe"""
3.
Command Prompt
ConsoleWindowClass
cmd.exe
0x14EF0000
0x000C0110
what ToolTips do you see when pressing the hotkeys ?
you may want desktop switching animations to be enabled for the ToolTip to last longer, but I think animations are enabled by default so it's not a problem
from vd.ahk.
nvm, there Are no VD animations in Win11
great news, I've been able to reproduce the issue again
from vd.ahk.
After receiving the GitHub notification, I rebooted my laptop to start from a clear state. Then I started a Terminal and could happily move it across all my virtual desktops without any other, at least noticeable, unintended behavior! Well, just like that, the bug is not present anymore! I did nothing regarding AutoHotKey or your repository!
To follow your instructions above, I checked out the branch you proposed:
C:\Users\christodoulos\VD.ahk>git branch
class_VD
* origin/tooltip-debug
Using the unedited script, I see no ToolTips of any kind when I press the hotkeys. Do I get it right? I checkout your branch and then move a window around the virtual desktops, and some tooltips should appear? Unfortunately, they don't. Nevertheless, the bug does not happen using the class_VD branch or the tooltip-debug branch.
I realize that bugs don't heal themselves. If you'd like to help you more, please don't hesitate to ask.
from vd.ahk.
I see no ToolTips of any kind when I press the hotkeys.
some tooltips should appear
I suspect that you have 2 VD.ahk folders
delete to recycle bin the files C:\Users\christodoulos\VD.ahk\VD.ahk
and C:\Users\christodoulos\VD.ahk\_VD.ahk
if your script still runs then you have 2 VD.ahk folders
___
I'm not able to change the VD of:
Microsoft Teams
Chrome_WidgetWin_1
Teams.exe
0x14C20000
0x00000100
(using VD.MoveWindowToDesktopNum)
this is a huge bug, it's also linked to the office 365 problem because if the window below active window is Teams.exe, then even if I removed all WinActivate in _VD.ahk and your script, office 365 still pops up
from vd.ahk.
I deleted everything to make sure that I have only one VD.ahk folder. Then I double-clicked on the VD-move-window-with-desktop.ahk
file, and the error message popped up:
Then I checked out the tooltip-debug branch and double-clicked again on the VD-move-window-with-desktop.ahk
file. This time the script ran, and the icon appeared in my taskbar. Then I can move any window around the virtual desktops, and the bug is not present anymore! Like it never happened! Unfortunately, though, I can see no tooltips. Perhaps I am missing something.
Just so you know, when I delete the files you propose (without exiting from the icon in the taskbar), the script continues to run, and I can move windows to other virtual desktops. After exiting from the icon in the taskbar, I cannot start the VD-move-window-with-desktop.ahk
, and I am getting the same error message as above. Restoring from the recycle bin, the script runs again successfully, and everything works again just fine, with no bugs and, unfortunately, no tooltips.
I don't know if it is relevant, but I also run two other AutoHotKey scripts:
For changing input language using Caps Lock:
sel := 0
#if (sel=0)
capslock::
send {lwin down}{Space}
sel := 1
return
#if
capslock up::
send {lwin up}
sel := 0
return
And for hiding the cursor while typing:
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: Stefan Z Camilleri - [email protected]
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Initialize the mouse cursor
SystemCursor("Init")
; Get the current mouse position, and store its coordinates
MouseGetPos mX0, mY0
; Set a timer to check if the mouse is still idle every 250ms
SetTimer, CheckIdle, 250
; Register the keys you want to listen on
keys = ``1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./
; For every defined key, register a call to hide the mouse cursor
Loop Parse, keys
HotKey ~*%A_LoopField%, Hoty
return
; Checks if the mouse has moved, and if so, shows it and records the new position
CheckIdle:
MouseGetPos mX, mY
if (mX0 != mX && mY0 != mY)
{
SystemCursor("On")
mX0 := mX, mY0 := mY
}
return
; Hides the mouse cursor
Hoty:
SystemCursor("Off")
return
; Ensure the cursor is made visible when the script exits.
#Persistent
OnExit, ShowCursor
return
; Shows the mouse cursor
ShowCursor:
SystemCursor("On")
ExitApp
; Function to hide or show the mouse cursor
SystemCursor(OnOff=1) ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
static AndMask, XorMask, $, h_cursor
,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
, b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 ; blank cursors
, h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13 ; handles of default cursors
if (OnOff = "Init" or OnOff = "I" or $ = "") ; init when requested or at first call
{
$ = h ; active default cursors
VarSetCapacity( h_cursor,4444, 1 )
VarSetCapacity( AndMask, 32*4, 0xFF )
VarSetCapacity( XorMask, 32*4, 0 )
system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
StringSplit c, system_cursors, `,
Loop %c0%
{
h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
, "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
}
}
if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
$ = b ; use blank cursors
else
$ = h ; use the saved cursors
Loop %c0%
{
h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
}
}
Unfortunately, I don't have the time to understand the scripts, and I blindly copy them.
from vd.ahk.
more a note to myself:
Loading Microsoft Teams
ahk_class Chrome_WidgetWin_1
ahk_exe Teams.exe
Style:0x1CC00000
ExStyle:0x00000100
moving pView from hwnd of "Loading Microsoft Teams" works, pView from hwnd of "Microsoft Teams" doesn't
from vd.ahk.
Related Issues (20)
- After pinning with AH2 version, I get an error when switching desktops by number.
- Script sending "Q" to discord | Desktop switch failure. HOT 2
- getDesktopNumOfWindow sometimes returns -1 rather than the correct num HOT 4
- Error HOT 10
- open Application directly on one virtual desktop in background HOT 2
- "Error: (0x80004002) No such interface supported" after updating Windows 11 (Beta insider channel) HOT 13
- sending keypress to specified virtual desktop only.
- Ah2: Desktop Looping & Switching + Other Feature Regression from Commit ee2f54f626914273f00853306c1daaf803f756cb HOT 2
- It doesn't work on Windows 11 Build 22621.2215 (22H2) HOT 2
- A problem with the new Windows update 11 HOT 18
- Virtual desktop Tasksbar icons HOT 4
- renaming desktops HOT 1
- Switching to Relative Desktop fails initially HOT 2
- Current desktop count is always zero
- New Windows Build 23606: VD.getCurrentDesktopNum() always returns 0 HOT 4
- Windows Server 2022 version HOT 3
- It doesn't work on Windows 11 Build 22631.3085 (23H2) HOT 13
- v2_port分支没有 TogglePinApp,PinApp,UnPinApp HOT 2
- WinExist in another virtual desktop HOT 7
- Previous Desktop HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vd.ahk.