Justmobile Posted August 22, 2009 Posted August 22, 2009 Hi all, im not so good at dll calls e.t. but i have a code which create a simple gui window, when i run this multiple times de desktop will show many gui's simple, but when i drag one window the focus of the mouse is gone, and i have click and try to catch the window which i want to move. for dragging i use code While _IsPressed("01") DllCall("user32.dll", "int", "SendMessage", "hWnd", WinGetHandle("[ACTIVE]"), "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0) and gui create $Gui = GUICreate($title, 180, 15, $Gui_X, $Gui_Y, $WS_POPUP, $WS_EX_TOOLWINDOW, WinGetHandle("[CLASS:Progman]")) GUISetBkColor(0xFFA500) please notice that multiple gui's have all the name $Gui, because i run the program more than ones. can this do? thanks
martin Posted August 22, 2009 Posted August 22, 2009 Hi all, im not so good at dll calls e.t. but i have a code which create a simple gui window, when i run this multiple times de desktop will show many gui's simple, but when i drag one window the focus of the mouse is gone, and i have click and try to catch the window which i want to move. for dragging i use code While _IsPressed("01") DllCall("user32.dll", "int", "SendMessage", "hWnd", WinGetHandle("[ACTIVE]"), "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0) and gui create $Gui = GUICreate($title, 180, 15, $Gui_X, $Gui_Y, $WS_POPUP, $WS_EX_TOOLWINDOW, WinGetHandle("[CLASS:Progman]")) GUISetBkColor(0xFFA500) please notice that multiple gui's have all the name $Gui, because i run the program more than ones. can this do? thanks Here is one way to do it. I added a bit so that the gui names could all be different, but that won't affect the way this example works. You will need to move one gui out of the way before the next instance is started or you will never see the previous instance. expandcollapse popup#include <guiconstantsEx.au3> #include <windowsconstants.au3> #include <misc.au3> #include <sendmessage.au3> Global Const $WM_BROADCAST = 0xFFFF Global Const $WM_ENTERSIZEMOVE = 0x231 $gui = GUICreate("drag group", 250, 70) $Lab1 = GUICtrlCreateLabel("no message", 20, 12) $ButF = GUICtrlCreateButton("Finish", 20, 40, 120, 26) GUISetState() Global $master = 0 #Region make unique title - not required Local $instance = True, $inst = 0 While $instance = True $inst += 1 _Singleton("dragmany_script" & $inst, 1) $instance = @error = 183 WEnd WinSetTitle("drag group", "", "drag No. " & $inst & " of group") #EndRegion make unique title ;get a message number to use $MyMsg1 = RegisterWindowMessage("drawmanywindows") GUIRegisterMsg($MyMsg1, "GetDrag") GUIRegisterMsg($WM_ENTERSIZEMOVE, "EnterSIzeMove") While 1 $Msg = GUIGetMsg() If $Msg = -3 Then Exit If $master <> 0 Then DoCatchup() EndIf if $Msg = $ButF Then _SendMessage($WM_BROADCAST,$MyMsg1,$Gui,2) Exit EndIf WEnd Func EnterSizeMove($hW, $iM, $WP, $Lp) _SendMessage($WM_BROADCAST, $MyMsg1, $gui, 1) EndFunc ;==>EnterSizeMove Func GetDrag($hW, $iM, $WP, $Lp) if $Lp = 1 Then $master = $WP GUICtrlSetData($Lab1, "Messages from " & Hex($master)) EndIf if $Lp = 2 Then Exit EndIf EndFunc ;==>GetDrag Func DoCatchup() $Mp = WinGetPos($master) $Sp = WinGetPos($gui) While _IsPressed(01) $Np = WinGetPos($master) WinMove($gui, "", $Sp[0] + $Np[0] - $Mp[0], $Sp[1] + $Np[1] - $Mp[1]) WEnd $master = 0 EndFunc ;==>DoCatchup ;register window message ;returns a unique message number. if the message has already been registered then the ;the unique number for $stext is returned. ;Usefule for two windows to communicate Func RegisterWindowMessage($sText) Local $aRet = DllCall('user32.dll', 'int', 'RegisterWindowMessage', 'str', $sText) Return $aRet[0] EndFunc ;==>RegisterWindowMessage 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.
CodyBarrett Posted August 22, 2009 Posted August 22, 2009 nice example martin!! [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size]
Yashied Posted August 22, 2009 Posted August 22, 2009 (edited) Here is one way to do it. I added a bit so that the gui names could all be different, but that won't affect the way this example works. You will need to move one gui out of the way before the next instance is started or you will never see the previous instance. expandcollapse popup#include <guiconstantsEx.au3> #include <windowsconstants.au3> #include <misc.au3> #include <sendmessage.au3> Global Const $WM_BROADCAST = 0xFFFF Global Const $WM_ENTERSIZEMOVE = 0x231 $gui = GUICreate("drag group", 250, 70) $Lab1 = GUICtrlCreateLabel("no message", 20, 12) $ButF = GUICtrlCreateButton("Finish", 20, 40, 120, 26) GUISetState() Global $master = 0 #Region make unique title - not required Local $instance = True, $inst = 0 While $instance = True $inst += 1 _Singleton("dragmany_script" & $inst, 1) $instance = @error = 183 WEnd WinSetTitle("drag group", "", "drag No. " & $inst & " of group") #EndRegion make unique title ;get a message number to use $MyMsg1 = RegisterWindowMessage("drawmanywindows") GUIRegisterMsg($MyMsg1, "GetDrag") GUIRegisterMsg($WM_ENTERSIZEMOVE, "EnterSIzeMove") While 1 $Msg = GUIGetMsg() If $Msg = -3 Then Exit If $master <> 0 Then DoCatchup() EndIf if $Msg = $ButF Then _SendMessage($WM_BROADCAST,$MyMsg1,$Gui,2) Exit EndIf WEnd Func EnterSizeMove($hW, $iM, $WP, $Lp) _SendMessage($WM_BROADCAST, $MyMsg1, $gui, 1) EndFunc ;==>EnterSizeMove Func GetDrag($hW, $iM, $WP, $Lp) if $Lp = 1 Then $master = $WP GUICtrlSetData($Lab1, "Messages from " & Hex($master)) EndIf if $Lp = 2 Then Exit EndIf EndFunc ;==>GetDrag Func DoCatchup() $Mp = WinGetPos($master) $Sp = WinGetPos($gui) While _IsPressed(01) $Np = WinGetPos($master) WinMove($gui, "", $Sp[0] + $Np[0] - $Mp[0], $Sp[1] + $Np[1] - $Mp[1]) WEnd $master = 0 EndFunc ;==>DoCatchup ;register window message ;returns a unique message number. if the message has already been registered then the ;the unique number for $stext is returned. ;Usefule for two windows to communicate Func RegisterWindowMessage($sText) Local $aRet = DllCall('user32.dll', 'int', 'RegisterWindowMessage', 'str', $sText) Return $aRet[0] EndFunc ;==>RegisterWindowMessage Nice example, martin. But WM_BROADCAST works very slowly (depending on the number of windows). I think in this case will be better to use the window handle. Edited August 22, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Justmobile Posted August 22, 2009 Author Posted August 22, 2009 Here is one way to do it. I added a bit so that the gui names could all be different, but that won't affect the way this example works. You will need to move one gui out of the way before the next instance is started or you will never see the previous instance. expandcollapse popup#include <guiconstantsEx.au3> #include <windowsconstants.au3> #include <misc.au3> #include <sendmessage.au3> Global Const $WM_BROADCAST = 0xFFFF Global Const $WM_ENTERSIZEMOVE = 0x231 $gui = GUICreate("drag group", 250, 70) $Lab1 = GUICtrlCreateLabel("no message", 20, 12) $ButF = GUICtrlCreateButton("Finish", 20, 40, 120, 26) GUISetState() Global $master = 0 #Region make unique title - not required Local $instance = True, $inst = 0 While $instance = True $inst += 1 _Singleton("dragmany_script" & $inst, 1) $instance = @error = 183 WEnd WinSetTitle("drag group", "", "drag No. " & $inst & " of group") #EndRegion make unique title ;get a message number to use $MyMsg1 = RegisterWindowMessage("drawmanywindows") GUIRegisterMsg($MyMsg1, "GetDrag") GUIRegisterMsg($WM_ENTERSIZEMOVE, "EnterSIzeMove") While 1 $Msg = GUIGetMsg() If $Msg = -3 Then Exit If $master <> 0 Then DoCatchup() EndIf if $Msg = $ButF Then _SendMessage($WM_BROADCAST,$MyMsg1,$Gui,2) Exit EndIf WEnd Func EnterSizeMove($hW, $iM, $WP, $Lp) _SendMessage($WM_BROADCAST, $MyMsg1, $gui, 1) EndFunc ;==>EnterSizeMove Func GetDrag($hW, $iM, $WP, $Lp) if $Lp = 1 Then $master = $WP GUICtrlSetData($Lab1, "Messages from " & Hex($master)) EndIf if $Lp = 2 Then Exit EndIf EndFunc ;==>GetDrag Func DoCatchup() $Mp = WinGetPos($master) $Sp = WinGetPos($gui) While _IsPressed(01) $Np = WinGetPos($master) WinMove($gui, "", $Sp[0] + $Np[0] - $Mp[0], $Sp[1] + $Np[1] - $Mp[1]) WEnd $master = 0 EndFunc ;==>DoCatchup ;register window message ;returns a unique message number. if the message has already been registered then the ;the unique number for $stext is returned. ;Usefule for two windows to communicate Func RegisterWindowMessage($sText) Local $aRet = DllCall('user32.dll', 'int', 'RegisterWindowMessage', 'str', $sText) Return $aRet[0] EndFunc ;==>RegisterWindowMessage Thanks, for the help, i can now continue again...
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