taurus905 Posted June 23, 2006 Share Posted June 23, 2006 I would like to have a tooltip for my gui that shows the coordinates (x, y, w, h) changing while I am using the mouse to drag and resize the window. I am not sure if this is possible. But AutoIt does so many things well, I am sure there must me a way to do this also. I need to be able to detect if the window size is changing. If someone could suggest a command or two for me to check out, I would be grateful. Thanks in advance. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Emperor Posted June 23, 2006 Share Posted June 23, 2006 (edited) #include <GuiConstants.au3> $Handle = GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_EVENT_RESIZED $WinPos = WinGetPos($Handle) ToolTip("X: " & $WinPos[0] & " Y: " & $WinPos[1] & " W: " & $WinPos[2] & " H: " & $WinPos[3]) EndSelect WEnd Exit Edited June 23, 2006 by Emperor Link to comment Share on other sites More sharing options...
GaryFrost Posted June 23, 2006 Share Posted June 23, 2006 (edited) #include <GuiConstants.au3> $Gui = GUICreate("Demo", 417, 356, 192, 125, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) GUISetState(@SW_SHOW) $win_pos = WinGetPos($Gui) $tmp_pos = $win_pos ToolTip("X: " & $win_pos[0] & @LF & "Y: " & $win_pos[1] & @LF & "Width: " & $win_pos[2] & @LF & "Height: " & $win_pos[3], 0, 0, "Monitor", 1, 1) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else $win_pos = WinGetPos($Gui) For $x = 0 To 3 If $win_pos[$x] <> $tmp_pos[$x]Then $tmp_pos = $win_pos ToolTip("X: " & $win_pos[0] & @LF & "Y: " & $win_pos[1] & @LF & "Width: " & $win_pos[2] & @LF & "Height: " & $win_pos[3], 0, 0, "Monitor", 1, 1) ExitLoop EndIf Next EndSelect WEnd Edited June 23, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Emperor Posted June 23, 2006 Share Posted June 23, 2006 #include <GuiConstants.au3> GUICreate("MyGUI", 392, 316, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GUIRegisterMsg(3, "ResizedFunc") GUIRegisterMsg(5, "ResizedFunc") GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Exit Func ResizedFunc($hWnd, $msg, $wParam, $lParam) $WinPos = WinGetPos($hWnd) ToolTip("X: " & $WinPos[0] & " Y: " & $WinPos[1] & " W: " & $WinPos[2] & " H: " & $WinPos[3]) EndFunc Link to comment Share on other sites More sharing options...
taurus905 Posted June 23, 2006 Author Share Posted June 23, 2006 @Emperor and @gafrost, Thanks for the quick responses of code. They are two examples that give me a good start. I would like to see the numbers changing as I am dragging, but I will settle for seeing the coordinates in the tooltip when I release the mouse button. Many thanks to you both. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
CyberSlug Posted June 23, 2006 Share Posted June 23, 2006 It is possible with two separate scripts. Please note that Windows' Appearance Effects must be configured to "Show window contents while dragging" in order for tooltip to dynamically update. You'd probably want to figure out a better way of launching the SizeWatcher.... SizeWatcher.au3 [Run this first in the backgroud] #include <Misc.au3> $dll = DllOpen("user32.dll") $win = "UniqueName" ;this could be a handle passed in via command line paramter While 1 If Not WinActive($win) Then ToolTip("") ContinueLoop EndIf $p = WinGetPos($win) If IsArray($p) And _IsPressed("01", $dll) Then ToolTip($p[2] & " x " & $p[3]) Else ToolTip("") EndIf sleep(10) WEnd DllClose($dll) Resizablewindow.au3 #include <GuiConstants.au3> $Gui = GUICreate("UniqueName", 417, 356, 192, 125, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) guiSetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE sleep(10) WEnd Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Emperor Posted June 23, 2006 Share Posted June 23, 2006 Please note that Windows' Appearance Effects must be configured to "Show window contents while dragging" in order for tooltip to dynamically update.If I set this effect then my second post in this topic does exactly what you want without the use of a second script Link to comment Share on other sites More sharing options...
taurus905 Posted June 24, 2006 Author Share Posted June 24, 2006 If I set this effect then my second post in this topic does exactly what you want without the use of a second script Emperor,That is exactly what I was hoping to be possible.Thank you for making the code so short and sweet. @CyberSlug, Thanks for your input. I learn so much when you guys put your heads together.taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
GaryFrost Posted June 28, 2006 Share Posted June 28, 2006 @Emperor, did a little research on the wm_move and wm_size events with the following you don't need to keep using wingetpos expandcollapse popup#include <GuiConstants.au3> Global Const $WM_MOVE = 0x3 Global Const $WM_SIZE = 0x5 $w = 392 $h = 316 $gui = GUICreate("MyGUI", $w, $h, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $WinPos = WinGetPos($gui) $x = $WinPos[0] $y = $WinPos[1] $btn1 = GUICtrlCreateButton("Register", 10, 20, 120, 20) $btn2 = GUICtrlCreateButton("Register to Dummy", 10, 50, 120, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btn1 GUIRegisterMsg($WM_MOVE, "_MovingFunc") GUIRegisterMsg($WM_SIZE, "_ResizedFunc") Case $msg = $btn2 GUIRegisterMsg($WM_MOVE, "_DummyFunc") GUIRegisterMsg($WM_SIZE, "_DummyFunc") ToolTip("") GUIRegisterMsg($WM_SIZE, "_DummyFunc") ; for some reason it don't take till the second time on this one EndSelect WEnd Exit Func _ResizedFunc($hWnd, $msg, $wParam, $lParam) ;~ lParam ;~ The low-order word of lParam specifies the new width of the client area. ;~ The high-order word of lParam specifies the new height of the client area. $h = _HiWord($lParam) $w = _LoWord($lParam) ToolTip("X: " & $x & " Y: " & $y & " W: " & $w & " H: " & $h, $x, $y) EndFunc ;==>_ResizedFunc Func _MovingFunc($hWnd, $msg, $wParam, $lParam) ;lParam ;Specifies the x and y coordinates of the upper-left corner of the client area of the window. ;The low-order word contains the x-coordinate while the high-order word contains the y coordinate. $y = _HiWord($lParam) $x = _LoWord($lParam) ToolTip("X: " & $x & " Y: " & $y & " W: " & $w & " H: " & $h, $x, $y) EndFunc ;==>_MovingFunc Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord Func _DummyFunc($hWnd, $msg, $wParam, $lParam) ;~ ConsoleWrite("Dummy fired" & @LF) EndFunc ;==>_DummyFunc SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
GaryFrost Posted June 29, 2006 Share Posted June 29, 2006 Here's another one: expandcollapse popup#include <GuiConstants.au3> Global Const $WM_WINDOWPOSCHANGED = 0x47; Global $x, $y, $w, $h $w = 392 $h = 316 $gui = GUICreate("MyGUI", $w, $h, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $WinPos = WinGetPos($gui) $x = $WinPos[0] $y = $WinPos[1] ConsoleWrite("$w: " & $w & " $WinPos[2]: " & $WinPos[2] & @LF) ConsoleWrite("$h: " & $h & " $WinPos[3]: " & $WinPos[3] & @LF) ; for some reason width/height don't match unless i do this ; the width/height passed into guicreate and the actual are 2 different values $w = $WinPos[2] $h = $WinPos[3] GUISetState() GUIRegisterMsg($WM_WINDOWPOSCHANGED, "_WINDOWPOSCHANGED") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Exit Func _WINDOWPOSCHANGED($hWnd, $msg, $wParam, $lParam) Local $WINDOWPOS = DllStructCreate("int[6];uint", $lParam) Local $tx = DllStructGetData($WINDOWPOS, 1, 3) Local $ty = DllStructGetData($WINDOWPOS, 1, 4) Local $cx = DllStructGetData($WINDOWPOS, 1, 5) Local $cy = DllStructGetData($WINDOWPOS, 1, 6) ;~ HWND hwnd; ;~ HWND hwndInsertAfter; ;~ int x; ;~ int y; ;~ int cx; ;~ int cy; ;~ UINT flags; If ($w <> $cx Or $h <> $cy) Then ConsoleWrite("Resized" & @LF) $x = $tx $w = $cx $y = $ty $h = $cy ElseIf ($x <> $tx Or $y <> $ty) Then ConsoleWrite("Moved" & @LF) $x = $tx $y = $ty EndIf ToolTip("X: " & $x & " Y: " & $y & " W: " & $w & " H: " & $h, $x, $y) Return $GUI_RUNDEFMSG EndFunc ;==>_WINDOWPOSCHANGED SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
taurus905 Posted June 29, 2006 Author Share Posted June 29, 2006 Here's another one:Gary,Thanks for another example. How would you turn off the tooltip if you minimize the gui and then restore it to the screen?taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
GaryFrost Posted June 29, 2006 Share Posted June 29, 2006 don't need to, try it. What happens when you minimize it is x and y get set to -32000 SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
taurus905 Posted June 29, 2006 Author Share Posted June 29, 2006 don't need to, try it.What happens when you minimize it is x and y get set to -32000But when you restore it to the screen, the tooltip is showing. I don't want the tooltip to show until I resize the gui again. "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
GaryFrost Posted June 29, 2006 Share Posted June 29, 2006 (edited) expandcollapse popup#include <GuiConstants.au3> Global Const $WM_WINDOWPOSCHANGED = 0x47; Global $x, $y, $w, $h, $minimized = 0 $w = 392 $h = 316 $x = 200 $y = 200 $gui = GUICreate("MyGUI", $w, $h, $x, $y, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $WinPos = WinGetPos($gui) $x = $WinPos[0] $y = $WinPos[1] ConsoleWrite("$w: " & $w & " $WinPos[2]: " & $WinPos[2] & @LF) ConsoleWrite("$h: " & $h & " $WinPos[3]: " & $WinPos[3] & @LF) ; for some reason width/height don't match unless i do this ; the width/height passed into guicreate and the actual are 2 different values $w = $WinPos[2] $h = $WinPos[3] GUISetState() GUIRegisterMsg($WM_WINDOWPOSCHANGED, "_WINDOWPOSCHANGED") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Exit Func _WINDOWPOSCHANGED($hWnd, $msg, $wParam, $lParam) Local $WINDOWPOS = DllStructCreate("int[6];uint", $lParam) Local $tx = DllStructGetData($WINDOWPOS, 1, 3) Local $ty = DllStructGetData($WINDOWPOS, 1, 4) Local $cx = DllStructGetData($WINDOWPOS, 1, 5) Local $cy = DllStructGetData($WINDOWPOS, 1, 6) ;~ HWND hwnd; ;~ HWND hwndInsertAfter; ;~ int x; ;~ int y; ;~ int cx; ;~ int cy; ;~ UINT flags; If ($w <> $cx Or $h <> $cy) Then If $tx = -32000 Or $ty = -32000 Then ConsoleWrite("Minimized" & @LF) $minimized = 1 ElseIf $minimized Then ConsoleWrite("Restored" & @LF) $minimized = 2 Else ConsoleWrite("Resized" & @LF) EndIf $x = $tx $y = $ty $w = $cx $h = $cy ElseIf ($x <> $tx Or $y <> $ty) Then ConsoleWrite("Moved" & @LF) $x = $tx $y = $ty EndIf If $minimized Then ToolTip("") If Not $minimized Then ToolTip("X: " & $x & " Y: " & $y & " W: " & $w & " H: " & $h, $x, $y) ElseIf $minimized = 2 Then $minimized = 0 EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WINDOWPOSCHANGED Edited June 29, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
taurus905 Posted June 30, 2006 Author Share Posted June 30, 2006 expandcollapse popup#include <GuiConstants.au3> Global Const $WM_WINDOWPOSCHANGED = 0x47; Global $x, $y, $w, $h, $minimized = 0 $w = 392 $h = 316 $x = 200 $y = 200 $gui = GUICreate("MyGUI", $w, $h, $x, $y, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $WinPos = WinGetPos($gui) $x = $WinPos[0] $y = $WinPos[1] ConsoleWrite("$w: " & $w & " $WinPos[2]: " & $WinPos[2] & @LF) ConsoleWrite("$h: " & $h & " $WinPos[3]: " & $WinPos[3] & @LF) ; for some reason width/height don't match unless i do this ; the width/height passed into guicreate and the actual are 2 different values $w = $WinPos[2] $h = $WinPos[3] GUISetState() GUIRegisterMsg($WM_WINDOWPOSCHANGED, "_WINDOWPOSCHANGED") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Exit Func _WINDOWPOSCHANGED($hWnd, $msg, $wParam, $lParam) Local $WINDOWPOS = DllStructCreate("int[6];uint", $lParam) Local $tx = DllStructGetData($WINDOWPOS, 1, 3) Local $ty = DllStructGetData($WINDOWPOS, 1, 4) Local $cx = DllStructGetData($WINDOWPOS, 1, 5) Local $cy = DllStructGetData($WINDOWPOS, 1, 6) ;~ HWND hwnd; ;~ HWND hwndInsertAfter; ;~ int x; ;~ int y; ;~ int cx; ;~ int cy; ;~ UINT flags; If ($w <> $cx Or $h <> $cy) Then If $tx = -32000 Or $ty = -32000 Then ConsoleWrite("Minimized" & @LF) $minimized = 1 ElseIf $minimized Then ConsoleWrite("Restored" & @LF) $minimized = 2 Else ConsoleWrite("Resized" & @LF) EndIf $x = $tx $y = $ty $w = $cx $h = $cy ElseIf ($x <> $tx Or $y <> $ty) Then ConsoleWrite("Moved" & @LF) $x = $tx $y = $ty EndIf If $minimized Then ToolTip("") If Not $minimized Then ToolTip("X: " & $x & " Y: " & $y & " W: " & $w & " H: " & $h, $x, $y) ElseIf $minimized = 2 Then $minimized = 0 EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WINDOWPOSCHANGEDGary, Nice one. That works perfectly. Now I have to dissect it to see if I can incorporate it into my script. Thanks, taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Emperor Posted June 30, 2006 Share Posted June 30, 2006 @Emperor, did a little research on the wm_move and wm_size eventswith the following you don't need to keep using wingetposYeah I wasn't too sure if both those messages sent the same info so I just decided to use WinGetPos for my example.Very nice examples btw Link to comment Share on other sites More sharing options...
GaryFrost Posted June 30, 2006 Share Posted June 30, 2006 Here's an example of something I'm working on for another project (to make the docking better). You'll see where i commented out the line in the while loop If you want to see how it worked the old way, uncomment that line and comment out the GUIRegisterMsg line expandcollapse popup#include <GuiConstants.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) Opt('MustDeclareVars', 1) Global Const $AW_FADE_IN = 0x00080000;fade-in Global Const $AW_FADE_OUT = 0x00090000;fade-out Global Const $AW_SLIDE_IN_LEFT = 0x00040001;slide in from left Global Const $AW_SLIDE_OUT_LEFT = 0x00050002;slide out to left Global Const $AW_SLIDE_IN_RIGHT = 0x00040002;slide in from right Global Const $AW_SLIDE_OUT_RIGHT = 0x00050001;slide out to right Global Const $AW_SLIDE_IN_TOP = 0x00040004;slide-in from top Global Const $AW_SLIDE_OUT_TOP = 0x00050008;slide-out to top Global Const $AW_SLIDE_IN_BOTTOM = 0x00040008;slide-in from bottom Global Const $AW_SLIDE_OUT_BOTTOM = 0x00050004;slide-out to bottom Global Const $AW_DIAG_SLIDE_IN_TOPLEFT = 0x00040005;diag slide-in from Top-left Global Const $AW_DIAG_SLIDE_OUT_TOPLEFT = 0x0005000a;diag slide-out to Top-left Global Const $AW_DIAG_SLIDE_IN_TOPRIGHT = 0x00040006;diag slide-in from Top-Right Global Const $AW_DIAG_SLIDE_OUT_TOPRIGHT = 0x00050009;diag slide-out to Top-Right Global Const $AW_DIAG_SLIDE_IN_BOTTOMLEFT = 0x00040009;diag slide-in from Bottom-left Global Const $AW_DIAG_SLIDE_OUT_BOTTOMLEFT = 0x00050006;diag slide-out to Bottom-left Global Const $AW_DIAG_SLIDE_IN_BOTTOMRIGHT = 0x0004000a;diag slide-in from Bottom-right Global Const $AW_DIAG_SLIDE_OUT_BOTTOMRIGHT = 0x00050005;diag slide-out to Bottom-right Global Const $AW_EXPLODE = 0x00040010;explode Global Const $AW_IMPLODE = 0x00050010;implode Global Const $WM_WINDOWPOSCHANGED = 0x47; Global $x, $y, $w, $h Dim $listview, $listview2, $Btn_MoveLeft, $Btn_MoveRight, $Btn_Exit1, $Btn_Exit2, $msg, $GUI1, $GUI2 Dim $Btn_CopyRight, $Btn_CopyLeft Dim $OptionsMenu, $OptionsItem1, $OptionsItem2, $separator1, $OptionsItem3, $OptionsItem4 Dim $Dock = 1, $Dock_Location = 1, $x1, $x2, $y1, $y2, $WinPos $GUI1 = GUICreate("GuiListView Copy Items", 300, 220, 10, 10) $WinPos = WinGetPos($GUI1) $x = $WinPos[0] $y = $WinPos[1] ConsoleWrite("$w: " & $w & " $WinPos[2]: " & $WinPos[2] & @LF) ConsoleWrite("$h: " & $h & " $WinPos[3]: " & $WinPos[3] & @LF) ; for some reason width/height don't match unless i do this ; the width/height passed into guicreate and the actual are 2 different values $w = $WinPos[2] $h = $WinPos[3] $OptionsMenu = GUICtrlCreateMenu("Options") $OptionsItem1 = GUICtrlCreateMenu("Docking", $OptionsMenu) $OptionsItem2 = GUICtrlCreateMenuitem("Docked", $OptionsItem1) $separator1 = GUICtrlCreateMenuitem("", $OptionsItem1) $OptionsItem3 = GUICtrlCreateMenuitem("Side By Side", $OptionsItem1) $OptionsItem4 = GUICtrlCreateMenuitem("Top And Bottom", $OptionsItem1) GUICtrlSetState($OptionsItem2, $GUI_CHECKED) GUICtrlSetState($OptionsItem3, $GUI_CHECKED) GUICtrlSetOnEvent($OptionsItem2, "_SetDocking") GUICtrlSetOnEvent($OptionsItem3, "_SetDockSideBySide") GUICtrlSetOnEvent($OptionsItem4, "_SetDockTopAndBottom") GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") $listview = GUICtrlCreateListView("col1|col2|col3", 5, 5, 150, 185, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListViewSetColumnWidth($listview, 0, 60) GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlSendMsg($listview, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES) $Btn_MoveRight = GUICtrlCreateButton("Move", 175, 35, 90, 20) GUICtrlSetOnEvent($Btn_MoveRight, "_MoveRight") $Btn_CopyRight = GUICtrlCreateButton("Copy", 175, 60, 90, 20) GUICtrlSetOnEvent($Btn_CopyRight, "_CopyRight") $Btn_Exit1 = GUICtrlCreateButton("Exit", 175, 140, 90, 25) GUICtrlSetOnEvent($Btn_Exit1, "_Exit") $GUI2 = GUICreate("Right/Bottom Window", 300, 220, 315, 10) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") $Btn_MoveLeft = GUICtrlCreateButton("Move", 175, 55, 90, 20) GUICtrlSetOnEvent($Btn_MoveLeft, "_MoveLeft") $Btn_CopyLeft = GUICtrlCreateButton("Copy", 175, 80, 90, 20) GUICtrlSetOnEvent($Btn_CopyLeft, "_CopyLeft") $Btn_Exit2 = GUICtrlCreateButton("Exit", 175, 160, 90, 25) GUICtrlSetOnEvent($Btn_Exit2, "_Exit") $listview2 = GUICtrlCreateListView("col1|col2|col3", 5, 25, 150, 185, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListViewSetColumnWidth($listview2, 0, 60) GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlSendMsg($listview2, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES) GUICtrlCreateListViewItem("line1|data1|more1", $listview) GUICtrlCreateListViewItem("line2|data2|more2", $listview) GUICtrlCreateListViewItem("line3|data3|more3", $listview) GUICtrlCreateListViewItem("line4|data4|more4", $listview) GUICtrlCreateListViewItem("line5|data5|more5", $listview) GUISetState(@SW_SHOW, $GUI2) ;~ GUISetState(@SW_SHOW, $GUI1) GUIRegisterMsg($WM_WINDOWPOSCHANGED, "_WINDOWPOSCHANGED") _ShowPreview($GUI1, $Dock_Location, $Dock) While 1 ;~ If $Dock Then _KeepWindowsDocked() Sleep(10) WEnd Func _SetDocking() If BitAND(GUICtrlRead($OptionsItem2), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($OptionsItem2, $GUI_UNCHECKED) $Dock = 0 Else GUICtrlSetState($OptionsItem2, $GUI_CHECKED) $Dock = 2 EndIf If $Dock Then _KeepWindowsDocked() EndFunc ;==>_SetDocking Func _SetDockSideBySide() If BitAND(GUICtrlRead($OptionsItem3), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($OptionsItem3, $GUI_UNCHECKED) GUICtrlSetState($OptionsItem4, $GUI_CHECKED) $Dock_Location = 2 Else GUICtrlSetState($OptionsItem3, $GUI_CHECKED) GUICtrlSetState($OptionsItem4, $GUI_UNCHECKED) $Dock_Location = 1 If $Dock Then $Dock = 2 EndIf If $Dock Then _KeepWindowsDocked() EndFunc ;==>_SetDockSideBySide Func _SetDockTopAndBottom() If BitAND(GUICtrlRead($OptionsItem4), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($OptionsItem4, $GUI_UNCHECKED) GUICtrlSetState($OptionsItem3, $GUI_CHECKED) $Dock_Location = 1 Else GUICtrlSetState($OptionsItem4, $GUI_CHECKED) GUICtrlSetState($OptionsItem3, $GUI_UNCHECKED) $Dock_Location = 2 If $Dock Then $Dock = 2 EndIf If $Dock Then _KeepWindowsDocked() EndFunc ;==>_SetDockTopAndBottom Func _KeepWindowsDocked() Local $p_win1 = WinGetPos($GUI1) Local $p_win2 = WinGetPos($GUI2) 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 $y2 = $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 = $p_win2[0] - $p_win1[2] $y1 = $y2 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 ;==>_KeepWindowsDocked Func _CopyRight() _GUICtrlListViewCopyItems($listview, $listview2) EndFunc ;==>_CopyRight Func _MoveRight() _GUICtrlListViewCopyItems($listview, $listview2, 1) EndFunc ;==>_MoveRight Func _CopyLeft() _GUICtrlListViewCopyItems($listview2, $listview) EndFunc ;==>_CopyLeft Func _MoveLeft() _GUICtrlListViewCopyItems($listview2, $listview, 1) EndFunc ;==>_MoveLeft Func _Exit() Exit EndFunc ;==>_Exit Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE Exit EndSelect EndFunc ;==>SpecialEvents Func _WINDOWPOSCHANGED($hWnd, $msg, $wParam, $lParam) Local $WINDOWPOS = DllStructCreate("int[6];uint", $lParam) Local $tx = DllStructGetData($WINDOWPOS, 1, 3) Local $ty = DllStructGetData($WINDOWPOS, 1, 4) Local $cx = DllStructGetData($WINDOWPOS, 1, 5) Local $cy = DllStructGetData($WINDOWPOS, 1, 6) If HWnd($hWnd) = HWnd($GUI1) Then ConsoleWrite("Left GUI" & @LF) If ($x <> $tx Or $y <> $ty) Then ConsoleWrite("Moved" & @LF) If $Dock Then _KeepWindowsDocked() $x = $tx $y = $ty EndIf ElseIf HWnd($hWnd) = HWnd($GUI2) Then ConsoleWrite("Right GUI" & @LF) If ($w <> $cx Or $h <> $cy) Then ConsoleWrite("Resized" & @LF) $x = $tx $w = $cx $y = $ty $h = $cy ElseIf ($x <> $tx Or $y <> $ty) Then ConsoleWrite("Moved" & @LF) If $Dock Then _KeepWindowsDocked() $x = $tx $y = $ty EndIf EndIf ;~ HWND hwnd; ;~ HWND hwndInsertAfter; ;~ int x; ;~ int y; ;~ int cx; ;~ int cy; ;~ UINT flags; ToolTip("X: " & $x & " Y: " & $y & " W: " & $w & " H: " & $h, $x, $y) Return $GUI_RUNDEFMSG EndFunc ;==>_WINDOWPOSCHANGED Func _WinAnimate($v_gui, $i_mode, $i_duration = 1000) If @OSVersion = "WIN_XP" Or @OSVersion = "WIN_2000" Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", WinGetHandle($v_gui), "int", $i_duration, "long", $i_mode) Local $ai_gle = DllCall('kernel32.dll', 'int', 'GetLastError') If $ai_gle[0] <> 0 Then SetError(1) Return 0 EndIf Return 1 EndIf EndFunc ;==>_WinAnimate Func _ShowPreview(ByRef $GUI_Edit, ByRef $DockItPos, ByRef $Dock, $show = 1) If $show Then If $DockItPos Then _WinAnimate($GUI_Edit, $AW_SLIDE_IN_RIGHT, 200) Else _WinAnimate($GUI_Edit, $AW_SLIDE_IN_LEFT, 200) EndIf GUISetState(@SW_SHOW, $GUI_Edit) $Dock = 2 Else If $DockItPos Then _WinAnimate($GUI_Edit, $AW_SLIDE_OUT_RIGHT, 200) Else _WinAnimate($GUI_Edit, $AW_SLIDE_OUT_LEFT, 200) EndIf GUISetState(@SW_HIDE, $GUI_Edit) EndIf EndFunc ;==>_ShowPreview SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
taurus905 Posted July 1, 2006 Author Share Posted July 1, 2006 Here's an example of something I'm working on for another project (to make the docking better).Gary,That's one hell of a script. I will have to look at it closer some time in the future.I just converted by script from GUIGetMsg() to OnEvent mode. My question is:If I have five buttons on a gui, is it possible to detect when the tab key (on the keyboard) has been pressed and changed the focus so I can automatically update the tooltip for that button?I know it is possible, I just need a little input to get started.Thanks,taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 1, 2006 Moderators Share Posted July 1, 2006 (edited) Gary,That's one hell of a script. I will have to look at it closer some time in the future.I just converted by script from GUIGetMsg() to OnEvent mode. My question is:If I have five buttons on a gui, is it possible to detect when the tab key (on the keyboard) has been pressed and changed the focus so I can automatically update the tooltip for that button?I know it is possible, I just need a little input to get started.Thanks,taurus905Well assuming your storing the "last" button that has focus then maybe... If _IsPressed() And ControlGetFocus() = 'Button Whatever' Then may help... Edited July 1, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
taurus905 Posted July 1, 2006 Author Share Posted July 1, 2006 Well assuming your storing the "last" button that has focus then maybe... If _IsPressed() And ControlGetFocus() = 'Button Whatever' Then may help...SmOke_N,I am storing the last button that has focus. Are you saying that I could use an _IsPressed() for the tab key?I will have to look at that.I guess part of my concern was that I am now using OnEvent mode and was not sure of the best way to procede.Thanks for the idea.taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now