顯示廣告
隱藏 ✕
看板 Programming
作者 tingyun60426. (tingyun60426.bbs@ptt.cc)
標題 [轉寄] ◇ [AHK-] AutoHotKey 入門教學 - 控制視窗
時間 2010年03月06日 Sat. AM 08:23:02


看板 EzHotKey
作者 VElysian (家瑀 致中和)
標題 [AHK-] AutoHotKey 入門教學 - 控制視窗
時間 Sun Jul 20 15:15:28 2008



http://www.autohotkey.com/docs/Tutorial.htm#Activate


  控制視窗:                                                                    


WinActivate 可以讓一個視窗變成作用中(active)(跑到其他視窗的上面)
IfWinExist 或 WinWait 來偵測視窗是否存在。


關於 WinActivate  http://www.autohotkey.com/docs/commands/WinActivate.htm
     IfWinExist   http://www.autohotkey.com/docs/commands/IfWinExist.htm
     WinWait      http://www.autohotkey.com/docs/commands/WinWait.htm


下面範例將說明這些指令的用法。


        IfWinExist  未命名 - 記事本            如果未命名 - 記事本視窗存在
        {
                                      {
            WinActivate                            未命名 - 記事本移到最上面
        }                                      }
        else                                   否則
        {                                      {
            Run  Notepad                           執行  記事本
            WinWait  未命名 - 記事本               等待  未命名 - 記事本執行
            WinActivate                            未命名 - 記事本移到最上面
        }                                      }


以這個例子來說,
首先會搜尋所有視窗的標題,
看看標題為“未命名 - 記事本”(請注意大小寫)的視窗是否存在。

如果視窗  存在,則會被移到最上面(active)。
如果視窗不存在,則 記事本(Notepad)會被自動執行。
                等到它被執行後,再把它移到最上層。


在上面這個例子中,因為總是會找到最後所要搜尋的視窗(未命名 - 記事本),
Last Found Window
所以使用 WinActive 時就可以不必指定是哪個視窗了。
(其實本來應該要這樣寫: WinActive, 未命名 - 記事本


關於 Last Found Window  http://www.autohotkey.com/docs/LastFoundWindow.htm



以下是其他一些常用的控制視窗的指令:

IfWinActive  :  指定的視窗是否正在作用中(active)。
                 http://www.autohotkey.com/docs/commands/IfWinActive.htm

WinWaitActive:  等待指定的視窗變成作用中(active)。
                 (typically used after sending a window-activating keystroke
                  such as pressing Control-F for "Find")
                 http://www.autohotkey.com/docs/commands/WinWaitActive.htm

WinClose     :  關閉指定的視窗。
                 http://www.autohotkey.com/docs/commands/WinClose.htm

WinMove   :  移動視窗或改變視窗大小(可同時進行)。
                 http://www.autohotkey.com/docs/commands/WinMove.htm

WinMinimize :  視窗最小化。
                 http://www.autohotkey.com/docs/commands/WinMinimize.htm

WinMaximize :  視窗最大化。
                 http://www.autohotkey.com/docs/commands/WinMaximize.htm

WinRestore: :  回復視窗先前的狀態。
                 http://www.autohotkey.com/docs/commands/WinRestore.htm


--

        主動是機會的誘餌


--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.62.72.180
ymore:推教學1F 07/20 15:33
hellk:請問如何在目前使用中的視窗內 新增資料夾2F 07/21 15:36
VElysian:   FileCreateDir, DirName3F 07/21 18:24
VElysian:省略 DirName 的絕對路徑表示直接建立在所在資料夾。
VElysian: DirName 是你所指定的資料夾名稱,例如 NewFolder。
※ 編輯: VElysian        來自: 61.62.93.10          (07/21 18:27)
VElysian:範例: FileCreateDir, New 或 FileCreateDir, C:\1\New6F 07/21 18:28
goode9969:好文必推  期待更多的教學文7F 07/21 18:58
kslman:好文推推8F 07/22 09:50
※ 編輯: VElysian        來自: 61.62.72.58          (08/01 19:04)
※ 看板: Programming 文章推薦值: 0 目前人氣: 0 累積人氣: 7560 
分享網址: 複製 已複製
ott 轉錄至看板 ott 時間:2010-04-26 16:55:12
1樓 時間: 2018-03-19 01:11:33 (台灣)
  03-19 01:11 TW
請問一下,在win10的環境下使用winget會不會無效?
2樓 時間: 2018-03-19 01:13:28 (台灣)
  03-19 01:13 TW
在win7環境使用winget可以很正常的抓到我所選取的視窗,但是換成win10,指令就沒反應了
r)回覆 e)編輯 d)刪除 M)收藏 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇