Sign in to follow this  
Followers 0
qay

Windows 10 using tray icons

1 post in this topic

Hello everyone,

I used for several years code  to shut down my Virus Scanner before backing up files.

Since Win 7 it displayed a Popup asking me if I really want it (I confirmed) and then a UAC.
After updating to Windows 10 the code is broken; I found this old Topic

and got at least the clicking on the tray icon solved. But interacting with the content Menu is not possible. Nether send() nor mousemove() is executed.

Any help would be great!

 

Thanks

Qay

 

#include <GuiToolbar.au3>

disable_AVAST()
Exit


func disable_AVAST()
    Global $hSysTray_Handle, $iSystray_ButtonNumber

    Global $sToolTipTitle = "Avast" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here

    $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle)

    If $iSystray_ButtonNumber = 0 Then
        MsgBox(16, "Error", "Icon not found in system tray")
    ;~     Exit
    Else



        BlockInput(1)
        Sleep(500)
        _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
        sleep(50)
        Send("{UP}")
        Send("{UP}")
        sleep(50)
        Send("{UP}")
        sleep(50)
        Send("{UP}")
        sleep(50)
        Send("{UP}")
        sleep(50)
        Send("{UP}")
        sleep(50)
        Send("{right}")
        sleep(50)
        Send("{down}")
        sleep(50)
        Send("{down}")
        sleep(50)
        Send("enter")
        BlockInput(0)
    EndIf

EndFunc



Func Get_Systray_Index($sToolTipTitle)

    ; Find systray handle
    $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:2]')
    If @error Then
        MsgBox(16, "Error", "System tray not found")
;~         Exit
    EndIf

    ; Get systray item count
    Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle)
    If $iSystray_ButCount = 0 Then
        MsgBox(16, "Error", "No items found in system tray")
;~         Exit
    EndIf

    ; Look for wanted tooltip
    For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1
        If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) = 1 Then ExitLoop
    Next

    If $iSystray_ButtonNumber = $iSystray_ButCount Then
        Return 0 ; Not found
    Else
        Return $iSystray_ButtonNumber ; Found
    EndIf

EndFunc

 

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0