-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwindowapi.h
More file actions
46 lines (36 loc) · 1.13 KB
/
windowapi.h
File metadata and controls
46 lines (36 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef WINDOWAPI_H
#define WINDOWAPI_H
#include <Windows.h>
#include <QSharedPointer>
#include "iwindowapi.h"
#include <QObject>
#define KEY_J 0x4A
#define KEY_ALT 164
class WindowApi : public IWindowApi
{
Q_OBJECT
private:
static inline HHOOK keyboardProcHook;
static inline bool isKeyJPressedDown = false;
static inline bool isKeyAltPressedDown = false;
WindowApi(){};
~WindowApi(){ cleanUp();};
public:
static WindowApi& instance(){
static WindowApi instance;
if(keyboardProcHook == nullptr){
keyboardProcHook = instance.SetWindowsHookExInvoke((int)WH_KEYBOARD_LL, detectKeys, 0, 0);
}
return instance;
};
static LRESULT CALLBACK detectKeys(int code, WPARAM wParam, LPARAM lParam);
HHOOK SetWindowsHookExInvoke(int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId) override;
BOOL UnhookWindowsHookExInoke(HHOOK hhk) override;
LRESULT CallNextHookExInvoke(HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam) override;
WId GetForegroundWindowInvoke() override;
signals:
void showApp();
protected:
void cleanUp();
};
#endif // WINDOWAPI_H