Esempio n. 1
0
        private static void PressYesPlease()
        {
            uint intReturn = 0;
            NativeMethods.INPUT[] structInput = new NativeMethods.INPUT[6];
            structInput[0].type = (int)NativeMethods.SendKeysInputType.INPUT_KEYBOARD;
            structInput[0].ki.wScan = 0;
            structInput[0].ki.time = 0;
            structInput[0].ki.dwFlags = 0;
            structInput[0].ki.dwExtraInfo = IntPtr.Zero;
            structInput[0].ki.wVk = (short)NativeMethods.VK.TAB;

            structInput[1].type = (int)NativeMethods.SendKeysInputType.INPUT_KEYBOARD;
            structInput[1].ki.wScan = 0;
            structInput[1].ki.time = 0;
            structInput[1].ki.dwFlags = 0;
            structInput[1].ki.dwExtraInfo = IntPtr.Zero;
            structInput[1].ki.dwFlags = NativeMethods.KEYEVENTF_KEYUP;
            structInput[1].ki.wVk = (short)NativeMethods.VK.TAB;

            structInput[2].type = (int)NativeMethods.SendKeysInputType.INPUT_KEYBOARD;
            structInput[2].ki.wScan = 0;
            structInput[2].ki.time = 0;
            structInput[2].ki.dwFlags = 0;
            structInput[2].ki.dwExtraInfo = IntPtr.Zero;
            structInput[2].ki.wVk = (short)NativeMethods.VK.TAB;

            structInput[3].type = (int)NativeMethods.SendKeysInputType.INPUT_KEYBOARD;
            structInput[3].ki.wScan = 0;
            structInput[3].ki.time = 0;
            structInput[3].ki.dwFlags = 0;
            structInput[3].ki.dwExtraInfo = IntPtr.Zero;
            structInput[3].ki.dwFlags = NativeMethods.KEYEVENTF_KEYUP;
            structInput[3].ki.wVk = (short)NativeMethods.VK.TAB;

            structInput[4].type = (int)NativeMethods.SendKeysInputType.INPUT_KEYBOARD;
            structInput[4].ki.wScan = 0;
            structInput[4].ki.time = 0;
            structInput[4].ki.dwFlags = 0;
            structInput[4].ki.dwExtraInfo = IntPtr.Zero;
            structInput[4].ki.wVk = (short)NativeMethods.VK.RETURN;

            structInput[5].type = (int)NativeMethods.SendKeysInputType.INPUT_KEYBOARD;
            structInput[5].ki.wScan = 0;
            structInput[5].ki.time = 0;
            structInput[5].ki.dwFlags = 0;
            structInput[5].ki.dwExtraInfo = IntPtr.Zero;
            structInput[5].ki.dwFlags = NativeMethods.KEYEVENTF_KEYUP;
            structInput[5].ki.wVk = (short)NativeMethods.VK.RETURN;

            intReturn = NativeMethods.SendInput(6, structInput, Marshal.SizeOf(structInput[0]));
            if (intReturn != 6)
            {
				Logger.LogError("OutlookSecurity/PressYesPlease failed.");
				Logger.LogError("SendInput returned " + intReturn.ToString());
				Logger.LogError("GetLastError returned " + Marshal.GetLastWin32Error().ToString());
            }
        }
Esempio n. 2
0
		private void PressButton(NativeMethods.VK key)
		{
			uint intReturn = 0;
			NativeMethods.INPUT[] structInput = new NativeMethods.INPUT[2];
			structInput[0].type = (int)NativeMethods.SendKeysInputType.INPUT_KEYBOARD;
			structInput[0].ki.wScan = 0;
			structInput[0].ki.time = 0;
			structInput[0].ki.dwFlags = 0;
			structInput[0].ki.dwExtraInfo = IntPtr.Zero;
			structInput[0].ki.wVk = (short)key;

			structInput[1].type = (int)NativeMethods.SendKeysInputType.INPUT_KEYBOARD;
			structInput[1].ki.wScan = 0;
			structInput[1].ki.time = 0;
			structInput[1].ki.dwFlags = 0;
			structInput[1].ki.dwExtraInfo = IntPtr.Zero;
			structInput[1].ki.dwFlags = NativeMethods.KEYEVENTF_KEYUP;
			structInput[1].ki.wVk = (short)key;

			intReturn = NativeMethods.SendInput(2, structInput, Marshal.SizeOf(structInput[0]));
			if (intReturn != 2)
			{
				Logger.LogError("WindowEnumerator/PressButton failed.");
				Logger.LogError("PressButton/SendInput returned " + intReturn.ToString());
				Logger.LogError("PressButton/GetLastError returned " + Marshal.GetLastWin32Error().ToString());
			}
		}