调整大小 – AutoHotKey – 调整Windows大小
发布时间:2021-01-24 22:08:35 所属栏目:系统 来源:网络整理
导读:我目前有一个HTPC连接到我客厅的等离子,我有一些图像保留问题.在长时间浏览网页等时,我会遇到这个问题.但是,看起来使用AutoHotKey设置脚本以在计时器上自动调整窗口大小应该相对容易.任何人都可以帮我开始编写脚本来完成这项任务吗? (也对任何其他想法开放)
|
我目前有一个HTPC连接到我客厅的等离子,我有一些图像保留问题.在长时间浏览网页等时,我会遇到这个问题.但是,看起来使用AutoHotKey设置脚本以在计时器上自动调整窗口大小应该相对容易.任何人都可以帮我开始编写脚本来完成这项任务吗? (也对任何其他想法开放) 谢谢! 解决方法很久以前我创建了一个脚本“标准化”窗口,即调整大小,移动,并执行其他操作以使窗口确认我的个人偏好.每当窗口第一次显示时,它就会被标准化.如果它已关闭并重新打开,则会再次标准化. 下面是脚本的功能版本,应该满足原始问题的要求. 我使用的版本要复杂得多,因为它有更多功能,例如它支持多个监视器并调整窗口大小,同时考虑Windows任务栏的高度.我使用脚本使打开/保存对话框更大(默认情况下它们太小).我还用它来自动登录某些网站和应用程序. ; This script "normalizes" windows,i.e. resizes,moves,and performs other
; actions to make a window confirm to my personal preference.
SetTitleMatchMode,2
; Go into an infinite loop
loop
{
; Pause so other apps can execute. 250 milliseconds seems to work well.
Sleep,250
; If hotkeys are suspended for this script,then suspend all functionality
if A_IsSuspended
continue
; We will build a unique window name using the window title and window handle.
; Store each unique name in an array.
WinGet,HWND,ID,A
WinGetTitle,WindowTitle,A
WinGetClass,WindowClass,A
; Remember the previous window we processed
WindowTitleCleanPrevious := WindowTitleClean
; Only normalize windows that we haven't seen before.
; If we haven't already normalized the window,we do
; the normalize,then set a flag so we don't normalize the same window again.
; Strip out all chars that may be invalid in an AHK variable name.
WindowTitleCleanTemp := StringRemoveAllNonAlphaNum(WindowTitle)
; Variable names can be at most 254 chars,so truncate to less than that.
StringLeft,WindowTitleClean,WindowTitleCleanTemp,230
; Process the window if:
; (1) It wasn't previously processed (i.e. not in our window-name list named WinList)
; (2) And we aren't sitting on the same window during each loop.
if (WinList%HWND%%WindowTitleClean% != 1 and WindowTitleClean != WindowTitleCleanPrevious)
{
; Get the window's position and size
WinGetPos,WinX,WinY,WinWidth,WinHeight,A
; Is this an MS Word window?
if (WindowClass == "OpusApp")
{
; Center the window and resize so it is 80% of the monitor width and 90% of height.
WinMove,A,(A_ScreenWidth/2)-(WinWidth/2),(A_ScreenHeight/2)-(WinHeight/2),A_ScreenWidth * .8,A_ScreenHeight * .9
}
; Is this the Calculator window?
else if (WindowClass == "SciCalc")
{
; Center the window
WinMove,(A_ScreenHeight/2)-(WinHeight/2)
}
; Set a flag indicating this window has been processed so it is
; not processed again.
WinList%HWND%%WindowTitleClean% = 1
}
}
; --- Win+F5 will Reload this script ---
~#F5::Reload
; --- Win+Escape will Pause this script ---
~#Escape::Suspend,Toggle
; --- Win+Alt+Escape will Exit this script ---
; Close this script
~#!Escape::ExitApp
; ===========================================================================
; Removes all non-alphabetic and non-numeric characters from the given
; string. The resulting string is returned.
; ===========================================================================
StringRemoveAllNonAlphaNum(SourceString)
{
StringSplit,SplitSourceString,SourceString
OutputString =
Loop,%SplitSourceString0%
{
Char := SplitSourceString%A_Index%
if (Char >= "a") and (Char <= "z")
OutputString := OutputString Char
else if (Char >= "0") and (Char <= "9")
OutputString := OutputString Char
}
return OutputString
}
(编辑:清远站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |

