Jump to content

locking other program GUI position


Recommended Posts

Hi, found sample like this

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Const $SC_MOVE = 0xF010

$hGUI = GUICreate("Not moved GUI")
GUISetState()
GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND")

While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0x0000FFF0) = $SC_MOVE Then Return False
    Return $GUI_RUNDEFMSG 
EndFunc

How to modify it to lock position (so it cant be dragged with mouse) of some other non-fullscreen program GUI window. Like for example Notepad?

Link to comment
Share on other sites

Hello,

Try this.

$wintitle = "Untitled - Notepad";

$x = 334 ; X
$y = 159 ; Y

While 1

    $pos = WinGetPos($wintitle);
    If $pos[0] <> $x OR $pos[1] <> $y Then
        WinMove($wintitle, "", $x, $y);
    EndIf
    sleep(10);
WEnd

If you want to stop it from being minimized, also look at WinGetState() & WinSetState()

Steve

Edited by Steveiwonder

They call me MrRegExpMan

Link to comment
Share on other sites

Hi,

Here is another option

#Include <WinAPI.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>

$wintitle = "Untitled - Notepad"
run("notepad.exe")
sleep(1000)
$hWnd =WinGetHandle($wintitle,"")
     $style = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE)
If BitXOR($style,$WS_SIZEBOX,$WS_BORDER) <> BitOr($style,BitXOR($style,$WS_SIZEBOX,$WS_BORDER)) Then _WinAPI_SetWindowLong($hWnd,$GWL_STYLE,BitXOR($style,$WS_SIZEBOX,$WS_BORDER))
$x=WinGetPos($wintitle,"")
WinMove($wintitle,"",$x[0],$x[1]+1)
_WinAPI_RedrawWindow($hWnd,0,0,BitOR($RDW_ERASE,$RDW_INVALIDATE,$RDW_UPDATENOW,$RDW_FRAME,$RDW_ALLCHILDREN)) ; works, but redraws entire screen.
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
 Share

  • Recently Browsing   0 members

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