Jump to content

WinTitleMatchMode


anixon
 Share

Recommended Posts

This code gets the client size of the windows notification area

Local $iMode = Opt("WinTitleMatchMode", 4)
Local $hControl = ControlGetHandle("[CLASS:Shell_TrayWnd]", "", "[CLASSNN:ToolbarWindow321]")
Local $acSize = WinGetClientSize($hControl)
_arraydisplay($acSize)

Is it possible to yet the x y width and height location of a specific Icon that appears somewhere on the notification area 'Skype' for example:

Assistance is always appreciated Ant..

Link to comment
Share on other sites

Thanks for that I have played with the software since your response and have been unable to get the $x $y position of the Icon. Silly question but if the Return is an array how do you then display the array produced by the called function? Ant..

Link to comment
Share on other sites

Thanks for that I have played with the software since your response and have been unable to get the $x $y position of the Icon.

The tray is just a toolbar control. You should be able to use things like _GUICtrlToolbar_GetButtonRect() on it.

Silly question but if the Return is an array how do you then display the array produced by the called function? Ant..

Very silly, since you used _ArrayDisplay() in your own code in the OP.

:D

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

The tray is just a toolbar control. You should be able to use things like _GUICtrlToolbar_GetButtonRect() on it.

Very silly, since you used _ArrayDisplay() in your own code in the OP.

:D

Can you give me an example of _GUICtrlToolbar_GetButtonRectEX() for Skype that appears as an Icon in the Notification Area to the Toolbar Thanks Ant..

Link to comment
Share on other sites

  • Moderators

anixon,

Here is a script that finds and clicks on a systray icon that you identify by the text content of the traytip - I have found it best to use the initial words of the traytip:

#Include <GuiToolBar.au3>

Global $hSysTray_Handle, $iSystray_ButtonNumber

Global $sToolTipTitle = "" ; <<<<<<<<<<<<<<<< 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
    Sleep(500)
    _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
EndIf

Exit

;............

Func Get_Systray_Index($sToolTipTitle)

    ; Find systray handle
    $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
    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

If you want the coordinates of the icon, then replace the _GUICtrlToolbar_ClickButton line with _GUICtrlToolbar_GetButtonRect or _GUICtrlToolbar_GetButtonRectEx.

I hope that helps. :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

This code

$Coordinates = _GUICtrlToolbar_GetButtonRect($hSysTray_Handle, $iSystray_ButtonNumber)

MsgBox(0,'',$Coordinates[0] & " " & $Coordinates[2])

Skype gives me these values for the x axis 54 Upper Left and 72 Lower Right how does that relate to Skypes position based on @DesktopWidth. In other words how would you translate

the Upper left X access of the Skype Icon X position based on desktop width because I am pretty sure it is not @desktopwidth - 54. Ant..

Link to comment
Share on other sites

  • Moderators

anixon,

Those coords are relative to the systray in which it sits - so you need to get the systray position (via WingetPos - you already have the handle :huggles: ) and do little maths to get the screen coords. Or you could use _WinAPI_ClientToScreen - as you have to create a struct to use this there is probably not a lot in it.... :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

That's the position of the button (icon) relative to the toolbar.

:D

Edit: Out typed by the Melba-bot!

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Thanks for the help this looks like it works I hope that the code is elegant enough this exercise has taught me heaps thanks again ...... Ant..

#Include <GuiToolBar.au3>


Global $hSysTray_Handle, $iSystray_ButtonNumber, $xAxisNTB, $xAxisIcon

Global $sToolTipTitle = "Skype" ; <<<<<<<<<<<<<<<< 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
    ;//'X' Axis Windows Notification Bar
    $xAxisNTB = WingetPos($hSysTray_Handle)
    ;//'X' Axis Icon on Notification Bar
    $xAxisIcon = _GUICtrlToolbar_GetButtonRect($hSysTray_Handle, $iSystray_ButtonNumber)
    ;//'X' Axis Skype Notification Toolbar Icon based on Desktop
    msgbox(0,"", "X Axis" & " NTB " & $xAxisNTB[0] & " Icon " & $xAxisIcon[0] & " X Pos Skype " & $xAxisNTB[0] + $xAxisIcon[0])
EndIf

Exit

Func _Get_Systray_Index($sToolTipTitle)
    ; Find systray handle
    $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
    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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...