Skip to content

How do I open the menu using windows shortcut (.lnk file)? #575

@paolosezart

Description

@paolosezart

I know that it is possible to call SystemTrayMenu from the windows tray (next to the clock). But it's much more familiar to me to do this from the "Quick Launch" menu, which is located in windows Explorer along the way. C:\Users\user\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch. I would like to create a shortcut there to run SystemTrayMenu.
I have now implemented this using a vbs+bat script. To simulate pressing LeftAlt + Win, I set this combination to open the SystemTrayMenu menu.

LeftAlt + Win.vbs
Option Explicit

Dim shell, fso, base, batPath

Set shell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

base = fso.GetParentFolderName(WScript.ScriptFullName)
shell.CurrentDirectory = base

batPath = """" & base & "\LeftAlt + Win.bat"""

shell.Run batPath, 0, False
LeftAlt + Win.bat
<# :
@echo off
powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((Get-Content '%~f0') -join [Environment]::NewLine)"
exit /b
#>

$Signature = @'
[DllImport("user32.dll")]
public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo);
'@

$Win32Keyboard = Add-Type -MemberDefinition $Signature -Name "Win32Keyboard" -Namespace "Win32" -PassThru

$VK_LALT = 0xA4   # Left Alt
$VK_LWIN = 0x5B   # Left Windows
$KEYEVENTF_KEYUP = 0x0002

$Win32Keyboard::keybd_event($VK_LALT, 0, 0, 0)
$Win32Keyboard::keybd_event($VK_LWIN, 0, 0, 0)

$Win32Keyboard::keybd_event($VK_LWIN, 0, $KEYEVENTF_KEYUP, 0)
$Win32Keyboard::keybd_event($VK_LALT, 0, $KEYEVENTF_KEYUP, 0)

However, it seems to me that this is not the best option.
Is it possible to access the SystemTrayMenu menu from a windows shortcut without creating workarounds in the form of simulating keyboard keystrokes?
Or at least implement a call from the command line (bat script) using arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions