【AHK】通过唤醒窗口快捷菜单调节窗口位置/打开窗口控制菜单的其他方法

需求:触控板使用AHK传统控制窗口位置和大小的方式不方便,故打算通过快捷方式唤醒窗口移动图标的方式来调节。但本人有使用utools的习惯,alt+space打开快捷方式菜单/窗口控制菜单会冲突,所以一直尝试新的打开该菜单的方式------先点击alt键,再shift+space打开。

此前想通过postmessage的方式打开,但或许没有或许不在技术范围,实现起来较困难就没有尝试了。

通过alt+shift+space键打开菜单,网上搜索出常规方法是alt+space,一度百思不得其解。

vbnet 复制代码
#z::
Send !+{space} 
WinWait , ahk_class #32768 ,, 1 ; Waits 1s for menu to exist
If !ErrorLevel ; ErrorLevel is 0 if menu exists
    Send {down}{enter}
return

其他方法

其他相似的实现方法,类似linux乌班图中F7调节窗口。

效果: 根据指针当前的位置调整至当前窗口的大小

vbnet 复制代码
#+z::
CoordMode Mouse, screen
id := WinExist("A")
WinGetPos x, y, width, height, ahk_id %id%
MouseGetPos mx, my
neww := width  + x - mx
newh := height + y - my
WinMove % "ahk_id" id,, mx, my, neww, newh
return

效果: 根据当前屏幕居中窗口,可用于解决窗口显示飘出桌面外的窗体程序

vbnet 复制代码
^+#z:: ;居中窗口
WinGetActiveTitle, var_title
CenterWindow(var_title)
return

CenterWindow(WinTitle)
{
    WinGetPos,,, Width, Height, %WinTitle%
    WinMove, %WinTitle%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
}
相关推荐
liuyukuan2 个月前
[AHK V2]SQLite测试用例
数据库·sqlite·ahk·autohotkey
liuyukuan3 个月前
[AHK V2]鼠标悬停展开窗口,鼠标离开折叠窗口
ahk·autohotkey·v2
liuyukuan6 个月前
【AHK v2】数据结构LinkedList实现示例
数据结构·ahk·autohotkey·v2
liuyukuan9 个月前
[AHK]一键调用office365的“放置在单元格中”功能
ahk
LAM LAB10 个月前
【AHK】自用模板新电脑快捷键自用习惯配置
ahk