views:

44

answers:

0

Below is some jscript code that I modified from the example code at http://msdn.microsoft.com/en-us/library/aew9yb99%28v=VS.85%29.aspx :

// Code snippet to create a desktop link:
var WshShell = WScript.CreateObject("WScript.Shell");
strDesktop = WshShell.SpecialFolders("Desktop");
var oShellLink = WshShell.CreateShortcut(strDesktop + "\\Shortcut to Notepad");
oShellLink.TargetPath = "notepad.exe";
oShellLink.WindowStyle = 1;
oShellLink.Hotkey = "CTRL+SHIFT+F";
oShellLink.IconLocation = "notepad.exe, 0";
oShellLink.Description = "Shortcut to Notepad";
oShellLink.WorkingDirectory = strDesktop;
oShellLink.Save();

Notice the "CTRL+SHIFT+F" value of the Hotkey setting above. Granted, I really should not have had included that hotkey setting in the script in the first place, because now I am unable to "undo" that global hotkey setting completely, as described below.

I ran the above via:

cscript my_file.js

And the CTRL+SHIFT+F shortcut works as expected, and invokes notepad.exe. I realized that I didn't want that hotkey, so I set the value to the empty string:

oShellLink.Hotkey = "";

And reran the script. Pressing CTRL+SHIFT+F key sequence doesn't execute notepad.exe (expected behavior). But now I expect to press that key sequence and have other applications "see" the event, but other applications are NOT seeing the event. What is going on here? I then logged into a different Windows system upon which I did not execute the above script at all, and confirmed that the CTRL+SHIFT+F hotkey is dutifully passed on to the window containing the focus.

How can I undo or unregister that hotkey so that other applications can "see" that event?

By the way, I don't have to have code in jscript to unregister the global hotkey, per se. If I have to manually twiddle the registry via regedit, that is fine by me, since this was just a test for setting up a shortcut on the desktop.