MacroBinds/WindowFinder/windowfinder.h
Jamie Greunbaum d418424c14 - Keys are now parsed from a QKeySequence and converted to Win32 input events.
- Dial rotations send a simultaneous press-release event.
2024-09-17 16:55:02 -04:00

68 lines
1.4 KiB
C++

#ifndef WINDOWFINDER_H
#define WINDOWFINDER_H
#include <QMetaType>
#include <QString>
#ifdef Q_OS_WIN
#include "win32/windowfinderkeymap.h"
#endif // Q_OS_WIN
#ifdef Q_OS_WIN
struct IconDirEntry
{
quint8 nWidth;
quint8 nHeight;
quint8 nNumColorsInPalette;
quint8 nReserved;
qint16 nNumColorPlanes;
qint16 nBitsPerPixel;
quint32 nDataLength;
quint32 nOffset;
};
#endif // Q_OS_WIN
enum class KeyEventType : qint8 {
PRESS,
RELEASE,
PRESS_AND_RELEASE
};
Q_DECLARE_METATYPE(KeyEventType)
class WindowData
{
public:
WindowData() = default;
~WindowData() = default;
WindowData(const WindowData &) = default;
WindowData &operator=(const WindowData &) = default;
void importDataFromSetting(const QString &value);
QString processName = "";
QString processPath = "";
QString processWindowTitle = "";
};
Q_DECLARE_METATYPE(WindowData);
class WindowFinder
{
public:
WindowFinder();
static WindowData getFrontmostWindowProcess();
static void sendInputToFrontmostWindow(const QKeySequence &keys, const KeyEventType &type);
private:
#ifdef Q_OS_WIN
static WindowData getWin32FrontmostWindowProcess();
// static bool getWin32IconData(HICON hIcon, int nColorBits, QByteArray &buffer);
static void sendWin32InputToFrontmostWindow(const QKeySequence &keys, const KeyEventType &type);
static void sendWin32InputEvent(const Qt::Key &key, const KeyEventType &type);
#endif // Q_OS_WIN
};
#endif // WINDOWFINDER_H