vmars Posted November 14, 2009 Share Posted November 14, 2009 I hope to create a "borderless, moveable, resizeable, visible object". One i can drag or push or pull around the screen. One i can rightClick on for more options. Any examples around that i can study? Thanks...vmars Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 14, 2009 Moderators Share Posted November 14, 2009 vmars, borderless, moveable, resizeable, visible objectDoes this fit the bill? expandcollapse popup#include <GuiConstants.au3> #include <windowsconstants.au3> #include <SendMessage.au3> Global Const $margin = 12; distance from edge of window where dragging is possible Global Const $SC_DRAGMOVE = 0xF012 $Gui = GUICreate("Drag sides to resize", 420, 200, -1, -1, $WS_POPUP) GUISetBkColor(0xf1f100) $chk1 = GUICtrlCreateCheckbox("allow resizing", 140, 40) GUICtrlSetResizing(-1,$GUI_DOCKWIDTH) $Button = GUICtrlCreateButton("Exit", 140, 90, 150, 30) GUISetState(@SW_SHOW, $Gui) GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN") GUIRegisterMsg($WM_MOUSEMOVE, "SetCursor") While 1 Switch GUIGetMsg() Case $Button Exit Case $GUI_EVENT_PRIMARYDOWN _SendMessage($Gui, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndSwitch WEnd ;GetMousePosType returns a code depending on the border the mouse cursor is near Func GetMousePosType() Local $cp = GUIGetCursorInfo() Local $wp = WinGetPos($Gui) Local $side = 0 Local $TopBot = 0 Local $curs If $cp[0] < $margin Then $side = 1 If $cp[0] > $wp[2] - $margin Then $side = 2 If $cp[1] < $margin Then $TopBot = 3 If $cp[1] > $wp[3] - $margin Then $TopBot = 6 Return $side + $TopBot EndFunc ;==>GetMousePosType Func SetCursor() Local $curs If GUICtrlRead($chk1) <> $GUI_CHECKED Then Return Switch GetMousePosType() Case 0 $curs = 2 Case 1, 2 $curs = 13 Case 3, 6 $curs = 11 Case 5, 7 $curs = 10 Case 4, 8 $curs = 12 EndSwitch GUISetCursor($curs, 1) EndFunc ;==>SetCursor Func WM_LBUTTONDOWN($hWnd, $iMsg, $StartWIndowPosaram, $lParam) If GUICtrlRead($chk1) <> $GUI_CHECKED Then Return $GUI_RUNDEFMSG Local $drag = GetMousePosType() If $drag > 0 Then DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", $WM_SYSCOMMAND, "int", 0xF000 + $drag, "int", 0) EndIf EndFunc ;==>WM_LBUTTONDOWN A bit rough around the edges, but as I have just hacked a few forum examples together that is hardly surprising. I am sure it can be polished considerably. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Mat Posted November 15, 2009 Share Posted November 15, 2009 (edited) A few improvements (I hope) expandcollapse popup#include <GuiConstants.au3> #include <WindowsConstants.au3> Global Const $margin = 12 ; distance from edge of window where dragging is possible Global Const $SC_DRAGMOVE = 0xF012 If Not IsDeclared ("WM_LBUTTONDOWN") Then Global Const $WM_LBUTTONDOWN = 0x0201 $Gui = GUICreate("Drag sides to resize", 420, 200, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) GUISetBkColor(0xf1f100) $chk1 = GUICtrlCreateCheckbox("allow resizing", 140, 40) GUICtrlSetResizing(-1,$GUI_DOCKWIDTH) $Button = GUICtrlCreateButton("Exit", 140, 90, 150, 30) GUISetState(@SW_SHOW, $Gui) While 1 Switch GUIGetMsg() Case $Button Exit Case $GUI_EVENT_PRIMARYDOWN If (BitAnd (GUICtrlRead($chk1), $GUI_CHECKED)) Then $curs = GUIGetCursorInfo() $win = WinGetPos ($Gui) If $curs[4] <> 0 Then ContinueLoop $drag = GetMousePosType() If $drag = 9 Then $win = WinGetPos ($Gui) GUISetCursor (9) MouseMove ($curs[0] + 1 + $win[0], $curs[1] + $win[1]) EndIf DllCall("user32.dll", "long", "SendMessage", "hwnd", $Gui, "int", $WM_SYSCOMMAND, "int", 0xF000 + $drag, "int", 0) EndIf Case $GUI_EVENT_MOUSEMOVE SetMouseType () EndSwitch WEnd Func GetMousePosType() Local $cp = GUIGetCursorInfo(), $wp = WinGetPos($Gui), $curs = 0 If $cp[0] < $margin Then $curs += 1 If $cp[0] > $wp[2] - $margin Then $curs += 2 If $cp[1] < $margin Then $curs += 3 If $cp[1] > $wp[3] - $margin Then $curs += 6 If $curs = 0 Then $curs += 9 Return $curs EndFunc ;==>GetMousePosType Func SetMouseType() If GUICtrlRead($chk1) <> $GUI_CHECKED Then Return Switch GetMousePosType() Case 9 $curs = 2 Case 1, 2 $curs = 13 Case 3, 6 $curs = 11 Case 5, 7 $curs = 10 Case 4, 8 $curs = 12 Case Else Return EndSwitch If $curs = MouseGetCursor () Then Return GUISetCursor ($curs) EndFunc ;==>SetMouseType Mat Edit: Several more improvements to code. Edited November 15, 2009 by Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
Mat Posted November 15, 2009 Share Posted November 15, 2009 (edited) And now a nice sort-of UDF for you to use I am feeling very generous today. All you need to do is to call _GUICreate in the same way as you normally would, and it'll sort out the rest for you. To change the margin just change the value of the global variables. expandcollapse popup#Include<Array.au3> Global $INTERNAL_GUI[1] = [0] Global $INTERNAL_MARGIN = 6 Global $INTERNAL_ALLOW = True Global $INTERNAL_LAST = 0 Func _GUICreate ($sTitle, $w, $h, $x = -1, $y = -1, $nStyle = 0, $nStyleEx = 0, $hParent = 0) Local $hRet = GUICreate($sTitle, $w, $h, $x, $y, BitOR (-2147483648, $nStyle), BitOR (136, 0), $hParent) If @Error Then Return SetError (@Error, 0, 0) GUIRegisterMsg (512, "INTERNAL_WM_MOUSEMOVE") GUIRegisterMsg (513, "INTERNAL_WM_LBUTTONDOWN") ReDim $INTERNAL_GUI[UBound ($INTERNAL_GUI) + 1] $INTERNAL_GUI[UBound ($INTERNAL_GUI) - 1] = $hRet $INTERNAL_GUI[0] += 1 $INTERNAL_LAST = $hRet Return $hRet EndFunc ; ==> _GUICreate Func _GUIDelete ($hWnd = default) If $hWnd = default Then $hWnd = $INTERNAL_LAST If Not IsHwnd ($hWnd) Then Return SetError (1, 0, 0) Local $i = INTERNAL_GET_INDEX_FROM_HWND ($hWnd) If $i = -1 Then Return SetError (1, 0, 0) _ArrayDelete ($INTERNAL_GUI, $i) $INTERNAL_GUI[0] -= 1 Return GUIDelete ($hWnd) EndFunc ; ==> _GUIDelete Func INTERNAL_GET_INDEX_FROM_HWND ($hWnd) If $hWnd = 0 Then Return -1 For $i = 1 to $INTERNAL_GUI[0] If $hWnd = $INTERNAL_GUI[$i] Then Return $i Next Return -1 EndFunc ; ==> INTERNAL_GET_INDEX_FROM_HWND Func INTERNAL_GET_MOUSE_POS_TYPE ($hWnd) Local $cp = GUIGetCursorInfo ($hWnd), $wp = WinGetPos ($hWnd), $curs = 0 If $cp[0] < $INTERNAL_MARGIN Then $curs += 1 If $cp[0] > $wp[2] - $INTERNAL_MARGIN Then $curs += 2 If $cp[1] < $INTERNAL_MARGIN Then $curs += 3 If $cp[1] > $wp[3] - $INTERNAL_MARGIN Then $curs += 6 If $curs = 0 Then $curs += 9 Return $curs EndFunc ; ==> INTERNAL_GET_MOUSE_POS_TYPE Func INTERNAL_WM_LBUTTONDOWN ($hWnd, $msgID, $wParam, $lParam) If Not $INTERNAL_ALLOW Then Return "GUI_RUNDEFMSG" Local $i = INTERNAL_GET_INDEX_FROM_HWND ($hWnd) If $i = -1 Then Return "GUI_RUNDEFMSG" Local $curs = GUIGetCursorInfo ($hWnd) If $curs[4] <> 0 Then Return "GUI_RUNDEFMSG" $drag = INTERNAL_GET_MOUSE_POS_TYPE ($hWnd) If $drag = 9 Then GUISetCursor (9, $hWnd) DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", 274, "int", 0xF000 + $drag, "int", 0) Return 1 EndFunc ; ==> INTERNAL_WM_LBUTTONDOWN Func INTERNAL_WM_MOUSEMOVE ($hWnd, $msgID, $wParam, $lParam) If Not $INTERNAL_ALLOW Then Return "GUI_RUNDEFMSG" Local $i = INTERNAL_GET_INDEX_FROM_HWND ($hWnd) If $i = -1 Then Return "GUI_RUNDEFMSG" Local $Curs Switch INTERNAL_GET_MOUSE_POS_TYPE ($hWnd) Case 9 $curs = 2 Case 1, 2 $curs = 13 Case 3, 6 $curs = 11 Case 5, 7 $curs = 10 Case 4, 8 $curs = 12 Case Else Return EndSwitch If $curs = MouseGetCursor () Then Return GUISetCursor ($curs) EndFunc ; ==> INTERNAL_WM_MOUSEMOVE example: $Gui = _GUICreate ("test", 500, 100, 300, 300) $hBtn = GUICtrlCreateButton ("X", 480, 2, 20, 20) GUICtrlSetResizing (-1, 4 + 32 + 768) GUISetstate () While GUIGetMsg () <> $hBtn Sleep (10) WEnd Mat Edited November 15, 2009 by Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 15, 2009 Moderators Share Posted November 15, 2009 Mat, You deserve a polishing badge from the Scouts for that! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Mat Posted November 15, 2009 Share Posted November 15, 2009 You deserve a polishing badge from the Scouts for that! got a bit carried away. It's not perfect (yet) mind you, just found another bug which could result in an error. So I'll fix that now. I think the most amusing thing is that I rewrote most of it between yours and my first one, and then kinda undid it all again.Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
martin Posted November 15, 2009 Share Posted November 15, 2009 [/autoit] .. I have just hacked a few forum examples together that is hardly surprising. I am sure it can be polished considerably. M23 Looks like just 1 example Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 16, 2009 Moderators Share Posted November 16, 2009 martin, Yus, it's a fair cop, guv. You got me bang to rights. I must get into the habit of marking the original author on the snippets I keep. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
martin Posted November 16, 2009 Share Posted November 16, 2009 martin,Yus, it's a fair cop, guv. You got me bang to rights. I must get into the habit of marking the original author on the snippets I keep. M23Only a Brit is going to say that I would guess, and I wasn't sure if you had some Canadian connection.No problem at all Melba23, you usually do credit people. I was actually pleased to see that someone had found my post usefule since it had very little obvious interest, and I was quite pleased with myself when I discovered those messages, although it could be that a lot of other people already knew about them of course. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Kymbo Posted November 17, 2009 Share Posted November 17, 2009 Matt / Martin Not bad. At the risk of being tedious ... how about the ability to send text strings to the form (so it looks like some kind of 'output only' console). That would be handy for unattended application installs as a way to post status updates as the install unfolds. Eg 'Installing application abc ...' 'Making post-install registry changes ...' 'Deleting desktop icon ...' 'Done !' Kym Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 17, 2009 Moderators Share Posted November 17, 2009 Kymbo,Welcome to the Autoit forums. If you want to send the messages from within your own script, then just add a label control to the GUI and use GUICtrlSetData to update it. If you want to capture the install apps console output then you will need to use StdoutRead to get the data - the Help file shows the syntax.Give it a try yourself and come back if you run into problems. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Dolemite50 Posted November 17, 2009 Share Posted November 17, 2009 Hehe! I thought it looked an awful lot like this. It's tough to find anything to code that Martin or MrCreator haven't already done better. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 17, 2009 Moderators Share Posted November 17, 2009 Dolemite50, Sorry to disappoint you, but that was not among the scripts I hacked together for the first example. However, I do share your sentiments regarding 2 of our more eminent members. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Dolemite50 Posted November 17, 2009 Share Posted November 17, 2009 I was actually pleased to see that someone had found my post usefule since it had very little obvious interest..Hey! What am I, chopped liver? Exhibit A Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 17, 2009 Moderators Share Posted November 17, 2009 Dolemite50, Now that one I did use! I am delighted someone else knows how to use Search too! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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