Jump to content

Drag Move current active window


Recommended Posts

Hi guys so I am trying to turn this script into a script that drag move current active window, even with a combination of keys if is easier..

This  script works perfectly with a gui window, I am simply trying to raplace what is moving (the gui) with current active window with no success.. Anyone has an idea?


#include <GuiconstantsEx.au3>
 #include <WindowsConstants.au3>
 #include <SendMessage.au3>

 HotKeySet("{ESC}", "On_Exit")

 $hGUI = GUICreate("X", 100, 100, -1, -1, $WS_POPUP)
 GUISetBkColor(0x00FF00, $hGUI)
 $hButton = GUICtrlCreateButton("Test", 10, 35, 80, 30)

 While 1
     Switch GUIGetMsg()
         Case $hButton

 Func On_Drag()
     Local $aCurInfo = GUIGetCursorInfo($hGUI)
     If $aCurInfo[4] = 0 Then ; Mouse not over a control
         DllCall("user32.dll", "int", "ReleaseCapture")
         _SendMessage($hGUI, $WM_NCLBUTTONDOWN, $HTCAPTION, 0)
 EndFunc   ;==>On_Drag

 Func On_Exit()
 EndFunc   ;==>On_Exit

 Func On_Button()
      MsgBox(0, "Hi", "Button Pressed")
 EndFunc   ;==>On_Button


Link to comment
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...