-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-// engine.h
-
-
-#ifndef _ENGINE_H
-# define _ENGINE_H
-
-# include "multithread.h"
-# include "setting.h"
-# include "msgstream.h"
-# include <set>
-# include <queue>
-
-
-enum
-{
- ///
- WM_APP_engineNotify = WM_APP + 110,
-};
-
-
-///
-enum EngineNotify
-{
- EngineNotify_shellExecute, ///
- EngineNotify_loadSetting, ///
- EngineNotify_showDlg, ///
- EngineNotify_helpMessage, ///
- EngineNotify_setForegroundWindow, ///
- EngineNotify_clearLog, ///
-};
-
-
-///
-class Engine
-{
-private:
- enum
- {
- MAX_GENERATE_KEYBOARD_EVENTS_RECURSION_COUNT = 64, ///
- MAX_KEYMAP_PREFIX_HISTORY = 64, ///
- };
-
- typedef Keymaps::KeymapPtrList KeymapPtrList; ///
-
- /// focus of a thread
- class FocusOfThread
- {
- public:
- DWORD m_threadId; /// thread id
- HWND m_hwndFocus; /** window that has focus on
- the thread */
- tstringi m_className; /// class name of hwndFocus
- tstringi m_titleName; /// title name of hwndFocus
- bool m_isConsole; /// is hwndFocus console ?
- KeymapPtrList m_keymaps; /// keymaps
-
- public:
- ///
- FocusOfThread() : m_threadId(0), m_hwndFocus(NULL), m_isConsole(false) { }
- };
- typedef std::map<DWORD /*ThreadId*/, FocusOfThread> FocusOfThreads; ///
-
- typedef std::list<DWORD /*ThreadId*/> DetachedThreadIds; ///
-
- /// current status in generateKeyboardEvents
- class Current
- {
- public:
- const Keymap *m_keymap; /// current keymap
- ModifiedKey m_mkey; /// current processing key that user inputed
- /// index in currentFocusOfThread->keymaps
- Keymaps::KeymapPtrList::iterator m_i;
-
- public:
- ///
- bool isPressed() const
- { return m_mkey.m_modifier.isOn(Modifier::Type_Down); }
- };
-
- friend class FunctionParam;
-
- /// part of keySeq
- enum Part
- {
- Part_all, ///
- Part_up, ///
- Part_down, ///
- };
-
- ///
- class EmacsEditKillLine
- {
- tstring m_buf; /// previous kill-line contents
-
- public:
- bool m_doForceReset; ///
-
- private:
- ///
- HGLOBAL makeNewKillLineBuf(const _TCHAR *i_data, int *i_retval);
-
- public:
- ///
- void reset() { m_buf.resize(0); }
- /** EmacsEditKillLineFunc.
- clear the contents of the clopboard
- at that time, confirm if it is the result of the previous kill-line
- */
- void func();
- /// EmacsEditKillLinePred
- int pred();
- };
-
- /// window positon for &WindowHMaximize, &WindowVMaximize
- class WindowPosition
- {
- public:
- ///
- enum Mode
- {
- Mode_normal, ///
- Mode_H, ///
- Mode_V, ///
- Mode_HV, ///
- };
-
- public:
- HWND m_hwnd; ///
- RECT m_rc; ///
- Mode m_mode; ///
-
- public:
- ///
- WindowPosition(HWND i_hwnd, const RECT &i_rc, Mode i_mode)
- : m_hwnd(i_hwnd), m_rc(i_rc), m_mode(i_mode) { }
- };
- typedef std::list<WindowPosition> WindowPositions;
-
- typedef std::list<HWND> WindowsWithAlpha; /// windows for &WindowSetAlpha
-
- enum InterruptThreadReason
- {
- InterruptThreadReason_Terminate,
- InterruptThreadReason_Pause,
- InterruptThreadReason_Resume,
- };
-
-private:
- CriticalSection m_cs; /// criticalSection
-
- // setting
- HWND m_hwndAssocWindow; /** associated window (we post
- message to it) */
- Setting * volatile m_setting; /// setting
-
- // engine thread state
- HANDLE m_device; /// mayu device
- bool m_didMayuStartDevice; /** Did the mayu start the
- mayu-device ? */
- HANDLE m_threadEvent; /** 1. thread has been started
- 2. thread is about to end*/
- HANDLE m_threadHandle;
- unsigned m_threadId;
- tstring m_mayudVersion; /// version of mayud.sys
-#if defined(_WINNT)
-#ifdef NO_DRIVER
- std::deque<KEYBOARD_INPUT_DATA> m_kidq;
- CriticalSection m_cskidq;
-#endif // NO_DRIVER
- HANDLE m_readEvent; /** reading from mayu device
- has been completed */
- HANDLE m_interruptThreadEvent; /// interrupt thread event
- volatile InterruptThreadReason
- m_interruptThreadReason; /// interrupt thread reason
- OVERLAPPED m_ol; /** for async read/write of
- mayu device */
- HANDLE m_hookPipe; /// named pipe for &SetImeString
- HMODULE m_sts4mayu; /// DLL module for ThumbSense
- HMODULE m_cts4mayu; /// DLL module for ThumbSense
-#endif // _WINNT
- bool volatile m_doForceTerminate; /// terminate engine thread
- bool volatile m_isLogMode; /// is logging mode ?
- bool volatile m_isEnabled; /// is enabled ?
- bool volatile m_isSynchronizing; /// is synchronizing ?
- HANDLE m_eSync; /// event for synchronization
- int m_generateKeyboardEventsRecursionGuard; /** guard against too many
- recursion */
-
- // current key state
- Modifier m_currentLock; /// current lock key's state
- int m_currentKeyPressCount; /** how many keys are pressed
- phisically ? */
- int m_currentKeyPressCountOnWin32; /** how many keys are pressed
- on win32 ? */
- Key *m_lastGeneratedKey; /// last generated key
- Key *m_lastPressedKey[2]; /// last pressed key
- ModifiedKey m_oneShotKey; /// one shot key
- unsigned int m_oneShotRepeatableRepeatCount; /// repeat count of one shot key
- bool m_isPrefix; /// is prefix ?
- bool m_doesIgnoreModifierForPrefix; /** does ignore modifier key
- when prefixed ? */
- bool m_doesEditNextModifier; /** does edit next user input
- key's modifier ? */
- Modifier m_modifierForNextKey; /** modifier for next key if
- above is true */
-
- /** current keymaps.
- <dl>
- <dt>when &OtherWindowClass
- <dd>currentKeymap becoms currentKeymaps[++ Current::i]
- <dt>when &KeymapParent
- <dd>currentKeymap becoms currentKeyamp->parentKeymap
- <dt>other
- <dd>currentKeyamp becoms *Current::i
- </dl>
- */
- const Keymap * volatile m_currentKeymap; /// current keymap
- FocusOfThreads /*volatile*/ m_focusOfThreads; ///
- FocusOfThread * volatile m_currentFocusOfThread; ///
- FocusOfThread m_globalFocus; ///
- HWND m_hwndFocus; /// current focus window
- DetachedThreadIds m_detachedThreadIds; ///
-
- // for functions
- KeymapPtrList m_keymapPrefixHistory; /// for &KeymapPrevPrefix
- EmacsEditKillLine m_emacsEditKillLine; /// for &EmacsEditKillLine
- const ActionFunction *m_afShellExecute; /// for &ShellExecute
-
- WindowPositions m_windowPositions; ///
- WindowsWithAlpha m_windowsWithAlpha; ///
-
- tstring m_helpMessage; /// for &HelpMessage
- tstring m_helpTitle; /// for &HelpMessage
- int m_variable; /// for &Variable,
- /// &Repeat
-
-public:
- tomsgstream &m_log; /** log stream (output to log
- dialog's edit) */
-
-public:
-#ifdef NO_DRIVER
- /// keyboard handler thread
- static unsigned int WINAPI keyboardDetour(Engine *i_this, KBDLLHOOKSTRUCT *i_kid);
-private:
- ///
- unsigned int keyboardDetour(KBDLLHOOKSTRUCT *i_kid);
- ///
- unsigned int injectInput(const KEYBOARD_INPUT_DATA *i_kid, const KBDLLHOOKSTRUCT *i_kidRaw);
-#endif // NO_DRIVER
-
-private:
- /// keyboard handler thread
- static unsigned int WINAPI keyboardHandler(void *i_this);
- ///
- void keyboardHandler();
-
- /// check focus window
- void checkFocusWindow();
- /// is modifier pressed ?
- bool isPressed(Modifier::Type i_mt);
- /// fix modifier key
- bool fixModifierKey(ModifiedKey *io_mkey, Keymap::AssignMode *o_am);
-
- /// output to log
- void outputToLog(const Key *i_key, const ModifiedKey &i_mkey,
- int i_debugLevel);
-
- /// genete modifier events
- void generateModifierEvents(const Modifier &i_mod);
-
- /// genete event
- void generateEvents(Current i_c, const Keymap *i_keymap, Key *i_event);
-
- /// generate keyboard event
- void generateKeyEvent(Key *i_key, bool i_doPress, bool i_isByAssign);
- ///
- void generateActionEvents(const Current &i_c, const Action *i_a,
- bool i_doPress);
- ///
- void generateKeySeqEvents(const Current &i_c, const KeySeq *i_keySeq,
- Part i_part);
- ///
- void generateKeyboardEvents(const Current &i_c);
- ///
- void beginGeneratingKeyboardEvents(const Current &i_c, bool i_isModifier);
-
- /// pop all pressed key on win32
- void keyboardResetOnWin32();
-
- /// get current modifiers
- Modifier getCurrentModifiers(Key *i_key, bool i_isPressed);
-
- /// describe bindings
- void describeBindings();
-
- /// update m_lastPressedKey
- void updateLastPressedKey(Key *i_key);
-
- /// set current keymap
- void setCurrentKeymap(const Keymap *i_keymap,
- bool i_doesAddToHistory = false);
- /** open mayu device
- @return true if mayu device successfully is opened
- */
- bool open();
-
- /// close mayu device
- void close();
-
- /// load/unload [sc]ts4mayu.dll
- void manageTs4mayu(TCHAR *i_ts4mayuDllName, TCHAR *i_dependDllName,
- bool i_load, HMODULE *i_pTs4mayu);
-
-private:
- // BEGINING OF FUNCTION DEFINITION
- /// send a default key to Windows
- void funcDefault(FunctionParam *i_param);
- /// use a corresponding key of a parent keymap
- void funcKeymapParent(FunctionParam *i_param);
- /// use a corresponding key of a current window
- void funcKeymapWindow(FunctionParam *i_param);
- /// use a corresponding key of the previous prefixed keymap
- void funcKeymapPrevPrefix(FunctionParam *i_param, int i_previous);
- /// use a corresponding key of an other window class, or use a default key
- void funcOtherWindowClass(FunctionParam *i_param);
- /// prefix key
- void funcPrefix(FunctionParam *i_param, const Keymap *i_keymap,
- BooleanType i_doesIgnoreModifiers = BooleanType_true);
- /// other keymap's key
- void funcKeymap(FunctionParam *i_param, const Keymap *i_keymap);
- /// sync
- void funcSync(FunctionParam *i_param);
- /// toggle lock
- void funcToggle(FunctionParam *i_param, ModifierLockType i_lock,
- ToggleType i_toggle = ToggleType_toggle);
- /// edit next user input key's modifier
- void funcEditNextModifier(FunctionParam *i_param,
- const Modifier &i_modifier);
- /// variable
- void funcVariable(FunctionParam *i_param, int i_mag, int i_inc);
- /// repeat N times
- void funcRepeat(FunctionParam *i_param, const KeySeq *i_keySeq,
- int i_max = 10);
- /// undefined (bell)
- void funcUndefined(FunctionParam *i_param);
- /// ignore
- void funcIgnore(FunctionParam *i_param);
- /// post message
- void funcPostMessage(FunctionParam *i_param, ToWindowType i_window,
- UINT i_message, WPARAM i_wParam, LPARAM i_lParam);
- /// ShellExecute
- void funcShellExecute(FunctionParam *i_param, const StrExprArg &i_operation,
- const StrExprArg &i_file, const StrExprArg &i_parameters,
- const StrExprArg &i_directory,
- ShowCommandType i_showCommand);
- /// SetForegroundWindow
- void funcSetForegroundWindow(FunctionParam *i_param,
- const tregex &i_windowClassName,
- LogicalOperatorType i_logicalOp
- = LogicalOperatorType_and,
- const tregex &i_windowTitleName
- = tregex(_T(".*")));
- /// load setting
- void funcLoadSetting(FunctionParam *i_param,
- const StrExprArg &i_name = StrExprArg());
- /// virtual key
- void funcVK(FunctionParam *i_param, VKey i_vkey);
- /// wait
- void funcWait(FunctionParam *i_param, int i_milliSecond);
- /// investigate WM_COMMAND, WM_SYSCOMMAND
- void funcInvestigateCommand(FunctionParam *i_param);
- /// show mayu dialog box
- void funcMayuDialog(FunctionParam *i_param, MayuDialogType i_dialog,
- ShowCommandType i_showCommand);
- /// describe bindings
- void funcDescribeBindings(FunctionParam *i_param);
- /// show help message
- void funcHelpMessage(FunctionParam *i_param,
- const StrExprArg &i_title = StrExprArg(),
- const StrExprArg &i_message = StrExprArg());
- /// show variable
- void funcHelpVariable(FunctionParam *i_param, const StrExprArg &i_title);
- /// raise window
- void funcWindowRaise(FunctionParam *i_param,
- TargetWindowType i_twt = TargetWindowType_overlapped);
- /// lower window
- void funcWindowLower(FunctionParam *i_param,
- TargetWindowType i_twt = TargetWindowType_overlapped);
- /// minimize window
- void funcWindowMinimize(FunctionParam *i_param, TargetWindowType i_twt
- = TargetWindowType_overlapped);
- /// maximize window
- void funcWindowMaximize(FunctionParam *i_param, TargetWindowType i_twt
- = TargetWindowType_overlapped);
- /// maximize window horizontally
- void funcWindowHMaximize(FunctionParam *i_param, TargetWindowType i_twt
- = TargetWindowType_overlapped);
- /// maximize window virtically
- void funcWindowVMaximize(FunctionParam *i_param, TargetWindowType i_twt
- = TargetWindowType_overlapped);
- /// maximize window virtically or horizontally
- void funcWindowHVMaximize(FunctionParam *i_param, BooleanType i_isHorizontal,
- TargetWindowType i_twt
- = TargetWindowType_overlapped);
- /// move window
- void funcWindowMove(FunctionParam *i_param, int i_dx, int i_dy,
- TargetWindowType i_twt
- = TargetWindowType_overlapped);
- /// move window to ...
- void funcWindowMoveTo(FunctionParam *i_param, GravityType i_gravityType,
- int i_dx, int i_dy, TargetWindowType i_twt
- = TargetWindowType_overlapped);
- /// move window visibly
- void funcWindowMoveVisibly(FunctionParam *i_param,
- TargetWindowType i_twt
- = TargetWindowType_overlapped);
- /// move window to other monitor
- void funcWindowMonitorTo(FunctionParam *i_param,
- WindowMonitorFromType i_fromType, int i_monitor,
- BooleanType i_adjustPos = BooleanType_true,
- BooleanType i_adjustSize = BooleanType_false);
- /// move window to other monitor
- void funcWindowMonitor(FunctionParam *i_param, int i_monitor,
- BooleanType i_adjustPos = BooleanType_true,
- BooleanType i_adjustSize = BooleanType_false);
- ///
- void funcWindowClingToLeft(FunctionParam *i_param,
- TargetWindowType i_twt
- = TargetWindowType_overlapped);
- ///
- void funcWindowClingToRight(FunctionParam *i_param,
- TargetWindowType i_twt
- = TargetWindowType_overlapped);
- ///
- void funcWindowClingToTop(FunctionParam *i_param,
- TargetWindowType i_twt
- = TargetWindowType_overlapped);
- ///
- void funcWindowClingToBottom(FunctionParam *i_param,
- TargetWindowType i_twt
- = TargetWindowType_overlapped);
- /// close window
- void funcWindowClose(FunctionParam *i_param,
- TargetWindowType i_twt = TargetWindowType_overlapped);
- /// toggle top-most flag of the window
- void funcWindowToggleTopMost(FunctionParam *i_param);
- /// identify the window
- void funcWindowIdentify(FunctionParam *i_param);
- /// set alpha blending parameter to the window
- void funcWindowSetAlpha(FunctionParam *i_param, int i_alpha);
- /// redraw the window
- void funcWindowRedraw(FunctionParam *i_param);
- /// resize window to
- void funcWindowResizeTo(FunctionParam *i_param, int i_width, int i_height,
- TargetWindowType i_twt
- = TargetWindowType_overlapped);
- /// move the mouse cursor
- void funcMouseMove(FunctionParam *i_param, int i_dx, int i_dy);
- /// send a mouse-wheel-message to Windows
- void funcMouseWheel(FunctionParam *i_param, int i_delta);
- /// convert the contents of the Clipboard to upper case or lower case
- void funcClipboardChangeCase(FunctionParam *i_param,
- BooleanType i_doesConvertToUpperCase);
- /// convert the contents of the Clipboard to upper case
- void funcClipboardUpcaseWord(FunctionParam *i_param);
- /// convert the contents of the Clipboard to lower case
- void funcClipboardDowncaseWord(FunctionParam *i_param);
- /// set the contents of the Clipboard to the string
- void funcClipboardCopy(FunctionParam *i_param, const StrExprArg &i_text);
- ///
- void funcEmacsEditKillLinePred(FunctionParam *i_param,
- const KeySeq *i_keySeq1,
- const KeySeq *i_keySeq2);
- ///
- void funcEmacsEditKillLineFunc(FunctionParam *i_param);
- /// clear log
- void funcLogClear(FunctionParam *i_param);
- /// recenter
- void funcRecenter(FunctionParam *i_param);
- /// Direct SSTP
- void funcDirectSSTP(FunctionParam *i_param,
- const tregex &i_name,
- const StrExprArg &i_protocol,
- const std::list<tstringq> &i_headers);
- /// PlugIn
- void funcPlugIn(FunctionParam *i_param,
- const StrExprArg &i_dllName,
- const StrExprArg &i_funcName = StrExprArg(),
- const StrExprArg &i_funcParam = StrExprArg(),
- BooleanType i_doesCreateThread = BooleanType_false);
- /// set IME open status
- void funcSetImeStatus(FunctionParam *i_param, ToggleType i_toggle = ToggleType_toggle);
- /// set string to IME
- void funcSetImeString(FunctionParam *i_param, const StrExprArg &i_data);
- /// enter to mouse event hook mode
- void funcMouseHook(FunctionParam *i_param, MouseHookType i_hookType, int i_hookParam);
-
- // END OF FUNCTION DEFINITION
-# define FUNCTION_FRIEND
-# include "functions.h"
-# undef FUNCTION_FRIEND
-
-public:
- ///
- Engine(tomsgstream &i_log);
- ///
- ~Engine();
-
- /// start/stop keyboard handler thread
- void start();
- ///
- void stop();
-
- /// pause keyboard handler thread and close device
- bool pause();
-
- /// resume keyboard handler thread and re-open device
- bool resume();
-
- /// do some procedure before quit which must be done synchronously
- /// (i.e. not on WM_QUIT)
- bool prepairQuit();
-
- /// logging mode
- void enableLogMode(bool i_isLogMode = true) { m_isLogMode = i_isLogMode; }
- ///
- void disableLogMode() { m_isLogMode = false; }
-
- /// enable/disable engine
- void enable(bool i_isEnabled = true) { m_isEnabled = i_isEnabled; }
- ///
- void disable() { m_isEnabled = false; }
- ///
- bool getIsEnabled() const { return m_isEnabled; }
-
- /// associated window
- void setAssociatedWndow(HWND i_hwnd) { m_hwndAssocWindow = i_hwnd; }
-
- /// associated window
- HWND getAssociatedWndow() const { return m_hwndAssocWindow; }
-
- /// setting
- bool setSetting(Setting *i_setting);
-
- /// focus
- bool setFocus(HWND i_hwndFocus, DWORD i_threadId,
- const tstringi &i_className,
- const tstringi &i_titleName, bool i_isConsole);
-
- /// lock state
- bool setLockState(bool i_isNumLockToggled, bool i_isCapsLockToggled,
- bool i_isScrollLockToggled, bool i_isKanaLockToggled,
- bool i_isImeLockToggled, bool i_isImeCompToggled);
-
- /// show
- void checkShow(HWND i_hwnd);
- bool setShow(bool i_isMaximized, bool i_isMinimized, bool i_isMDI);
-
- /// sync
- bool syncNotify();
-
- /// thread detach notify
- bool threadDetachNotify(DWORD i_threadId);
-
- /// shell execute
- void shellExecute();
-
- /// get help message
- void getHelpMessages(tstring *o_helpMessage, tstring *o_helpTitle);
-
- /// command notify
- void commandNotify(HWND i_hwnd, UINT i_message, WPARAM i_wParam,
- LPARAM i_lParam);
-
- /// get current window class name
- const tstringi &getCurrentWindowClassName() const { return m_currentFocusOfThread->m_className; }
-
- /// get current window title name
- const tstringi &getCurrentWindowTitleName() const { return m_currentFocusOfThread->m_titleName; }
-
- /// get mayud version
- const tstring &getMayudVersion() const { return m_mayudVersion; }
-};
-
-
-///
-class FunctionParam
-{
-public:
- bool m_isPressed; /// is key pressed ?
- HWND m_hwnd; ///
- Engine::Current m_c; /// new context
- bool m_doesNeedEndl; /// need endl ?
- const ActionFunction *m_af; ///
-};
-
-
-#endif // !_ENGINE_H
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+// engine.h\r
+\r
+\r
+#ifndef _ENGINE_H\r
+# define _ENGINE_H\r
+\r
+# include "multithread.h"\r
+# include "setting.h"\r
+# include "msgstream.h"\r
+# include "hook.h"\r
+# include <set>\r
+# include <queue>\r
+\r
+\r
+enum {\r
+ ///\r
+ WM_APP_engineNotify = WM_APP + 110,\r
+};\r
+\r
+\r
+///\r
+enum EngineNotify {\r
+ EngineNotify_shellExecute, ///\r
+ EngineNotify_loadSetting, ///\r
+ EngineNotify_showDlg, ///\r
+ EngineNotify_helpMessage, ///\r
+ EngineNotify_setForegroundWindow, ///\r
+ EngineNotify_clearLog, ///\r
+};\r
+\r
+\r
+///\r
+class Engine\r
+{\r
+private:\r
+ enum {\r
+ MAX_GENERATE_KEYBOARD_EVENTS_RECURSION_COUNT = 64, ///\r
+ MAX_KEYMAP_PREFIX_HISTORY = 64, ///\r
+ };\r
+\r
+ typedef Keymaps::KeymapPtrList KeymapPtrList; ///\r
+\r
+ /// focus of a thread\r
+ class FocusOfThread\r
+ {\r
+ public:\r
+ DWORD m_threadId; /// thread id\r
+ HWND m_hwndFocus; /** window that has focus on\r
+ the thread */\r
+ tstringi m_className; /// class name of hwndFocus\r
+ tstringi m_titleName; /// title name of hwndFocus\r
+ bool m_isConsole; /// is hwndFocus console ?\r
+ KeymapPtrList m_keymaps; /// keymaps\r
+\r
+ public:\r
+ ///\r
+ FocusOfThread() : m_threadId(0), m_hwndFocus(NULL), m_isConsole(false) { }\r
+ };\r
+ typedef std::map<DWORD /*ThreadId*/, FocusOfThread> FocusOfThreads; ///\r
+\r
+ typedef std::list<DWORD /*ThreadId*/> ThreadIds; ///\r
+\r
+ /// current status in generateKeyboardEvents\r
+ class Current\r
+ {\r
+ public:\r
+ const Keymap *m_keymap; /// current keymap\r
+ ModifiedKey m_mkey; /// current processing key that user inputed\r
+ /// index in currentFocusOfThread->keymaps\r
+ Keymaps::KeymapPtrList::iterator m_i;\r
+\r
+ public:\r
+ ///\r
+ bool isPressed() const {\r
+ return m_mkey.m_modifier.isOn(Modifier::Type_Down);\r
+ }\r
+ };\r
+\r
+ friend class FunctionParam;\r
+\r
+ /// part of keySeq\r
+ enum Part {\r
+ Part_all, ///\r
+ Part_up, ///\r
+ Part_down, ///\r
+ };\r
+\r
+ ///\r
+ class EmacsEditKillLine\r
+ {\r
+ tstring m_buf; /// previous kill-line contents\r
+\r
+ public:\r
+ bool m_doForceReset; ///\r
+\r
+ private:\r
+ ///\r
+ HGLOBAL makeNewKillLineBuf(const _TCHAR *i_data, int *i_retval);\r
+\r
+ public:\r
+ ///\r
+ void reset() {\r
+ m_buf.resize(0);\r
+ }\r
+ /** EmacsEditKillLineFunc.\r
+ clear the contents of the clopboard\r
+ at that time, confirm if it is the result of the previous kill-line\r
+ */\r
+ void func();\r
+ /// EmacsEditKillLinePred\r
+ int pred();\r
+ };\r
+\r
+ /// window positon for &WindowHMaximize, &WindowVMaximize\r
+ class WindowPosition\r
+ {\r
+ public:\r
+ ///\r
+ enum Mode {\r
+ Mode_normal, ///\r
+ Mode_H, ///\r
+ Mode_V, ///\r
+ Mode_HV, ///\r
+ };\r
+\r
+ public:\r
+ HWND m_hwnd; ///\r
+ RECT m_rc; ///\r
+ Mode m_mode; ///\r
+\r
+ public:\r
+ ///\r
+ WindowPosition(HWND i_hwnd, const RECT &i_rc, Mode i_mode)\r
+ : m_hwnd(i_hwnd), m_rc(i_rc), m_mode(i_mode) { }\r
+ };\r
+ typedef std::list<WindowPosition> WindowPositions;\r
+\r
+ typedef std::list<HWND> WindowsWithAlpha; /// windows for &WindowSetAlpha\r
+\r
+ enum InterruptThreadReason {\r
+ InterruptThreadReason_Terminate,\r
+ InterruptThreadReason_Pause,\r
+ InterruptThreadReason_Resume,\r
+ };\r
+\r
+ ///\r
+ class InputHandler {\r
+ public:\r
+ typedef int (*INSTALL_HOOK)(INPUT_DETOUR i_keyboardDetour, Engine *i_engine, bool i_install);\r
+\r
+ static unsigned int WINAPI run(void *i_this);\r
+\r
+ InputHandler(INSTALL_HOOK i_installHook, INPUT_DETOUR i_inputDetour);\r
+\r
+ ~InputHandler();\r
+\r
+ void run();\r
+\r
+ int start(Engine *i_engine);\r
+\r
+ int stop();\r
+\r
+ private:\r
+ unsigned m_threadId;\r
+ HANDLE m_hThread;\r
+ HANDLE m_hEvent; \r
+ INSTALL_HOOK m_installHook;\r
+ INPUT_DETOUR m_inputDetour;\r
+ Engine *m_engine;\r
+ };\r
+\r
+private:\r
+ CriticalSection m_cs; /// criticalSection\r
+\r
+ // setting\r
+ HWND m_hwndAssocWindow; /** associated window (we post\r
+ message to it) */\r
+ Setting * volatile m_setting; /// setting\r
+\r
+ // engine thread state\r
+ HANDLE m_threadHandle;\r
+ unsigned m_threadId;\r
+ std::deque<KEYBOARD_INPUT_DATA> *m_inputQueue;\r
+ HANDLE m_queueMutex;\r
+ MSLLHOOKSTRUCT m_msllHookCurrent;\r
+ bool m_buttonPressed;\r
+ bool m_dragging;\r
+ InputHandler m_keyboardHandler;\r
+ InputHandler m_mouseHandler;\r
+ HANDLE m_readEvent; /** reading from mayu device\r
+ has been completed */\r
+ OVERLAPPED m_ol; /** for async read/write of\r
+ mayu device */\r
+ HANDLE m_hookPipe; /// named pipe for &SetImeString\r
+ HMODULE m_sts4mayu; /// DLL module for ThumbSense\r
+ HMODULE m_cts4mayu; /// DLL module for ThumbSense\r
+ bool volatile m_isLogMode; /// is logging mode ?\r
+ bool volatile m_isEnabled; /// is enabled ?\r
+ bool volatile m_isSynchronizing; /// is synchronizing ?\r
+ HANDLE m_eSync; /// event for synchronization\r
+ int m_generateKeyboardEventsRecursionGuard; /** guard against too many\r
+ recursion */\r
+\r
+ // current key state\r
+ Modifier m_currentLock; /// current lock key's state\r
+ int m_currentKeyPressCount; /** how many keys are pressed\r
+ phisically ? */\r
+ int m_currentKeyPressCountOnWin32; /** how many keys are pressed\r
+ on win32 ? */\r
+ Key *m_lastGeneratedKey; /// last generated key\r
+ Key *m_lastPressedKey[2]; /// last pressed key\r
+ ModifiedKey m_oneShotKey; /// one shot key\r
+ unsigned int m_oneShotRepeatableRepeatCount; /// repeat count of one shot key\r
+ bool m_isPrefix; /// is prefix ?\r
+ bool m_doesIgnoreModifierForPrefix; /** does ignore modifier key\r
+ when prefixed ? */\r
+ bool m_doesEditNextModifier; /** does edit next user input\r
+ key's modifier ? */\r
+ Modifier m_modifierForNextKey; /** modifier for next key if\r
+ above is true */\r
+\r
+ /** current keymaps.\r
+ <dl>\r
+ <dt>when &OtherWindowClass\r
+ <dd>currentKeymap becoms currentKeymaps[++ Current::i]\r
+ <dt>when &KeymapParent\r
+ <dd>currentKeymap becoms currentKeyamp->parentKeymap\r
+ <dt>other\r
+ <dd>currentKeyamp becoms *Current::i\r
+ </dl>\r
+ */\r
+ const Keymap * volatile m_currentKeymap; /// current keymap\r
+ FocusOfThreads /*volatile*/ m_focusOfThreads; ///\r
+ FocusOfThread * volatile m_currentFocusOfThread; ///\r
+ FocusOfThread m_globalFocus; ///\r
+ HWND m_hwndFocus; /// current focus window\r
+ ThreadIds m_attachedThreadIds; ///\r
+ ThreadIds m_detachedThreadIds; ///\r
+\r
+ // for functions\r
+ KeymapPtrList m_keymapPrefixHistory; /// for &KeymapPrevPrefix\r
+ EmacsEditKillLine m_emacsEditKillLine; /// for &EmacsEditKillLine\r
+ const ActionFunction *m_afShellExecute; /// for &ShellExecute\r
+\r
+ WindowPositions m_windowPositions; ///\r
+ WindowsWithAlpha m_windowsWithAlpha; ///\r
+\r
+ tstring m_helpMessage; /// for &HelpMessage\r
+ tstring m_helpTitle; /// for &HelpMessage\r
+ int m_variable; /// for &Variable,\r
+ /// &Repeat\r
+\r
+public:\r
+ tomsgstream &m_log; /** log stream (output to log\r
+ dialog's edit) */\r
+\r
+public:\r
+ /// keyboard handler thread\r
+ static unsigned int WINAPI keyboardDetour(Engine *i_this, WPARAM i_wParam, LPARAM i_lParam);\r
+ /// mouse handler thread\r
+ static unsigned int WINAPI mouseDetour(Engine *i_this, WPARAM i_wParam, LPARAM i_lParam);\r
+private:\r
+ ///\r
+ unsigned int keyboardDetour(KBDLLHOOKSTRUCT *i_kid);\r
+ ///\r
+ unsigned int mouseDetour(WPARAM i_message, MSLLHOOKSTRUCT *i_mid);\r
+ ///\r
+ unsigned int injectInput(const KEYBOARD_INPUT_DATA *i_kid, const KBDLLHOOKSTRUCT *i_kidRaw);\r
+\r
+private:\r
+ /// keyboard handler thread\r
+ static unsigned int WINAPI keyboardHandler(void *i_this);\r
+ ///\r
+ void keyboardHandler();\r
+\r
+ /// check focus window\r
+ void checkFocusWindow();\r
+ /// is modifier pressed ?\r
+ bool isPressed(Modifier::Type i_mt);\r
+ /// fix modifier key\r
+ bool fixModifierKey(ModifiedKey *io_mkey, Keymap::AssignMode *o_am);\r
+\r
+ /// output to log\r
+ void outputToLog(const Key *i_key, const ModifiedKey &i_mkey,\r
+ int i_debugLevel);\r
+\r
+ /// genete modifier events\r
+ void generateModifierEvents(const Modifier &i_mod);\r
+\r
+ /// genete event\r
+ void generateEvents(Current i_c, const Keymap *i_keymap, Key *i_event);\r
+\r
+ /// generate keyboard event\r
+ void generateKeyEvent(Key *i_key, bool i_doPress, bool i_isByAssign);\r
+ ///\r
+ void generateActionEvents(const Current &i_c, const Action *i_a,\r
+ bool i_doPress);\r
+ ///\r
+ void generateKeySeqEvents(const Current &i_c, const KeySeq *i_keySeq,\r
+ Part i_part);\r
+ ///\r
+ void generateKeyboardEvents(const Current &i_c);\r
+ ///\r
+ void beginGeneratingKeyboardEvents(const Current &i_c, bool i_isModifier);\r
+\r
+ /// pop all pressed key on win32\r
+ void keyboardResetOnWin32();\r
+\r
+ /// get current modifiers\r
+ Modifier getCurrentModifiers(Key *i_key, bool i_isPressed);\r
+\r
+ /// describe bindings\r
+ void describeBindings();\r
+\r
+ /// update m_lastPressedKey\r
+ void updateLastPressedKey(Key *i_key);\r
+\r
+ /// set current keymap\r
+ void setCurrentKeymap(const Keymap *i_keymap,\r
+ bool i_doesAddToHistory = false);\r
+ /** open mayu device\r
+ @return true if mayu device successfully is opened\r
+ */\r
+ bool open();\r
+\r
+ /// close mayu device\r
+ void close();\r
+\r
+ /// load/unload [sc]ts4mayu.dll\r
+ void manageTs4mayu(TCHAR *i_ts4mayuDllName, TCHAR *i_dependDllName,\r
+ bool i_load, HMODULE *i_pTs4mayu);\r
+\r
+private:\r
+ // BEGINING OF FUNCTION DEFINITION\r
+ /// send a default key to Windows\r
+ void funcDefault(FunctionParam *i_param);\r
+ /// use a corresponding key of a parent keymap\r
+ void funcKeymapParent(FunctionParam *i_param);\r
+ /// use a corresponding key of a current window\r
+ void funcKeymapWindow(FunctionParam *i_param);\r
+ /// use a corresponding key of the previous prefixed keymap\r
+ void funcKeymapPrevPrefix(FunctionParam *i_param, int i_previous);\r
+ /// use a corresponding key of an other window class, or use a default key\r
+ void funcOtherWindowClass(FunctionParam *i_param);\r
+ /// prefix key\r
+ void funcPrefix(FunctionParam *i_param, const Keymap *i_keymap,\r
+ BooleanType i_doesIgnoreModifiers = BooleanType_true);\r
+ /// other keymap's key\r
+ void funcKeymap(FunctionParam *i_param, const Keymap *i_keymap);\r
+ /// sync\r
+ void funcSync(FunctionParam *i_param);\r
+ /// toggle lock\r
+ void funcToggle(FunctionParam *i_param, ModifierLockType i_lock,\r
+ ToggleType i_toggle = ToggleType_toggle);\r
+ /// edit next user input key's modifier\r
+ void funcEditNextModifier(FunctionParam *i_param,\r
+ const Modifier &i_modifier);\r
+ /// variable\r
+ void funcVariable(FunctionParam *i_param, int i_mag, int i_inc);\r
+ /// repeat N times\r
+ void funcRepeat(FunctionParam *i_param, const KeySeq *i_keySeq,\r
+ int i_max = 10);\r
+ /// undefined (bell)\r
+ void funcUndefined(FunctionParam *i_param);\r
+ /// ignore\r
+ void funcIgnore(FunctionParam *i_param);\r
+ /// post message\r
+ void funcPostMessage(FunctionParam *i_param, ToWindowType i_window,\r
+ UINT i_message, WPARAM i_wParam, LPARAM i_lParam);\r
+ /// ShellExecute\r
+ void funcShellExecute(FunctionParam *i_param, const StrExprArg &i_operation,\r
+ const StrExprArg &i_file, const StrExprArg &i_parameters,\r
+ const StrExprArg &i_directory,\r
+ ShowCommandType i_showCommand);\r
+ /// SetForegroundWindow\r
+ void funcSetForegroundWindow(FunctionParam *i_param,\r
+ const tregex &i_windowClassName,\r
+ LogicalOperatorType i_logicalOp\r
+ = LogicalOperatorType_and,\r
+ const tregex &i_windowTitleName\r
+ = tregex(_T(".*")));\r
+ /// load setting\r
+ void funcLoadSetting(FunctionParam *i_param,\r
+ const StrExprArg &i_name = StrExprArg());\r
+ /// virtual key\r
+ void funcVK(FunctionParam *i_param, VKey i_vkey);\r
+ /// wait\r
+ void funcWait(FunctionParam *i_param, int i_milliSecond);\r
+ /// investigate WM_COMMAND, WM_SYSCOMMAND\r
+ void funcInvestigateCommand(FunctionParam *i_param);\r
+ /// show mayu dialog box\r
+ void funcMayuDialog(FunctionParam *i_param, MayuDialogType i_dialog,\r
+ ShowCommandType i_showCommand);\r
+ /// describe bindings\r
+ void funcDescribeBindings(FunctionParam *i_param);\r
+ /// show help message\r
+ void funcHelpMessage(FunctionParam *i_param,\r
+ const StrExprArg &i_title = StrExprArg(),\r
+ const StrExprArg &i_message = StrExprArg());\r
+ /// show variable\r
+ void funcHelpVariable(FunctionParam *i_param, const StrExprArg &i_title);\r
+ /// raise window\r
+ void funcWindowRaise(FunctionParam *i_param,\r
+ TargetWindowType i_twt = TargetWindowType_overlapped);\r
+ /// lower window\r
+ void funcWindowLower(FunctionParam *i_param,\r
+ TargetWindowType i_twt = TargetWindowType_overlapped);\r
+ /// minimize window\r
+ void funcWindowMinimize(FunctionParam *i_param, TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ /// maximize window\r
+ void funcWindowMaximize(FunctionParam *i_param, TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ /// maximize window horizontally\r
+ void funcWindowHMaximize(FunctionParam *i_param, TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ /// maximize window virtically\r
+ void funcWindowVMaximize(FunctionParam *i_param, TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ /// maximize window virtically or horizontally\r
+ void funcWindowHVMaximize(FunctionParam *i_param, BooleanType i_isHorizontal,\r
+ TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ /// move window\r
+ void funcWindowMove(FunctionParam *i_param, int i_dx, int i_dy,\r
+ TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ /// move window to ...\r
+ void funcWindowMoveTo(FunctionParam *i_param, GravityType i_gravityType,\r
+ int i_dx, int i_dy, TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ /// move window visibly\r
+ void funcWindowMoveVisibly(FunctionParam *i_param,\r
+ TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ /// move window to other monitor\r
+ void funcWindowMonitorTo(FunctionParam *i_param,\r
+ WindowMonitorFromType i_fromType, int i_monitor,\r
+ BooleanType i_adjustPos = BooleanType_true,\r
+ BooleanType i_adjustSize = BooleanType_false);\r
+ /// move window to other monitor\r
+ void funcWindowMonitor(FunctionParam *i_param, int i_monitor,\r
+ BooleanType i_adjustPos = BooleanType_true,\r
+ BooleanType i_adjustSize = BooleanType_false);\r
+ ///\r
+ void funcWindowClingToLeft(FunctionParam *i_param,\r
+ TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ ///\r
+ void funcWindowClingToRight(FunctionParam *i_param,\r
+ TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ ///\r
+ void funcWindowClingToTop(FunctionParam *i_param,\r
+ TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ ///\r
+ void funcWindowClingToBottom(FunctionParam *i_param,\r
+ TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ /// close window\r
+ void funcWindowClose(FunctionParam *i_param,\r
+ TargetWindowType i_twt = TargetWindowType_overlapped);\r
+ /// toggle top-most flag of the window\r
+ void funcWindowToggleTopMost(FunctionParam *i_param);\r
+ /// identify the window\r
+ void funcWindowIdentify(FunctionParam *i_param);\r
+ /// set alpha blending parameter to the window\r
+ void funcWindowSetAlpha(FunctionParam *i_param, int i_alpha);\r
+ /// redraw the window\r
+ void funcWindowRedraw(FunctionParam *i_param);\r
+ /// resize window to\r
+ void funcWindowResizeTo(FunctionParam *i_param, int i_width, int i_height,\r
+ TargetWindowType i_twt\r
+ = TargetWindowType_overlapped);\r
+ /// move the mouse cursor\r
+ void funcMouseMove(FunctionParam *i_param, int i_dx, int i_dy);\r
+ /// send a mouse-wheel-message to Windows\r
+ void funcMouseWheel(FunctionParam *i_param, int i_delta);\r
+ /// convert the contents of the Clipboard to upper case or lower case\r
+ void funcClipboardChangeCase(FunctionParam *i_param,\r
+ BooleanType i_doesConvertToUpperCase);\r
+ /// convert the contents of the Clipboard to upper case\r
+ void funcClipboardUpcaseWord(FunctionParam *i_param);\r
+ /// convert the contents of the Clipboard to lower case\r
+ void funcClipboardDowncaseWord(FunctionParam *i_param);\r
+ /// set the contents of the Clipboard to the string\r
+ void funcClipboardCopy(FunctionParam *i_param, const StrExprArg &i_text);\r
+ ///\r
+ void funcEmacsEditKillLinePred(FunctionParam *i_param,\r
+ const KeySeq *i_keySeq1,\r
+ const KeySeq *i_keySeq2);\r
+ ///\r
+ void funcEmacsEditKillLineFunc(FunctionParam *i_param);\r
+ /// clear log\r
+ void funcLogClear(FunctionParam *i_param);\r
+ /// recenter\r
+ void funcRecenter(FunctionParam *i_param);\r
+ /// Direct SSTP\r
+ void funcDirectSSTP(FunctionParam *i_param,\r
+ const tregex &i_name,\r
+ const StrExprArg &i_protocol,\r
+ const std::list<tstringq> &i_headers);\r
+ /// PlugIn\r
+ void funcPlugIn(FunctionParam *i_param,\r
+ const StrExprArg &i_dllName,\r
+ const StrExprArg &i_funcName = StrExprArg(),\r
+ const StrExprArg &i_funcParam = StrExprArg(),\r
+ BooleanType i_doesCreateThread = BooleanType_false);\r
+ /// set IME open status\r
+ void funcSetImeStatus(FunctionParam *i_param, ToggleType i_toggle = ToggleType_toggle);\r
+ /// set string to IME\r
+ void funcSetImeString(FunctionParam *i_param, const StrExprArg &i_data);\r
+ /// enter to mouse event hook mode\r
+ void funcMouseHook(FunctionParam *i_param, MouseHookType i_hookType, int i_hookParam);\r
+ /// cancel prefix\r
+ void funcCancelPrefix(FunctionParam *i_param);\r
+\r
+ // END OF FUNCTION DEFINITION\r
+# define FUNCTION_FRIEND\r
+# include "functions.h"\r
+# undef FUNCTION_FRIEND\r
+\r
+public:\r
+ ///\r
+ Engine(tomsgstream &i_log);\r
+ ///\r
+ ~Engine();\r
+\r
+ /// start/stop keyboard handler thread\r
+ void start();\r
+ ///\r
+ void stop();\r
+\r
+ /// pause keyboard handler thread and close device\r
+ bool pause();\r
+\r
+ /// resume keyboard handler thread and re-open device\r
+ bool resume();\r
+\r
+ /// do some procedure before quit which must be done synchronously\r
+ /// (i.e. not on WM_QUIT)\r
+ bool prepairQuit();\r
+\r
+ /// logging mode\r
+ void enableLogMode(bool i_isLogMode = true) {\r
+ m_isLogMode = i_isLogMode;\r
+ }\r
+ ///\r
+ void disableLogMode() {\r
+ m_isLogMode = false;\r
+ }\r
+\r
+ /// enable/disable engine\r
+ void enable(bool i_isEnabled = true) {\r
+ m_isEnabled = i_isEnabled;\r
+ }\r
+ ///\r
+ void disable() {\r
+ m_isEnabled = false;\r
+ }\r
+ ///\r
+ bool getIsEnabled() const {\r
+ return m_isEnabled;\r
+ }\r
+\r
+ /// associated window\r
+ void setAssociatedWndow(HWND i_hwnd) {\r
+ m_hwndAssocWindow = i_hwnd;\r
+ }\r
+\r
+ /// associated window\r
+ HWND getAssociatedWndow() const {\r
+ return m_hwndAssocWindow;\r
+ }\r
+\r
+ /// setting\r
+ bool setSetting(Setting *i_setting);\r
+\r
+ /// focus\r
+ bool setFocus(HWND i_hwndFocus, DWORD i_threadId,\r
+ const tstringi &i_className,\r
+ const tstringi &i_titleName, bool i_isConsole);\r
+\r
+ /// lock state\r
+ bool setLockState(bool i_isNumLockToggled, bool i_isCapsLockToggled,\r
+ bool i_isScrollLockToggled, bool i_isKanaLockToggled,\r
+ bool i_isImeLockToggled, bool i_isImeCompToggled);\r
+\r
+ /// show\r
+ void checkShow(HWND i_hwnd);\r
+ bool setShow(bool i_isMaximized, bool i_isMinimized, bool i_isMDI);\r
+\r
+ /// sync\r
+ bool syncNotify();\r
+\r
+ /// thread attach notify\r
+ bool threadAttachNotify(DWORD i_threadId);\r
+\r
+ /// thread detach notify\r
+ bool threadDetachNotify(DWORD i_threadId);\r
+\r
+ /// shell execute\r
+ void shellExecute();\r
+\r
+ /// get help message\r
+ void getHelpMessages(tstring *o_helpMessage, tstring *o_helpTitle);\r
+\r
+ /// command notify\r
+ template <typename WPARAM_T, typename LPARAM_T>\r
+ void commandNotify(HWND i_hwnd, UINT i_message, WPARAM_T i_wParam,\r
+ LPARAM_T i_lParam)\r
+ {\r
+ Acquire b(&m_log, 0);\r
+ HWND hf = m_hwndFocus;\r
+ if (!hf)\r
+ return;\r
+\r
+ if (GetWindowThreadProcessId(hf, NULL) ==\r
+ GetWindowThreadProcessId(m_hwndAssocWindow, NULL))\r
+ return; // inhibit the investigation of MADO TSUKAI NO YUUTSU\r
+\r
+ const _TCHAR *target = NULL;\r
+ int number_target = 0;\r
+\r
+ if (i_hwnd == hf)\r
+ target = _T("ToItself");\r
+ else if (i_hwnd == GetParent(hf))\r
+ target = _T("ToParentWindow");\r
+ else {\r
+ // Function::toMainWindow\r
+ HWND h = hf;\r
+ while (true) {\r
+ HWND p = GetParent(h);\r
+ if (!p)\r
+ break;\r
+ h = p;\r
+ }\r
+ if (i_hwnd == h)\r
+ target = _T("ToMainWindow");\r
+ else {\r
+ // Function::toOverlappedWindow\r
+ HWND h = hf;\r
+ while (h) {\r
+#ifdef MAYU64\r
+ LONG_PTR style = GetWindowLongPtr(h, GWL_STYLE);\r
+#else\r
+ LONG style = GetWindowLong(h, GWL_STYLE);\r
+#endif\r
+ if ((style & WS_CHILD) == 0)\r
+ break;\r
+ h = GetParent(h);\r
+ }\r
+ if (i_hwnd == h)\r
+ target = _T("ToOverlappedWindow");\r
+ else {\r
+ // number\r
+ HWND h = hf;\r
+ for (number_target = 0; h; number_target ++, h = GetParent(h))\r
+ if (i_hwnd == h)\r
+ break;\r
+ return;\r
+ }\r
+ }\r
+ }\r
+\r
+ m_log << _T("&PostMessage(");\r
+ if (target)\r
+ m_log << target;\r
+ else\r
+ m_log << number_target;\r
+ m_log << _T(", ") << i_message\r
+ << _T(", 0x") << std::hex << i_wParam\r
+ << _T(", 0x") << i_lParam << _T(") # hwnd = ")\r
+ << reinterpret_cast<int>(i_hwnd) << _T(", ")\r
+ << _T("message = ") << std::dec;\r
+ if (i_message == WM_COMMAND)\r
+ m_log << _T("WM_COMMAND, ");\r
+ else if (i_message == WM_SYSCOMMAND)\r
+ m_log << _T("WM_SYSCOMMAND, ");\r
+ else\r
+ m_log << i_message << _T(", ");\r
+ m_log << _T("wNotifyCode = ") << HIWORD(i_wParam) << _T(", ")\r
+ << _T("wID = ") << LOWORD(i_wParam) << _T(", ")\r
+ << _T("hwndCtrl = 0x") << std::hex << i_lParam << std::dec << std::endl;\r
+ }\r
+\r
+ /// get current window class name\r
+ const tstringi &getCurrentWindowClassName() const {\r
+ return m_currentFocusOfThread->m_className;\r
+ }\r
+\r
+ /// get current window title name\r
+ const tstringi &getCurrentWindowTitleName() const {\r
+ return m_currentFocusOfThread->m_titleName;\r
+ }\r
+};\r
+\r
+\r
+///\r
+class FunctionParam\r
+{\r
+public:\r
+ bool m_isPressed; /// is key pressed ?\r
+ HWND m_hwnd; ///\r
+ Engine::Current m_c; /// new context\r
+ bool m_doesNeedEndl; /// need endl ?\r
+ const ActionFunction *m_af; ///\r
+};\r
+\r
+\r
+#endif // !_ENGINE_H\r