我目前在客厅里有一台连接到等离子的 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, , (A_ScreenWidth/2)-(WinWidth/2), (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
}
我正在解决同样的问题。这是一个脚本,可根据您当前的屏幕尺寸打开并居中Windows 计算器。我还在弄清楚一切,但也许这会让你开始。
;This script opens and centers the calculator on your screen.
#NoTrayIcon
Run, calc.exe
WinWait, Calculator
WinGetPos,,, Width, Height, %WinTitle%
WinMove, %WinTitle%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
Return
您可以使用以下快捷方式调整窗口大小和对齐窗口。
您可以使用以下快捷方式调整窗口大小和对齐窗口。您可以使用脚本来运行这些命令。
Windows 键 + 左箭头 = 窗口捕捉到屏幕左侧
Windows 键 + 右箭头 = 窗口捕捉到屏幕右侧
Windows 键 + 向上箭头 = 窗口捕捉到屏幕的上侧
Windows 键 + 向下箭头 = 窗口捕捉到屏幕的下侧
Windows 键 + 向上和向左箭头 = 窗口捕捉到屏幕的左上角
Windows 键 + 向上和向右箭头 = 窗口捕捉到屏幕的右上角