-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from ruchuby/develop
Starter v0.5.3
- Loading branch information
Showing
10 changed files
with
285 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
title: searchText | ||
author: ruchuby | ||
order: 1 | ||
date: 2023-04-15 | ||
--- | ||
|
||
## 定义 | ||
|
||
```ahk | ||
static searchText { | ||
get => SearchGui.gui.Hwnd | ||
} | ||
``` | ||
|
||
## 类型 | ||
|
||
动态属性 \{Int\} | ||
|
||
## 说明 | ||
|
||
**获取**搜索界面hwnd。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
title: 窗口切换 | ||
author: ruchuby | ||
date: 2023-05-12 | ||
--- | ||
|
||
## 介绍 | ||
|
||
窗口切换功能,模仿Switcheroo | ||
|
||
显示当前窗口列表,输入内容对列表进行检索,支持拼音首字母。 | ||
|
||
![窗口切换:无输入内容](./images/window-switcher-1.jpg) | ||
|
||
![窗口切换:有输入内容](./images/window-switcher-2.jpg) | ||
|
||
|
||
## 使用方式 | ||
|
||
插件入口在启动模式中,其他关键词为`["CKQH"]`。 | ||
|
||
启动该插件启动项,进入窗口切换插件。 | ||
|
||
当未输入任何内容时,在搜索结果中可以看到当前所有窗口的标题列表,即介绍中的第一张图片。 | ||
|
||
输入任意文本,即可对窗口标题进行检索,**支持拼音首字母**。 | ||
|
||
最后,启动某列表项即可完成切换到指定窗口。 | ||
|
||
## 进阶技巧 | ||
|
||
添加对应的[关键词快捷键](https://ruchuby.github.io/Starter/guide/setting/#控制),可以通过快捷键**快速启动插件**。 | ||
|
||
![窗口切换:关键词快捷键](./images/window-switcher-3.jpg) | ||
|
||
参考设置如上图,可以通过按下`Alt` + `CapsLK`快捷键来启动该插件。 | ||
|
||
:::tip | ||
如果需要用来代替`Alt` + `Tab`功能,请将**按键类型**设置为**自定义**,**按键内容**设置为`!Tab` | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
/** | ||
* @Name: 窗口切换 | ||
* @Version: 0.0.1 | ||
* @Author: ruchuby | ||
* @LastEditors: ruchuby | ||
* @LastEditTime: 2023-05-12 | ||
* @Description: 窗口切换,支持使用拼音首字母检索窗口标题进行切换,类似Switcheroo | ||
*/ | ||
|
||
/* | ||
===Starter Plugin Info==> | ||
{ | ||
"author": "ruchuby", | ||
"version": "0.0.1", | ||
"introduction": "窗口切换,支持使用拼音首字母检索窗口标题进行切换,类似Switcheroo", | ||
"icon": "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAA81JREFUWEftll9oW3UUx7/nd9NMKqZTVtT1bjrSrXeNw4cW0iGjLY048GUKLXN/UF+UbdJ2Ix2ID8sQlC3q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SUXxeO1UoJ2n+rhoQ4gTe1R9rP1AoINf/mr/rLRAOzX0VO8lln1I+f3e1KRABs89JUA7NJUBu1mM7+4qN/+uYrHph32NkurMXkOLSKI+444m+HePFRWXUBS+l95K0mJj/Af4E/+8XBQoX0rkAAAAASUVORK5CYII=" | ||
} | ||
<==Starter Plugin Info=== | ||
*/ | ||
|
||
|
||
#Include ..\Utils\PluginHelper.ah2 | ||
PluginHelper.addEntryFunc((*) => Plugin_窗口切换.main()) ; 添加入口函数等待执行 | ||
|
||
#DllLoad "dwmapi" ; 预先加载dwmapi.dll | ||
|
||
class Plugin_窗口切换 { | ||
|
||
static main() { | ||
SplitPath(A_LineFile, &name) ; 获取插件id即文件名 | ||
this.name := name | ||
this.hwnd := PluginHelper.searchGuiHwnd | ||
|
||
this.addToStartupMode() | ||
} | ||
|
||
; 获取所有窗口列表(结果和Alt+Tab一致) | ||
static getAllAltWinList() ; v0.21 by SKAN for ah2 on D51K/D51O @ autohotkey.com/r?t=99157 | ||
{ | ||
Static S_OK := 0 ; 非0时表示DwmGetWindowAttribute函数错误 | ||
|
||
Local List := [] | ||
, Style := 0 | ||
, ExStyle := 0 | ||
, hwnd := 0 | ||
|
||
For , hwnd in WinGetList() | ||
If IsVisible(hwnd) | ||
&& StyledRight(hwnd) | ||
&& IsAltTabWindow(hwnd) | ||
List.Push(hwnd) | ||
|
||
Return List | ||
|
||
IsVisible(hwnd, Cloaked := 0) | ||
{ | ||
If S_OK = 0 | ||
S_OK := DllCall("dwmapi\DwmGetWindowAttribute", "ptr", hwnd | ||
, "int", 14 ; DWMWA_CLOAKED | ||
, "uintp", &Cloaked | ||
, "int", 4 ; sizeof uint | ||
) | ||
|
||
Style := WinGetStyle(hwnd) | ||
Return (Style & 0x10000000) && !Cloaked ; WS_VISIBLE | ||
} | ||
|
||
|
||
StyledRight(hwnd) | ||
{ | ||
ExStyle := WinGetExStyle(hwnd) | ||
|
||
Return (ExStyle & 0x8000000) ? False ; WS_EX_NOACTIVATE | ||
: (ExStyle & 0x40000) ? True ; WS_EX_APPWINDOW | ||
: (ExStyle & 0x80) ? False ; WS_EX_TOOLWINDOW | ||
: True | ||
} | ||
|
||
|
||
IsAltTabWindow(Hwnd) | ||
{ | ||
|
||
ExStyle := WinGetExStyle(hwnd) | ||
If (ExStyle & 0x40000) ; WS_EX_APPWINDOW | ||
Return True | ||
|
||
While hwnd := DllCall("GetParent", "ptr", hwnd, "ptr") | ||
{ | ||
If IsVisible(Hwnd) | ||
Return False | ||
|
||
ExStyle := WinGetExStyle(hwnd) | ||
|
||
If (ExStyle & 0x80) ; WS_EX_TOOLWINDOW | ||
&& !(ExStyle & 0x40000) ; WS_EX_APPWINDOW | ||
Return False | ||
} | ||
|
||
Return !Hwnd | ||
} | ||
} | ||
|
||
; 获取匹配搜索的窗口信息列表 | ||
static getWinList(searchText) { | ||
o := A_DetectHiddenWindows | ||
DetectHiddenWindows(false) | ||
|
||
out := [] | ||
idList := this.getAllAltWinList() | ||
for id in idList { | ||
; 窗口不存在则跳过 | ||
if (!WinExist("ahk_id " id)) | ||
continue | ||
|
||
title := WinGetTitle() | ||
if ( | ||
id == this.hwnd || ; 是主程序窗口则跳过 | ||
; 带有搜索内容 且 标题或转拼音首字母后 都不包含搜索文本则跳过 | ||
searchText && | ||
!( | ||
InStr(title, searchText) || | ||
Instr(PluginHelper.Utils.chineseFirstChar(title), searchText) ; 标题中文 | ||
) | ||
) | ||
continue | ||
|
||
; 获取hIcon | ||
if !(hIcon := SendMessage(0x7F, 0, 0)) | ||
if !(hIcon := SendMessage(0x7F, 1, 0)) | ||
if (!(hIcon := SendMessage(0x7F, 2, 0))) | ||
if (!(hIcon := DllCall("GetClassLongPtr", "Ptr", id, "Int", -14, "Ptr"))) | ||
if (!(hIcon := DllCall("GetClassLongPtr", "Ptr", id, "Int", -34, "Ptr"))) | ||
hIcon := DllCall("LoadIcon", "uint", 0, "uint", 32512) ; 使用默认图标 | ||
|
||
; 添加到输出列表 | ||
out.push({ hwnd: id, title: title, hIcon: hIcon }) | ||
} | ||
|
||
DetectHiddenWindows(o) | ||
|
||
if (out.Length >= 2) { | ||
; 交换1,2元素位置 | ||
tmp := out[1] | ||
out[1] := out[2] | ||
out[2] := tmp | ||
} | ||
return out | ||
} | ||
|
||
static addToStartupMode() { | ||
searchHandler(that, searchText) { | ||
that.pluginSearchResult := this.getWinList(searchText) | ||
|
||
; 定义了loadImgsHandler,重载当前图像列表 | ||
that.reloadLVIL(true) | ||
|
||
; 重新加载列表 | ||
that.listView.Opt("-Redraw") ;禁用重绘 | ||
|
||
; that.listView.Delete() ; reloadLVIL中已经删除了 | ||
for item in that.pluginSearchResult | ||
that.listView.Add("icon" that.imgPathToImgListIndex[item.hwnd], " " item.title) | ||
|
||
that.resizeGui() ;根据搜索结果数量调整gui尺寸 并启用重绘 | ||
} | ||
|
||
runHandler(that, rowNum) { | ||
; 激活对应窗口然后隐藏搜索框 | ||
hwnd := that.pluginSearchResult[rowNum].hwnd | ||
try WinActivate("ahk_id " hwnd) | ||
catch { | ||
; 激活失败则重载搜索结果 | ||
searchHandler(that, PluginHelper.searchText) | ||
return | ||
} | ||
PluginHelper.hideSearchGui() | ||
} | ||
|
||
loadImgsHandler(that) { | ||
static defaultHIcon := DllCall("LoadIcon", "uint", 0, "uint", 32512) ; 默认图标 | ||
|
||
that.imgPathToImgListIndex["default"] := IL_Add(that.imgListID, "hIcon:*" defaultHIcon) | ||
for item in that.pluginSearchResult { | ||
; hwnd作为路径 | ||
index := IL_Add(that.imgListID, "hIcon:*" item.hIcon) | ||
; 加载失败则使用默认图标 | ||
that.imgPathToImgListIndex[item.hwnd] := index ? index : that.imgPathToImgListIndex["default"] | ||
} | ||
} | ||
|
||
PluginHelper.addPluginToStartupMode( | ||
this.name, | ||
"窗口切换", | ||
["CKQH"], | ||
(*) => PluginHelper.showPluginMode( | ||
[], | ||
searchHandler, | ||
runHandler, { | ||
loadImgsHandler: loadImgsHandler, | ||
thumb: PluginHelper.getPluginHIcon(this.name) | ||
} | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters