DongVo Posted October 7 Share Posted October 7 Hi, I’ve been search in the forum and could not find about the override the maximum size rule of Winmove function. As AutoIT Help said that the maximum pixel resizing of a window is @DesktopWidth/Height + 12px. I would like to resize a window to a size: DesktopHeight + 26px. Please help. Link to comment Share on other sites More sharing options...
argumentum Posted October 7 Share Posted October 7 (edited) ..can't make a window bigger than the screen. But you say that they say +12, ok. You wanna do + 26, try it. But if you said that you'd like a full screen without the title bar, then that can be done. Search the forum or google for the code Edited October 7 by argumentum Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
DongVo Posted October 7 Author Share Posted October 7 Yes, I would like to make a window borderless. I use ANYGUI UDF and my code is working. The problem here is that after I removed the Title bar and set the window style borderless, the window is stretch in vertical, any icon and image in that window will stretch, too. So I think removing the title bar and set the borderless window style is not a good solution in fact. In my opinion, if we could modify the WinMove function of AutoIT to increase the limit @DestktopWidth/Height + 12px, we can do a trick by moving this window title bar outside the desktop screen. Please help me. Link to comment Share on other sites More sharing options...
pixelsearch Posted October 7 Share Posted October 7 23 minutes ago, DongVo said: In my opinion, if we could modify the WinMove function of AutoIT to increase the limit @DestktopWidth/Height + 12px [...] AutoIt has nothing to do with this limitation as AutoIt WinMove function simply calls Windows MoveWindow function. 2 links here and there that show it's Microsoft that added years ago this limitation of +12 pixels. Note : The maximum value of this property is limited by the resolution of the screen on which the form runs. The value cannot be greater than 12 pixels over each screen dimension (horizontal + 12 and vertical + 12). Now when it's your own GUI, you can bypass this limitation by registering the WM_GETMINMAXINFO message (just tested successfully) : thanks to Hans Passant for this info, in this link Good luck Link to comment Share on other sites More sharing options...
ioa747 Posted October 7 Share Posted October 7 take a look https://www.autoitscript.com/forum/topic/210078-full-screen-gui/ I know that I know nothing Link to comment Share on other sites More sharing options...
argumentum Posted October 7 Share Posted October 7 2 hours ago, DongVo said: The problem here is that after I removed the Title bar and set the window style borderless, the window is stretch in vertical, any icon and image in that window will stretch, too. Use GUICtrlSetResizing(). That will declare how a control resize. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
DongVo Posted October 8 Author Share Posted October 8 Thank for the help. Please help one more. As I search in the forum, there are many solution for dragging a borderless GUI, not a window program. I can set the borderless window style for the program by style $WS_POPUP. Can we make this one available for dragging ? Link to comment Share on other sites More sharing options...
ioa747 Posted October 8 Share Posted October 8 (edited) Edited October 8 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
argumentum Posted October 8 Share Posted October 8 9 hours ago, DongVo said: I can set the borderless window style for the program by style $WS_POPUP. Can we make this one available for dragging ? If it's your script with a GUI yes. If you are medaling with someone else's program, ... yes too but, why ? So you know, I have to consult tarot cards and pull an astrological chart every time you ask a question Show me some code. Musashi 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
DongVo Posted October 9 Author Share Posted October 9 My bad response. I am playing with the program name 'Text Pad 8'. Below is my code to set the borderless window style for Text Pad 8. It's not available in dragging after I set that one. As I search in the forum, somebody said that if the program does not support dragging in borderless style, so it is impossible to do this. Can we do a trick ? expandcollapse popup#RequireAdmin #NoTrayIcon #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 214, 108, 627, 324) $cbBorderless = GUICtrlCreateCheckbox("Borderless", 56, 40, 105, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cbBorderless If WinExists('TextPad - [Document1]') Then Local $textpad = WinGetHandle('TextPad - [Document1]') ;My propgram is Textpad 8 If _IsChecked($cbBorderless) Then WinSetStyle($textpad, $WS_POPUP) Else WinSetStyle($textpad) EndIf EndIf EndSwitch WEnd Func _IsChecked($idControlID) Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED EndFunc ;==>_IsChecked Func WinSetStyle($hWnd, $Style = -1, $ExStyle = 0) Local Const $GWL_STYLE = -16 Local Const $GWL_EXSTYLE = -20 Local Const $SWP_NOMOVE = 0x2 Local Const $SWP_NOSIZE = 0x1 Local Const $SWP_SHOWWINDOW = 0x40 Local Const $SWP_NOZORDER = 0x4 Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER) If $Style = -1 Then $Style = $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style) DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle) DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, _ "int", 0, "int", 0, "int", $iFlags) EndFunc ;==>WinSetStyle Link to comment Share on other sites More sharing options...
ioa747 Posted October 9 Share Posted October 9 (edited) Edited October 9 by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
argumentum Posted October 9 Share Posted October 9 3 hours ago, DongVo said: if the program does not support dragging in borderless style, so it is impossible to do this. To me impossible lacks imagination. But I lack time. There is code in the forum to know what program is under the cursor. Then, once identified the hWin and the size of it and the distance to the mouse, what I would do is wait X seconds after _isPressed() and either, draw a border or show a ToolTip(), indicating that is now draggable. Then dragging is done with WinMove x,y away from the pointer's x,y. That would move any window, title bar or not. So there, imagination Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
pixelsearch Posted October 9 Share Posted October 9 (edited) Scripted this, hope it helps . Just drag the mouse inside the NotePad window to move it. expandcollapse popup#include <GUIConstantsEx.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Run("notepad.exe") Local $hPad = WinWaitActive("[CLASS:Notepad]", "", 10) If Not WinActive($hPad) Then Exit MsgBox(0, "Error", "NotePad didn't open") Local $aWinPos, $aMPos, $aMPosOld, $hDLL = DllOpen("user32.dll") #Region ### START Koda GUI section ### Form= GUICreate("Form1", 214, 108, 627, 324, -1, $WS_EX_TOPMOST) Local $cbBorderless = GUICtrlCreateCheckbox("Borderless", 56, 40, 105, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 If _IsPressed("01", $hDLL) Then ; "01" = Left mouse button If WinActive($hPad) Then $aMPosOld = MouseGetPos() While _IsPressed("01", $hDll) $aMPos = MouseGetPos() If $aMPos[0] <> $aMPosOld[0] Or $aMPos[1] <> $aMPosOld[1] Then $aWinpos = WinGetPos($hPad) WinMove($hPad, "", $aWinpos[0] + ($aMPos[0] - $aMPosOld[0]), $aWinpos[1] + ($aMPos[1] - $aMPosOld[1])) $aMPosOld = $aMPos EndIf Sleep(10) Wend EndIf EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE DllClose($hDLL) WinClose($hPad) Exit Case $cbBorderless WinSetStyle($hPad, (GUICtrlRead($cbBorderless) = $GUI_CHECKED) _ ? $WS_POPUP _ ; possible BitOr($WS_POPUP, $WS_SIZEBOX) : -1) EndSwitch WEnd ;================================================ Func WinSetStyle($hWnd, $Style = -1, $ExStyle = 0) Local Static $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER) ; If $Style = -1 Then $Style = BitOr($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU) If $Style = -1 Then $Style = $WS_OVERLAPPEDWINDOW ; this style includes maximize & resize _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $Style) _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $ExStyle) _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $iFlags) EndFunc ;==>WinSetStyle Edit1: based on an older script from 2020 Edit2: a 2nd version of the script found in next post is more interesting. Edited October 12 by pixelsearch minor changes in code Link to comment Share on other sites More sharing options...
pixelsearch Posted October 9 Share Posted October 9 (edited) Good news In the preceding post, I found it frustrating that we couldn't save the original style of the external window (NotePad) immediately after it is active for the first time, then reuse this value constantly within the script when we UNcheck the Borderless checkbox in the GUI When I tried it, NotePad was always poorly redrawn, so in the preceding post I kept (more or less) what was in OP's WinSetStyle function, i.e. this kind of line : ; If $Style = -1 Then $Style = BitOr($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU) ; If $Style = -1 Then $Style = $WS_OVERLAPPEDWINDOW ; this style includes maximize & resize In fact, if we add a flag to _WinAPI_SetWindowPos, then it is possible to save the original style and reuse it later. The flag to add is $SWP_FRAMECHANGED . In msdn words : SWP_FRAMECHANGED : Applies new frame styles set using the SetWindowLong function. Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed. So here is a 2nd version of the script, taking care of the original style of the external window (NotePad) expandcollapse popup#include <GUIConstantsEx.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Run("notepad.exe") Local $hPad = WinWaitActive("[CLASS:Notepad]", "", 10) If Not WinActive($hPad) Then Exit MsgBox(0, "Error", "NotePad didn't open") Else Local $Style_Original = _WinAPI_GetWindowLong($hPad, $GWL_STYLE) Local $ExStyle_Original = _WinAPI_GetWindowLong($hPad, $GWL_EXSTYLE) EndIf Local $aWinPos, $aMPos, $aMPosOld, $hDLL = DllOpen("user32.dll") #Region ### START Koda GUI section ### Form= GUICreate("Form1", 214, 108, 627, 324, -1, $WS_EX_TOPMOST) Local $cbBorderless = GUICtrlCreateCheckbox("Borderless", 56, 40, 105, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 If _IsPressed("02", $hDLL) Then ; "02" = Right mouse button If WinActive($hPad) Then $aMPosOld = MouseGetPos() While _IsPressed("02", $hDll) $aMPos = MouseGetPos() If $aMPos[0] <> $aMPosOld[0] Or $aMPos[1] <> $aMPosOld[1] Then $aWinpos = WinGetPos($hPad) WinMove($hPad, "", $aWinpos[0] + ($aMPos[0] - $aMPosOld[0]), $aWinpos[1] + ($aMPos[1] - $aMPosOld[1])) $aMPosOld = $aMPos EndIf Sleep(10) Wend EndIf EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE DllClose($hDLL) If GUICtrlRead($cbBorderless) = $GUI_CHECKED Then WinSetStyle($hPad, $Style_Original, $ExStyle_Original) EndIf ; WinClose($hPad) Exit Case $cbBorderless If GUICtrlRead($cbBorderless) = $GUI_CHECKED Then WinSetStyle($hPad, $WS_POPUP, 0) ; possible BitOr($WS_POPUP, $WS_SIZEBOX) in some cases Else WinSetStyle($hPad, $Style_Original, $ExStyle_Original) EndIf EndSwitch WEnd ;================================================ Func WinSetStyle($hWnd, $Style, $ExStyle) ; Local Static $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER) Local Static $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER, $SWP_FRAMECHANGED) _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, $Style) _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, $ExStyle) _WinAPI_SetWindowPos($hWnd, 0, 0, 0, 0, 0, $iFlags) EndFunc ;==>WinSetStyle Edit: I added code to restore also the original ExStyle when needed (i.e. when user UNchecks the checkbox to bring back the external window to its initial state) . For example, NotePad window got normally these extended styles : WS_EX_WINDOWEDGE, WS_EX_ACCEPTFILES If we keep on setting the extended style to 0 (as in OP's initial script, by checking / unchecking the GUI checkbox), then the WS_EX_ACCEPTFILES is lost and you can't drag any text file inside the Notepad window, this is not user friendly at all. In fact, I'm not sure the WS_EX_ACCEPTFILES extended style should be lost when the external window is displayed borderless, but well... at least with this reworked code, all initial extended styles will be restored when the external window retrieves its initial state (i.e. when UNchecking the GUI checkbox) Edited October 12 by pixelsearch When needed, restore original Style AND ExStyle Link to comment Share on other sites More sharing options...
pixelsearch Posted October 10 Share Posted October 10 (edited) A little suggestion : it seems interesting to use the right-click for dragging the external window, instead of the left-click, ie use this... If _IsPressed("02", $hDLL) Then ; "02" = Right mouse button ... While _IsPressed("02", $hDll) ... ...instead of If _IsPressed("01", $hDLL) Then ; "01" = Left mouse button ... While _IsPressed("01", $hDll) ... This will allow to drag the scrollbars normally, to select text with your mouse and all other actions that require to drag the mouse while its left button is pressed. Please note that a useless context menu may appear when you release the right button (after the external window was moved), just cancel it, imho it's a little price to pay for this good functionality. Edited October 10 by pixelsearch typo Link to comment Share on other sites More sharing options...
DongVo Posted October 10 Author Share Posted October 10 Sorry for my late response. I am just going this topic and reading your help @pixelsearch . I can't imagine this trick is in real life. Your code is working perfectly. Thank you so much @pixelsearch and @argumentum for giving me a wonderful idea. Now I can drag and move a borderless window with the code of "pixelsearch". argumentum 1 Link to comment Share on other sites More sharing options...
pixelsearch Posted October 12 Share Posted October 12 (edited) Glad we could help I just added 3 lines in the preceding script, changing this... Case $GUI_EVENT_CLOSE DllClose($hDLL) WinClose($hPad) Exit ...to that Case $GUI_EVENT_CLOSE DllClose($hDLL) If GUICtrlRead($cbBorderless) = $GUI_CHECKED Then WinSetStyle($hPad, $Style_Original, $ExStyle_Original) EndIf WinClose($hPad) Exit Without this change, here is an annoying scenario that may happen : * Try some changes in the external window (in our example, just type some characters in the external window (NotePad) * Check the borderless CheckBox in the Gui => the external window (NotePad) becomes borderless without caption and no X close button ($WS_POPUP) * Move the borderless external window as you wish (by dragging the mouse while right click is pressed) * Close the GUI to end the script => a message will appear "Do you want to save changes..." (in NotePad) with 3 options (Yes, No, Cancel) or (Save, Don't save, Cancel) depending on your OS. * If you choose Cancel, then you'll be left facing an external window which has no borders and no Close (X) button. In the example, you still could close NotePad because there is a menu in NotePad (File => Quit) Now imagine there is no menu in the external window, then you won't be able to close (easily) the external window. That's why I added the 3 lines, to reset original styles + extended styles to the external window, in case the user ends the script when the external window was borderless without a close button. As discussed before, I also changed this in the preceding script : "01" = Left mouse button became "02" = Right mouse button Edit: now that there is code to always reset the original style + extended style of the external window when we end the script, then the exiting script shouldn't close the external window anymore, i.e. ; WinClose($hPad) This leaves more freedom to interact with any already existing external window, without forcing this external window to close automatically when the user ends the script. Edited October 12 by pixelsearch argumentum 1 Link to comment Share on other sites More sharing options...
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