Sign in to follow this  
Followers 0
shaqan

locking other program GUI position

4 posts in this topic

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?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thank you :)

also looks like I should have made this topic into "GUI help section", sorry :(

Edited by shaqan

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0