Sign in to follow this  
Followers 0
hot202

ControlGetPos taskbar?

17 posts in this topic

hi how do i tell if the taskbar is at the top or bottom or left or right i can only know if its on the bottom or left.

Opt('WINTITLEMATCHMODE', 4)

$pos = ControlGetPos("classname=Shell_TrayWnd", "", "ToolbarWindow322")
Switch $pos[0]
case 66
    ;bottom
Case 0
    ;left
EndSwitch

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

thanks but that dont seem to work its just coming up with 3 all the time in a msg box even when imove the task bar

Share this post


Link to post
Share on other sites

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

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

still have probs with that its finding it on the bottom but says (bottom hidden) same as on the right it works but says its hidden. When its on the top or left it just shows 0

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

im using win xp. its on a asus eee900 pc so it has a small screen would that have anything to dowith it?

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

i used your script above.

and this is what i got with that other thing u asked

Width = 1024

Height = 600

and yesi used the info tool and the class was Shell_trayWnd

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

bottom = -2 - 572 - 1028 - 30

top = -2 - -2 - 1028 - 30

left = -2 - -2 - 60 - 604

right = 966 - -2 - 60 - 604 ( that was black text the other ones were orange)

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

omg thanks heaps:) that worked and thanks 4 the extra help with the colour stuff :D so if i use the taskbar script that works 4 my computer on a diff computer it will get messed up like it was happining to me before?

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

that 1 worked on mine to. U r so smart thanks heaps :D

Share this post


Link to post
Share on other sites

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

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