HiNoTora Posted February 18, 2014 Share Posted February 18, 2014 (edited) I have script like this (copied from forum ) e.e $hGui1 = GUICreate('Just a Way To End SCript', 1100,800) GUISetState() Run("notepad.exe") WinWait("Untitled","",10) $hw1 = WinGetHandle("Untitled") WinMove($hw1, "", 0, 0, 400, 300);the position of notepad will be the relative positions in the our gui Sleep(100) $origParent = DllCall("user32.dll", "int", "SetParent", "hwnd", $hw1, "hwnd",$hGui1); WinGetHandle("Program Manager")) While 1 $msg = GUIGetMsg() If $msg = -3 Then ;set Notepad back To Original parent DllCall("user32.dll", "int", "SetParent", "hwnd", $hw1, "hwnd", $origParent[0]) Exit EndIf WEnd Now, there notepad.exe what opens in my GUI. Is there a way to make in unmovable and remove that minimize, maximize and close buttons from notepad window and if main GUI is closed then Notepad will close to. And how to set notepad window size to be something as i want x: y: Edited February 18, 2014 by HiNoTora Link to comment Share on other sites More sharing options...
Solution FireFox Posted February 18, 2014 Solution Share Posted February 18, 2014 I have script like this (copied from forum ) e.e Ewwwwwwwwwwwwww, not even using autoit winapi func names. expandcollapse popup;by FireFox, 2014 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> Run("notepad.exe") Local $hNotepad = WinWait("[CLASS:Notepad]", "", 10) If $hNotepad = 0 Then Exit 1 Local $aOriPos = WinGetPos($hNotepad) Local $hGUI = GUICreate("MyGUI", Default, Default, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX)) GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUIRegisterMsg($WM_EXITSIZEMOVE, "WM_EXITSIZEMOVE") GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE") GUISetState(@SW_SHOW, $hGUI) Local $hOriParent = _WinAPI_SetParent($hNotepad, $hGUI) Local $iStyle = _WinAPI_GetWindowLong($hNotepad, $GWL_STYLE) _WinAPI_SetWindowLong($hNotepad, $GWL_STYLE, BitXOR($iStyle, $WS_OVERLAPPEDWINDOW)) _WinAPI_SetWindowPos($hNotepad, 0, 0, 0, 400, 400, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOZORDER)) Local $iMsg = 0 While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;restore the notepad window _WinAPI_SetParent($hNotepad, $hOriParent) _WinAPI_SetWindowLong($hNotepad, $GWL_STYLE, $iStyle) _WinAPI_SetWindowPos($hNotepad, 0, $aOriPos[0], $aOriPos[1], $aOriPos[2], $aOriPos[3], BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOZORDER)) GUIDelete($hGUI) ;when the notepad window is closed the gui is activated, so check if this one has been closed Func WM_ACTIVATE($hWnd, $iMsg, $wParam, $lParam) If Number($wParam) = 1 And WinExists($hNotepad) = 0 Then GUIDelete($hGUI) Exit EndIf Return $GUI_RUNDEFMSG EndFunc ;otherwise the menu is not redrawn Func WM_EXITSIZEMOVE($hWnd, $iMsg, $wParam, $lParam) _WinAPI_RedrawWindow($hGUI, 0, 0, $RDW_INVALIDATE) Return $GUI_RUNDEFMSG EndFunc ;resize the notepad window according to the gui Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam) Local $iWidth = BitAND($lParam, 0xFFFF) Local $iHeight = BitShift($lParam, 16) WinMove($hNotepad, "", 0, 0, $iWidth, $iHeight) Return $GUI_RUNDEFMSG EndFunc Br, FireFox. 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