Jump to content

ControlGetPos taskbar?


hot202
 Share

Recommended Posts

Func task_get_pos()
    $pos = WinGetPos("[CLASS:Shell_TrayWnd]")
    If $pos[0]<>0 Then Return 3 ; right side
    If $pos[1] = 0 Then
        If $pos[2] = @DesktopWidth Then
            Return 4 ; top
        Else
            Return 1 ; left
        EndIf
    EndIf
    Return 2 ; bottom
EndFunc

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Link to comment
Share on other sites

  • Moderators

hot202,

This function has found the TaskBar successfully for me and the many others to whom I have given it: :D

ConsoleWrite(Find_Taskbar() & @CRLF)

Func Find_Taskbar()

    ; Find taskbar
    Local $iPrevMode = AutoItSetOption("WinTitleMatchMode", 4)
    Local $aTaskBar_Pos = WinGetPos("classname=Shell_TrayWnd")
    AutoItSetOption("WinTitleMatchMode", $iPrevMode)

    ; If error in finding taskbar
    If Not IsArray($aTaskBar_Pos) Then Return SetError(1, 0, "")

    ; Determine position of taskbar
    If $aTaskBar_Pos[1] > 0 Then
        ; Taskbar at BOTTOM
        If $aTaskBar_Pos[1] > @DesktopHeight - $aTaskBar_Pos[3] Then
            Return "Bottom Hidden"
        Else
            Return "Bottom"
        EndIf
    ElseIf $aTaskBar_Pos[0] > 0 Then
        ; Taskbar at RIGHT
        If $aTaskBar_Pos[0] > @DesktopWidth - $aTaskBar_Pos[2] Then
            Return "Right Hidden"
        Else
            Return "Right"
        EndIf
    ElseIf $aTaskBar_Pos[2] = @DesktopWidth Then
        ; Taskbar at TOP
        If $aTaskBar_Pos[1] < 0 Then
            Return "Top Hidden"
        Else
            Return "Top"
        EndIf
    ElseIf $aTaskBar_Pos[3] = @DesktopHeight Then
        ; Taskbar at LEFT
        If $aTaskBar_Pos[0] < 0 Then
            Return "Left Hidden"
        Else
            Return "Left"
        EndIf
    EndIf

EndFunc

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

  • Moderators

hot202,

Use the Au3 Window Info tool to check your taskbar is actually meets the "classname=Shell_TrayWnd" criteria - although I have yet to meet one that does not.

What OS are you using?

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

  • Moderators

hot202,

I have no idea. :D

Could you please post the exact script you are trying to use (unless it is the one I posted above!) and then run this short script from SciTE and post what appears in the SciTE console (the bit at the bottom of the SciTE window).

ConsoleWrite("Width =  " & @DesktopWidth & @CRLF & "Height = " & @DesktopHeight & @CRLF)

And have you checked your Taskbar with the Au3 Window Info tool to see if it is a Shell_TrayWnd?

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

  • Moderators

hot202,

Well, at least the script can use the @DeskTop* macros to read your screen size - not that I thought it could not. :D

Next step, move your task bar to the 4 edges of the screen, run this script each time and tell me what it says:

Local $iPrevMode = AutoItSetOption("WinTitleMatchMode", 4)
Local $aTaskBar_Pos = WinGetPos("classname=Shell_TrayWnd")
AutoItSetOption("WinTitleMatchMode", $iPrevMode)

If IsArray($aTaskBar_Pos) Then
    ConsoleWrite($aTaskBar_Pos[0] & " - " & $aTaskBar_Pos[1] & " - " & $aTaskBar_Pos[2] & " - " & $aTaskBar_Pos[3] & @CRLF)
Else
    ConsoleWrite("Not Found" & @CRLF)
EndIf

Please add where your TaskBar was each time (i.e Bottom, Left, Top, Right) so I can see what results come from where. :huggles:

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

  • Moderators

hot202,

Interesting, your taskbar overlaps the screen by 2 pixels in all directions - every other one I have seen fits into the corners!

But now that we know about it, try this script - I think I have got the corrections the right way round! :huggles:

ConsoleWrite(Find_Taskbar() & @CRLF)

Func Find_Taskbar()

    ; Find taskbar
    Local $iPrevMode = AutoItSetOption("WinTitleMatchMode", 4)
    Local $aTaskBar_Pos = WinGetPos("classname=Shell_TrayWnd")
    AutoItSetOption("WinTitleMatchMode", $iPrevMode)

    ; If error in finding taskbar
    If Not IsArray($aTaskBar_Pos) Then Return SetError(1, 0, "")

    ; Determine position of taskbar
    If $aTaskBar_Pos[1] > 0 Then
        ; Taskbar at BOTTOM
        If $aTaskBar_Pos[1] > @DesktopHeight - $aTaskBar_Pos[3] + 2 Then
            Return "Bottom Hidden"
        Else
            Return "Bottom"
        EndIf
    ElseIf $aTaskBar_Pos[0] > 0 Then
        ; Taskbar at RIGHT
        If $aTaskBar_Pos[0] > @DesktopWidth - $aTaskBar_Pos[2] + 2 Then
            Return "Right Hidden"
        Else
            Return "Right"
        EndIf
    ElseIf $aTaskBar_Pos[2] = @DesktopWidth + 4 Then
        ; Taskbar at TOP
        If $aTaskBar_Pos[1] < -2 Then
            Return "Top Hidden"
        Else
            Return "Top"
        EndIf
    ElseIf $aTaskBar_Pos[3] = @DesktopHeight + 4 Then
        ; Taskbar at LEFT
        If $aTaskBar_Pos[0] < -2 Then
            Return "Left Hidden"
        Else
            Return "Left"
        EndIf
    EndIf

EndFunc

By the way, the different colours in the SciTE console are nothing to do with the taskbar - it al depends on the leading character of the string being written. Try running this:

ConsoleWrite('! = Red' & @LF)
ConsoleWrite('> = Blue' & @LF)
ConsoleWrite('- = Orange' & @LF)
ConsoleWrite('+ = Green' & @LF)
ConsoleWrite('(5) : = Red (jump to line 5 when double-clicked)' & @LF)
ConsoleWrite('Start with String or Integer then ' & @TAB & '6' & ' = Pink (jump to line 6 when double-clicked)' & @LF)
;
;
ConsoleWrite('(' & @ScriptLineNumber & ') : = Red (jump to line ' & @ScriptLineNumber & ' when double-clicked)' & @CRLF)

It is very useful to highlight various lines within the output. And do try double-clicking on the lines - the jumps do work.

And you will be pleased to know that the last bit of SciTE knowledge comes at no extra charge to the fee I will be charging you in due course. :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

  • Moderators

hot202,

You are correct - the new version only works on a TaskBar like yours. Perhaps you are unique in the world? Actually I think it is more a function of the NetBook you are using. :D

I will try and produce a universal script this afternoon.

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

  • Moderators

hot202,

This works on my "normal" TaskBar - try it on your "abnormal" one. :huggles:

ConsoleWrite(Find_Taskbar() & @CRLF)

Func Find_Taskbar()

    ; Find taskbar
    Local $iPrevMode = AutoItSetOption("WinTitleMatchMode", 4)
    Local $aTaskBar_Pos = WinGetPos("classname=Shell_TrayWnd")
    AutoItSetOption("WinTitleMatchMode", $iPrevMode)

    ; If error in finding taskbar
    If Not IsArray($aTaskBar_Pos) Then Return SetError(1, 0, "")

    ; Determine position of taskbar
    If $aTaskBar_Pos[1] > 0 Then
        ; Taskbar at BOTTOM
        If $aTaskBar_Pos[1] > @DesktopHeight - $aTaskBar_Pos[3]  + 2 Then
            Return "Bottom Hidden"
        Else
            Return "Bottom"
        EndIf
    ElseIf $aTaskBar_Pos[0] > 0 Then
        ; Taskbar at RIGHT
        If $aTaskBar_Pos[0] > @DesktopWidth - $aTaskBar_Pos[2] + 2 Then
            Return "Right Hidden"
        Else
            Return "Right"
        EndIf
    ElseIf $aTaskBar_Pos[2] >= @DesktopWidth Then
        ; Taskbar at TOP
        If $aTaskBar_Pos[1] < -2 Then
            Return "Top Hidden"
        Else
            Return "Top"
        EndIf
    ElseIf $aTaskBar_Pos[3] >= @DesktopHeight Then
        ; Taskbar at LEFT
        If $aTaskBar_Pos[0] < -2 Then
            Return "Left Hidden"
        Else
            Return "Left"
        EndIf
    EndIf

EndFunc

Let me know if you run into any problems on other machines from now on. If you do run across any more ill-behaved TaskBars that do not give the correct response, it would be very helpful to have the same info that I asked you for earlier so I can see where it is actually placed. :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

  • 8 months later...

hot202,

This works on my "normal" TaskBar - try it on your "abnormal" one. :)

ConsoleWrite(Find_Taskbar() & @CRLF)

Func Find_Taskbar()

    ; Find taskbar
    Local $iPrevMode = AutoItSetOption("WinTitleMatchMode", 4)
    Local $aTaskBar_Pos = WinGetPos("classname=Shell_TrayWnd")
    AutoItSetOption("WinTitleMatchMode", $iPrevMode)

    ; If error in finding taskbar
    If Not IsArray($aTaskBar_Pos) Then Return SetError(1, 0, "")

    ; Determine position of taskbar
    If $aTaskBar_Pos[1] > 0 Then
        ; Taskbar at BOTTOM
        If $aTaskBar_Pos[1] > @DesktopHeight - $aTaskBar_Pos[3]  + 2 Then
            Return "Bottom Hidden"
        Else
            Return "Bottom"
        EndIf
    ElseIf $aTaskBar_Pos[0] > 0 Then
        ; Taskbar at RIGHT
        If $aTaskBar_Pos[0] > @DesktopWidth - $aTaskBar_Pos[2] + 2 Then
            Return "Right Hidden"
        Else
            Return "Right"
        EndIf
    ElseIf $aTaskBar_Pos[2] >= @DesktopWidth Then
        ; Taskbar at TOP
        If $aTaskBar_Pos[1] < -2 Then
            Return "Top Hidden"
        Else
            Return "Top"
        EndIf
    ElseIf $aTaskBar_Pos[3] >= @DesktopHeight Then
        ; Taskbar at LEFT
        If $aTaskBar_Pos[0] < -2 Then
            Return "Left Hidden"
        Else
            Return "Left"
        EndIf
    EndIf

EndFunc

Let me know if you run into any problems on other machines from now on. If you do run across any more ill-behaved TaskBars that do not give the correct response, it would be very helpful to have the same info that I asked you for earlier so I can see where it is actually placed. ;)

M23

I had a similar issue, but your solution worked. I needed the taskbar position, though, so I modified your function a little:

Local $aTaskBar_Pos = Find_Taskbar()
If @error Then Exit
Local $TaskBarInfo =""
For $i=0 To UBound($aTaskBar_Pos)-1 Step 1
    $TaskBarInfo &=$aTaskBar_Pos[$i]&@CRLF
Next
MsgBox(0,'TaskBarInfo',$TaskBarInfo)

Func Find_Taskbar()
    Dim $aTaskBarPos[5]
    ; Find taskbar
    Local $iPrevMode = AutoItSetOption("WinTitleMatchMode", 4)
    Local $aTaskBar_Pos = WinGetPos("classname=Shell_TrayWnd")
    AutoItSetOption("WinTitleMatchMode", $iPrevMode)

    ; If error in finding taskbar
    If Not IsArray($aTaskBar_Pos) Then Return SetError(1, 0, "")
    ; Determine position of taskbar
    Select
        Case $aTaskBar_Pos[1] > 0
            ; TaskBar at BOTTOM
            If $aTaskBar_Pos[1] > @DesktopHeight - $aTaskBar_Pos[3] + 2 Then
                $aTaskBarPos[0] = "Bottom Hidden"
            Else
                $aTaskBarPos[0] = "Bottom"
            EndIf
        Case $aTaskBar_Pos[0] > 0
            ; TaskBar at RIGHT
            If $aTaskBar_Pos[0] > @DesktopWidth - $aTaskBar_Pos[2] + 2 Then
                $aTaskBarPos[0] = "Right Hidden"
            Else
                $aTaskBarPos[0] = "Right"
            EndIf
        Case $aTaskBar_Pos[2] >= @DesktopWidth
            ; TaskBar at TOP
            If $aTaskBar_Pos[1] < -2 Then
                $aTaskBarPos[0] = "Top Hidden"
            Else
                $aTaskBarPos[0] = "Top"
            EndIf
        Case $aTaskBar_Pos[3] >= @DesktopHeight
            ; TaskBar at LEFT
            If $aTaskBar_Pos[0] < -2 Then
                $aTaskBarPos[0] = "Left Hidden"
            Else
                $aTaskBarPos[0] = "Left"
            EndIf
    EndSelect
    For $i=0 To UBound($aTaskBar_Pos)-1 Step 1
        $aTaskBarPos[$i+1]=$aTaskBar_Pos[$i]
    Next
    Return $aTaskBarPos

EndFunc   ;==>GetTaskbarPos
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...