IfWinActive / IfWinNotActive / WinActive

ÁöÁ¤µÈ âÀÌ Á¸ÀçÇÏ´ÂÁö ±×¸®°í ÇöÀç È°¼ºÈ­ »óÅÂÀÎÁö Á¡°ËÇÕ´Ï´Ù (ÃÖÀü¹æ). ±×·¸´Ù¸é, WinActive()´Â ±×ÀÇ Unique ID (HWND)¸¦ µ¹·ÁÁÝ´Ï´Ù.

IfWinActive [, WinTitle, WinText,  ExcludeTitle, ExcludeText]
IfWinNotActive [, WinTitle, WinText, ExcludeTitle, ExcludeText]
UniqueID := WinActive("WinTitle", "WinText", "ExcludeTitle", "ExcludeText")

¸Å°³º¯¼ö

WinTitle

â Á¦¸ñ ¶Ç´Â ¸ñÇ¥ âÀ» ½Äº°ÇÏ´Â ´Ù¸¥ ±âÁØ WinTitle ÂüÁ¶.

WinText

Á¸ÀçÇϸé, ¸ñÇ¥ â ÅؽºÆ®ÀÇ ºÎ¹®ÀÚ¿­ÀÔ´Ï´Ù (Window Spy¿¡ ³ëÃâµÊ). ¼ûÀº ÅؽºÆ®´Â DetectHiddenText°¡ ÄÑÁ® ÀÖ¾î¾ß(ON) ŽÁöµË´Ï´Ù.

ExcludeTitle

Á¦¸ñ¿¡ ÀÌ °ªÀÌ Àִ âÀº ¹«½ÃµË´Ï´Ù. ÁÖÀÇ: ÇÏÀ§ ȣȯÀÇ ¹®Á¦ ¶§¹®¿¡, IfWinActive¿Í IfWinNotActive´Â ¸í·É¾îÀÇ À̸§¿¡ Á¤È®ÇÏ°Ô ºÎÇÕÇÏ¸é ¸Å°³º¯¼ö¸¦ ÀÌ ¸í·É¾î·Î ÀÌÇØÇÕ´Ï´Ù. À̸¦ ¿ìȸÇÏ·Á¸é, ´ë½Å¿¡ WinActive() ÇÔ¼ö¸¦ »ç¿ëÇϽʽÿÀ.

ExcludeText

ÅؽºÆ®¿¡ ÀÌ °ªÀÌ Àִ âÀº Á¦¿ÜµË´Ï´Ù.

³íÆò

¸ðµç ¸Å°³º¯¼ö°¡ »ý·«µÇ¸é, ¸¶Áö¸· ¹ß°ß âÀÌ »ç¿ëµË´Ï´Ù.

ÀÌ ¸í·É¾î Áß Çϳª¶óµµ È°¼ºÃ¢ÀÌ ºÎÇÕÇÑ´Ù´Â °ÍÀ» ¾Ë°Ô µÇ¸é, ¸¶Áö¸· ¹ß°ß âÀÌ ±× È°¼º âÀ¸·Î °»½ÅµË´Ï´Ù. Áï, IfWinActive°¡ Âü("true")À¸·Î Æò°¡µÇ°Å³ª IfWinNotActive°¡ °ÅÁþ("false")À¸·Î Æò°¡µÇ¸é, ¸¶Áö¸· ¹ß°ß âÀÌ °»½ÅµË´Ï´Ù.

ÇÔ¼ö WinActive()´Â ÁöÁ¤ÇÑ ±âÁØ¿¡ ºÎÇÕÇÏ´Â È°¼º âÀÇUnique ID (HWND)¸¦ µ¹·ÁÁÝ´Ï´Ù. ¾øÀ¸¸é 0À» µ¹·ÁÁÝ´Ï´Ù. 0ÀÌ-¾Æ´Ñ ¸ðµç ¼ýÀÚ´Â Âü("true")À¸·Î °£ÁֵǹǷÎ, ´ÙÀ½ ¼­¼ú¹® if WinActive("WinTitle")´Â WinTitleÀÌ È°¼ºÈ­µÇ¾î ÀÖÀ¸¸é ÂüÀÔ´Ï´Ù.

È°¼º âÀÇ À¯ÀÏÇÑ ID¸¦ ¿­¶÷ÇÏ´Â ½¬¿î ¹æ¹ýÀº ActiveHwnd := WinExist("A")ÀÔ´Ï´Ù.

SetWinDelay´Â IfWinExist/IfWinActive¿¡ Àû¿ëµÇÁö ¾Ê½À´Ï´Ù.

â Á¦¸ñ°ú ÅؽºÆ®´Â ´ë¼Ò¹®ÀÚ¸¦ ±¸º°ÇÕ´Ï´Ù. ¼ûÀº âÀº DetectHiddenWindowsÀÌ ÄÑÁ® ÀÖ¾î¾ß ŽÁöµË´Ï´Ù.

°ü·Ã Ç׸ñ

IfWinExist, SetTitleMatchMode, DetectHiddenWindows, Last Found Window, WinActivate, WinWaitActive, WinWait, WinWaitClose, #IfWinActive/Exist

¿¹Á¦

IfWinActive, Untitled - Notepad
{
    WinMaximize  ; À§¿¡¼­ IfWinActive°¡ ¹ß°ßÇÑ ³ëÆ®Æеå âÀ» ÃÖ´ëÈ­ÇÕ´Ï´Ù.
    Send, Some text.{Enter}
    return
}

if WinActive("ahk_class Notepad") or WinActive("ahk_class" . ClassName)  ; "ahk_class"´Â µÚ¿¡ ½ºÆäÀ̽º°¡ ÇÊ¿äÇÏÁö ¾Ê½À´Ï´Ù.
    WinClose  ; ¸¶Áö¸· ¹ß°ß âÀ» »ç¿ëÇÕ´Ï´Ù.