Bert

Docking

11 posts in this topic

#1 ·  Posted (edited)

I made a script based on GaFrost docking script to test a concept:

CODE
#include <GuiConstants.au3>

Opt ("WinTitleMatchMode", 2)

Opt ("GUIOnEventMode", 1)

Opt ('MustDeclareVars', 1)

Dim $Btn_Exit1 , $Btn_msg1

DIM $GUI1, $GUI2

Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1

;===================================================================================================

$GUI1 = GUICreate("Toolbar", 120, 50, "", "", "", $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

$Btn_Exit1 = GUICtrlCreateButton("Exit",1, 1, 40, 25)

GUICtrlSetOnEvent($Btn_Exit1, "_Exit")

$Btn_msg1 = GUICtrlCreateButton("button",51, 1, 50, 25)

GUICtrlSetOnEvent($Btn_msg1, "_msg")

;===================================================================================================

$GUI2 = winwaitactive("Untitled - Notepad")

;$GUI2 = winwaitactive("gar.txt")

;$GUI2 = winwaitactive("111.txt")

;===================================================================================================

GUISetState(@SW_SHOW, $GUI1)

;===================================================================================================

;Winactivate("gar.txt")

;Winactivate("111.txt")

Winactivate("Untitled - Notepad")

While 1

_ToolbarDocked()

Sleep(10)

WEnd

Func _ToolbarDocked()

$p_win1 = WinGetPos($GUI1) ;parent

$p_win2 = WinGetPos($GUI2) ;toolbar

If $Dock_Location == 1 Then

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1),8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $p_win1[2] + $x1 - 125

$y2 = $y1 - 44

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2),8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $p_win2[0] - $p_win1[2] + 125

$y1 = $y2 + 44

WinMove($GUI1, "", $x1, $y1)

EndIf

Else

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1),8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $x1

$y2 = $p_win1[3] + $y1

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2),8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $x2

$y1 = $p_win2[1] - $p_win1[3]

WinMove($GUI1, "", $x1, $y1)

EndIf

EndIf

EndFunc ;==>_ToolbarDocked

Func _Exit()

Exit

EndFunc ;==>_Exit

Func SpecialEvents()

Select

Case @GUI_CtrlId = $GUI_EVENT_CLOSE

Exit

EndSelect

EndFunc ;==>SpecialEvents

Func _msg()

msgbox(0, "", "button pushed")

EndFunc ;==>_msg

I have 2 problems.

1- how do I have it so the toolbar will a ontop characteristic when the parent window has focus? I know I currently have the GUICREATE with the $WS_EX_TOPMOST switch in it, but I do not know a better way to do this.

2. For some reason, the script will only run if 111.txt is running on the desktop. You can see in the code where I comment out the 111.txt and tried to use untitled or gar.txt. I get a error on line 50 when I do this.

Thoughts?

Edited by vollyman

Share this post


Link to post
Share on other sites



#include <GuiConstants.au3>
Opt("WinTitleMatchMode", 2)
Opt("GUIOnEventMode", 1)
Opt('MustDeclareVars', 1)
Dim $Btn_Exit1, $Btn_msg1
Dim $GUI1, $GUI2
Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1


WinWait("Untitled - Notepad")
$GUI2 = WinGetHandle("Untitled - Notepad")
;===================================================================================================



$GUI1 = GUICreate("Toolbar", 120, 50, -1, -1, -1, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW, $GUI2)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

$Btn_Exit1 = GUICtrlCreateButton("Exit", 1, 1, 40, 25)
GUICtrlSetOnEvent($Btn_Exit1, "_Exit")
$Btn_msg1 = GUICtrlCreateButton("button", 51, 1, 50, 25)
GUICtrlSetOnEvent($Btn_msg1, "_msg")

;===================================================================================================




GUISetState(@SW_SHOW, $GUI1)

;===================================================================================================



WinActivate("Untitled - Notepad")
While 1
 If Not WinExists ("Untitled - Notepad") Then Exit
   _ToolbarDocked()
   Sleep(10)
WEnd


Func _ToolbarDocked()
   $p_win1 = WinGetPos($GUI1);parent
   $p_win2 = WinGetPos($GUI2);toolbar
   If $Dock_Location == 1 Then
      If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then
         $x1 = $p_win1[0]
         $y1 = $p_win1[1]
         $x2 = $p_win1[2] + $x1 - 125
         $y2 = $y1 - 44
         WinMove($GUI2, "", $x2, $y2)
         $Dock = 1
      ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then
         $x2 = $p_win2[0]
         $y2 = $p_win2[1]
         $x1 = $p_win2[0] - $p_win1[2] + 125
         $y1 = $y2 + 44
         WinMove($GUI1, "", $x1, $y1)
      EndIf
   Else
      If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then
         $x1 = $p_win1[0]
         $y1 = $p_win1[1]
         $x2 = $x1
         $y2 = $p_win1[3] + $y1
         WinMove($GUI2, "", $x2, $y2)
         $Dock = 1
      ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then
         $x2 = $p_win2[0]
         $y2 = $p_win2[1]
         $x1 = $x2
         $y1 = $p_win2[1] - $p_win1[3]
         WinMove($GUI1, "", $x1, $y1)
      EndIf
   EndIf
EndFunc  ;==>_ToolbarDocked

Func _Exit()
   Exit
EndFunc  ;==>_Exit

Func SpecialEvents()
   Select
      Case @GUI_CtrlId = $GUI_EVENT_CLOSE
         Exit
   EndSelect
EndFunc  ;==>SpecialEvents

Func _msg()
   MsgBox(0, "", "button pushed")
EndFunc  ;==>_msg


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Nice one, I didn't know you made a UDF for this Gary!


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Nice one, I didn't know you made a UDF for this Gary!

Didn't in scripts and scraps somewhere, used it in a couple of projects, code snippet for one


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I see it working, but it still has the problem of the toolbar with the ontop function when the parent window is not active. Not sure on how to handle that one.

edit: I tried this, and it will work at first. When you go back to the window to make it active again, the script gets hung. I think I know why, but I'm not sure on how to fix it.

CODE
#include <GuiConstants.au3>

Opt("WinTitleMatchMode", 2)

Opt("GUIOnEventMode", 1)

Opt('MustDeclareVars', 1)

Dim $Btn_Exit1, $Btn_msg1

Dim $GUI1, $GUI2

Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1

WinWait("Untitled - Notepad")

$GUI2 = WinGetHandle("Untitled - Notepad")

;===================================================================================================

$GUI1 = GUICreate("Toolbar", 120, 50, -1, -1, -1, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW, $GUI2)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

$Btn_Exit1 = GUICtrlCreateButton("Exit", 1, 1, 40, 25)

GUICtrlSetOnEvent($Btn_Exit1, "_Exit")

$Btn_msg1 = GUICtrlCreateButton("button", 51, 1, 50, 25)

GUICtrlSetOnEvent($Btn_msg1, "_msg")

;===================================================================================================

GUISetState(@SW_SHOW, $GUI1)

;===================================================================================================

WinActivate("Untitled - Notepad")

While 1

If Not WinExists ("Untitled - Notepad") Then Exit

if winexists("Untitled - Notepad") Then

if winactive ("Untitled - Notepad") then GUISetState(@SW_SHOW, $GUI1)

sleep(1000)

if not winactive ("Untitled - Notepad") then GUISetState(@SW_hide, $GUI1)

endif

_ToolbarDocked(131, 44)

Sleep(10)

WEnd

Func _ToolbarDocked($xx, $yy)

$p_win1 = WinGetPos($GUI1);parent

$p_win2 = WinGetPos($GUI2);toolbar

If $Dock_Location == 1 Then

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $p_win1[2] + $x1 - $xx

$y2 = $y1 - $yy

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $p_win2[0] - $p_win1[2] + $xx

$y1 = $y2 + $yy

WinMove($GUI1, "", $x1, $y1)

EndIf

Else

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $x1

$y2 = $p_win1[3] + $y1

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $x2

$y1 = $p_win2[1] - $p_win1[3]

WinMove($GUI1, "", $x1, $y1)

EndIf

EndIf

EndFunc ;==>_ToolbarDocked

Func _Exit()

Exit

EndFunc ;==>_Exit

Func SpecialEvents()

Select

Case @GUI_CtrlId = $GUI_EVENT_CLOSE

Exit

EndSelect

EndFunc ;==>SpecialEvents

Func _msg()

MsgBox(0, "", "button pushed")

EndFunc ;==>_msg

Edited by vollyman

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>
Opt("WinTitleMatchMode", 2)
Opt("GUIOnEventMode", 1)
Opt('MustDeclareVars', 1)
Dim $Btn_Exit1, $Btn_msg1
Dim $GUI1, $GUI2
Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1


WinWait("Untitled - Notepad")
$GUI2 = WinGetHandle("Untitled - Notepad")
;===================================================================================================



$GUI1 = GUICreate("Toolbar", 120, 50, -1, -1, $WS_CLIPSIBLINGS, BitOR($WS_EX_MDICHILD, $WS_EX_TOOLWINDOW), $GUI2)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

$Btn_Exit1 = GUICtrlCreateButton("Exit", 1, 1, 40, 25)
GUICtrlSetOnEvent($Btn_Exit1, "_Exit")
$Btn_msg1 = GUICtrlCreateButton("button", 51, 1, 50, 25)
GUICtrlSetOnEvent($Btn_msg1, "_msg")

;===================================================================================================




GUISetState(@SW_SHOW, $GUI1)

;===================================================================================================



WinActivate("Untitled - Notepad")
While 1
   If Not WinExists("Untitled - Notepad") Then Exit
   _ToolbarDocked()
   Sleep(10)
WEnd


Func _ToolbarDocked()
   $p_win1 = WinGetPos($GUI1);parent
   $p_win2 = WinGetPos($GUI2);toolbar
   If $Dock_Location == 1 Then
      If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then
         $x1 = $p_win1[0]
         $y1 = $p_win1[1]
         $x2 = $p_win1[2] + $x1 - 125
         $y2 = $y1 - 44
         WinMove($GUI2, "", $x2, $y2)
         $Dock = 1
      ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then
         $x2 = $p_win2[0]
         $y2 = $p_win2[1]
         $x1 = $p_win2[0] - $p_win1[2] + 125
         $y1 = $y2 + 44
         WinMove($GUI1, "", $x1, $y1)
      EndIf
   Else
      If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then
         $x1 = $p_win1[0]
         $y1 = $p_win1[1]
         $x2 = $x1
         $y2 = $p_win1[3] + $y1
         WinMove($GUI2, "", $x2, $y2)
         $Dock = 1
      ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then
         $x2 = $p_win2[0]
         $y2 = $p_win2[1]
         $x1 = $x2
         $y1 = $p_win2[1] - $p_win1[3]
         WinMove($GUI1, "", $x1, $y1)
      EndIf
   EndIf
EndFunc  ;==>_ToolbarDocked

Func _Exit()
   Exit
EndFunc  ;==>_Exit

Func SpecialEvents()
   Select
      Case @GUI_CtrlId = $GUI_EVENT_CLOSE
         Exit
   EndSelect
EndFunc  ;==>SpecialEvents

Func _msg()
   MsgBox(0, "", "button pushed")
EndFunc  ;==>_msg


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Tested it, and it works great. I want to take it a step further so the function can be used with multiple windows and toolbars. I use a web based application that I want to have a toolbar for, but I want to have it so the toolbar will customized for each window. thoughts?

Edited by vollyman

Share this post


Link to post
Share on other sites

I came up with this, but now the test window will shoot off the end of the screen! I'm not sure what I did wrong, but I was attempting to make it easier to use by being able to plug in that you need to make the functions work. (my first attempt to make a function with parameters) :)

CODE

#include <GuiConstants.au3>

Opt("WinTitleMatchMode", 2)

Opt("GUIOnEventMode", 1)

Opt('MustDeclareVars', 1)

Dim $Btn_msg1

Dim $GUI1, $GUI2, $childw, $Btn_Exit1, $Btn_msg1

Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1

_ChildDockWindow("Toolbar", 120, 50, "Untitled - Notepad")

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

$Btn_Exit1 = GUICtrlCreateButton("Exit", 1, 1, 40, 25)

GUICtrlSetOnEvent($Btn_Exit1, "_Exit")

$Btn_msg1 = GUICtrlCreateButton("button", 51, 1, 50, 25)

GUICtrlSetOnEvent($Btn_msg1, "_msg")

WinActivate("Untitled - Notepad")

While 1

If Not WinExists("Untitled - Notepad") Then Exit

_ToolbarDocked("Untitled - Notepad", "Toolbar",125, 44)

WEnd

Func _ToolbarDocked($parent, $child, $xx, $yy)

$GUI1 = WinGetHandle($parent)

$GUI2 = WinGetHandle($child)

$p_win1 = WinGetPos($GUI1);parent

$p_win2 = WinGetPos($GUI2);toolbar

If $Dock_Location == 1 Then

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $p_win1[2] + $x1 - $xx

$y2 = $y1 - $yy

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $p_win2[0] - $p_win1[2] + $xx

$y1 = $y2 + $yy

WinMove($GUI1, "", $x1, $y1)

EndIf

Else

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $x1

$y2 = $p_win1[3] + $y1

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $x2

$y1 = $p_win2[1] - $p_win1[3]

WinMove($GUI1, "", $x1, $y1)

EndIf

EndIf

sleep(10)

EndFunc ;==>_ToolbarDocked

Func _ChildDockWindow($name, $xa, $ya, $parent)

GUICreate($name, $xa, $ya, -1, -1, $WS_CLIPSIBLINGS, BitOR($WS_EX_MDICHILD, $WS_EX_TOOLWINDOW), $parent)

GUISetState(@SW_SHOW)

endfunc ;==>_ChildDockWindows

Func _Exit()

Exit

EndFunc ;==>_Exit

Func SpecialEvents()

Select

Case @GUI_CtrlId = $GUI_EVENT_CLOSE

Exit

EndSelect

EndFunc ;==>SpecialEvents

Func _msg()

MsgBox(0, "", "button pushed")

EndFunc ;==>_msg

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Note trying to hijack, but I tried to create 3 new buttons and now notepad runs at the rightside in a little corner too .. it wont go back to normal, either fullscreen or in the corner.. even on a full restart!! don't even have autoit running :)

[EDIT] I fixed it by pressing size! and resizing.. issue resolved :mellow:

CODE

#include <GuiConstants.au3>

Opt("WinTitleMatchMode", 2)

Opt("GUIOnEventMode", 1)

Opt('MustDeclareVars', 1)

Dim $Btn_Exit1, $Btn_msg1

Dim $GUI1, $GUI2

Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1

WinWait("Untitled - Notepad")

$GUI2 = WinGetHandle("Untitled - Notepad")

;===================================================================================================

$GUI1 = GUICreate("Toolbar", 120, 50, -1, -1, $WS_CLIPSIBLINGS, BitOR($WS_EX_MDICHILD, $WS_EX_TOOLWINDOW), $GUI2)

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

$Btn_Exit1 = GUICtrlCreateButton("Exit", 1, 1, 40, 25)

GUICtrlSetOnEvent($Btn_Exit1, "_Exit")

$Btn_msg1 = GUICtrlCreateButton("button", 51, 1, 50, 25)

GUICtrlSetOnEvent($Btn_msg1, "_msg1")

$Btn_msg2 = GUICtrlCreateButton("button1", 71, 1, 50, 25)

GUICtrlSetOnEvent($Btn_msg2, "_msg2")

$Btn_msg3 = GUICtrlCreateButton("button2", 91, 1, 50, 25)

GUICtrlSetOnEvent($Btn_msg3, "_msg3")

;===================================================================================================

GUISetState(@SW_SHOW, $GUI1)

;===================================================================================================

WinActivate("Untitled - Notepad")

While 1

If Not WinExists("Untitled - Notepad") Then Exit

_ToolbarDocked()

Sleep(10)

WEnd

Func _ToolbarDocked()

$p_win1 = WinGetPos($GUI1);parent

$p_win2 = WinGetPos($GUI2);toolbar

If $Dock_Location == 1 Then

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $p_win1[2] + $x1 - 125

$y2 = $y1 - 44

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $p_win2[0] - $p_win1[2] + 125

$y1 = $y2 + 44

WinMove($GUI1, "", $x1, $y1)

EndIf

Else

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $x1

$y2 = $p_win1[3] + $y1

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $x2

$y1 = $p_win2[1] - $p_win1[3]

WinMove($GUI1, "", $x1, $y1)

EndIf

EndIf

EndFunc ;==>_ToolbarDocked

Func _Exit()

Exit

EndFunc ;==>_Exit

Func SpecialEvents()

Select

Case @GUI_CtrlId = $GUI_EVENT_CLOSE

Exit

EndSelect

EndFunc ;==>SpecialEvents

Func _msg()

MsgBox(0, "", "button pushed")

EndFunc ;==>_msg

Func _msg2()

MsgBox(0, "", "button pushed")

EndFunc ;==>_msg

Func _msg3()

MsgBox(0, "", "button pushed")

EndFunc ;==>_msg

Edited by slightly_abnormal

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

When I ran it, I had the notepad window zoom from one side to the other, then back again. If I can get this working right, it should be a good function to have when working with a toolbar. I also thought of making a function on where to place the docked window depending on the size of the IE toolbars. I figure this would be helpful.

@frost: I know you gave me a working solution earlier, but if you could take a look at this latest script and figure out where I went wrong, I would be very grateful. Also, I found when you resize the toolbar, you need to change the x position. It looks like it grabs the right side of the box, and not the left when determining position.

Edited by vollyman

Share this post


Link to post
Share on other sites

CODE

#include <GuiConstants.au3>

Opt("WinTitleMatchMode", 2)

Opt("GUIOnEventMode", 1)

Opt('MustDeclareVars', 1)

Dim $Btn_msg1

Dim $GUI1, $GUI2, $childw, $Btn_Exit1, $Btn_msg1

Dim $p_win1, $p_win2, $x1 = 10, $x2 = 315, $y1 = 10, $y2 = 10, $Dock = 1, $Dock_Location = 1

WinWait("Untitled - Notepad")

$GUI1 = WinGetHandle("Untitled - Notepad")

_ChildDockWindow("Toolbar", 120, 50, "Untitled - Notepad")

GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")

$Btn_Exit1 = GUICtrlCreateButton("Exit", 1, 1, 40, 25)

GUICtrlSetOnEvent($Btn_Exit1, "_Exit")

$Btn_msg1 = GUICtrlCreateButton("button", 51, 1, 50, 25)

GUICtrlSetOnEvent($Btn_msg1, "_msg")

WinActivate("Untitled - Notepad")

While 1

If Not WinExists("Untitled - Notepad") Then Exit

_ToolbarDocked("Untitled - Notepad", "Toolbar",125, 44)

WEnd

Func _ToolbarDocked($parent, $child, $xx, $yy)

$p_win1 = WinGetPos($GUI1);parent

$p_win2 = WinGetPos($GUI2);toolbar

If $Dock_Location == 1 Then

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $p_win1[2] + $x1 - $xx

$y2 = $y1 - $yy

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $p_win2[0] - $p_win1[2] + $xx

$y1 = $y2 + $yy

WinMove($GUI1, "", $x1, $y1)

EndIf

Else

If (($p_win1[0] <> $x1 Or $p_win1[1] <> $y1) And BitAND(WinGetState($GUI1), 8) Or $Dock = 2) Then

$x1 = $p_win1[0]

$y1 = $p_win1[1]

$x2 = $x1

$y2 = $p_win1[3] + $y1

WinMove($GUI2, "", $x2, $y2)

$Dock = 1

ElseIf (($p_win2[0] <> $x2 Or $p_win2[1] <> $y2) And BitAND(WinGetState($GUI2), 8)) Then

$x2 = $p_win2[0]

$y2 = $p_win2[1]

$x1 = $x2

$y1 = $p_win2[1] - $p_win1[3]

WinMove($GUI1, "", $x1, $y1)

EndIf

EndIf

sleep(10)

EndFunc ;==>_ToolbarDocked

Func _ChildDockWindow($name, $xa, $ya, $parent)

$GUI2 = GUICreate($name, $xa, $ya, -1, -1, $WS_CLIPSIBLINGS, BitOR($WS_EX_MDICHILD, $WS_EX_TOOLWINDOW), $GUI1)

GUISetState(@SW_SHOW)

endfunc ;==>_ChildDockWindows

Func _Exit()

Exit

EndFunc ;==>_Exit

Func SpecialEvents()

Select

Case @GUI_CtrlId = $GUI_EVENT_CLOSE

Exit

EndSelect

EndFunc ;==>SpecialEvents

Func _msg()

MsgBox(0, "", "button pushed")

EndFunc ;==>_msg


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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