Пример #1
0
        /// <summary>Adds a mouse event to the queue, with no movement in mouse location.  Data param only needed for wheel/XUP/XDOWN events</summary>
        public virtual void AddMouseEvent(Windows.MOUSEEVENTF eventType, int mouseData = 0)
        {
            Debug.Assert((eventType & Windows.MOUSEEVENTF.ABSOLUTE) == 0);             // should be relative (as we will supply coords = 0)
            var data = new Windows.tagINPUT(Windows.INPUTTYPE.MOUSE);

            data.union.mi.dwFlags = eventType;
            // coords left at 0,0 (relative)
            data.union.mi.mouseData = mouseData;
            // time stamp left at zero
            // likewise extra info
            m_Output.Add(data);
        }
Пример #2
0
 /// <summary>Adds an event changing the state of the given key.  Only for low level use - usually use SendStringKeys</summary>
 public void AddKeyEvent(Keys key, bool down)
 {
     Windows.tagINPUT create = new Windows.tagINPUT(Windows.INPUTTYPE.KEYBOARD);
     create.union.ki.dwExtraInfo = UIntPtr.Zero;
     if (!down)
     {
         create.union.ki.dwFlags = Windows.KEYEVENTF.KEYUP;
     }
     if (key != Keys.Menu && key != Keys.ControlKey && m_AltMode == false)             // eKey <> Keys.LMenu And eKey <> Keys.RMenu
     {
         // must NOT be used when sending Alt codes.  But is required to make (eg) ctrl-shift-left work
         create.union.ki.dwFlags = create.union.ki.dwFlags | Windows.KEYEVENTF.EXTENDEDKEY;
     }
     create.union.ki.time  = 0;
     create.union.ki.wScan = (short)Windows.MapVirtualKey((uint)key, Windows.MAPVK_VK_TO_VSC);             // required to make Alt+NNNN work
     if (Switches.Switching.KeySwitch.KeyCurrentlyUsedForSwitching(key))
     {
         create.union.ki.wScan = 0;                 // the keyhook will ignore keys if the scan code is not set at all
     }
     create.union.ki.wVk = (short)key;
     Debug.WriteLine(key + " " + (down ? "down" : "up"));
     m_Output.Add(create);
 }