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

Function UpdateKeyEventHistory

source/keyboard_mouse.cpp:2943–2967  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2941
2942
2943void UpdateKeyEventHistory(bool aKeyUp, vk_type aVK, sc_type aSC)
2944{
2945 if (!g_KeyHistory) // Don't access the array if it doesn't exist (i.e. key history is disabled).
2946 return;
2947 g_KeyHistory[g_KeyHistoryNext].key_up = aKeyUp;
2948 g_KeyHistory[g_KeyHistoryNext].vk = aVK;
2949 g_KeyHistory[g_KeyHistoryNext].sc = aSC;
2950 g_KeyHistory[g_KeyHistoryNext].event_type = 'i'; // Callers all want this.
2951 g_HistoryTickNow = GetTickCount();
2952 g_KeyHistory[g_KeyHistoryNext].elapsed_time = (g_HistoryTickNow - g_HistoryTickPrev) / (float)1000;
2953 g_HistoryTickPrev = g_HistoryTickNow;
2954 HWND fore_win = GetForegroundWindow();
2955 if (fore_win)
2956 {
2957 if (fore_win != g_HistoryHwndPrev)
2958 GetWindowText(fore_win, g_KeyHistory[g_KeyHistoryNext].target_window, _countof(g_KeyHistory[g_KeyHistoryNext].target_window));
2959 else // i.e. avoid the call to GetWindowText() if possible.
2960 *g_KeyHistory[g_KeyHistoryNext].target_window = '\0';
2961 }
2962 else
2963 _tcscpy(g_KeyHistory[g_KeyHistoryNext].target_window, _T("N/A"));
2964 g_HistoryHwndPrev = fore_win; // Update unconditionally in case it's NULL.
2965 if (++g_KeyHistoryNext >= g_MaxHistoryKeys)
2966 g_KeyHistoryNext = 0;
2967}
2968
2969
2970

Callers 2

PlaybackProcFunction · 0.85
KeyEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected