IfWinExist / IfWinNotExist / WinExist

ºÎÇÕÇϴ âÀÌ Á¸ÀçÇÏ´ÂÁö Á¡°ËÇÕ´Ï´Ù. WinExist()´Â ù ¹ø°·Î ºÎÇÕÇϴ âÀÇ Unique ID (HWND)¸¦ µ¹·ÁÁÝ´Ï´Ù.

IfWinExist [, WinTitle, WinText,  ExcludeTitle, ExcludeText]
IfWinNotExist [, WinTitle, WinText, ExcludeTitle, ExcludeText]
UniqueID := WinExist("WinTitle", "WinText", "ExcludeTitle", "ExcludeText")

¸Å°³º¯¼ö

UniqueID

ÁÖ¾îÁø ±âÁØ¿¡ ºÎÇÕÇϴ ù ¹ø° âÀÇ Unique ID (HWND) (½ÊÀ°Áø Á¤¼ö)

WinTitle

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

WinText

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

ExcludeTitle

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

ExcludeText

ÅؽºÆ®¿¡ ÀÌ °ªÀÌ ¾ø´Â âÀº ¹«½ÃÇÕ´Ï´Ù.

³íÆò

¸ðµç ¸Å°³º¯¼ö°¡ »ý·«µÇ¸é, ¸¶Áö¸· ¹ß°ß âÀ» Á¡°ËÇÏ¿© ¿©ÀüÈ÷ Á¸ÀçÇÏ´ÂÁö (IfWinNotExistÀ̶ó¸é Á¸ÀçÇÏÁö ¾Ê´ÂÁö) ¾Ë¾Æ º¾´Ï´Ù.

ÀÌ ¸í·É¾î Áß Çϳª¶óµµ ºÎÇÕÇϴ âÀÌ ÀÖ´Ù´Â °ÍÀ» ¾Ë°Ô µÇ¸é, ¸¶Áö¸· ¹ß°ß âÀÌ ±× âÀ¸·Î °»½ÅµË´Ï´Ù. Áï, IfWinExist°¡ ÂüÀ¸·Î Æò°¡µÇ°Å³ª IfWinNotExist°¡ °ÅÁþÀ¸·Î Æò°¡µÇ¸é, ¸¶Áö¸· ¹ß°ß âÀÌ °»½ÅµË´Ï´Ù.

ÇÔ¼ö WinExist()´Â ù ¹ø°·Î ºÎÇÕÇϴ âÀÇ Unique ID (HWND)¸¦ (¾øÀ¸¸é 0) µ¹·ÁÁÝ´Ï´Ù. 0-¾Æ´Ñ ¸ðµç ¼ýÀÚ´Â Âü("true")À¸·Î °£ÁֵǹǷÎ, ´ÙÀ½ ¼­¼ú¹® if WinExist("WinTitle")´ÂWinTitleÀÌ Á¸ÀçÇϸé ÂüÀÔ´Ï´Ù.

ÄÜÆ®·ÑÀÇ HWND¸¦ ¹ß°ßÇÏ·Á¸é (Post/SendMessage ¶Ç´Â DllCall¿¡ »ç¿ëÇϱâ À§ÇØ), ControlGet Hwnd ¶Ç´Â MouseGetPos¸¦ »ç¿ëÇϽʽÿÀ.

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

â Á¦¸ñ°ú ÅؽºÆ®´Â ´ë¼Ò¹®ÀÚ¿¡ ¹Î°¨ÇÕ´Ï´Ù. ¼ûÀº âÀº DetectHiddenWindows°¡ ÄÑÁ® ÀÖÀ¸¸é ŽÁöµË´Ï´Ù.

°ü·Ã Ç׸ñ

IfWinActive, SetTitleMatchMode, DetectHiddenWindows, ¸¶Áö¸· ¹ß°ß â, Process, WinActivate, WinWaitActive, WinWait, WinWaitClose, #IfWinActive/Exist

¿¹Á¦

; ¿¹Á¦ 1
IfWinExist, Untitled - Notepad
{
    WinActivate  ; À§¿¡¼­ ¹ß°ßÇÑ Ã¢À» ÀÚµ¿À¸·Î »ç¿ëÇÕ´Ï´Ù.
    WinMaximize  ; À§¿Í °°½À´Ï´Ù
    Send, Some text.{Enter}
    return
}

; ¿¹Á¦ 2
IfWinNotExist, Calculator
    return
else
{
    WinActivate  ; À§ÀÇ "IfWinNotExist"´Â ¶Ç "¸¶Áö¸· ¹ß°ß â"À» °»½ÅÇØ ÁÝ´Ï´Ù.
    WinMove, 40, 40  ; »õ·Î¿î À§Ä¡·Î À̵¿ÇÕ´Ï´Ù.
    return
}

; ¿¹Á¦ 3
if WinExist("ahk_class Notepad") or WinExist("ahk_class" . ClassName)
    WinActivate  ; ¸¶Áö¸·À¸·Î ¹ß°ßµÈ âÀ» »ç¿ëÇÕ´Ï´Ù.

MsgBox % "The active window's ID is " . WinExist("A")

; ¿¹Á¦ 4: ´ÙÀ½°ú µ¿µîÇÕ´Ï´Ù: IfWinNotExist, Calculator
If !WinExist("Calculator")
    return