locked
How do you use send key to send the windows key RRS feed

Answers

  • ok, gonna do it with crtl / esc
    • Marked as answer by FENGE2 Friday, June 3, 2016 7:53 AM
    Friday, June 3, 2016 7:53 AM

All replies

  • ok, gonna do it with crtl / esc
    • Marked as answer by FENGE2 Friday, June 3, 2016 7:53 AM
    Friday, June 3, 2016 7:53 AM
  • Friday, June 3, 2016 2:17 PM
  • ok, gonna do it with crtl / esc

     I`m not sure what using  ctrl/esc  to do it means because you have not explained what your main goal is by simulating the Win key being pressed.  If you care to explain the reason for needing to simulate the Win key being pressed,  perhaps there is another way to do what you need.

     Anyways,  in case you or anyone else that views this thread is interested,  here is a small example of using the keybrd_event Api function to simulate the (Win + D) key combo being pressed.  That key combination will minimize all windows and show the desktop.

     
    Imports System.Runtime.InteropServices
    
    Public Class Form1
        Private Const KEYEVENTF_KEYDOWN As Integer = &H0
        Private Const KEYEVENTF_KEYUP As Integer = &H2
    
        <DllImport("user32.dll", EntryPoint:="keybd_event")>
        Private Shared Sub keybd_event(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As UInteger, ByVal dwExtraInfo As UInteger)
        End Sub
    
        Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
            keybd_event(CByte(Keys.LWin), 0, KEYEVENTF_KEYDOWN, 0) 'Press the Left Win key
            keybd_event(CByte(Keys.D), 0, KEYEVENTF_KEYDOWN, 0)    'Press the D key
            keybd_event(CByte(Keys.D), 0, KEYEVENTF_KEYUP, 0)      'Release the D key
            keybd_event(CByte(Keys.LWin), 0, KEYEVENTF_KEYUP, 0)   'Release the Left Win key
        End Sub
    End Class
    


    If you say it can`t be done then i`ll try it

    • Proposed as answer by Mr. Monkeyboy Saturday, June 4, 2016 12:25 AM
    Friday, June 3, 2016 10:40 PM