在新窗口上触发 Autohotkey

Mal*_*rba 4 windows-7 window-manager autohotkey

每当在自动热键中打开新窗口时,如何设置要触发的操作?例如,我可以将任何 Windows 资源管理器窗口设置为在出现时立即标记为“始终在最前面”。或者我可以将任何新的 Skype 窗口设置为始终在第二台显示器上打开,或者始终为半透明等...

我认为 autohotkey 可以实现这一点,但我不知道如何实现。我需要它在新窗口出现后立即对它执行一些任意操作。

小智 6

像这样的东西会很好地工作:http : //www.autohotkey.com/forum/topic63673.html

万一链接因任何原因更改或关闭:

;========================================================================
; 
; Template:     WinTrigger (former OnOpen/OnClose)
; Description:  Act upon (de)activation/(un)existance of programs/windows
; Online Ref.:  http://www.autohotkey.com/forum/viewtopic.php?t=63673
;
; Last Update:  15/Mar/2010 17:30
;
; Created by:   MasterFocus
;               http://www.autohotkey.net/~MasterFocus/AHK/
;
; Thanks to:    Lexikos, for improving it significantly
;               http://www.autohotkey.com/forum/topic43826.html#267338
;
;========================================================================
;
; This template contains two examples by default. You may remove them.
;
; * HOW TO ADD A PROGRAM to be checked upon (de)activation/(un)existance:
;
; 1. Add a variable named ProgWinTitle# (Configuration Section)
; containing the desired title/ahk_class/ahk_id/ahk_group
;
; 2. Add a variable named WinTrigger# (Configuration Section)
; containing the desired trigger ("Exist" or "Active")
;
; 3. Add labels named LabelTriggerOn# and/or LabelTriggerOff#
; (Custom Labels Section) containing the desired actions
;
; 4. You may also change CheckPeriod value if desired
;
;========================================================================

#Persistent

; ------ ------ CONFIGURATION SECTION ------ ------

; Program Titles
ProgWinTitle1 = ahk_class Notepad
WinTrigger1 = Exist
ProgWinTitle2 = Calculator
WinTrigger2 = Active

; SetTimer Period
CheckPeriod = 200

; ------ END OF CONFIGURATION SECTION ------ ------

SetTimer, LabelCheckTrigger, %CheckPeriod%
Return

; ------ ------ ------

LabelCheckTrigger:
  While ( ProgWinTitle%A_Index% != "" && WinTrigger := WinTrigger%A_Index% )
    if ( !ProgRunning%A_Index% != !Win%WinTrigger%( ProgWinTitle := ProgWinTitle%A_Index% ) )
      GoSubSafe( "LabelTriggerO" ( (ProgRunning%A_Index% := !ProgRunning%A_Index%) ? "n" : "ff" ) A_Index )
Return

; ------ ------ ------

GoSubSafe(mySub)
{
  if IsLabel(mySub)
    GoSub %mySub%
}

; ------ ------ CUSTOM LABEL SECTION ------ ------

LabelTriggerOn1:
LabelTriggerOff1:
LabelTriggerOn2:
  MsgBox % "A_ThisLabel:`t" A_ThisLabel "`nProgWinTitle:`t" ProgWinTitle "`nWinTrigger:`t" WinTrigger
Return

; ------ END OF CUSTOM LABEL SECTION ------ ------
Run Code Online (Sandbox Code Playgroud)

请注意,我没有编写此代码。