AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1457314
Accepted
Krzysztof Bociurko
Krzysztof Bociurko
Asked: 2019-07-09 02:28:37 +0800 CST2019-07-09 02:28:37 +0800 CST 2019-07-09 02:28:37 +0800 CST

使用 Autohotkey 在一个虚拟桌面上的窗口之间切换 - alt+tab 按原样工作

  • 772

我正在寻找一个自动热键功能、系统快捷方式或 dll 调用以在当前虚拟桌面上的所有窗口之间循环。

Windows 10 有此选项(按 Alt+Tab 显示仅对我正在使用的桌面打开的窗口),但这是一个全局设置,会影响正常的 alt+tab 使用。我想将其保留为多桌面交换机。

windows-10 autohotkey
  • 1 1 个回答
  • 310 Views

1 个回答

  • Voted
  1. Best Answer
    user3419297
    2019-07-09T05:52:26+08:002019-07-09T05:52:26+08:00

    尝试这个:

    F1:: WinMenuOnCurrentVirtualDesktop()
    
    WinMenuOnCurrentVirtualDesktop(){
        list := ""
        Menu, windows, Add
        Menu, windows, deleteAll
        WinGet, id, list
        Loop, %id%
        {
            this_ID := id%A_Index%
            WinGetTitle, title, ahk_id %this_ID%
            If (title = "")
                continue            
            If !IsWindow(WinExist("ahk_id" . this_ID))
                continue
            If !IsWindowOnCurrentVirtualDesktop(this_ID)
                continue
            Menu, windows, Add, %title%, ActivateTitle      
            WinGet, Path, ProcessPath, ahk_id %this_ID%
            Try 
                Menu, windows, Icon, %title%, %Path%,, 0
            Catch 
                Menu, windows, Icon, %title%, %A_WinDir%\System32\SHELL32.dll, 3, 0 
        }
        CoordMode, Mouse, Screen
        MouseMove, (0.4*A_ScreenWidth), (0.35*A_ScreenHeight)
        CoordMode, Menu, Screen
        Xm := (0.25*A_ScreenWidth)
        Ym := (0.25*A_ScreenHeight)
        Menu, windows, Show, %Xm%, %Ym%
    }
    
    ActivateTitle:
        SetTitleMatchMode 3
        WinActivate, %A_ThisMenuItem%
    return
    
    ;-----------------------------------------------------------------
    ; Check whether the target window is activation target
    ;-----------------------------------------------------------------
    
    IsWindow(hwnd) {
        WinGet, s, Style, ahk_id %hwnd% 
        return s & 0xC00000 ? (s & 0x100 ? 0 : 1) : 0
    } 
    
    /* 
    IsWindow(hWnd){
        WinGet, dwStyle, Style, ahk_id %hWnd%
        if ((dwStyle&0x08000000) || !(dwStyle&0x10000000)) {
            return false
        }
        WinGet, dwExStyle, ExStyle, ahk_id %hWnd%
        if (dwExStyle & 0x00000080) {
            return false
        }
        WinGetClass, szClass, ahk_id %hWnd%
        if (szClass = "TApplication") {
            return false
        }
        return true
    }
    */
    
    
    ;--------------------------------------------------------------------------------
    ;Indicates whether the provided window is on the currently active virtual desktop.
    ;https://autohotkey.com/boards/viewtopic.php?p=64295#p64295
    ;--------------------------------------------------------------------------------
    IsWindowOnCurrentVirtualDesktop(hWnd) {
        onCurrentDesktop := ""
        CLSID := "{aa509086-5ca9-4c25-8f95-589d3c07b48a}" 
        IID := "{a5cd92ff-29be-454c-8d04-d82879fb3f1b}"
        IVirtualDesktopManager := ComObjCreate(CLSID, IID)  
        Error := DllCall(NumGet(NumGet(IVirtualDesktopManager+0), 3*A_PtrSize), "Ptr", IVirtualDesktopManager, "Ptr", hWnd, "IntP", onCurrentDesktop)
        ObjRelease(IVirtualDesktopManager)  
        if !(Error=0)
            return false, ErrorLevel := true
        return onCurrentDesktop, ErrorLevel := false
    }
    

    编辑:

    也试试

    F1:: WinMenuOnCurrentVirtualDesktop()
    
    WinMenuOnCurrentVirtualDesktop(){
        Menu, Windows, Add
        Menu, Windows, deleteAll
        WinGet, id, list
        Loop %id%
        {
            this_ID := id%A_Index%
            WinGetTitle title, ahk_id %this_ID%
            If (title = "")
                continue
            ; If (title = "this title") ; add exceptions
                ; continue
            If !IsWindow(WinExist("ahk_id" . this_ID))
                continue
            If !IsWindowOnCurrentVirtualDesktop(WinExist("ahk_id" . this_ID))
                continue
            WinGetClass class, ahk_id %this_ID%
            ; If (class = "this class") ; add exceptions
                ; continue
            If (class = "ApplicationFrameWindow") 
            {
                WinGetText, text, ahk_id %this_ID%      
                If (text = "")
                {
                    WinGet, style, style, ahk_id %this_ID%
                    If !(style = "0xB4CF0000")   ; the window isn't minimized
                        continue
                }
            }
            WinGet, Path, ProcessPath, ahk_id %this_ID%
            Menu, Windows, Add, %title%, Activate_Window
            Try 
                Menu, Windows, Icon, %title%, %Path%,, 0
            Catch
                Menu, Windows, Icon, %title%, %A_WinDir%\System32\SHELL32.dll, 3, 0
        }
        CoordMode, Mouse, Screen
        MouseMove, (0.4*A_ScreenWidth), (0.35*A_ScreenHeight)
        CoordMode, Menu, Screen
        Xm := (0.25*A_ScreenWidth)
        Ym := (0.25*A_ScreenHeight)
        Menu, windows, Show, %Xm%, %Ym%
    }
    
    Activate_Window:
        SetTitleMatchMode, 3
        WinGetClass, Class, %A_ThisMenuItem%
        If (Class="Windows.UI.Core.CoreWindow") ; the minimized window has another class 
            WinActivate, %A_ThisMenuItem% ahk_class ApplicationFrameWindow
        else
            WinActivate, %A_ThisMenuItem%
    return
    
    ;-----------------------------------------------------------------
    ; Check whether the target window is activation target
    ;-----------------------------------------------------------------
    
    IsWindow(hwnd) {
        WinGet, s, Style, ahk_id %hwnd% 
        return s & 0xC00000 ? (s & 0x100 ? 0 : 1) : 0
    } 
    
    
    ;--------------------------------------------------------------------------------
    ;Indicates whether the provided window is on the currently active virtual desktop.
    ;https://autohotkey.com/boards/viewtopic.php?p=64295#p64295
    ;--------------------------------------------------------------------------------
    IsWindowOnCurrentVirtualDesktop(hWnd) {
        onCurrentDesktop := ""
        CLSID := "{aa509086-5ca9-4c25-8f95-589d3c07b48a}" 
        IID := "{a5cd92ff-29be-454c-8d04-d82879fb3f1b}"
        IVirtualDesktopManager := ComObjCreate(CLSID, IID)  
        Error := DllCall(NumGet(NumGet(IVirtualDesktopManager+0), 3*A_PtrSize), "Ptr", IVirtualDesktopManager, "Ptr", hWnd, "IntP", onCurrentDesktop)
        ObjRelease(IVirtualDesktopManager)  
        if !(Error=0)
            return false, ErrorLevel := true
        return onCurrentDesktop, ErrorLevel := false
    }
    
    • 1

相关问题

  • VMware Workstation USB 仲裁服务无法自动启动

  • 如何在域和 Linux 活动目录中启用指纹传感器

  • 资源管理器侧面板中的桌面外壳快捷方式

  • 为什么我不能将文件从 Android 发送到 Windows 10?

  • 在多个文件上打开方式?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    Windows 10 服务称为 AarSvc_70f961。它是什么,我该如何禁用它?

    • 2 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Marko Smith

    ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1056)

    • 4 个回答
  • Marko Smith

    我如何知道 Windows 安装在哪个驱动器上?

    • 6 个回答
  • Martin Hope
    Albin 支持结束后如何激活 WindowsXP? 2019-11-18 03:50:17 +0800 CST
  • Martin Hope
    fixer1234 “HTTPS Everywhere”仍然相关吗? 2019-10-27 18:06:25 +0800 CST
  • Martin Hope
    Kagaratsch Windows 10 删除大量小文件的速度非常慢。有什么办法可以加快速度吗? 2019-09-23 06:05:43 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    Inter Sys Ctrl+C 和 Ctrl+V 是如何工作的? 2019-05-15 02:51:21 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve