Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy

Search Results for "INPUT" in [All]

iphlpapi

.

      Add-Member -InputObject $objOutput -MemberType NoteProperty -Name "LocalAddress" -Value ([System.Net.IPAddress]::new($y[$i].localAddr).IPAddressToString)

.

      Add-Member -InputObject $objOutput -MemberType NoteProperty -Name "RemoteAddress" -Value ([System.Net.IPAddress]::new($y[$i].remoteAddr).IPAddressToString)

.

      Add-Member -InputObject $objOutput -MemberType NoteProperty -Name "LocalPort" -Value ($y[$i].localPort[1]+($y[$i].localPort[0]*0x100)+($y[$i].localPort[3]*0x1000)+($y[$i].localPort[2]*0x10000))

.

      Add-Member -InputObject $objOutput -MemberType NoteProperty -Name "RemotePort" -Value ($y[$i].remotePort[1]+($y[$i].remotePort[0]*0x100)+($y[$i].remotePort[3]*0x1000)+($y[$i].remotePort[2]*0x10000))

.

      Add-Member -InputObject $objOutput -MemberType NoteProperty -Name "PID" -Value $y[$i].owningPid

.

      Add-Member -InputObject $objOutput -MemberType NoteProperty -Name "ProcessName" -Value ((Get-Process -Id $y[$i].owningPid).ProcessName)

.

      Add-Member -InputObject $objOutput -MemberType NoteProperty -Name "StateValue" -Value $y[$i].state

.

      Add-Member -InputObject $objOutput -MemberType NoteProperty -Name "State" -Value $StateList[$y[$i].state]

.

      Add-Member -InputObject $objOutput -MemberType NoteProperty -Name "ServiceName" -Value $services[$j].Caption

.

      if ($boolNoService) { Add-Member -InputObject $objOutput -MemberType NoteProperty -Name "ServiceName" -Value $null }

.

    /// On input, specifies the size in bytes of the buffer pointed to by the pIfTable parameter.

.

        /// <param name="pdwSize">On input, specifies the size of the buffer pointed to

.

    /// <param name="cInFilters">[in] Specifies the number of input filter descriptions pointed to by the pfiltIn parameter.</param>

.

    /// <param name="pfiltIn">[in] Pointer to an array of filter descriptions to use as input filters.</param>

.

    /// <param name="inAction">[in] Specifies a default action for an input packet. This member can be one of the following values.</param>

.

    /// <param name="cInFilters">[in] Specifies the number of input filter descriptions pointed to by the pfiltIn parameter.</param>

.

    /// <param name="pfiltIn">[in] Pointer to an array of filter descriptions to use as input filters.</param>

.

    /// <param name="pInInterface">[in, optional] Handle to an interface to use as an input interface for the packet. This parameter is optional and may be NULL.</param>

httpapi

.

     IntPtr pInputConfigInfo,

.

     int InputConfigInfoLength,

.

Depending on the value of ConfigId, both pInputConfigInfo and pOutputConfigInfo should point to a different type of structure. If it wasn't for this, I could redifine the PInvoke signature to explicitly specify the underlying structure type.

.
ConfigId Value InputConfigInfor Structure Type
.
HttpServiceConfigIPListenList No input data; set to NULL.
.

     HTTP_SERVICE_CONFIG_URLACL_QUERY inputConfigInfoQuery = new HTTP_SERVICE_CONFIG_URLACL_QUERY();

.

     inputConfigInfoQuery.QueryDesc = HTTP_SERVICE_CONFIG_QUERY_TYPE.HttpServiceConfigQueryExact;

.

     inputConfigInfoQuery.KeyDesc = keyDesc;

.

     inputConfigInfoQuery.dwToken = 0;

.

     IntPtr pInputConfigInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_QUERY)));

.

     Marshal.StructureToPtr(inputConfigInfoQuery, pInputConfigInfo, true);

.

     size = Marshal.SizeOf(inputConfigInfoQuery);

.

         pInputConfigInfo,

.

         Marshal.SizeOf(inputConfigInfoQuery),

.

         pInputConfigInfo,

.

         Marshal.SizeOf(inputConfigInfoQuery),

.

     HTTP_SERVICE_CONFIG_URLACL_SET inputConfigInfoSet = new HTTP_SERVICE_CONFIG_URLACL_SET();

.

     inputConfigInfoSet.KeyDesc = keyDesc;

.

     inputConfigInfoSet.ParamDesc = paramDesc;

.

     IntPtr pInputConfigInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET)));

.

     Marshal.StructureToPtr(inputConfigInfoSet, pInputConfigInfo, false);

.

         pInputConfigInfo,

.

         Marshal.SizeOf(inputConfigInfoSet),

.

         pInputConfigInfo,

.

         Marshal.SizeOf(inputConfigInfoSet),

.

             pInputConfigInfo,

.

             Marshal.SizeOf(inputConfigInfoSet),

.

     Marshal.FreeCoTaskMem(pInputConfigInfo);

.

        IntPtr pInputConfigInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_SSL_SET)));

.

        Marshal.StructureToPtr(configSslSet, pInputConfigInfo, false);

.

            pInputConfigInfo,

.

            pInputConfigInfo,

.

                pInputConfigInfo,

.

        Marshal.FreeCoTaskMem(pInputConfigInfo);

ntdll

.

        SeUnsolicitedInputPrivilege = 5,

oleaut32

.

        Public Sub New(input As Drawing.Bitmap)

.

            BitmapHandle = input.GetHbitmap()

.

        Public Sub New(input As Drawing.Icon)

.

            IconHandle = input.Handle

.

    Public Function ConvertToIPictureDisplay(input As Bitmap) As stdole.IPictureDisp

.

        Dim bitmap As PICTDESC.Bitmap = New PICTDESC.Bitmap(input)

user32

.

/// <summary>Sets the input locale identifier (formerly called the keyboard layout handle) for the calling thread or the current process. The input locale identifier specifies a locale as well as the physical layout of the keyboard</summary>

.

/// <param name="hkl">Input locale identifier to be activated.</param>

.

/// <param name="Flags">Specifies how the input locale identifier is to be activated.</param>

.

/// <returns>The return value is of type HKL. If the function succeeds, the return value is the previous input locale identifier. Otherwise, it is zero</returns>

.

''' <summary>Sets the input locale identifier (formerly called the keyboard layout handle) for the calling thread or the current process. The input locale identifier specifies a locale as well as the physical layout of the keyboard</summary>

.

''' <param name="hkl">Input locale identifier to be activated.</param>

.

''' <param name="Flags">Specifies how the input locale identifier is to be activated.</param>

.

''' <returns>The return value is of type HKL. If the function succeeds, the return value is the previous input locale identifier.

.

[System.Windows.Forms.InputLanguage]

.

- The process received the last input event.

.
Summary
.

static extern bool AttachThreadInput(uint idAttach, uint idAttachTo,

.

Public Shared Function AttachThreadInput(ByVal idAttach As System.UInt32, ByVal idAttachTo As System.UInt32, ByVal fAttach As Boolean) As Boolean

.

AttachThreadInput(idAttach, curThreadId, true);

.

AttachThreadInput(idAttach, curThreadId, false);

.
Documentation
[AttachThreadInput] on MSDN
.
Summary
.

static extern bool BlockInput(bool fBlockIt);

.

Declare Fuhhhhhon BlockInput Lib "user32" (ByVal fBlockIt As Boolean) As Boolean

.

    ''' <summary>The BlockInput function blocks keyboard and mouse input events from reaching applications

.

    ''' and mouse input events are blocked. If this parameter is zero, keyboard and mouse events are unblocked.

.

    ''' If input is already blocked, the return value is zero.

.

    ''' <remarks>Note that only the thread that blocked input can successfully unblock input</remarks>

.

    <DllImport("user32.dll", EntryPoint:="BlockInput", SetLastError:=True, CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)>

.

    Friend Shared Function BlockInput(fBlockIt As Boolean) As Integer

.

Note that this definition does not use Boolean input and return types

.

Blocks or unblocks mouse and keyboard input.

.

Useful to create a temporary block in input for sensitive GUI operations. For instance when manually activating a screen saver from within a GUI function, a short blocking delay will prevent the user mouse movements directly after selection from accidently escaping the screen saver.

.

Class BlockInput

.

    <DllImport("user32.dll", EntryPoint:="BlockInput", SetLastError:=True, CharSet:=CharSet.Auto, CallingConvention:=CallingConvention.StdCall)>

.

    Friend Shared Function BlockInput(fBlockIt As Boolean) As Boolean

.

   Friend Shared Function DisableInput(makeDisabled As Boolean) as Boolean

.

      Return BlockInput(makeDisabled)

.

The ManagedWindowsApi project (http://mwinapi.sourceforge.net) provides an InputBlocker class that can block input.

.
Documentation
[BlockInput] on MSDN
.

        void EnableInput(Control control, bool enabled)

.

Windows Input Simulator

.

An open source managed .NET wrapper written in C# is available on Codeplex at http://inputsimulator.codeplex.com/. It has all of these definitions complete with documented code comments and can be used to determine key states as well. Thanks to all the contributors at pinvoke.

.

Retrieves a handle to the window (if any) that has captured the mouse. Only one window at a time can capture the mouse; this window receives mouse input whether or not the cursor is within its borders.

.

                     //    CURSOR_SUPPRESSED    (Windows 8 and above.) The cursor is suppressed. This flag indicates that the system is not drawing the cursor because the user is providing input through touch or pen instead of the mouse.

.

'&HF = control ID for text area (classname: "Edit") for inputting text

.
Summary
.

static extern bool GetInputState();

.

       if ( !GetInputState() )

.
Documentation
[GetInputState] on MSDN
.

Windows Input Simulator

.

An open source managed .NET wrapper written in C# is available on Codeplex at http://inputsimulator.codeplex.com/. It has all of these definitions complete with documented code comments and can be used to determine key states as well. Thanks to all the contributors at pinvoke.

.
Summary
Gets the time of the last user input (in ms since the system started)
.

static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);

.

Shared Function GetLastInputInfo(ByRef plii As LASTINPUTINFO) As Boolean

.

static bool GetLastInputInfo(LASTINPUTINFO* plii);

.

   type LastInputInfo = {

.

   extern int GetLastInputInfo(LastInputInfo& lpi);

.

LASTINPUTINFO

.

Compare to Environment.TickCount to get the time since the last user input.

.

This function retrieves the time in seconds since last user input

.

    static uint GetLastInputTime()

.

        LASTINPUTINFO lastInputInfo = new LASTINPUTINFO();

.

        lastInputInfo.cbSize = (uint)Marshal.SizeOf( lastInputInfo );

.

        lastInputInfo.dwTime = 0;

.

        if ( GetLastInputInfo( ref lastInputInfo ) )

.

        uint lastInputTick = lastInputInfo.dwTime;

.

        idleTime = envTicks - lastInputTick;

.

This function retrieves the time in seconds since last user input

.

Dim lastInputInf As New LASTINPUTINFO()

.

   Public Function GetLastInputTime() As Integer

.

    lastInputInf.cbSize = Marshal.SizeOf(lastInputInf)

.

    lastInputInf.dwTime = 0

.

    If GetLastInputInfo(lastInputInf) Then

.

        idletime = Environment.TickCount - lastInputInf.dwTime

.

This function retrieves the time in seconds since last user input

.

    LASTINPUTINFO lastInputInfo;

.

    lastInputInfo.cbSize = (UInt32)Marshal::SizeOf(lastInputInfo);

.

    lastInputInfo.dwTime = 0;

.

    if (GetLastInputInfo(&lastInputInfo))

.

        int lastInputTicks = (int)lastInputInfo.dwTime;

.

        idleTicks = systemUptime - lastInputTicks;

.

     let size = sizeof<LastInputInfo>

.

     match GetLastInputInfo(&info) with

.

Prints time in seconds since last user input.

.

    LASTINPUTINFO lastInputInfo;

.

    lastInputInfo.cbSize = sizeof (lastInputInfo);

.

    lastInputInfo.dwTime = 0;

.

    if (GetLastInputInfo(&lastInputInfo)) {        

.

        int lastInputTicks = (int)lastInputInfo.dwTime;

.

        idleTicks = systemUptime - lastInputTicks;

.
Documentation
[GetLastInputInfo] on MSDN
.

The WM_KEYFIRST and WM_KEYLAST constants can be used as filter values to retrieve all messages related to keyboard input; the WM_MOUSEFIRST and WM_MOUSELAST constants can be used to retrieve all mouse messages. If the wMsgFilterMin and wMsgFilterMax parameters are both zero, the GetMessage function returns all available messages (that is, without performing any filtering).

.

        QS_RAWINPUT =       0x0400,

.

        QS_INPUT = (QS_MOUSE | QS_KEY | QS_RAWINPUT),

.

        QS_ALLEVENTS = (QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY),

.

        QS_ALLINPUT = (QS_INPUT | QS_POSTMESSAGE | QS_TIMER | QS_PAINT | QS_HOTKEY | QS_SENDMESSAGE)

.
Summary
Function to read raw data from an input device such as a keyboard, mouse or other HID.
.

    /// Function to retrieve raw input data.

.

    /// <param name="hRawInput">Handle to the raw input.</param>

.

    /// <param name="pData">Raw input data.</param>

.

    public static extern int GetRawInputData(IntPtr hRawInput, RawInputCommand uiCommand, out RAWINPUT pData, ref int pcbSize, int cbSizeHeader);

.

    /// Function to retrieve raw input data.

.

    /// <param name="hRawInput">Handle to the raw input.</param>

.

    /// <param name="pData">Raw input data.</param>

.

    public static extern int GetRawInputData(IntPtr hRawInput, RawInputCommand uiCommand, byte[] pData, ref int pcbSize, int cbSizeHeader);

.

    <DllImport("user32.dll", CharSet:=CharSet.Auto, EntryPoint:="GetRawInputData", SetLastError:=True)>

.

    Function GetRawInputData(hRawInput As IntPtr,

.

RAWINPUT is incompatible with x64. See RAWINPUTHEADER.Device and RAWINPUTHEADER.wParam.

.

        if (m.Msg == (int)WindowMessages.RawInput)  // WindowMessages.RawInput = 0x00FF (WM_INPUT)

.

            RAWINPUT input = new RAWINPUT();

.

            int size = Marshal.SizeOf(typeof(RAWINPUT));

.

            outSize = Win32API.GetRawInputData(m.LParam, RawInputCommand.Input, out input, ref size, Marshal.SizeOf(typeof(RAWINPUTHEADER)));

.

                if (input.Header.Type == RawInputType.Mouse)

.

                    p.X += input.Mouse.LastX;

.

                    p.Y += input.Mouse.LastY;

.

                    label1.Text = "Mouse: " + p.X.ToString() + "x" + p.Y.ToString() + " " + input.Mouse.ButtonFlags.ToString();

.
Documentation
[GetRawInputData] on MSDN
.

    public static extern uint GetRawInputDeviceInfo(int deviceHandle, uint command, ref DeviceInfo data, ref uint dataSize);

.

Declare Function GetRawInputDeviceInfo  Lib "user32.dll" (TODO) As TODO

.

    User32.GetRawInputDeviceInfo(device.hDevice, User32.RIDI_DEVICEINFO, ref di, ref size);

.
Documentation
.
Summary
The GetRawInputDeviceInfo function gets information about the raw input device.
.

static extern uint GetRawInputDeviceInfo(IntPtr hDevice, uint uiCommand, IntPtr pData, ref uint pcbSize);

.

[DllImport("user32.dll", SetLastError = true, EntryPoint = "GetRawInputDeviceInfoA")]

.

public static extern uint GetRawInputDeviceInfo(IntPtr hDevice, uint uiCommand, ref RID_DEVICE_INFO pData, ref uint pcbSize);

.

[DllImport("user32.dll", SetLastError = true, EntryPoint = "GetRawInputDeviceInfoA", CharSet = CharSet.Ansi)]

.

public static extern uint GetRawInputDeviceInfo(IntPtr hDevice, uint uiCommand, StringBuilder pData, ref uint pcbSize);

.

Declare Function GetRawInputDeviceInfo Lib "user32.dll" Alias "GetRawInputDeviceInfoW" (ByVal hDevice As IntPtr, ByVal uiCommand As DeviceInfoTypes, ByVal pData As IntPtr, ByRef pcbSize As UInteger) As Integer

.

        var firstCall = GetRawInputDeviceInfo(deviceHandle, RIDI_DEVICENAME, devBufer, ref returnedDataSize);

.

        var secondCall = GetRawInputDeviceInfo(deviceHandle, RIDI_DEVICEINFO, ref devInfo, ref returnedDataSize);

.

    ' First half heavily borrowed from C# example on GetRawInputDeviceList()

.

         Dim dwSize As Integer = CInt(Marshal.SizeOf(GetType(RAWINPUTDEVICELIST)))

.

         Dim retValue As UInt32 = GetRawInputDeviceList(IntPtr.Zero, deviceCount, dwSize)

.

         retValue = GetRawInputDeviceList(devPtr, deviceCount, dwSize)

.

         Dim deviceList As RAWINPUTDEVICELIST

.

         Dim rawDevs As New Dictionary(Of IntPtr, RawInputDeviceType)

.

         deviceList = CType(Marshal.PtrToStructure(New IntPtr((devPtr.ToInt32() + (dwSize * i))), GetType(RAWINPUTDEVICELIST)), RAWINPUTDEVICELIST)

.

         If deviceList.dwType = RawInputDeviceType.KEYBOARD Then

.

         For Each itm As KeyValuePair(Of IntPtr, RawInputDeviceType) In rawDevs

.

         GetRawInputDeviceInfo(itm.Key, DeviceInfoTypes.RIDI_DEVICENAME, IntPtr.Zero, pcbSize)

.

         GetRawInputDeviceInfo(itm.Key, DeviceInfoTypes.RIDI_DEVICENAME, pData, pcbSize)

.
Documentation
[GetRawInputDeviceInfo] on MSDN
.
Summary
The GetRawInputDeviceList function enumerates the raw input devices attached to the system.
.

    public enum RawInputDeviceType : uint

.

    public struct RAWINPUTDEVICELIST

.

        public RawInputDeviceType Type;

.

    public static extern uint GetRawInputDeviceList

.

        [In, Out] RAWINPUTDEVICELIST[] RawInputDeviceList,

.

        uint Size /* = (uint)Marshal.SizeOf(typeof(RawInputDeviceList)) */

.

    Public Structure RAWINPUTDEVICELIST

.

    EntryPOint:="GetRawInputDeviceList", SetLastError:=True)> _

.

    Public Function GetRawInputDeviceList(ByVal pRawInputDeviceList As

.

Declare Function GetRawInputDeviceList Lib "user32.dll" (ByVal pRawInputDeviceList As

.

int structSize = Marshal.SizeOf(typeof(RAWINPUTDEVICELIST));    

.

int deviceCount = GetRawInputDeviceList(buffer, ref bufferCount, structSize);

.

    RAWINPUTDEVICELIST device = (RAWINPUTDEVICELIST)Marshal.PtrToStructure(

.

new IntPtr((buffer.ToInt32() + (structSize * i))),typeof(RAWINPUTDEVICELIST));

.

    // A convenient function for getting all raw input devices.

.

    public static RAWINPUTDEVICELIST[] GetAllRawDevices()

.

        uint dwSize = (uint)Marshal.SizeOf(typeof(RAWINPUTDEVICELIST));

.

        uint retValue = Win32API.GetRawInputDeviceList(null, ref deviceCount, dwSize);

.

        RAWINPUTDEVICELIST[] deviceList = new RAWINPUTDEVICELIST[deviceCount];

.

        retValue = Win32API.GetRawInputDeviceList(deviceList, ref deviceCount, dwSize);

.

       //IntPtr pRawInputDeviceList = Marshal.AllocHGlobal((int)(dwSize * deviceCount));

.

       //Marshal.FreeHGlobal(pRawInputDeviceList);

.
Documentation
[GetRawInputDeviceList] on MSDN
.

This function is useful to simulate Key presses (for input use the virtual keycodes from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp or windows CE universal core virtual key code compact chart http://msdn2.microsoft.com/en-us/library/ms927178.aspx ).

.

Use FindWindow and SetForegroundWindow to direct input to the desired window.

.
Note
WaitForInputIdle (Warning this will only wait once! See Raymond Chen's Blog Post http://blogs.msdn.com/b/oldnewthing/archive/2010/03/25/9984720.aspx ), or a Sleep may be required to assure Window is ready for input:
.

// This is not alternative, this will set the default input language based on installed keyboard layouts, if

.

//the layout is not installed in regional settings, nothing will happen, but with LoadKeyboardLayout, the input

.

InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new System.Globalization.CultureInfo("fa-IR"));

.

InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(new System.Globalization.CultureInfo("En-US"));

.

FYI, Microsoft tells us for "Windows NT/2000/XP: This function has been superseded. Use SendInput instead."

.

Thus I have resigned myself to unmanaged code for now. I will post the SendInput version shortly as mouse_event has been deprecated by Bill in favor of SendInput.

.
Summary
.

static extern IntPtr OpenInputDesktop(uint dwFlags, bool fInherit,

.

     Private Shared Function OpenInputDesktop(ByVal dwFlags As UInteger, ByVal fInherit As Boolean, ByVal dwDesiredAccess As UInteger) As IntPtr

.
Documentation
[OpenInputDesktop] on MSDN
.
Summary
Registers a device to send its raw input data.
.

/// <summary>Function to register a raw input device.</summary>

.

/// <param name="pRawInputDevices">Array of raw input devices.</param>

.

/// <param name="cbSize">Size of the RAWINPUTDEVICE structure.</param>

.

public static extern bool RegisterRawInputDevices([MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] RAWINPUTDEVICE[] pRawInputDevices, int uiNumDevices, int cbSize);

.

''' <summary>Function to register a raw input device.</summary>

.

''' <param name="pRawInputDevices">Array of raw input devices.</param>

.

''' <param name="cbSize">Size of the RAWINPUTDEVICE structure.</param>

.

Public Shared Function RegisterRawInputDevices(<MarshalAs(UnmanagedType.LPArray, SizeParamIndex := 0)> ByVal pRawInputDevices As RAWINPUTDEVICE(), ByVal uiNumDevices As Integer, ByVal cbSize As Integer) As Boolean

.

RAWINPUTDEVICE

.

        RAWINPUTDEVICE device;

.

        device.Flags = RawInputDeviceFlags.InputSink;

.

        Win32API.RegisterRawInputDevices(device);

.

    /// Function to register a raw input device.

.

    public static bool RegisterRawInputDevices(RAWINPUTDEVICE device)

.

        RAWINPUTDEVICE[] devices = new RAWINPUTDEVICE[1];        // Raw input devices.

.

        return RegisterRawInputDevices(devices, 1, Marshal.SizeOf(typeof(RAWINPUTDEVICE)));

.
Documentation
[RegisterRawInputDevices] on MSDN
.

  TWF_FINETOUCH = 0x00000001, //Specifies that hWnd prefers noncoalesced touch input.

.
Summary
.

static extern uint SendInput(uint nInputs, INPUT [] pInputs, int cbSize);

.

Declare Function SendInput Lib "user32.dll" (nInputs As Integer, pInputs() As _

.

   INPUT, cbSize As Integer)

.

INPUT, and VK is used in the sample code.

.

    INPUT structInput;

.

    structInput.type = Win32Consts.INPUT_KEYBOARD;

.

    structInput.ki.wScan = 0;

.

    structInput.ki.time = 0;

.

    structInput.ki.dwFlags = 0;

.

    structInput.ki.dwExtraInfo = Win32.GetMessageExtraInfo();

.

        structInput.ki.wVk = (ushort)VK.SHIFT;

.

        intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT));

.

        structInput.ki.wVk = (ushort)VK.CONTROL;

.

        intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT));

.

        structInput.ki.wVk = (ushort)VK.MENU;

.

        intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT));

.

        structInput.ki.wVk = (ushort)VK.LWIN;

.

        intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT));

.

    structInput.ki.wVk = vk;

.

    intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT));

.

    structInput.ki.dwFlags = Win32Consts.KEYEVENTF_KEYUP;

.

    intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT));

.

        structInput.ki.wVk = (ushort)VK.SHIFT;

.

        intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT));

.

        structInput.ki.wVk = (ushort)VK.CONTROL;

.

        intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT));

.

        structInput.ki.wVk = (ushort)VK.MENU;

.

        intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT));

.

        structInput.ki.wVk = (ushort)VK.LWIN;

.

        intReturn = Win32.SendInput(1, ref structInput, (UInt32)sizeof(INPUT));

.
Documentation
[SendInput] on MSDN
.

    ///     Brings the thread that created the specified window into the foreground and activates the window. Keyboard input is

.

    ///     <item>The process received the last input event.</item>

.

    ///     the foreground window the next time the user generates input, unless the input is directed at that process, or

.

The trick is to make windows ‘think’ that our process and the target window (hwnd) are related by attaching the threads (using AttachThreadInput API) and using an alternative API: BringWindowToTop.

.

        AttachThreadInput(foreThread, appThread, true);

.

        AttachThreadInput(foreThread, appThread, false);