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

Function SystemHasAnotherMouseHook

source/hook.cpp:4226–4239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4224
4225
4226bool SystemHasAnotherMouseHook()
4227{
4228 if (sMouseMutex)
4229 CloseHandle(sMouseMutex); // But don't set it to NULL because we need its value below as a flag.
4230 HANDLE mutex = CreateMutex(NULL, FALSE, MOUSE_MUTEX_NAME); // Create() vs. Open() has enough access to open the mutex if it exists.
4231 DWORD last_error = GetLastError();
4232 // Don't check g_MouseHook because in the case of aChangeIsTemporary, it might be NULL even though
4233 // we want a handle to the mutex maintained here.
4234 if (sMouseMutex) // It was open originally, so update the handle the the newly opened one.
4235 sMouseMutex = mutex;
4236 else if (mutex) // Keep it closed because the system tracks how many handles there are, deleting the mutex when zero.
4237 CloseHandle(mutex); // This facilitates other instances of the program getting the proper last_error value.
4238 return last_error == ERROR_ALREADY_EXISTS;
4239}
4240
4241
4242

Callers 2

SendKeysFunction · 0.85
PerformMouseCommonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected