Sign in to follow this  
Followers 0
WSCPorts

general purpose Window Tool

1 post in this topic

i was wondering if there was any other way to window a app other that the supplied method..

if there is could u pls post the apis to use and i will do the research myself ... ty

#include <GuiConstants.au3>
#include <AnyGuiv2.6.au3>
Global $cHandle, $pos, $spos; Declare Global Variables
Const $SC_MINIMIZE = 61472, _ 
$SC_RESTORE = 61728, _
$SC_MOVE = 61458, _
$WM_SYSCOMMAND = 274, _
$SWP_ASYNCWINDOWPOS = 16384, _
$SWP_NOMOVE = 0x0002, $SWP_NOSIZE = 0x0001, _
$SWP_NOZORDER = 0x0004, $SWP_FRAMECHANGED = 0x0020, _
$HWND_BOTTOM = 1, $HWND_TOPMOST = -1, $HWND_NOTOPMOST = -2, _
$SWP_DRAWFRAME = 32, $SWP_NOSENDCHANGING = 0x0400, $WM_PAINT = 16 
;Declare some Windows Specific Constants to use...
GUICreate("BaNiMiZeR", 200, 200); Create the GuiBase
$MiniBTN = GUICtrlCreateButton("Mini", 0, 0, 50, 60, -1, -1)
;add Button to GuiBase with a handle to it...
$RestoreBTN = GUICtrlCreateButton("Restore", 50, 0, 50, 60, -1, -1);''
$EraseBTN = GUICtrlCreateButton("Erase", 100, 0, 50, 60, -1, -1);''
$RedrawBTN = GUICtrlCreateButton("ReDraw", 150, 0, 50, 60, -1, -1);''
$iHandle = GUICtrlCreateInput("Title", 60, 60, 70, 60);''
$GlobHandle = GUICtrlCreateButton("Get Handle", 0, 60, 60, 60);''
$SetOnTop = GUICtrlCreateButton("SetOnTop", 130, 60, 70, 60);''
$Window = GUICtrlCreateButton("Window It", 0, 120, 60, 60);'' = ditto;p
GUISetState( )
; Set the state of the Gui to show it with alls its pretty buttons and input.. :O
$spos = WinGetPos("BaNiMiZeR")
; Get the Global default Pos and Size for The Gui..
Func GetHandle()
    $iTitle = GUICtrlRead($iHandle)
;Read the input from the Input at $iHandle 
    $cHandle = ControlGetHandle($iTitle, "", 0)
;Get and Set Global Control handle to be more precise in the app u are working with
    $Pos = WinGetPos($cHandle)
;Get and Set the Global Handles WindowPos 
EndFunc
Func SetParent($oHwnd, $nHwnd);SetParent for windowing
    $ret = DllCall("User32.dll", "hwnd", "SetParent", "hwnd", $oHwnd, "hwnd", $nHwnd)
Return $ret[0]
; return the result of the Call ..
EndFunc
Func SendMessage($hwnd, $Msg, $wParam, $lParam)
Local $ret = DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  $hwnd, _
        "int",   $Msg, _
        "int",   $wParam, _
        "long",  $lParam)
If @error Then
        SetError(1)
        Return 0
    EndIf
Return $ret[0]
EndFunc
Func SendMessageMove($hwnd, $Msg, $wParam, $x, $y)
    Local $ret = DllCall("user32.dll", "int", "SendMessage", _
        "hwnd",  $hwnd, _
        "int",   $Msg, _
        "int",   $wParam, _
        "long",  MakeLong($x, $y))
If @error Then
        SetError(1)
        Return 0
    EndIf
Return $ret[0]
EndFunc
Func MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
Func SetWindowPos( $hwnd, $InsertHwnd, $X, $Y, $cX, $cY, $uFlags )
$ret = DllCall("user32.dll", "long", "SetWindowPos", "hwnd", $hwnd, "hwnd", $InsertHwnd, _
"int", $X, "int", $Y, "int", $cX, "int", $cY, "long", $uFlags)
    Return $ret[0]
EndFunc 
Func WindowIt()
    GUICreate("Game Embedder", @DesktopWidth, @DesktopHeight, 0, 0, -1, -1)
;Create and Gui to Be the Parent 
    GuiSetState();Set to show a big window...
    $gPos = WinGetPos("Game Embedder");Get Default WindowPos
    SetWindowPos($cHandle, $HWND_NOTOPMOST, $spos[0], $spos[1], $spos[2], $spos[3], $SWP_ASYNCWINDOWPOS)
;This Behind Game Embedder pls..
    SetWindowPos(WinGetHandle("Game Embedder"), $HWND_TOPMOST, $gPos[0], $gPos[1], $gPos[2], $gPos[3], $SWP_ASYNCWINDOWPOS)
;Set Game Embedder TopMost i.e. if there is a topmost window it is behind it...;p
    SetWindowPos(WinGetHandle("BaNiMiZeR"), $HWND_TOPMOST, $spos[0], $spos[1], $spos[2], $spos[3], $SWP_ASYNCWINDOWPOS)
;BaNiMiZeR on top pls
    _TargetStyle("set", 0, $WS_CHILD, $WS_EX_MDICHILD, $cHandle)
;Set the Child and MDICHILD Bits of the Handle..
    SetParent($cHandle, WinGetHandle("Game Embedder"))
;Windows the app by making Game Embedder the parent
EndFunc
;simple functions... 
Func Mini()
SendMessage($cHandle, $WM_SYSCOMMAND, $SC_MINIMIZE, 0)
EndFunc
Func EraseWin()
SetWindowPos($cHandle, 0, $pos[0], $pos[1], 0, 0, $SWP_ASYNCWINDOWPOS);/
EndFunc
Func ReDrawWind()
SetWindowPos($cHandle, 0, $pos[0], $pos[1], $pos[2], $pos[3], $SWP_ASYNCWINDOWPOS)
EndFunc
Func Rest()
SendMessage($cHandle, $WM_SYSCOMMAND, $SC_RESTORE, 0)
EndFunc

Do
$SRO_MSG = GUIGetMsg( )
If $SRO_MSG = $MiniBTN Then
    Mini()
ElseIf $SRO_MSG = $RestoreBTN Then
    Rest()
ElseIf $SRO_MSG = $EraseBTN Then
    EraseWin()
ElseIf $SRO_MSG = $GlobHandle Then
    GetHandle()
ElseIf $SRO_MSG = $Window Then
    WindowIT()
ElseIf $SRO_MSG = $SetOnTop Then
    SetWindowPos(WinGetHandle("BaNiMiZeR"), $HWND_TOPMOST, $spos[0], $spos[1], $spos[2], $spos[3], $SWP_ASYNCWINDOWPOS) 
Elseif $SRO_MSG = $RedrawBTN Then
    ReDrawWind()
Else 
    Sleep(50)
EndIf
Until $SRO_MSG = $GUI_EVENT_CLOSE
;my simple control Structure to the gui figure it out so0000 simple..

http://www.myclanhosting.com/defiasVisit Join and contribute to a soon to be leader in Custumized tools development in [C# .Net 1.1 ~ 2.0/C/C++/MFC/AutoIt3/Masm32]

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