NotifyIcon Detect Key down state and add extra menus

This topic contains 1 reply, has 1 voice, and was last updated by  Ronnie Slater 5 months, 1 week ago.

  • Author
    Posts
  • #73076

    Ronnie Slater
    Participant

    What I want to happen:
    When a user clicks Refresh, it will detect the Shift and Control key states. When the NotifyIcon reloads if the keys are DOWN it will add the additional ADMIN menu options. When the user clicks Refresh again, and SHIFT and Control are not DOWN. It removes them. The full code is not listed with all functions.

    Please help

    If I launch the script using ISE, it detects the Key down states and adds the menu. Launching from Console it does not.

    I have tried $Host.UI.RawUI option but I am unable to get it working properly. What am I missing.

    How the script is being launched:
    Script is launched from a logon Powershell script using the following command:
    Start-Process (powershell.exe -WindowStyle Hidden -ExecutionPolicy bypass -File "\\pathtofile\trayicon.ps1") -WindowStyle Hidden

    Script:

  • #73102

    Ronnie Slater
    Participant

    I got it working. Added the Test-KeyPress.ps1 function. Within Refresh I added $script:keypress = Test-KeyPress -Keys LShift,LCtrl

    In createicon I just checked if $script:keypress was true. And added the menu items

You must be logged in to reply to this topic.