Palkiao Posted January 24, 2022 Posted January 24, 2022 (edited) Hi guys, there is plenty of material on how to drag move GUIs, is there a way to do so also with active window? https://www.autoitscript.com/wiki/Moving_and_Resizing_PopUp_GUIs move drag an active window using a certain key + left mouse drag? Similar to what AltDrag does? I am using second monitor that is a tablet and It does not work there Edited January 25, 2022 by big_daddy
Solution ad777 Posted January 25, 2022 Solution Posted January 25, 2022 (edited) @Palkiao you can move drag window:(G Key + Left Mouse): #include <Misc.au3> $dll = dllopen("user32.dll") if _IsPressed("47",$dll)And _IsPressed("01",$dll)Then _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) or using ALT+SPACE(Move): expandcollapse popup#include <Misc.au3> Global $window = WinWaitActive("Untitled - Notepad"),$dll = DllOpen("user32.dll") SendKeepActive($window) Send("{ALT}+{SPACE}") Send("{DOWN}") Send("{ENTER}") Global $TB,$RL,$PRL,$PTB,$state = "on" While 1 if WinActive("Untitled - Notepad") Then if $state = "on" Then $PRL = MouseGetPos(0); Sleep(500) $PTB = MouseGetPos(1); $state = "off" EndIf $RL = MouseGetPos(0); $TB = MouseGetPos(1); if _IsPressed("47",$dll)And _IsPressed("01",$dll) Then ; if [47] G key + [01] Left mouse button is pressed $state = "on" if $RL > $PRL Then Send("{RIGHT}") Sleep(200) Send("{ALT}+{SPACE}") Send("{DOWN}") Send("{ENTER}") Elseif $RL < $PRL Then Send("{LEFT}") Sleep(200) Send("{ALT}+{SPACE}") Send("{DOWN}") Send("{ENTER}") EndIf if $TB > $PTB Then Send("{DOWN}") Sleep(200) Send("{ALT}+{SPACE}") Send("{DOWN}") Send("{ENTER}") Elseif $TB < $PTB Then Send("{UP}") Sleep(200) Send("{ALT}+{SPACE}") Send("{DOWN}") Send("{ENTER}") EndIf EndIf EndIf WEnd or you can simply move window: #include <Misc.au3> local $dll = dllopen("user32.dll") if _IsPressed("47",$dll)And _IsPressed("01",$dll) Then ; if [47] G key + [01] Left mouse button is pressed WinMove($window,"",mousegetpos(0)-400,MouseGetPos(1)) EndIf or using (if your drag window like notepad it will Send ESC else if you G+LeftMouse) #include <Misc.au3> Global $state = "on" $dll = DllOpen("user32.dll") While 1 if _IsPressed("01",$dll) And WinActive("Untitled - Notepad") Then if $state = "off" Then Else Send("{ESC}") EndIf EndIf if _IsPressed("47",$dll) And _IsPressed("01",$dll) And WinActive("Untitled - Notepad") Then $state = "off" Else $state = "on" EndIf WEnd or by using Mouse Drag using (border): expandcollapse popup#include <FrameConstants.au3> #include <WinAPISysWin.au3> #include <WinAPIGdiDC.au3> #include <SendMessage.au3> #include <BorderConstants.au3> #include <Misc.au3> #include <WinAPIGdiDC.au3> ToolTip("waitting for window....") WinWaitActive("Untitled - Notepad") HotKeySet("{ESC}", "On_Exit") Global Const $tagRECT2 = DllStructCreate("struct; long Left;long Top;long Right;long Bottom; endstruct") Global $dll = DllOpen("user32.dlL"), $state = "on" $Width = WinGetPos("Untitled - Notepad", "")[2] $Height = WinGetPos("Untitled - Notepad", "")[3] While 1 ToolTip("") If _KeyPeleased("01") = 1 Then WinMove("Untitled - Notepad", "", DllStructGetData($tagRECT2, "Left"), DllStructGetData($tagRECT2, "Top")) EndIf If $state = "on" Then ;ToolTip("") $hGUI = GUICreate("", @DesktopWidth + 10, @DesktopHeight + 10, -1, -1, 0x80000000) GUISetState() WinSetTrans($hGUI, "", 100) ;Make window invisible. $state = "off" EndIf If _IsPressed("01", $dll) Then _WinAPI_InvalidateRect($hGUI, 0, True) DllStructSetData($tagRECT2, "Left", MouseGetPos(0)) DllStructSetData($tagRECT2, "Top", MouseGetPos(1)) DllStructSetData($tagRECT2, "Right", MouseGetPos(0) + $Width) DllStructSetData($tagRECT2, "Bottom", MouseGetPos(1) + $Height) _WinAPI_DrawEdge(_WinAPI_GetDC($hGUI), $tagRECT2, $EDGE_BUMP, $BF_SOFT) _WinAPI_DrawEdge(_WinAPI_GetDC($hGUI), $tagRECT2, $EDGE_BUMP, $BF_TOP) _WinAPI_DrawEdge(_WinAPI_GetDC($hGUI), $tagRECT2, $EDGE_BUMP, $BF_BOTTOMRIGHT) _WinAPI_DrawEdge(_WinAPI_GetDC($hGUI), $tagRECT2, $EDGE_BUMP, $BF_BOTTOMLEFT) EndIf WEnd Func On_Exit() Exit EndFunc ;==>On_Exit Func _KeyPeleased($key) Global $stat If _IsPressed($key, $dll) Then $stat = 1 Sleep(5) EndIf If Not _IsPressed($key, $dll) Then If $stat = 1 Then $stat = 0 Return 1 ; Sleep(10) EndIf EndIf EndFunc ;==>_KeyPeleased Edited February 10, 2022 by ad777 Palkiao 1 none
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