AHK 快餐店[11] 之 虚拟桌面 AutoHotkey 版
2010-10-19 15:52
127 查看
文章标签: AHK / 桌面工具 / 虚拟.
上回我们把键盘折腾个半死,今天我们要折腾的是:桌面。
虚拟桌面有什么用捏?如果你想在上班的时候看小众、煎蛋、玩游戏……又怕 boss 走过来的时候,手忙脚乱地关闭一堆窗口,那么虚拟桌面是必备的啦。
小众介绍过三款虚拟桌面:Yod’m 3D – 3D 虚拟桌面、VirtuaWin – 很酷的虚拟桌面[更新]、VirtuaWin – 很酷的虚拟桌面[更新]。
废话少说。下载虚拟桌面 AHK 版 | 来源。
;虚拟桌面 - Ahk ;Autohotkey的脚本,实现虚拟桌面的功能,快捷键Alt+1,2,3,4 SetBatchLines, -1 ; maximize script speed! SetWinDelay, -1 OnExit, CleanUp ; clean up in case of error (otherwise some windows will get lost) numDesktops := 4 ; maximum number of desktops curDesktop := 1 ; index number of current desktop WinGet, windows1, List ; get list of all currently visible windows ; ***** hotkeys ***** !1::SwitchToDesktop(1) !2::SwitchToDesktop(2) !3::SwitchToDesktop(3) !4::SwitchToDesktop(4) ^!1::SendActiveToDesktop(1) ^!2::SendActiveToDesktop(2) ^!3::SendActiveToDesktop(3) ^!4::SendActiveToDesktop(4) !0::ExitApp ; ***** functions ***** ; switch to the desktop with the given index number SwitchToDesktop(newDesktop) { global if (curDesktop <> newDesktop) { GetCurrentWindows(curDesktop) ;WinGet, windows%curDesktop%, List,,, Program Manager ; get list of all visible windows ShowHideWindows(curDesktop, false) ShowHideWindows(newDesktop, true) curDesktop := newDesktop Send, {ALT DOWN}{TAB}{ALT UP} ; activate the right window } return } ; sends the given window from the current desktop to the given desktop SendToDesktop(windowID, newDesktop) { global RemoveWindowID(curDesktop, windowID) ; add window to destination desktop windows%newDesktop% += 1 i := windows%newDesktop% windows%newDesktop%%i% := windowID WinHide, ahk_id %windowID% Send, {ALT DOWN}{TAB}{ALT UP} ; activate the right window } ; sends the currently active window to the given desktop SendActiveToDesktop(newDesktop) { WinGet, id, ID, A SendToDesktop(id, newDesktop) } ; removes the given window id from the desktop RemoveWindowID(desktopIdx, ID) { global Loop, % windows%desktopIdx% { if (windows%desktopIdx%%A_Index% = ID) { RemoveWindowID_byIndex(desktopIdx, A_Index) Break } } } ; this removes the window id at index from desktop number RemoveWindowID_byIndex(desktopIdx, ID_idx) { global Loop, % windows%desktopIdx% - ID_idx { idx1 := % A_Index + ID_idx - 1 idx2 := % A_Index + ID_idx windows%desktopIdx%%idx1% := windows%desktopIdx%%idx2% } windows%desktopIdx% -= 1 } ; this builds a list of all currently visible windows in stores it in desktop GetCurrentWindows(index) { global WinGet, windows%index%, List,,, Program Manager ; get list of all visible windows ; now remove task bar “window” (is there a simpler way?) Loop, % windows%index% { id := % windows%index%%A_Index% WinGetClass, windowClass, ahk_id %id% if windowClass = Shell_TrayWnd ; remove task bar window id { RemoveWindowID_byIndex(index, A_Index) Break } } } ; if show=true then shows windows of desktop %index%, otherwise hides them ShowHideWindows(index, show) { global Loop, % windows%index% { id := % windows%index%%A_Index% if show WinShow, ahk_id %id% else WinHide, ahk_id %id% } } ; show all windows from all desktops on exit CleanUp: Loop, %numDesktops% ShowHideWindows(A_Index, true) ExitApp
运行,看看下面代码你就知道怎么用了:
!1::SwitchToDesktop(1)
!2::SwitchToDesktop(2)
!3::SwitchToDesktop(3)
!4::SwitchToDesktop(4)
^!1::SendActiveToDesktop(1)
^!2::SendActiveToDesktop(2)
^!3::SendActiveToDesktop(3)
^!4::SendActiveToDesktop(4)
再啰嗦一下使用方法:Alt + 1 切换到第一个桌面。其他类推。Ctrl + Alt + 1 把当前窗口发送到 第一个桌面。另外,如果虚拟桌面不够用的话,再添加:
!5::SwitchToDesktop(5)
如果你的键盘按键够用的话,是可以支持无限多个虚拟桌面的。
相关文章推荐
- AHK 快餐店[11] 之 虚拟桌面 AutoHotkey 版
- Win10系统下虚拟桌面的切换方法全程图解
- 从平板电脑的红火到虚拟桌面的联想
- 虚拟桌面技术的应用
- 虚拟桌面原理及实现
- 快速搭建虚拟桌面测试环境(NetScaler10.1.119.7、StoreFront、XenDesktop7.5)
- 只允许允许一个程序实例,即使是通过虚拟桌面方式连接过来的,也是只允许一个人运行。
- 手动创建安卓关闭虚拟键背景灯桌面快捷方式
- Citrix 的虚拟桌面技术
- 11-4 12 Nginx安装 默认虚拟主机 用户认证 域名重定向
- 企业云桌面-11-准备虚拟机-151-CTXXA01
- 同时虚拟多个3D桌面
- View 5应用之一:虚拟桌面基本体验
- Unix/Linux环境C编程入门教程(11) 开发环境搭建VMWare虚拟安装之虚拟化检测
- Oracle11新特性——虚拟列
- 虚拟桌面技术的初步探讨
- 怎样让USB key(U盾)在xendesktop虚拟桌面使用
- [ahk]AutoHotkey从EXCEL 获取单元格内容
- 虚拟桌面更新,自定义快捷键
- VirtuaWin (虚拟桌面)介绍