2013-11-28 70 views
0

我想要一個熱鍵,當我按住windows鍵並按下「c」時打開Chrome。這是我寫的:如果語句在autohotkey

#c::Run chrome.exe 

但是,如果chrome已經打開,我希望它激活該窗口,而不是。在初學者的教程給出了這樣一個腳本的例子是這樣的

IfWinExist Untitled - Notepad 
{ 
    WinActivate 
} 
else 
{ 
    Run Notepad 
    WinWait Untitled - Notepad 
    WinActivate 
} 

不幸的是,任何Chrome窗口的名稱是(當前網站) - 谷歌瀏覽器,所以我需要知道如何使用某種通用名稱爲我的Chrome窗口,以便它將它們識別爲一個程序。任何幫助表示讚賞。我總是新手

+0

http://www.autohotkey.com/docs/commands/SetTitleMatchMode.htm – this

回答

0

您可以使用窗口的ahk_class來代替,它就像窗口的唯一標識符。你可以通過右鍵點擊任務欄中的autohotkey圖標,選擇「Window Spy」,然後點擊Chrome並複製ahk_class

if (WinExist("ahk_class Chrome_WidgetWin_1")) 
    WinActivate, % "ahk_id " WinExist("ahk_class Chrome_WidgetWin_1") 
else { 
    MsgBox, Run Google Chrome 
    ;Run, chrome.exe? 
}