0

I'm trying to send a shortcut with VB.NET 4.5 (ALT + SCROLLOCK).

Option Strict On
Imports System.Windows.Forms
Module Module1
    Sub Main()
        SendKeys.SendWait("%{SCROLLLOCK}")
    End Sub
End Module

When I execute it, nothing happens. I read something about security issues of Windows, but didn't found a solution so far.

Is there a way to do it? It is also okay for me to use something like AutoIT. I'm using Windows 7 64Bit.

flohdieter
  • 130
  • 4
  • 15
  • The Solution was the following thread: [P/Invoking keybd_event()](http://stackoverflow.com/questions/11402643/sendkey-send-not-working) – flohdieter Jul 08 '16 at 10:27

1 Answers1

0

You have to specify that ALT should be held down when SCROLL LOCK is pressed.

For that you must add parentheses around {SCROLLLOCK}:

SendKeys.SendWait("%({SCROLLLOCK})")
Visual Vincent
  • 18,045
  • 5
  • 28
  • 75
  • Still doesn't work, I tried some other simple Keys like `SendKeys.SendWait("{END}")` but doesn't work too. – flohdieter Jul 08 '16 at 09:55
  • @flohdieter : How can you tell it doesn't work? You know it sends the keys to the currently active window, right? If the active window is your console app then it will be sent to that and nothing else. – Visual Vincent Jul 08 '16 at 09:57
  • @flohdieter : For instance, what happens if you try: `^({ESC})` (CTRL + ESC)? It should open the Start Menu. – Visual Vincent Jul 08 '16 at 09:59
  • nothing happens when im sending`^({ESC})`...does it work on your system? – flohdieter Jul 08 '16 at 10:02
  • @flohdieter : Yes, and I use Windows 7 x64 too. `SendKeys` should call WinAPI's `SendInput()` functions, which is why I find it strange that it doesn't work. You could always try [P/Invoking keybd_event()](http://stackoverflow.com/questions/11402643/sendkey-send-not-working). – Visual Vincent Jul 08 '16 at 10:03
  • did you change any settings? I'm using Visual Studio 2013, a VB Console Application with the .Net Framework 4.5. In Both modes, Debug and Release nothing happens. I try it on two machines, both Win7 x64. – flohdieter Jul 08 '16 at 10:06
  • @flohdieter : No I did not change anything. It should work for anyone, especially on W7. – Visual Vincent Jul 08 '16 at 10:09
  • May the hater please stop downvoting my posts without reason? What did I ever do to you? – Visual Vincent Jul 08 '16 at 18:11