CodeMaster Rapture Posted April 11, 2008 Posted April 11, 2008 Hey there, I'm working on a simple script to resize and move some windows (tile them). I've got the foundation working. I was curious if it is possible to change the styles/ex-styles of windows not created through Au3. I want to strip the titlebars and borders from 3 windows so all I get is the client area. Any suggestions (Au3, C++, or even C#)? Obviously GUISetStyle() doesn't work because I didn't create the window in Au3 (even if I do pass the handle). Here's my code so far: expandcollapse popupHotKeySet("{F9}","_LayoutOne") HotKeySet("{F10}","_LayoutTwo") HotKeySet("{F11}","_LayoutThree") Opt("MouseCoordMode",1) Global $a_WindowInfo[3][5] ;[X][0] = Window Title ;[X][1] = Current X Position ;[X][2] = Current Y Position ;[X][3] = Current Width ;[X][4] = Current Height $a_WindowInfo[0][0] = "myNotepad One" $a_WindowInfo[1][0] = "myNotepad Two" $a_WindowInfo[2][0] = "myNotepad Three" Global $a_WindowPreset[3][4] ;Preset for window 1 $a_WindowPreset[0][0] = -4 ;Xpos $a_WindowPreset[0][1] = -30 ;Ypos $a_WindowPreset[0][2] = 1288 ;Width $a_WindowPreset[0][3] = 824 ;Height ;Preset for window 2 $a_WindowPreset[1][0] = -4 $a_WindowPreset[1][1] = 764 $a_WindowPreset[1][2] = 645 $a_WindowPreset[1][3] = 265 ;Preset for window 3 $a_WindowPreset[2][0] = 640 $a_WindowPreset[2][1] = 764 $a_WindowPreset[2][2] = 645 $a_WindowPreset[2][3] = 265 While 1 If (WinActive("Notepad")) Then $sz_Rename = InputBox("Setup","Rename it to what?") WinSetTitle("Notepad","",$sz_Rename) EndIf Sleep(100) WEnd Func _SetWindowToPreset($Char,$Preset) If (Not WinExists($a_WindowInfo[0][0]) Or Not WinExists($a_WindowInfo[1][0]) Or Not WinExists($a_WindowInfo[2][0])) Then Return EndIf $a_WindowInfo[$Char][1] = $a_WindowPreset[$Preset][0] $a_WindowInfo[$Char][2] = $a_WindowPreset[$Preset][1] $a_WindowInfo[$Char][3] = $a_WindowPreset[$Preset][2] $a_WindowInfo[$Char][4] = $a_WindowPreset[$Preset][3] EndFunc Func _LayoutOne() _SetWindowToPreset(0,0) _SetWindowToPreset(1,1) _SetWindowToPreset(2,2) _MoveEm() EndFunc Func _LayoutTwo() _SetWindowToPreset(1,0) _SetWindowToPreset(0,1) _SetWindowToPreset(2,2) _MoveEm() EndFunc Func _LayoutThree() _SetWindowToPreset(2,0) _SetWindowToPreset(1,1) _SetWindowToPreset(0,2) _MoveEm() EndFunc Func _MoveEm() If (Not WinExists($a_WindowInfo[0][0]) Or Not WinExists($a_WindowInfo[1][0]) Or Not WinExists($a_WindowInfo[2][0])) Then Return EndIf WinMove($a_WindowInfo[0][0],"",$a_WindowInfo[0][1],$a_WindowInfo[0][2],$a_WindowInfo[0][3],$a_WindowInfo[0][4]) WinMove($a_WindowInfo[1][0],"",$a_WindowInfo[1][1],$a_WindowInfo[1][2],$a_WindowInfo[1][3],$a_WindowInfo[1][4]) WinMove($a_WindowInfo[2][0],"",$a_WindowInfo[2][1],$a_WindowInfo[2][2],$a_WindowInfo[2][3],$a_WindowInfo[2][4]) EndFunc Thanx in advance, CMR
BrettF Posted April 12, 2008 Posted April 12, 2008 (edited) To set the extended style: $hwnd = window $nExStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -20) $nExStyle = $nExStyle[0] DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", -20, "int", BitOR($nExStyle, $all_other_ex_styles)) I'm sure you can work out the rest now you know where to look Edited April 12, 2008 by Bert Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
therks Posted April 12, 2008 Posted April 12, 2008 Funny, I was just playing with this recently. I wrote up this function: Func _ChangeWinStyle($hWnd, $aSetStyles = false) Local Const $GWL_EXSTYLE = -20 Local Const $GWL_STYLE = -16 Local $aSize = WinGetPos($hWnd) Local $aStyle = DllCall('user32.dll', 'int', 'GetWindowLong', 'hwnd', $hWnd, 'int', $GWL_STYLE) If @error Then Return SetError(1, 0, 0) Local $aExStyle = DllCall('user32.dll', 'int', 'GetWindowLong', 'hwnd', $hWnd, 'int', $GWL_EXSTYLE) If @error Then Return SetError(2, 0, 0) Local $aReturn[2] = [ $aStyle[0], $aExStyle[0] ] If UBound($aSetStyles) < 2 Then Local $t[2] = [ BitOr($WS_OVERLAPPED, $WS_CAPTION, $WS_SYSMENU, $WS_THICKFRAME), $WS_EX_TOOLWINDOW ] $aSetStyles = $t EndIf WinSetState($hWnd, '', @SW_HIDE) DllCall('user32.dll', 'int', 'SetWindowLong', _ 'hwnd', $hWnd, _ 'int', $GWL_STYLE, _ 'int', $aSetStyles[0]) DllCall('user32.dll', 'int', 'SetWindowLong', _ 'hwnd', $hWnd, _ 'int', $GWL_EXSTYLE, _ 'int', $aSetStyles[1]) WinMove($hWnd, '', $aSize[0], $aSize[1], $aSize[2]+1, $aSize[3]+1) WinMove($hWnd, '', $aSize[0], $aSize[1], $aSize[2], $aSize[3]) WinSetState($hWnd, '', @SW_SHOW) Return $aReturn EndFuncoÝ÷ زë"²¶§X¤zØb±«¢+ØÀÌØí¡]¹ô]¥¹Ñ!¹± Ìäím 1MLé9½ÑÁtÌäì¤(ÀÌØí=±MÑå±Ìô} ¡¹]¥¹MÑå± ÀÌØí¡]¹¤)M±À ÔÀÀÀ¤)} ¡¹]¥¹MÑå± ÀÌØí¡]¹°ÀÌØí=±MÑå±Ì¤ I've had some weird graphical glitches with some windows which seemed to be fixed by resizing the window just a bit, hence the WinMove statements at the end of the function. I'm sure it's not exactly what you're looking for, but something to work from. My AutoIt Stuff | My Github
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