½ºÅ©¸³Æ®°¡ ÁöÁ¤µÈ ¸Þ½ÃÁö¸¦ ¹ÞÀ» ¶§ ÀÚµ¿À¸·Î È£ÃâÇÒ ÇÔ¼ö ¶Ç´Â ÇÔ¼ö °´Ã¼¸¦ ÁöÁ¤ÇÕ´Ï´Ù .
OnMessage(MsgNumber [, Function, MaxThreads])
°¨½Ã ¶Ç´Â ÁúÀÇÇÒ ¸Þ½ÃÁö ¹øÈ£, ¹üÀ§´Â 0ºÎÅÍ 4294967295 (0xFFFFFFFF)±îÁö. ½Ã½ºÅÛ ¸Þ½ÃÁö (Áï, 0x400 ¾Æ·¡ÀÇ ¸Þ½ÃÁö)¸¦ °¨½ÃÇÏ°í ½ÍÁö ¾ÊÀ¸¸é, °¡´ÉÇϸé 4096 (0x1000)º¸´Ù ´õ Å« ¹øÈ£¸¦ °í¸£´Â °ÍÀÌ Á¦ÀÏ ÁÁ½À´Ï´Ù. ÀÌ·¸°Ô ÇÏ¸é ¿ÀÅäÇÖÅ°¿¡ ³»ºÎÀûÀ¸·Î »ç¿ëµÇ´Â ¸Þ½ÃÁö¸¦ °£¼·ÇÒ ±âȸ°¡ ÁÙ¾îµì´Ï´Ù.
ÇÔ¼öÀÇ À̸§, [v1.1.20+]¿¡¼´Â ÇÔ¼ö °´Ã¼. ±âÈ£ ±×´ë·ÎÀÇ ÇÔ¼ö À̸§À» °Ç³×·Á¸é, µû¿ÈÇ¥·Î µÑ·¯ ½Î¾ß ÇÕ´Ï´Ù.
¾î¶»°Ô ÇÔ¼ö°¡ µî·ÏµÇ´Â°¡ ±×¸®°í OnMessageÀÇ ¹Ýȯ °ªÀº ÀÌ ¸Å°³º¯¼ö°¡ ¹®ÀÚ¿Àΰ¡ ¾Æ´Ï¸é ÇÔ¼ö °´Ã¼Àΰ¡¿¡ ´Þ·Á ÀÖ½À´Ï´Ù. ´õ ÀÚ¼¼ÇÑ °ÍÀº ÇÔ¼ö À̸§ vs °´Ã¼¸¦ ÂüÁ¶ÇϽʽÿÀ.
ÀÌ Á¤¼ö´Â º¸Åë »ý·«µË´Ï´Ù. ÀÌ °æ¿ì °¨½Ã ÇÔ¼ö´Â ÇÑ ¹ø¿¡ ÇÑ ¾²·¹µå·Î Á¦Çѵ˴ϴÙ. ÀÌ°ÍÀÌ º¸Åë Á¦ÀÏ ÁÁ½À´Ï´Ù. ±×·¸Áö ¾ÊÀ¸¸é ½ºÅ©¸³Æ®°¡ °¨½Ã ÇÔ¼ö°¡ ÀÚ½ÅÀ» È£ÃâÇÏ¸é ½Ã°£ ¼ø¼°¡ ¾û¸ÁÀΠä·Î ¸Þ½ÃÁöµéÀ» ó¸®Çϱ⠶§¹®ÀÔ´Ï´Ù. ±×·¯¹Ç·Î, MaxThreads¿¡ ´ëÇÑ ´ë¾ÈÀ¸·Î¼, ¾Æ·¡¿¡ ±â¼úÇÏ´Â °Íó·³ CriticalÀ» »ç¿ëÀ» °í·ÁÇØ º¸½Ê½Ã¿À.
[v1.1.20+]: ±âº»°ªÀ¸·Î, ¿©·¯ ÇÔ¼ö°¡ ÇϳªÀÇ MsgNumber¿¡ µî·ÏµÇ¾î ÀÖÀ¸¸é, µî·ÏµÈ ¼ø¼´ë·Î È£ÃâµË´Ï´Ù. ÀÌÀü¿¡ µî·ÏµÈ ÇÔ¼öº¸´Ù ¸ÕÀú È£ÃâµÉ ÇÔ¼ö¸¦ µî·ÏÇÏ·Á¸é, MaxThreads¿¡ À½¼ö¸¦ ÁöÁ¤ÇϽʽÿÀ. ¿¹¸¦ µé¾î, OnMessage(Msg, Fn, -2)
´Â ÀÌÀü¿¡ Msg¿¡ µî·ÏµÈ ´Ù¸¥ ¾î¶² ÇÔ¼öº¸´Ùµµ ¸ÕÀú Fn
À» È£ÃâµÇµµ·Ï µî·ÏÇÕ´Ï´Ù. ±×¸®°í Fn¿¡ ÃÖ´ë 2 °³ÀÇ ¾²·¹µå¸¦ Çã¿ëÇÕ´Ï´Ù. ±×·¸Áö¸¸, ±× ÇÔ¼ö°¡ ÀÌ¹Ì µî·ÏµÇ¾î ÀÖÀ¸¸é, µî·ÏÀ» ÇØÁ¦ÇÏ°í ´Ù½Ã Àçµî·Ï ÇÏÁö ¾ÊÀº ÇÑ ¼ø¼°¡ ¹Ù²îÁö ¾Ê½À´Ï´Ù.
OnMessageÀÇ ¹Ýȯ °ª°ú ÇàÀ§´Â Function ¸Å°³º¯¼ö°¡ ÇÔ¼ö À̸§Àΰ¡ ¾Æ´Ï¸é °´Ã¼Àΰ¡¿¡ µû¶ó ´Ù¸¨´Ï´Ù.
ÇÏÀ§ ȣȯÀ» À§ÇØ, °¢°¢ÀÇ À¯ÀÏÇÑ MsgNumber¸¦ °¨½ÃÇÏ·Á¸é ±â²¯ÇØ¾ß ÇÑ °³ÀÇ ÇÔ¼ö¸¸ À̸§À¸·Î µî·ÏÇÒ ¼ö ÀÖ½À´Ï´Ù -- ÀÌ°ÍÀ» "legacy" °¨½Ã¶ó°í ºÎ¸¨´Ï´Ù.
legacy °¨½Ã ÇÔ¼ö°¡ óÀ½ µî·ÏµÇ¸é, ÀÌÀü¿¡ µî·ÏµÈ °¨½Ã ÇÔ¼öµé ¾Õ¿¡ È£ÃâµÉÁö µÚ¿¡ È£ÃâµÉÁö´Â MaxThreads ¸Å°³º¯¼ö¿¡ ´Þ·Á ÀÖ½À´Ï´Ù. ÀÌ °¨½Ã ÇÔ¼ö°¡ ´Ù¸¥ ÇÔ¼ö¸¦ È£ÃâÇϵµ·Ï ¾÷µ¥ÀÌÆ®ÇÏ´õ¶óµµ ¸ÕÀú µî·ÏÇØÁ¦ ÇÏÁö ¾Ê´Â ÇÑ ¼ø¼¿¡ ¿µÇâÀ» ÁÖÁö ¾Ê½À´Ï´Ù.
´ÙÀ½ ÄÚµå´Â MsgNumber¿¡ ´ëÇÏ¿© ÇöÀç legacy °¨½Ã ÇÔ¼ö¸¦ µî·ÏÇϰųª ¾÷µ¥ÀÌÆ®ÇÕ´Ï´Ù (º¯¼ö¸¦ °Ç³Ù´Ù¸é µû¿ÈÇ¥´Â »ý·«ÇÕ´Ï´Ù):
Name := OnMessage(MsgNumber, "FunctionName")
¹Ýȯ °ªÀº ´ÙÀ½ Áß ÇϳªÀÔ´Ï´Ù:
´ÙÀ½Àº MsgNumber¿¡ ´ëÇÏ¿© ÇöÀçÀÇ legacy °¨½ÃÀÚ¸¦ (ÀÖ´Ù¸é) µî·ÏÀ» ÇØÁ¦ÇÏ°í ±×ÀÇ À̸§À» µ¹·ÁÁÝ´Ï´Ù (¾øÀ¸¸é ºó °ªÀ» µ¹·ÁÁÜ):
Name := OnMessage(MsgNumber, "")
´ÙÀ½Àº MsgNumber¿¡ ´ëÇÏ¿© ÇöÀçÀÇ legacy °¨½ÃÀÚÀÇ À̸§À» µ¹·ÁÁÝ´Ï´Ù (¾ø´Ù¸é ºó °ªÀ» µ¹·ÁÁÜ):
Name := OnMessage(MsgNumber)
(Á¤»ó ÇÔ¼ö¸¦ Æ÷ÇÔÇÏ¿©) °¹¼ö¿¡ »ó°ü¾øÀÌ ¾ó¸¶µçÁö ÇÔ¼ö °´Ã¼´Â ÁÖ¾îÁø MsgNumber¸¦ °¨½ÃÇÒ ¼ö ÀÖ½À´Ï´Ù.
´ÙÀ½ µÎ ÁÙÀº ÀÌÀü¿¡ µî·ÏÇÑ ÇÔ¼öµé ´ÙÀ½¿¡ È£ÃâµÉ ÇÔ¼ö °´Ã¼¸¦ µî·ÏÇÕ´Ï´Ù:
OnMessage(MsgNumber, FuncObj) ; Option 1 OnMessage(MsgNumber, FuncObj, 1) ; Option 2 (MaxThreads = 1)
´ÙÀ½Àº ÀÌÀü¿¡ µî·ÏµÈ ÇÔ¼öº¸´Ù ¸ÕÀú È£ÃâµÉ ÇÔ¼ö °´Ã¼¸¦ µî·ÏÇÕ´Ï´Ù:
OnMessage(MsgNumber, FuncObj, -1)
ÇÔ¼ö °´Ã¼¸¦ µî·Ï ÇØÁ¦ÇÏ·Á¸é MaxThreads¿¡ 0À» ÁöÁ¤ÇϽʽÿÀ:
OnMessage(MsgNumber, FuncObj, 0)
½ÇÆд FunctionÀÌ ´ÙÀ½°ú °°Àº °æ¿ì¿¡ ÀϾ´Ï´Ù:
v1.1.19.03 ÀÌÀü¿¡¼ ½ÇÆд ÀÌ¹Ì 500 °³ÀÇ ¸Þ½ÃÁö¸¦ °¨½Ã ÁßÀε¥ ½ºÅ©¸³Æ®°¡ »õ ¸Þ½ÃÁö¸¦ °¨½ÃÇÏ·Á°í ½ÃµµÇÏ´Â °æ¿ì¿¡µµ ÀϾ´Ï´Ù.
FunctionÀÌ °´Ã¼À̸é, ½ÇÆнà ¿¹¿Ü¸¦ ´øÁý´Ï´Ù. ±×·¸Áö ¾ÊÀ¸¸é, ºó ¹®ÀÚ¿À» µ¹·ÁÁÝ´Ï´Ù.
¿©·¯ ¸Þ½ÃÁö¸¦ °¨½ÃÇϵµ·Ï ÇÒ´çµÈ ÇÔ¼ö´Â ÃÖ´ë ³× °³±îÁö ¸Å°³º¯¼ö¸¦ ¹ÞÀ» ¼ö ÀÖ½À´Ï´Ù:
MyMessageMonitor(wParam, lParam, msg, hwnd) { ... body of function... }
¸Å°³º¯¼ö¿¡ °Ç³Ù À̸§¿¡ »ó°ü ¾øÀÌ, ´ÙÀ½ Á¤º¸°¡ ¼ø¼´ë·Î ¸Å°³º¯¼ö¿¡ ÇÒ´çµË´Ï´Ù.:
¸Å°³º¯¼ö #1: ¸Þ½ÃÁöÀÇ WPARAM °ª.
¸Å°³º¯¼ö #2: ¸Þ½ÃÁöÀÇ LPARAM °ª.
¸Å°³º¯¼ö #3: ¸Þ½ÃÁö ¹øÈ£, ÇÔ¼ö°¡ ¿©·¯ ¸Þ½ÃÁö¸¦ °¨½ÃÇÒ ¶§ À¯¿ëÇÕ´Ï´Ù.
¸Å°³º¯¼ö #4: ¸Þ½ÃÁö°¡ Àü¼ÛµÈ âÀ̳ª ÄÜÆ®·ÑÀÇ HWND (À¯ÀÏÇÑ ID). HWND´Â ahk_id¿Í ÇÔ²² »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.
WPARAM ±×¸®°í LPARAMÀº ½ºÅ©¸³Æ®ÀÇ ½ÇÇà ÆÄÀÏÀÌ 32-ºñÆ®ÀÎÁö 64-ºñÆ®ÀÎÁö¿¡ µû¶ó ºÎÈ£ ¾ø´Â 32-ºñÆ® Á¤¼öÀ̰ųª (0ºÎÅÍ 232-1±îÁö) ¶Ç´Â ºÎÈ£ ÀÖ´Â 64-ºñÆ® Á¤¼öÀÔ´Ï´Ù (-263ºÎÅÍ 263-1±îÁö). 32-ºñÆ® ½ºÅ©¸³Æ®¿¡ ´ëÇÏ¿©, µé¾î¿À´Â ¸Å°³º¯¼ö°¡ ºÎÈ£ ÀÖ´Â Á¤¼ö¸¦ ÀǵµÇÑ´Ù¸é, À½¼ö´Â ´ÙÀ½ ¿¹Á¦¸¦ µû¶ó ³ëÃâ½Ãų ¼ö ÀÖ½À´Ï´Ù:
if (A_PtrSize = 4 && wParam > 0x7FFFFFFF) ; A_PtrSize¸¦ Á¡°ËÇØ ½ºÅ©¸³Æ®°¡ 32-ºñÆ®ÀÓÀ» È®ÀÎÇÕ´Ï´Ù. wParam := -(~wParam) - 1
»óÀÀÇÏ´Â Á¤º¸°¡ ÇÊ¿äÇÏÁö ¾ÊÀ¸¸é ¸®½ºÆ®ÀÇ ³¡À¸·ÎºÎÅÍ Çϳª ÀÌ»óÀÇ ¸Å°³º¯¼ö¸¦ »ý·«ÇÒ ¼ö ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î, MyMsgMonitor(wParam, lParam)
·Î Á¤ÀÇµÈ ÇÔ¼ö´Â ¾Õ¿¡¼ µÎ °³ÀÇ ¸Å°³º¯¼ö¸¸ ¹Þ½À´Ï´Ù. ±×¸®°í MyMsgMonitor()
·Î Á¤ÀÇµÈ ÇÔ¼ö´Â ¸Å°³º¯¼ö¸¦ ÀüÇô ¹ÞÁö ¾Ê½À´Ï´Ù.
À§¿¡¼ ¹ÞÀº ¸Å°³º¯¼ö ¸»°íµµ, ÇÔ¼ö´Â ´ÙÀ½ ³»Àå º¯¼ö·ÎºÎÅÍ °ªµéÀ» Âü°íÇÒ ¼öµµ ÀÖ½À´Ï´Ù:
°¨½Ã ÇÔ¼öÀÇ ¸¶Áö¸· ¹ß°ß âÀº ¸Þ½ÃÁö°¡ Àü¼ÛµÈ ºÎ¸ð âÀ¸·Î ½ÃÀÛÇÕ´Ï´Ù (ÄÜÆ®·Ñ¿¡ Àü¼ÛµÇ¾ú¾îµµ ¸¶Âù°¡ÁöÀÔ´Ï´Ù). âÀº ¼û¾î ÀÖÁö¸¸ GUI âÀº ¾Æ´Ï¶ó¸é (¿¹¸¦ µé¾î ½ºÅ©¸³Æ®ÀÇ ¸ÞÀΠâ), »ç¿ëÇϱâ Àü¿¡ ¸ÕÀú DetectHiddenWindows¸¦ ÄѽʽÿÀ. ¿¹¸¦ µé¾î:
DetectHiddenWindows On MsgParentWindow := WinExist() ; ¸Þ½ÃÁö°¡ Àü¼ÛµÈ âÀÇ À¯ÀÏÇÑ ID¸¦ ÀúÀåÇÕ´Ï´Ù.
°¨½Ã ÇÔ¼ö°¡ ¸Å°³º¯¼ö ¾øÀÌ ReturnÀ» »ç¿ëÇϰųª, ""¿Í °°Àº ºó °ªÀ» ÁöÁ¤Çϸé (¶Ç´Â ÀüÇô ReturnÀ» »ç¿ëÇÏÁö ¾ÊÀ¸¸é), µé¾î¿À´Â ¸Þ½ÃÁö´Â ÇÔ¼ö°¡ ³¡³¯ ¶§ Á¤»óÀûÀ¸·Î 󸮵˴ϴÙ. ÇÔ¼ö°¡ Á¾·áÇϰųª(Exits) Á¸ÀçÇÏÁö ¾Ê´Â ÆÄÀÏÀ» ½ÇÇàÇÏ´Â ½ÇÇà½Ã°£ ¿¡·¯¸¦ ¾ß±âÇÏ´õ¶óµµ °°Àº ÀÏÀÌ ÀϾ´Ï´Ù. ´ëÁ¶ÀûÀ¸·Î, Á¤¼ö¸¦ µ¹·ÁÁÖ¸é, ±× ¸Þ½ÃÁö´Â Áï½Ã ¹Ý¼ÛµË´Ï´Ù; Áï, ÇÁ·Î±×·¥Àº ¸Þ½ÃÁö¸¦ ´õ ÀÌ»ó ó¸®ÇÏÁö ¾Ê½À´Ï´Ù. ¿¹¸¦ µé¾î, WM_LBUTTONDOWN (0x201)À» °¨½ÃÇÏ´Â ÇÔ¼ö°¡ Á¤¼ö¸¦ µ¹·ÁÁÖ¸é ¸ñÇ¥ âÀº ¸¶¿ì½º Ŭ¸¯ÀÌ ÀÏ¾î³ »ç½ÇÀ» °íÁö ¹ÞÁö ¸øÇÕ´Ï´Ù. ¸¹Àº °æ¿ì (¿¹¸¦ µé¾î PostMessage¸¦ ÅëÇÏ¿© µµÂøÇÏ´Â ¸Þ½ÃÁöÀÇ °æ¿ì), ¾î¶² Á¤¼ö°¡ ¹ÝȯµÇ¾îµµ »ó°üÇÏÁö ¾Ê½À´Ï´Ù; ±×·¯³ª Àß ¸ð¸£°Ú´Ù¸é, 0ÀÌ º¸Åë °¡Àå ¾ÈÀüÇÕ´Ï´Ù.
À¯È¿ÇÑ ¹Ýȯ °ªÀÇ ¹üÀ§´Â ½ºÅ©¸³Æ®ÀÇ ½ÇÇàÆÄÀÏÀÌ 32-ºñÆ®Àΰ¡ 64-ºñÆ®Àΰ¡¿¡ µû¶ó ´Ù¸¨´Ï´Ù. ºñ¾î ÀÖÁö ¾ÊÀº °ªÀº ¹Ýµå½Ã ¹üÀ§°¡ 32ºñÆ®-½ºÅ©¸³Æ®¿¡ ´ëÇÏ¿© (A_PtrSize = 4
) -231ºÎÅÍ 232-1±îÁö ±×¸®°í 64-ºñÆ® ½ºÅ©¸³Æ®¿¡ ´ëÇÏ¿©(A_PtrSize = 8
) -263ºÎÅÍ 263-1±îÁöÀÔ´Ï´Ù.
[v1.1.20+]: ÇϳªÀÇ ¸Þ½ÃÁö¿¡ ´ëÇÏ¿© ¿©·¯ °¨½Ã ÇÔ¼ö°¡ ÀÖ´Ù¸é, ºñ¾î ÀÖÁö ¾ÊÀº °ªÀ» µ¹·ÁÁÙ ¶§±îÁö Çϳª¾¿ È£ÃâµË´Ï´Ù.
Á¤»ó ÇÔ¼ö-È£Ãâ°ú ´Ù¸£°Ô, °¨½Ã ¸Þ½ÃÁö°¡ µµÂøÇϸé ÇÔ¼ö´Â »õ·Î¿î ¾²·¹µå·Î È£ÃâµË´Ï´Ù. ÀÌ ¶§¹®¿¡, ÇÔ¼ö´Â SendMode ±×¸®°í DetectHiddenWindows°ú °°Àº ±âº»°ªÀ» °¡Áö°í »õ·Ó°Ô ½ÃÀÛÇÕ´Ï´Ù. ÀÌ ±âº»°ªÀº ÀÚµ¿-½ÇÇà ¼½¼Ç¿¡¼ ¹Ù²Ü ¼ö ÀÖ½À´Ï´Ù.
ÄÜÆ®·Ñ¿¡ (Æ÷½ºÆ® ¹æ½ÄÀÌ ¾Æ´Ï¶ó) ¼¾µå ¹æ½ÄÀ¸·Î Àü¼ÛµÇ´Â ¸Þ½ÃÁö´Â °üÁ¦µÇÁö ¾Ê½À´Ï´Ù. ¿Ö³ÄÇÏ¸é ½Ã½ºÅÛÀº ±×·± ¸Þ½ÃÁöµéÀ» È¸é µÚÀÇ ÄÜÆ®·Ñ¿¡ Á÷Á¢ º¸³» ¹ö¸®±â ¶§¹®ÀÔ´Ï´Ù. ÀÌ·± ÀÏÀº ½Ã½ºÅÛ¿¡¼-»ý¼ºµÇ´Â ¸Þ½ÃÁöµé¿¡´Â º°·Î ¹®Á¦°¡ µÇÁö ¾Ê½À´Ï´Ù. ¿Ö³ÄÇÏ¸é ´ëºÎºÐ Æ÷½ºÆ® ¹æ½ÄÀ¸·Î Àü¼ÛµÇ±â ¶§¹®ÀÔ´Ï´Ù..
OnMessage¸¦ È£ÃâÇÏ´Â ½ºÅ©¸³Æ®´Â ÀÚµ¿À¸·Î ¿µ¼ÓÀûÀÌ µË´Ï´Ù. ¶ÇÇÑ ´ÜÀÏ ½ÇüÀ̱⵵ ÇÕ´Ï´Ù. ´Ü, #SingleInstance¸¦ »ç¿ëÇÏ¿© ¿À¹ö¶óÀ̵åµÈ °æ¿ì´Â ¿¹¿ÜÀÔ´Ï´Ù.
ÇÔ¼ö°¡ ¿©ÀüÈ÷ ½ÇÇàÁßÀÎ µ¿¾È¿¡ ¶Ç °°Àº ¸Þ½ÃÁö°¡ µµÂøÇϸé, ±× ÇÔ¼ö´Â ´Ù½Ã È£ÃâµÇÁö ¾Ê½À´Ï´Ù (´Ü, MaxThreads°¡ 1º¸´Ù Å« °æ¿ì´Â ¿¹¿ÜÀÔ´Ï´Ù); ´ë½Å¿¡, ±× ¸Þ½ÃÁö´Â °¨½ÃµÇÁö ¾ÊÀº °ÍÀ¸·Î Ãë±ÞµË´Ï´Ù. ÀÌ°ÍÀÌ ¸¶À½¿¡ µéÁö ¾ÊÀ¸¸é, 0x312 ÀÌ»óÀÇ ¸Þ½ÃÁö´Â ±×ÀÇ ÇÔ¼ö°¡ ¿Ï·áÇÒ ¶§±îÁö ¹öÆÛ Ã³¸®ÇÒ ¼ö ÀÖ½À´Ï´Ù. ÇÔ¼öÀÇ Ã¹ ÁÙ¿¡ CriticalÀ» ÁöÁ¤ÇÏ¸é µË´Ï´Ù. ´ë¾ÈÀ¸·Î, °¨½Ã ÇÔ¼ö°¡ ÀÏÀ» ³¡³¾¸¸Å ÃæºÐÈ÷ ±ä ½Ã°£À» Áö¼ÓÇϱ⸸ ÇÏ¸é ¾²·¹µå ÀÎÅÍ·´Æ®·Î °°Àº ÀÏÀ» ´Þ¼ºÇÒ ¼ö ÀÖ½À´Ï´Ù. ´ëÁ¶ÀûÀ¸·Î, 0x312º¸´Ù ÀÛÀº ¸Þ½ÃÁö´Â Critical ¶Ç´Â Thread InterruptÀ¸·Î ¹öÆÛ Ã³¸®ÇÒ ¼ö ¾ø½À´Ï´Ù (±×·¸Áö¸¸, v1.0.46+¿¡¼, CriticalÀº µµ¿òÀÌ µË´Ï´Ù. ¿Ö³ÄÇÏ¸é ¸Þ½ÃÁö¸¦ ´ú Á¡°ËÇϱ⠶§¹®¿¡, ÇÔ¼ö°¡ ´õ ¸¹Àº ½Ã°£À» °¡Áö°í ÀÏÀ» ³¡³¾ ¼ö ÀÖ½À´Ï´Ù). ±×·± ¸Þ½ÃÁö¸¦ ³õÄ¡Áö ¾Êµµ·Ï º¸ÀåÇÏ´Â À¯ÀÏÇÑ ¹æ¹ýÀº ÇÔ¼ö°¡ 6¹Ð¸®ÃÊ ¾Æ·¡¿¡¼ ÀÏÀ» ³¡³»µµ·Ï È®ÀÎÇÏ´Â °ÍÀÔ´Ï´Ù (¹°·Ð ÀÌ Á¦ÇÑÀº Critical 30À» ÅëÇÏ¿© ´õ ¿Ã¸± ¼ö ÀÖ½À´Ï´Ù). ÀÌ·¸°Ô ÇÏ´Â ÇÑ °¡Áö ¹æ¹ýÀº 0x312º¸´Ù Å« °¨½Ã ¸Þ½ÃÁö¸¦ ÀÚ½ÅÀÇ ½ºÅ©¸³Æ®¿¡ Æ÷½ºÆ®Çؼ ¹Ì·¡ÀÇ ¾²·¹µå¸¦ ¹Ì¸® Å¥¿¡ ÁغñÇÏ´Â °ÍÀÔ´Ï´Ù. ±× ¸Þ½ÃÁöÀÇ ÇÔ¼ö´Â ÀӰ豸¿ªÀ» ±×ÀÇ Ã¹ ÁÙ¿¡ ÁöÁ¤Çؼ ±×ÀÇ ¸Þ½ÃÁö°¡ ¹öÆÛ Ã³¸® µÇµµ·Ï È®ÀÎÇØ¾ß ÇÕ´Ï´Ù.
½ºÅ©¸³Æ®°¡ Àý´ëÀûÀ¸·Î ÀÎÅÍ·´Æ®°¡ ºÒ°¡´ÉÇÑ µ¿¾È¿¡ 0x312º¸´Ù ÀÛÀº °¨½Ã ¸Þ½ÃÁö°¡ µµÂøÇϸé -- ¿¹¸¦ µé¾î ¸Þ´º°¡ º¸¿©Áö°Å³ª, KeyDelay/MouseDelay°¡ ÁøÇà ÁßÀ̰ųª, ¶Ç´Â Ŭ¸³º¸µå°¡ ¿·Á ÀÖ´Ù¸é -- ±× ¸Þ½ÃÁöÀÇ ÇÔ¼ö´Â È£ÃâµÇÁö ¾Ê½À´Ï´Ù. ±×¸®°í ±× ¸Þ½ÃÁö´Â °üÁ¦µÇÁö ¾ÊÀº °ÍÀ¸·Î 󸮵˴ϴÙ. ´ëÁ¶ÀûÀ¸·Î 0x312 ÀÌ»óÀÇ °¨½Ã ¸Þ½ÃÁö´Â ÀÌ·± ÀÎÅÍ·´Æ® ºÒ°¡´É ±â°£µ¿¾È¿¡ ¹öÆÛ Ã³¸®µË´Ïµð; Áï, ±×ÀÇ ÇÔ¼ö´Â ½ºÅ©¸³Æ®°¡ ÀÎÅÍ·´Æ® °¡´ÉÇØÁú ¶§ È£ÃâµË´Ï´Ù.
¾²·¹µå ÀÎÅÍ·´Æ® ¶Ç´Â ÀӰ豸¿ªÀÇ ¼³Á¤ ¶§¹®¿¡ ½ºÅ©¸³Æ®°¡ ÀÎÅÍ·´Æ®°¡ ºÒ°¡´ÉÇÑ µ¿¾È¿¡ 0x312 º¸´Ù ÀÛÀº °¨½Ã ¸Þ½ÃÁö°¡ µµÂøÇϸé, ÇöÀç ¾²·¹µå°¡ ÀÎÅÍ·´Æ® µÇ¾î ±×ÀÇ °¨½Ã ÇÔ¼ö¸¦ È£ÃâÇÒ ¼ö ÀÖ½À´Ï´Ù. ´ëÁ¶ÀûÀ¸·Î 0x312 ÀÌ»óÀÇ °¨½Ã ¸Þ½ÃÁö´Â ¾²·¹µå°¡ ÀÏÀ» ³¡³»°Å³ª ÀÎÅÍ·´Æ®°¡ °¡´ÉÇØÁú ¶§±îÁö ¹öÆÛ Ã³¸®µË´Ï´Ù.
OnMessage ¾²·¹µåÀÇ ¿ì¼± ¼øÀ§´Â ¾ðÁ¦³ª 0ÀÔ´Ï´Ù. °á°úÀûÀ¸·Î ÇöÀç ¾²·¹µåÀÇ ¿ì¼± ¼øÀ§°¡ 0º¸´Ù ³ôÀ¸¸é ¾î¶² ¸Þ½ÃÁöµµ °üÁ¦µÇÁö ¾Ê°í ¹öÆÛ Ã³¸®µÇÁö ¾Ê½À´Ï´Ù.
(0x400¹Ì¸¸ÀÇ) ½Ã½ºÅÛ ¸Þ½ÃÁö´Â ÁÖÀÇÇؼ »ç¿ëÇØ¾ß ÇÕ´Ï´Ù. ¿¹¸¦ µé¾î, °¨½Ã ÇÔ¼ö°¡ »¡¸® ÀÏÀ» ³¡³»Áö ¸øÇϸé, ±× ¸Þ½ÃÁö¿¡ ´ëÇÑ ÀÀ´äÀº ½Ã½ºÅÛÀÇ ¿¹»óº¸´Ù ÈξÀ ´õ °É¸³´Ï´Ù. ÀÌ ¶§¹®¿¡ ºÎÀÛ¿ëÀ» ¾ß±âÇÒ ¼ö ÀÖ½À´Ï´Ù. °¨½Ã ÇÁ·Î±×·¥ÀÌ ´õ ÀÌ»óÀÇ ¸Þ½ÃÁö 󸮸¦ ¾ï´©¸£±â À§ÇØ Á¤¼ö¸¦ µ¹·ÁÁÖ¸é ¿øÇÏÁö ¾Ê´Â ÇàÀ§°¡ ÀϾ ¼öµµ ÀÖ½À´Ï´Ù. ½Ã½ºÅÛÀº ´Ù¸¥ ó¸® ´Ù¸¥ ÀÀ´äÀ» ¿¹»óÇÏ°í Àֱ⠶§¹®ÀÔ´Ï´Ù.
½ºÅ©¸³Æ®°¡ MsgBox¿Í °°Àº ½Ã½ºÅÛ Ã¢À» º¸¿©ÁÖ°í ÀÖÀ» ¶§, ÄÜÆ®·Ñ¿¡ Æ÷½ºÆ®µÇ´Â ¸Þ½ÃÁö´Â ¸ðµÎ °üÁ¦°¡ µÇÁö ¾Ê½À´Ï´Ù. ¿¹¸¦ µé¾î, ½ºÅ©¸³Æ®°¡ MsgBox¸¦ º¸¿©ÁÖ°í ÀÖ°í »ç¿ëÀÚ°¡ GUI â¿¡ ¹öÆ°À» Ŭ¸¯Çϸé, WM_LBUTTONDOWN ¸Þ½ÃÁö´Â °¨½Ã ÇÔ¼ö¸¦ È£ÃâÇÏÁö ¾Ê°í Á÷Á¢ ¹öÆ°¿¡ Àü¼ÛµË´Ï´Ù.
¿ÜºÎ ÇÁ·Î±×·¥Àº PostThreadMessage() ¶Ç´Â ±âŸ API È£ÃâÀ» ÅëÇÏ¿© ¸Þ½ÃÁö¸¦ Á÷Á¢ ½ºÅ©¸³Æ®ÀÇ ¾²·¹µå¿¡ Æ÷½ºÆ®ÇÒ ¼ö ÀÖÁö¸¸, ÀÌ°ÍÀº ±ÇÀåÇÏÁö ¾Ê½À´Ï´Ù. ¿Ö³ÄÇÏ¸é ±× ¸Þ½ÃÁöµéÀº ½ºÅ©¸³Æ®°¡ MsgBox °°Àº ½Ã½ºÅÛ Ã¢À» º¸¿©ÁÖ°í ÀÖ´Â ÁßÀ̶ó¸é ¼Ò½ÇµÇ¾î ¹ö¸®±â ¶§¹®ÀÔ´Ï´Ù. ´ë½Å¿¡, º¸Åë ½ºÅ©¸³Æ®ÀÇ ¸ÞÀΠâÀ̳ª ±×ÀÇ GUI â ÁßÀÇ Çϳª¿¡ ¸Þ½ÃÁö¸¦ º¸³»´Â °ÍÀÌ °¡Àå ÁÁ½À´Ï´Ù (send vs post).
RegisterCallback(), OnExit, OnClipboardChange, Post/SendMessage, ÇÔ¼ö, â ¸Þ½ÃÁö ¸ñ·Ï, ¾²·¹µå, Critical, DllCall()
; ¿¹Á¦: ´ÙÀ½ÀÇ ÀÛµ¿ÇÏ´Â ½ºÅ©¸³Æ®´Â GUI â¿¡¼ ¸¶¿ì½º Ŭ¸¯À» °¨½ÃÇÕ´Ï´Ù ; °ü·Ã ÁÖÁ¦: GuiContextMenu Gui, Add, Text,, ÀÌ Ã¢ ¾Æ¹«µ¥³ª Ŭ¸¯ÇϽʽÿÀ. Gui, Add, Edit, w200 vMyEdit Gui, Show OnMessage(0x201, "WM_LBUTTONDOWN") return WM_LBUTTONDOWN(wParam, lParam) { X := lParam & 0xFFFF Y := lParam >> 16 if A_GuiControl Control := "`n(in control " . A_GuiControl . ")" ToolTip Gui #%A_Gui% â¿¡¼ Ŭ¶óÀ̾ðÆ® ÁÂÇ¥ %X%x%Y%.%Control%¿¡ ¿ÞŬ¸¯ Çß½À´Ï´Ù. } GuiClose: ExitApp
; ¿¹Á¦: ´ÙÀ½ ½ºÅ©¸³Æ®´Â ½Ã½ºÅÛ ¼Ë´Ù¿î/·Î±×¿ÀÆ÷¸¦ ŽÁöÇÕ´Ï´Ù. ±×¸®°í ±×°ÍÀ» Ãë¼ÒÇÒ ±âȸ¸¦ ÁÝ´Ï´Ù ; Windows Vista ÀÌÈÄ´Â ÀÛµ¿ÇÏÁö ¾Ê´Â´Ù°í º¸°íµÇ¾ú½À´Ï´Ù). ; °ü·Ã ÁÖÁ¦: OnExit ; ´ÙÀ½ DllCallÀº ¼±ÅÃÀûÀÔ´Ï´Ù: OS¿¡°Ô ÀÌ ½ºÅ©¸³Æ®¸¦ (´Ù¸¥ ¸ðµç ¾îÇø®ÄÉÀ̼Ǻ¸´Ù) ¸ÕÀú ´ÝÀ¸¶ó°í ¸í·ÉÇÕ´Ï´Ù. DllCall("kernel32.dll\SetProcessShutdownParameters", UInt, 0x4FF, UInt, 0) OnMessage(0x11, "WM_QUERYENDSESSION") return WM_QUERYENDSESSION(wParam, lParam) { ENDSESSION_LOGOFF = 0x80000000 if (lParam & ENDSESSION_LOGOFF) ; »ç¿ëÀÚ°¡ ·Î±×¿ÀÇÁÁßÀÔ´Ï´Ù. EventType = Logoff else ; ½Ã½ºÅÛÀº ¼Ë´Ù¿î ¶Ç´Â Àç½ÃÀÛ ÁßÀÔ´Ï´Ù. EventType = Shutdown MsgBox, 4,, %EventType% in progress. Allow it? IfMsgBox Yes return true ; OS¿¡°Ô ¼Ë´Ù¿î/·Î±×¿ÀÇÁ¸¦ °è¼Ó Çã¿ëÇϵµ·Ï ¸í·ÉÇÕ´Ï´Ù. else return false ; OS¿¡°Ô ¼Ë´Ù¿î/·Î±×¿ÀÇÁ¸¦ Ãë¼ÒÇϵµ·Ï ¸í·ÉÇÕ´Ï´Ù. }
; ¿¹Á¦: ½ºÅ©¸³Æ®¿¡°Ô ´Ù¸¥ ½ºÅ©¸³Æ®³ª ÇÁ·Î±×·¥À¸·ÎºÎÅÍ ¸ÂÃã ¸Þ½ÃÁö¿Í ÃÖ´ë µÎ °³ÀÇ ¼ýÀÚ¸¦ ¹Þµµ·Ï ¸¸µì´Ï´Ù. ; (¼ýÀÚ ´ë½Å¿¡ ¹®ÀÚ¿À» Àü¼ÛÇÏ·Á¸é, ÀÌ ´ÙÀ½ ¿¹Á¦¸¦ º¸½Ê½Ã¿À). OnMessage(0x5555, "MsgMonitor") OnMessage(0x5556, "MsgMonitor") MsgMonitor(wParam, lParam, msg) { ; ½Å¼ÓÇÏ°Ô µ¹¾Æ°¡´Â °ÍÀÌ Áß¿äÇÏ´Ù¸é, ToolTipÀ» »ç¿ëÇÏ´Â ÆíÀÌ ´õ ÁÁ½À´Ï´Ù. ; MsgBox °°Àº °æ¿ì´Â ÇÔ¼ö°¡ ÀÏÀ» ³¡³»Áö ¸øÇϵµ·Ï ¹æÇØÇϱ⠶§¹®ÀÔ´Ï´Ù: ToolTip Message %msg% arrived:`nWPARAM: %wParam%`nLPARAM: %lParam% } ; ´ÙÀ½À» ´Ù¸¥ ½ºÅ©¸³Æ® ¾È¿¡¼ »ç¿ëÇϸé À§ÀÇ ½ºÅ©¸³Æ® ¾È¿¡¼ ÇÔ¼ö¸¦ ½ÇÇàÇÒ ¼ö ÀÖ½À´Ï´Ù: SetTitleMatchMode 2 DetectHiddenWindows On if WinExist("Name of Receiving Script.ahk ahk_class AutoHotkey") PostMessage, 0x5555, 11, 22 ; ÀÌ ¸Þ½ÃÁö´Â À§ÀÇ WinExist() ¶§¹®¿¡ "¸¶Áö¸· ¹ß°ß â"À¸·Î Àü¼ÛµË´Ï´Ù. DetectHiddenWindows Off ; PostMessage°¡ ³¡³¯ ¶§±îÁö ²ô¸é ¾È µË´Ï´Ù.
; ¿¹Á¦: ¹®ÀÚ¿À» ±æÀÌ¿¡ »ó°ü¾øÀÌ ÇÑ ½ºÅ©¸³Æ®¿¡¼ ´Ù¸¥ ½ºÅ©¸³Æ®·Î Àü¼ÛÇÕ´Ï´Ù. ´ÙÀ½Àº ÀÛµ¿ÇÏ´Â ¿¹Á¦ÀÔ´Ï´Ù. ; »ç¿ëÇÏ·Á¸ç´Ï, ´ÙÀ½ ½ºÅ©¸³Æ®µéÀ» ÀúÀåÇÏ°í ½ÇÇàÇÑ ´ÙÀ½ Win+Space¸¦ ´©¸£¸é ; InputBox¸¦ º¼¼ö ÀÖ½À´Ï´Ù. ±× ¾È¿¡ ¹®ÀÚ¿À» ŸÀÚÇØ ³ÖÀ¸¸é µË´Ï´Ù. ; ´ÙÀ½ ½ºÅ©¸³Æ®¸¦ "Receiver.ahk"·Î ÀúÀåÇÏ°í ±âµ¿½ÃÅ°½Ê½Ã¿À: #SingleInstance OnMessage(0x4a, "Receive_WM_COPYDATA") ; 0x4a is WM_COPYDATA return Receive_WM_COPYDATA(wParam, lParam) { StringAddress := NumGet(lParam + 2*A_PtrSize) ; CopyDataStructÀÇ lpData ¸â¹ö¸¦ ¹Þ½À´Ï´Ù. CopyOfData := StrGet(StringAddress) ; ±¸Á¶Ã¼·ÎºÎÅÍ ¹®ÀÚ¿À» º¹»çÇÕ´Ï´Ù. ; ±×°ÍÀ» ToolTip vs. MsgBox·Î º¸¿©ÁÝ´Ï´Ù. ±×·¡¼ ÀûÀýÇÑ ½Ã°£¿¡ µ¹·ÁÁÙ ¼ö ÀÖ½À´Ï´Ù: ToolTip %A_ScriptName%`nReceived the following string:`n%CopyOfData% return true ; 1 (true)À» µ¹·ÁÁÖ´Â °ÍÀÌ ÀÌ ¸Þ½ÃÁö¸¦ ½ÂÀÎÇÏ´Â ÀüÅëÀûÀÎ ¹æ½ÄÀÔ´Ï´Ù. } ; ´ÙÀ½ ½ºÅ©¸³Æ®¸¦ "Sender.ahk"·Î ÀúÀåÇÑ ´ÙÀ½ ±âµ¿½ÃÅ°½Ê½Ã¿À. ±× ´ÙÀ½, Win+Space ÇÖÅ°¸¦ ´©¸£½Ê½Ã¿À. TargetScriptTitle = Receiver.ahk ahk_class AutoHotkey #space:: ; Win+Space ÇÖÅ°. ´©¸£¸é ¸Þ½ÃÁö ¹®ÀÚ¿À» ÀÔ·ÂÇÒ InputBox°¡ ³ªÅ¸³³´Ï´Ù. InputBox, StringToSend, Send text via WM_COPYDATA, Enter some text to Send: if ErrorLevel ; »ç¿ëÀÚ°¡ Ãë¼Ò ¹öÆ°À» ´·¶½À´Ï´Ù. return result := Send_WM_COPYDATA(StringToSend, TargetScriptTitle) if result = FAIL MsgBox SendMessage failed. Does the following WinTitle exist?:`n%TargetScriptTitle% else if result = 0 MsgBox Message sent but the target window responded with 0, which may mean it ignored it. return Send_WM_COPYDATA(ByRef StringToSend, ByRef TargetScriptTitle) ; ByRef´Â ÀÌ °æ¿ì ¸Þ¸ð¸®¸¦ »ó´çÈ÷ Àý¾àÇØ ÁÝ´Ï´Ù. ; ´ÙÀ½ ÇÔ¼ö´Â ÁöÁ¤µÈ ¹®ÀÚ¿À» ÁöÁ¤µÈ â¿¡ Àü¼ÛÇÏ°í ÀÀ´äÀ» µ¹·ÁÁÝ´Ï´Ù. ; ¸ñÇ¥ âÀÌ ¸Þ½ÃÁö¸¦ ó¸®ÇßÀ¸¸é ÀÀ´äÀº 1ÀÔ´Ï´Ù. ¶Ç´Â ¹«½ÃÇß´Ù¸é 0ÀÔ´Ï´Ù. { VarSetCapacity(CopyDataStruct, 3*A_PtrSize, 0) ; ±¸Á¶Ã¼ÀÌ ¸Þ¸ð¸® ±¸¿ªÀ» ¼³Á¤ÇÕ´Ï´Ù. ; ¸ÕÀú ±¸Á¶Ã¼ÀÇ cbData ¸â¹ö¿¡ ¹®ÀÚ¿ÀÇ Å©±â¸¦ ¼³Á¤ÇÕ´Ï´Ù. ±×ÀÇ 0 Á¾·á¹®ÀÚ¸¦ Æ÷ÇÔÇÕ´Ï´Ù: SizeInBytes := (StrLen(StringToSend) + 1) * (A_IsUnicode ? 2 : 1) NumPut(SizeInBytes, CopyDataStruct, A_PtrSize) ; OSÀÇ ¿ä±¸´ë·Î ÀÌ·¸°Ô ó¸®ÇÕ´Ï´Ù. NumPut(&StringToSend, CopyDataStruct, 2*A_PtrSize) ; lpData¿¡ ¹®ÀÚ¿ ÀÚü¸¦ °¡¸®Å°µµ·Ï ¼³Á¤ÇÕ´Ï´Ù. Prev_DetectHiddenWindows := A_DetectHiddenWindows Prev_TitleMatchMode := A_TitleMatchMode DetectHiddenWindows On SetTitleMatchMode 2 SendMessage, 0x4a, 0, &CopyDataStruct,, %TargetScriptTitle% ; 0x4a´Â WM_COPYDATAÀÔ´Ï´Ù. Post°¡ ¾Æ´Ï¶ó Send¸¦ »ç¿ëÇØ¾ß ÇÕ´Ï´Ù. DetectHiddenWindows %Prev_DetectHiddenWindows% ; È£ÃâÀÚ¿¡ ´ëÇÏ¿© ¿ø·¡ ¼³Á¤À» º¹±¸ÇÕ´Ï´Ù. SetTitleMatchMode %Prev_TitleMatchMode% ; À§¿Í °°½À´Ï´Ù. return ErrorLevel ; SendMessageÀÇ ÀÀ´äÀ» ´Ù½Ã È£ÃâÀÚ¿¡°Ô Àü¼ÛÇÕ´Ï´Ù. }
; ¿¹Á¦: WinLIRC Ŭ¶óÀ̾ðÆ® ½ºÅ©¸³Æ®¸¦ ÂüÁ¶ÇϽʽÿÀ. ; ³×Æ®¿öÅ© Á¢¼Ó¿¡ µ¥ÀÌÅÍ°¡ µµÂøÇÒ ¶§ OnMessage()¸¦ »ç¿ëÇÏ¿© °íÁö¸¦ ¹Þ´Â ¹æ¹ýÀ» º¸¿© ÁÝ´Ï´Ù.