3

現在、居間のプラズマに接続された HTPC を使用していますが、残像に関していくつかの問題がありました。Web などを長時間閲覧しているときに、問題が発生します。ただし、AutoHotKey を使用してスクリプトを設定し、タイマーで自動的にウィンドウのサイズを変更するのは比較的簡単なようです。このタスクを達成するためのスクリプトを開始するのを手伝ってくれる人はいますか? (その他のアイデアも歓迎します)

ありがとう!

4

4 に答える 4

5

私はかなり前に、ウィンドウを「正規化」するスクリプトを作成しました。つまり、サイズ変更、移動、およびその他のアクションを実行して、ウィンドウを私の個人的な好みに合わせて確認します。

ウィンドウが初めて表示されるときはいつでも、正規化されます。閉じて再度開くと、再び正規化されます。

以下はスクリプトの機能バージョンであり、元の質問の要件を満たす必要があります。

私が使用しているバージョンは、複数のモニターをサポートし、Windows タスク バーの高さを考慮してウィンドウのサイズを変更するなど、より多くの機能を備えているため、はるかに複雑です。スクリプトを使用して、開く/保存するダイアログを大きくします (デフォルトでは小さすぎます)。また、一部の Web サイトやアプリケーションへの自動ログインにも使用しています。

; 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
}
于 2010-11-22T19:18:04.217 に答える
2

私は同じ問題に取り組んでいます。これは、現在の画面サイズに基づいて 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
于 2010-10-19T20:56:21.040 に答える
0

以下のショートカットを使用して、ウィンドウのサイズを変更してスナップすることができます。

  • Windows キー + 左矢印= ウィンドウが画面の左側にスナップ
  • Windows キー + 右矢印= ウィンドウが画面の右側にスナップします
  • Windows キー + 上矢印= ウィンドウが画面の上側にスナップ
  • Windows キー + 下矢印= ウィンドウが画面の下側にスナップ
  • Windows キー + 上矢印と左矢印= ウィンドウを画面の左上隅にスナップ
  • Windows キー + 上 & 右矢印= ウィンドウを画面の右上隅にスナップ
于 2020-01-15T05:15:25.290 に答える