-
Mar 26th, 2014, 12:13 PM
#1
Thread Starter
Junior Member
How do I activate keyboard shortcuts?
Okay, so I figured out a while ago how to do something like this:
Code:
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "Hey, I need some help!"
Is there any way I can use the same .SendKeys command to activate keyboard shortcuts such as Ctrl+Alt+Del or Win+L or Fn+F5 etc?
Last edited by techaddict; Mar 26th, 2014 at 12:20 PM.
-
Mar 26th, 2014, 05:47 PM
#2
Re: How do I activate keyboard shortcuts?
The SendKeys method doesn't recognize either Windows key or Function key so you won't be able to activate keyboard shortcuts such as Win+L or Fn+F5. You can, however, simulate pressing the three-finger salute with:
Code:
CreateObject("WScript.Shell").SendKeys "^%{DEL}"
You may want to consult the SendKeys method for more info on keys it recognizes.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Mar 26th, 2014, 05:49 PM
#3
Thread Starter
Junior Member
Re: How do I activate keyboard shortcuts?
Thanks. Do you know how else I could simulate Win+L? That's the lock screen shortcut for Windows 8 and I'd love to be able to link a .vbs or something of it to voice commands
-
Mar 26th, 2014, 06:17 PM
#4
Re: How do I activate keyboard shortcuts?
Don't know if this will work in Windows 8:
Code:
CreateObject("WScript.Shell").Run "rundll32.exe user32.dll,LockWorkStation"
I got that from Rob van der Woude's Scripting Pages site.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Mar 26th, 2014, 07:58 PM
#5
Thread Starter
Junior Member
Re: How do I activate keyboard shortcuts?
Tried both. The one for locking the computer works perfectly, Thanks! The other one didn't...
-
Mar 27th, 2014, 05:41 AM
#6
Re: How do I activate keyboard shortcuts?
If you're done with this thread, please don't forget to mark it Resolved! Thanks!
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Mar 27th, 2014, 12:17 PM
#7
Thread Starter
Junior Member
Re: How do I activate keyboard shortcuts?
Originally Posted by Bonnie West
If you're done with this thread, please don't forget to mark it Resolved! Thanks!
Yep, I will, I'd still like to know how to activate ctrl+alt+del though...
-
Mar 27th, 2014, 02:13 PM
#8
Re: How do I activate keyboard shortcuts?
Originally Posted by techaddict
... I'd still like to know how to activate ctrl+alt+del though...
Didn't the code in post #2 work for you?
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Mar 27th, 2014, 04:44 PM
#9
Thread Starter
Junior Member
Re: How do I activate keyboard shortcuts?
Originally Posted by techaddict
Tried both. The one for locking the computer works perfectly, Thanks! The other one didn't...
Unfortunately, no...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|