MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / MsgMonitor

Function MsgMonitor

source/application.cpp:1693–1725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1691
1692inline bool MsgMonitor(MsgMonitorInstance &aInstance, HWND aWnd, UINT aMsg, WPARAM awParam, LPARAM alParam, MSG *apMsg, LRESULT &aMsgReply);
1693bool MsgMonitor(HWND aWnd, UINT aMsg, WPARAM awParam, LPARAM alParam, MSG *apMsg, LRESULT &aMsgReply)
1694// Returns false if the message is not being monitored, or it is but the called function indicated
1695// that the message should be given its normal processing. Returns true when the caller should
1696// not process this message but should instead immediately reply with aMsgReply (if a reply is possible).
1697// When false is returned, caller should ignore the value of aMsgReply.
1698{
1699 // This function directly launches new threads rather than posting them as something like
1700 // AHK_GUI_ACTION (which would allow them to be queued by means of MSG_FILTER_MAX) because a message
1701 // monitor function in the script can return "true" to exempt the message from further processing.
1702 // Consequently, the MSG_FILTER_MAX queuing effect will only occur for monitored messages that are
1703 // numerically greater than WM_HOTKEY. Other messages will not be subject to the filter and thus
1704 // will arrive here even when the script is currently uninterruptible, in which case it seems best
1705 // for flexibility to allow the interruption (the same is done for CreateCallback).
1706 //if (!INTERRUPTIBLE_IN_EMERGENCY)
1707 // return false;
1708
1709 bool result = false; // Set default: Tell the caller to give this message any additional/default processing.
1710 MsgMonitorInstance inst (g_MsgMonitor); // Register this instance so that index can be adjusted by BIF_OnMessage if an item is deleted.
1711
1712 // Linear search vs. binary search should perform better on average because the vast majority
1713 // of message monitoring scripts are expected to monitor only a few message numbers.
1714 for (inst.index = 0; inst.index < inst.count; ++inst.index)
1715 if (g_MsgMonitor[inst.index].msg == aMsg)
1716 {
1717 if (MsgMonitor(inst, aWnd, aMsg, awParam, alParam, apMsg, aMsgReply))
1718 {
1719 result = true;
1720 break;
1721 }
1722 }
1723
1724 return result;
1725}
1726
1727bool MsgMonitor(MsgMonitorInstance &aInstance, HWND aWnd, UINT aMsg, WPARAM awParam, LPARAM alParam, MSG *apMsg, LRESULT &aMsgReply)
1728{

Callers 4

GuiWindowProcFunction · 0.85
MainWindowProcFunction · 0.85
InputBoxProcFunction · 0.85
MsgSleepFunction · 0.85

Calls 4

InitNewThreadFunction · 0.85
GetNonChildParentFunction · 0.85
CallMethodFunction · 0.85
ResumeUnderlyingThreadFunction · 0.85

Tested by

no test coverage detected