Skip to content

Instantly share code, notes, and snippets.

@macks2008
Created May 7, 2021 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macks2008/c28f7eacc719b7d4073faffebee13fa5 to your computer and use it in GitHub Desktop.
Save macks2008/c28f7eacc719b7d4073faffebee13fa5 to your computer and use it in GitHub Desktop.
to release, there is also a command that calls keybd_event with a 1 instead of 0 for one of the parameters.
' Script Lindsay Adam 2010 www.pcbyvoice.com
' Declare keyboard events Windows API function
Declare Function keybd_event Lib "user32.dll" (ByVal vKey As _
Long, bScan As Long, ByVal Flag As Long, ByVal exInfo As Long) As Long
' declare virtual key constant for the left Windows key,
' control key, shift key and alt key
' ... in addition to a few others added by this system's admin
Const VK_LWIN = &h5B
Const VK_CTRL = &h11
Const VK_SHIFT = &h10
Const VK_ALT = &h12
Const VK_UP = &h26
Const VK_LEFT = &h25
Const VK_RIGHT = &h27
Const VK_SPACE = &h20
Sub Main
If ListVar1 = "WINDOWS Key" Then keybd_event(VK_LWIN,0,0,0)
If ListVar1 = "CONTROL Key" Then keybd_event(VK_CTRL,0,0,0)
If ListVar1 = "SHIFT Key" Then keybd_event(VK_SHIFT,0,0,0)
If ListVar1 = "ALT Key" Then keybd_event(VK_ALT,0,0,0)
If ListVar1 = "FORWARD Key" Then keybd_event(VK_UP,0,0,0)
If ListVar1 = "UP Key" Then keybd_event(VK_UP,0,0,0) 'alias of the above
If ListVar1 = "LEFT Key" Then keybd_event(VK_LEFT,0,0,0)
If ListVar1 = "LEFT Arrow" Then keybd_event(VK_LEFT,0,0,0)
If ListVar1 = "RIGHT Key" Then keybd_event(VK_RIGHT,0,0,0)
If ListVar1 = "RIGHT Arrow" Then keybd_event(VK_RIGHT,0,0,0)
If ListVar1 = "SPACE Key" Then keybd_event(VK_SPACE,0,0,0)
If ListVar1 = "SPACEBAR" Then keybd_event(VK_SPACE,0,0,0) 'alias of the above
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment