Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I use VBScript to display the Win 10 clipboard (Win key + V) ?

Status
Not open for further replies.

JustRay

MIS
Nov 5, 2021
2
US
I'm trying to figure out how to toss the "Win + V" key combonation at Windows via VBScript so that the clipbord is displayed on the users desktop.
I'm lost.
Anyone have any suggestions ?
Thanks
 
Sadly, this isn't really feasible in raw VbScript. You will see 'solutions' that suggest you can doo it with Sendkeys (essentially sending CTL-ESC-V' where CTL-ESC is the Windows key. Sadly this does not work, the V is ignored)

AutoHotKey does provide a Windows key capability, or you need to use a language that can make API calls, and look at keybd_event API

For example, in VBA something like the following would work:

Code:
[COLOR=blue]Option Explicit
Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Public Const KEYEVENTF_KEYUP = &H2
Public Const KEYEVENTF_EXTENDEDKEY = 1
Public Const LWin = 91

public Sub ShowClipboard()
    KeyDown LWin
    KeyDown Asc("V")
    KeyUp LWin
    KeyUp Asc("V")
End Sub

Private Sub KeyDown(vKey As Byte)
    keybd_event vKey, 0, KEYEVENTF_EXTENDEDKEY, 0
End Sub
        
Private Sub KeyUp(vKey As Byte)
    keybd_event vKey, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
End Sub[/color]
 
Thanks for the code AND your efforts on my behalf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top