public void SetUserGeoID([In] int geoId)
 {
     if (InternalNativeMethods.SetUserGeoID(geoId: geoId) == -1)
     {
         throw new LanguageRegionManagerException(message: string.Format(format: "GEO ID specified was not found on the system: {0}", arg0: geoId));
     }
 }
 public InputDeviceTouchRIM()
 {
     if (!InternalNativeMethods.InitializePointerDeviceInjection(type: POINTER_INPUT_TYPE.TOUCH, contactCount: 256U, monitor: IntPtr.Zero, visualMode: TOUCH_FEEDBACK.INDIRECT, device: out this.device))
     {
         throw new Win32Exception(error: Marshal.GetLastWin32Error());
     }
 }
        public string GetUserLanguages([In] char languageDelimiter)
        {
            var empty = string.Empty;

            InternalNativeMethods.GetUserLanguages(delimiter: languageDelimiter, userLanguages: ref empty);
            return(empty);
        }
 public void GetKeyboardState([Out] byte[] keyState)
 {
     if (!InternalNativeMethods.GetKeyboardState(keyState: keyState))
     {
         throw new Win32Exception(error: Marshal.GetLastWin32Error());
     }
 }
 protected override void RemoveInjectionDevice()
 {
     if (!(this.device != IntPtr.Zero))
     {
         return;
     }
     this.device = InternalNativeMethods.RemoveInjectionDevice(device: this.device) ? IntPtr.Zero : throw new Win32Exception(error: Marshal.GetLastWin32Error());
 }
 public override void InjectPointer(PointerData pointerData)
 {
     Log.Out(msg: "Inject Pointer: {0}", (object)pointerData.ToString());
     if (!InternalNativeMethods.InjectPointerInput(device: this.device, pointerTypeInfo: new PointerTypeInfo[1] {
         TransformPointer(pointerData: pointerData, inputType: POINTER_INPUT_TYPE.TOUCH)
     }, count: 1U))
     {
         throw new Win32Exception(error: Marshal.GetLastWin32Error());
     }
 }
 public static void InjectMouseInput([In] MouseInput mouseInput)
 {
     Log.Out(msg: "Inject Mouse: {0}", (object)mouseInput.ToString());
     if (!InternalNativeMethods.InjectMouseInput(mouseInput: new MouseInput[1] {
         mouseInput
     }, count: 1U))
     {
         throw new Win32Exception(error: Marshal.GetLastWin32Error());
     }
 }
 public static void InjectKeyboardInput([In] KeyboardInput keyboardInput)
 {
     Log.Out(msg: "Inject Keyboard: {0}", (object)keyboardInput.ToString());
     if (!InternalNativeMethods.InjectKeyboardInput(keyboardInput: new KeyboardInput[1] {
         keyboardInput
     }, count: 1U))
     {
         throw new Win32Exception(error: Marshal.GetLastWin32Error());
     }
 }
Example #9
0
        void EndPeriod(uint uPeriod)
        {
            Log.Out(msg: "EndPeriod with timer resolution {0}", (object)uPeriod);
            var num = InternalNativeMethods.timeEndPeriod(uPeriod: uPeriod);

            if (num != 0U)
            {
                throw new Exception(message: string.Format(format: "P/Invoke of timeEndPeriod returned error {0}", arg0: num));
            }
        }
Example #10
0
        uint GetMinimumTimerResolution()
        {
            var timeCaps = new TimeCaps();
            var devCaps  = InternalNativeMethods.timeGetDevCaps(timeCaps: ref timeCaps, sizeTimeCaps: (uint)Marshal.SizeOf(structure: timeCaps));

            if (devCaps != 0U)
            {
                throw new Exception(message: string.Format(format: "P/Invoke of timeGetDevCaps returned error {0}", arg0: devCaps));
            }
            return(timeCaps.periodMin);
        }
        public static void PressButton(UIObject obj, GamepadButton button)
        {
            Log.Comment("Pressing Gamepad button: {0}", button);
            KeyboardInput[] array = new KeyboardInput[1];
            array[0].virtualKeyCode = (ushort)button;
            InternalNativeMethods.InjectKeyboardInput(array, 1);

            // Without a delay, the input gets dropped.
            Wait.ForMilliseconds(50);

            array[0].flags = KEY_EVENT_FLAGS.KEYUP;
            InternalNativeMethods.InjectKeyboardInput(array, 1);
        }
Example #12
0
        public RectangleI GetClientArea()
        {
            var systemMetrics1 = InternalNativeMethods.GetSystemMetrics(nIndex: 76);
            var systemMetrics2 = InternalNativeMethods.GetSystemMetrics(nIndex: 77);
            var systemMetrics3 = InternalNativeMethods.GetSystemMetrics(nIndex: 78);
            var systemMetrics4 = InternalNativeMethods.GetSystemMetrics(nIndex: 79);

            if (systemMetrics3 == 0 || systemMetrics4 == 0)
            {
                throw new Exception(message: "GetSystemMetrics failed");
            }
            Log.Out(msg: "Client Area ({0}, {1}, {2}, {3})", (object)systemMetrics1, (object)systemMetrics2, (object)systemMetrics3, (object)systemMetrics4);
            return(new RectangleI(x: systemMetrics1, y: systemMetrics2, width: systemMetrics3, height: systemMetrics4));
        }
        public static void PressButton(UIObject obj, GamepadButton button)
        {
            var keyInputReceivedUIObject = FindElement.ById("__KeyInputReceived");

            if (keyInputReceivedUIObject != null)
            {
                var keyInputReceivedCheckbox = new CheckBox(keyInputReceivedUIObject);

                if (keyInputReceivedCheckbox.ToggleState == ToggleState.On)
                {
                    keyInputReceivedCheckbox.Uncheck();
                }
                Verify.IsTrue(keyInputReceivedCheckbox.ToggleState == ToggleState.Off);
            }

            Log.Comment("Pressing Gamepad button: {0}", button);
            KeyboardInput[] array = new KeyboardInput[1];
            array[0].virtualKeyCode = (ushort)button;
            InternalNativeMethods.InjectKeyboardInput(array, 1);


            // Wait until app reports it received the input
            if (keyInputReceivedUIObject == null)
            {
                // Fallback if we don't find out helper
                Wait.ForMilliseconds(50);
            }
            else
            {
                var keyInputReceivedCheckbox = new CheckBox(keyInputReceivedUIObject);
                keyInputReceivedCheckbox.GetToggledWaiter().TryWait(TimeSpan.FromMilliseconds(50));
            }

            Wait.ForIdle();
            array[0].flags = KEY_EVENT_FLAGS.KEYUP;
            InternalNativeMethods.InjectKeyboardInput(array, 1);
        }
        public override void InjectPointer(PointerData[] pointerData)
        {
            if (pointerData.Length > 256)
            {
                throw new ArgumentOutOfRangeException(paramName: string.Format(format: "The maximum number of simultaneous touch points is {0}.", arg0: 256U));
            }
            if (Log.OutImplementation != null)
            {
                foreach (var pointerData1 in pointerData)
                {
                    Log.Out(msg: "Inject Pointer: {0}", (object)pointerData1.ToString());
                }
            }
            var pointerTypeInfo = new PointerTypeInfo[pointerData.Length];

            for (var index = 0; index < pointerData.Length; ++index)
            {
                pointerTypeInfo[index] = TransformPointer(pointerData: pointerData[index], inputType: POINTER_INPUT_TYPE.TOUCH);
            }
            if (!InternalNativeMethods.InjectPointerInput(device: this.device, pointerTypeInfo: pointerTypeInfo, count: (uint)pointerTypeInfo.Length))
            {
                throw new Win32Exception(error: Marshal.GetLastWin32Error());
            }
        }
Example #15
0
 public void SetUserLanguages([In] string languages, [In] char languageDelimiter)
 {
     InternalNativeMethods.SetUserLanguages(delimiter: languageDelimiter, userLanguages: languages);
 }
Example #16
0
 public bool GetMouseButtonsSwapped()
 {
     return(InternalNativeMethods.GetSystemMetrics(nIndex: 23) != 0);
 }