FuPeiJiang / VD.ahk

Windows Virtual Desktop, AutoHotkey, Windows 11 support, Windows Server 2022, switch desktop, move window(wintitle) to current desktop; createDesktop, PinWindow, getCount, getDesktopNumOfWindow -> mute all windows in Virtual Desktop
MIT License
319 stars 45 forks source link

5月24号新改的代码在桌面下没有任何应用的情况下切换很慢 #41

Closed huo-feng-ding closed 1 year ago

huo-feng-ding commented 1 year ago

我是win10 X64的系统,更新v2_port分支成最新代码后,在切换桌面的时候,如果某个桌面下没有任何应用窗口,那么在切的时候,会等好几秒才能切过去

FuPeiJiang commented 1 year ago

@huo-feng-ding updated

huo-feng-ding commented 1 year ago

代码里有个 Send "q" 这个是否可以去掉,在有个应用下边切换的时候因为这个没切过去

huo-feng-ding commented 1 year ago

我试了 去了 send “q”, 但是在TIM.exe,xyplorer.exe等一些应用下边还是切换不了桌面

FuPeiJiang commented 1 year ago

change Sleep 10 to Sleep 100, does it fix it ?

Send "q" can be replaced by any letter, it is needed to set keyboard focus to hWnd

FuPeiJiang commented 1 year ago

actually, change the whole function so there are 2 Sleep:

  static _WinActivate_CreateRemoteThread(hWnd) {
    foregroundWindow := DllCall("GetForegroundWindow", "Ptr")
    threadID := DllCall("GetWindowThreadProcessId", "Ptr", foregroundWindow, "Uint*", &PID := 0)
    currentThreadID := DllCall("GetCurrentThreadId")
    if (threadID != currentThreadID) {
      hThread := DllCall("OpenThread", "Uint", 0x0002, "Int", 0, "Uint", threadID)
      DllCall("SuspendThread", "Ptr", hThread)
      hProcess := DllCall("OpenProcess", "Uint", 0x0002, "Int", 0, "Uint", PID, "Ptr")
      user32 := DllCall("GetModuleHandleA", "AStr", "user32", "Ptr")
      SetForegroundWindow := DllCall("GetProcAddress", "Ptr", user32, "AStr", "SetForegroundWindow", "Ptr")
      DllCall("CreateRemoteThread", "Ptr", hProcess, "Ptr", 0, "Ptr", 0, "Ptr", SetForegroundWindow, "Ptr", hWnd, "Uint", 0, "Ptr", 0)
      Sleep 100
      Send "q"
      Sleep 100
      DllCall("ResumeThread", "Ptr", hThread)
      DllCall("CloseHandle", "Ptr", hThread)
      DllCall("CloseHandle", "Ptr", hProcess)
    }
  }
huo-feng-ding commented 1 year ago

换上了边的代码也不行,TIM.exe在窗口激活的情况下,去切换不起作用,切不过去

FuPeiJiang commented 1 year ago

我用xyplorer.exe切换不了, 可以不用下载TIM.exe了, 谢谢bug report

XYplorer Trial Version ThunderRT6FormDC XYplorer.exe 0x16C00080 0x00000109

XYplorer ThunderRT6FormDC XYplorer.exe 0x06CF0000 0x00040100

XYplorer ThunderRT6Main XYplorer.exe 0x94090000 0x00000080

___

This PC - XYplorer ### 30-Day Trial Version - Day 1 ### - 24.40.0100 ThunderRT6FormDC XYplorer.exe 0x16CF0000 0x00040100

XYplorer ThunderRT6Main XYplorer.exe 0x94090000 0x00000080

huo-feng-ding commented 1 year ago

借助SetForeGroundWindow.exe切换桌面没有问题了,谢谢