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

Function SystemHasAnotherKeybdHook

source/hook.cpp:4209–4222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4207
4208
4209bool SystemHasAnotherKeybdHook()
4210{
4211 if (sKeybdMutex)
4212 CloseHandle(sKeybdMutex); // But don't set it to NULL because we need its value below as a flag.
4213 HANDLE mutex = CreateMutex(NULL, FALSE, KEYBD_MUTEX_NAME); // Create() vs. Open() has enough access to open the mutex if it exists.
4214 DWORD last_error = GetLastError();
4215 // Don't check g_KeybdHook because in the case of aChangeIsTemporary, it might be NULL even though
4216 // we want a handle to the mutex maintained here.
4217 if (sKeybdMutex) // It was open originally, so update the handle the the newly opened one.
4218 sKeybdMutex = mutex;
4219 else if (mutex) // Keep it closed because the system tracks how many handles there are, deleting the mutex when zero.
4220 CloseHandle(mutex); // This facilitates other instances of the program getting the proper last_error value.
4221 return last_error == ERROR_ALREADY_EXISTS;
4222}
4223
4224
4225

Callers 1

SendKeysFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected