elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  [Tutorial] Como Superponer Form Sobre Juegos En "Pantalla Completa"
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Tutorial] Como Superponer Form Sobre Juegos En "Pantalla Completa"  (Leído 2,346 veces)
**Aincrad**


Desconectado Desconectado

Mensajes: 668



Ver Perfil WWW
[Tutorial] Como Superponer Form Sobre Juegos En "Pantalla Completa"
« en: 2 Octubre 2020, 00:44 am »

Hola , A todos. Algunos ya sabran que es Imposible Superponer tu Aplicación sobre un Juego que trabaja con Direcx y que esta en Pantalla Completa.

Bien Empecemos !



Introduccion :

     Es un Problema muy Común que cuando algún Programador en .Net , (Que haga Cheats) para juegos.
     Cuando quiera superponer su Applicacion sobre el juego en pantalla completa no lo logre. ya que basicamente El Juego "Secuestra la pantalla".

     En este caso , hago este Post , para Compartir "Mi" solución a este Problema.


     Cabe Resaltar que :
 
     
  •      Los Juegos que Usan Como motor OPENGL, No tienen este Problema. Se puede superponer facilmente otra Applicacion sobre ellos.
  •      No todos Los juegos Direcx tienen este Problema, Por Ejemplo Operation7, WolfTeam, Swat4 ,Entre Otros...
  •      La mayoría de Juegos creados con Unity Tampoco tienen este Problema.

     Entonces Empecemos...



    Primero que todo Mi solución no fue Intentar Forzar de alguna manera la superposición. ya que no lo logre.

     Quiero resaltar que hay un método que funciona, pero No muy Practico a mi parecer. Basicamente tienes que Conectar con EndScene .

     Basicamente usando SlimDX y EasyHook, Aca un Breve tutorial : [Tutorial] How to become an EndScene() hooker

     Por que no es muy Practico? , No lo es ya que Este metodo es facilmente Detectado por los AC (Anti-Cheats).




Solución :

     Bien mi Método , Fue una Solucion facil , Si no puedo Superponer sobre un Juego en pantalla Completa. Entonces :

     - EMULARE EL MODO PANTALLA COMPLETA.

     Básicamente Hacemos esto :


     1) Corremos Nuestro Juego en modo ventana, Algunos traen la opción en el Apartado de Configuración - Video.

     En caso de que No traiga esta Opción , Tienes que Crear un Acceso Directo, Abrir las Propiedades del Acceso Directo y Colocar al final el Parámetro : "-window"
     De todos modos aquí dejo un Tutorial Sobre esto : Play a Computer Game in Windowed Mode

     2) Emulamos / Forzamos El modo FullScreen. Para Ello Hacemos :


      Paso 1 : Agregamos a Su Proyecto Las Clases SetWindowStyle.vb y SetWindowState.vb.


SetWindowStyle.vb
Código
  1. ' ***********************************************************************
  2. ' Author           : Destroyer
  3. ' Last Modified On : 29-09-2020
  4. ' ***********************************************************************
  5. ' <copyright file="SetWindowStyle.vb" company="Elektro Studios">
  6. '     Copyright (c) All rights reserved.
  7. ' </copyright>
  8. ' ***********************************************************************
  9.  
  10. #Region " Usage Examples "
  11.  
  12. 'Dim HWND As IntPtr = Process.GetProcessesByName("devenv").First.MainWindowHandle
  13. '
  14. 'SetWindowState.SetWindowStyle(HWND, SetWindowStyle.WindowStyles.WS_BORDER)
  15. 'SetWindowState.SetWindowStyle("devenv", SetWindowStyle.WindowStyles.WS_BORDER, Recursivity:=False)
  16.  
  17. #End Region
  18.  
  19. #Region " Imports "
  20.  
  21. Imports System.Runtime.InteropServices
  22.  
  23. #End Region
  24.  
  25. ''' <summary>
  26. ''' Sets the style of a window.
  27. ''' </summary>
  28. Public NotInheritable Class SetWindowStyle
  29.  
  30. #Region " P/Invoke "
  31.  
  32.    ''' <summary>
  33.    ''' Platform Invocation methods (P/Invoke), access unmanaged code.
  34.    ''' This class does not suppress stack walks for unmanaged code permission.
  35.    ''' <see cref="System.Security.SuppressUnmanagedCodeSecurityAttribute"/>  must not be applied to this class.
  36.    ''' This class is for methods that can be used anywhere because a stack walk will be performed.
  37.    ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/ms182161.aspx
  38.    ''' </summary>
  39.    Protected NotInheritable Class NativeMethods
  40.  
  41. #Region " Methods "
  42.  
  43.        ''' <summary>
  44.        ''' Retrieves a handle to the top-level window whose class name and window name match the specified strings.
  45.        ''' This function does not search child windows.
  46.        ''' This function does not perform a case-sensitive search.
  47.        ''' To search child windows, beginning with a specified child window, use the FindWindowEx function.
  48.        ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499%28v=vs.85%29.aspx
  49.        ''' </summary>
  50.        ''' <param name="lpClassName">The class name.
  51.        ''' If this parameter is NULL, it finds any window whose title matches the lpWindowName parameter.</param>
  52.        ''' <param name="lpWindowName">The window name (the window's title).
  53.        ''' If this parameter is NULL, all window names match.</param>
  54.        ''' <returns>If the function succeeds, the return value is a handle to the window that has the specified class name and window name.
  55.        ''' If the function fails, the return value is NULL.</returns>
  56.        <DllImport("user32.dll", SetLastError:=False, CharSet:=CharSet.Auto, BestFitMapping:=False)>
  57.        Friend Shared Function FindWindow(
  58.           ByVal lpClassName As String,
  59.           ByVal lpWindowName As String
  60.        ) As IntPtr
  61.        End Function
  62.  
  63.        ''' <summary>
  64.        ''' Retrieves a handle to a window whose class name and window name match the specified strings.
  65.        ''' The function searches child windows, beginning with the one following the specified child window.
  66.        ''' This function does not perform a case-sensitive search.
  67.        ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633500%28v=vs.85%29.aspx
  68.        ''' </summary>
  69.        ''' <param name="hwndParent">
  70.        ''' A handle to the parent window whose child windows are to be searched.
  71.        ''' If hwndParent is NULL, the function uses the desktop window as the parent window.
  72.        ''' The function searches among windows that are child windows of the desktop.
  73.        ''' </param>
  74.        ''' <param name="hwndChildAfter">
  75.        ''' A handle to a child window.
  76.        ''' The search begins with the next child window in the Z order.
  77.        ''' The child window must be a direct child window of hwndParent, not just a descendant window.
  78.        ''' If hwndChildAfter is NULL, the search begins with the first child window of hwndParent.
  79.        ''' </param>
  80.        ''' <param name="strClassName">
  81.        ''' The window class name.
  82.        ''' </param>
  83.        ''' <param name="strWindowName">
  84.        ''' The window name (the window's title).
  85.        ''' If this parameter is NULL, all window names match.
  86.        ''' </param>
  87.        ''' <returns>
  88.        ''' If the function succeeds, the return value is a handle to the window that has the specified class and window names.
  89.        ''' If the function fails, the return value is NULL.
  90.        ''' </returns>
  91.        <DllImport("User32.dll", SetLastError:=False, CharSet:=CharSet.Auto, BestFitMapping:=False)>
  92.        Friend Shared Function FindWindowEx(
  93.           ByVal hwndParent As IntPtr,
  94.           ByVal hwndChildAfter As IntPtr,
  95.           ByVal strClassName As String,
  96.           ByVal strWindowName As String
  97.        ) As IntPtr
  98.        End Function
  99.  
  100.        ''' <summary>
  101.        ''' Retrieves the identifier of the thread that created the specified window
  102.        ''' and, optionally, the identifier of the process that created the window.
  103.        ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633522%28v=vs.85%29.aspx
  104.        ''' </summary>
  105.        ''' <param name="hWnd">A handle to the window.</param>
  106.        ''' <param name="ProcessId">
  107.        ''' A pointer to a variable that receives the process identifier.
  108.        ''' If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the variable;
  109.        ''' otherwise, it does not.
  110.        ''' </param>
  111.        ''' <returns>The identifier of the thread that created the window.</returns>
  112.        <DllImport("user32.dll")>
  113.        Friend Shared Function GetWindowThreadProcessId(
  114.            ByVal hWnd As IntPtr,
  115.            ByRef ProcessId As Integer
  116.        ) As Integer
  117.        End Function
  118.  
  119.        <System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint:="SetWindowLong")> _
  120.        Friend Shared Function SetWindowLong32(ByVal hWnd As IntPtr, <MarshalAs(UnmanagedType.I4)> nIndex As WindowLongFlags, ByVal dwNewLong As Integer) As Integer
  121.        End Function
  122.  
  123.        <System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint:="SetWindowLongPtr")> _
  124.        Friend Shared Function SetWindowLongPtr64(ByVal hWnd As IntPtr, <MarshalAs(UnmanagedType.I4)> nIndex As WindowLongFlags, ByVal dwNewLong As IntPtr) As IntPtr
  125.        End Function
  126.  
  127.        Friend Shared Function SetWindowLongPtr(ByVal hWnd As IntPtr, nIndex As WindowLongFlags, ByVal dwNewLong As IntPtr) As IntPtr
  128.            If IntPtr.Size = 8 Then
  129.                Return SetWindowLongPtr64(hWnd, nIndex, dwNewLong)
  130.            Else
  131.                Return New IntPtr(SetWindowLong32(hWnd, nIndex, dwNewLong.ToInt32))
  132.            End If
  133.        End Function
  134.  
  135. #End Region
  136.  
  137.    End Class
  138.  
  139. #End Region
  140.  
  141. #Region " Enumerations "
  142.  
  143.    Public Enum WindowLongFlags As Integer
  144.        GWL_EXSTYLE = -20
  145.        GWLP_HINSTANCE = -6
  146.        GWLP_HWNDPARENT = -8
  147.        GWL_ID = -12
  148.        GWL_STYLE = -16
  149.        GWL_USERDATA = -21
  150.        GWL_WNDPROC = -4
  151.        DWLP_USER = &H8
  152.        DWLP_MSGRESULT = &H0
  153.        DWLP_DLGPROC = &H4
  154.    End Enum
  155.  
  156.   <FlagsAttribute()> _
  157.  Public Enum WindowStyles As Long
  158.  
  159.        Todo1 = 2
  160.        Todo2 = 2048
  161.        Todo3 = 32768
  162.  
  163.        WS_OVERLAPPED = 0
  164.        WS_POPUP = 2147483648
  165.        WS_CHILD = 1073741824
  166.        WS_MINIMIZE = 536870912
  167.        WS_VISIBLE = 268435456
  168.        WS_DISABLED = 134217728
  169.        WS_CLIPSIBLINGS = 67108864
  170.        WS_CLIPCHILDREN = 33554432
  171.        WS_MAXIMIZE = 16777216
  172.        WS_BORDER = 8388608
  173.        WS_DLGFRAME = 4194304
  174.        WS_VSCROLL = 2097152
  175.        WS_HSCROLL = 1048576
  176.        WS_SYSMENU = 524288
  177.        WS_THICKFRAME = 262144
  178.        WS_GROUP = 131072
  179.        WS_TABSTOP = 65536
  180.  
  181.        WS_MINIMIZEBOX = 131072
  182.        WS_MAXIMIZEBOX = 65536
  183.  
  184.        WS_CAPTION = WS_BORDER Or WS_DLGFRAME
  185.        WS_TILED = WS_OVERLAPPED
  186.        WS_ICONIC = WS_MINIMIZE
  187.        WS_SIZEBOX = WS_THICKFRAME
  188.        WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW
  189.  
  190.        WS_OVERLAPPEDWINDOW = WS_OVERLAPPED Or WS_CAPTION Or WS_SYSMENU Or _
  191.                  WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
  192.        WS_POPUPWINDOW = WS_POPUP Or WS_BORDER Or WS_SYSMENU
  193.        WS_CHILDWINDOW = WS_CHILD
  194.  
  195.        WS_EX_DLGMODALFRAME = 1
  196.        WS_EX_NOPARENTNOTIFY = 4
  197.        WS_EX_TOPMOST = 8
  198.        WS_EX_ACCEPTFILES = 16
  199.        WS_EX_TRANSPARENT = 32
  200.  
  201.        '#If (WINVER >= 400) Then
  202.        WS_EX_MDICHILD = 64
  203.        WS_EX_TOOLWINDOW = 128
  204.        WS_EX_WINDOWEDGE = 256
  205.        WS_EX_CLIENTEDGE = 512
  206.        WS_EX_CONTEXTHELP = 1024
  207.  
  208.        WS_EX_RIGHT = 4096
  209.        WS_EX_LEFT = 0
  210.        WS_EX_RTLREADING = 8192
  211.        WS_EX_LTRREADING = 0
  212.        WS_EX_LEFTSCROLLBAR = 16384
  213.        WS_EX_RIGHTSCROLLBAR = 0
  214.  
  215.        WS_EX_CONTROLPARENT = 65536
  216.        WS_EX_STATICEDGE = 131072
  217.        WS_EX_APPWINDOW = 262144
  218.  
  219.        WS_EX_OVERLAPPEDWINDOW = WS_EX_WINDOWEDGE Or WS_EX_CLIENTEDGE
  220.        WS_EX_PALETTEWINDOW = WS_EX_WINDOWEDGE Or WS_EX_TOOLWINDOW Or WS_EX_TOPMOST
  221.        '#End If
  222.  
  223.        '#If (WIN32WINNT >= 500) Then
  224.        WS_EX_LAYERED = 524288
  225.        '#End If
  226.  
  227.        '#If (WINVER >= 500) Then
  228.        WS_EX_NOINHERITLAYOUT = 1048576 ' Disable inheritence of mirroring by children
  229.        WS_EX_LAYOUTRTL = 4194304 ' Right to left mirroring
  230.        '#End If
  231.  
  232.        '#If (WIN32WINNT >= 500) Then
  233.        WS_EX_COMPOSITED = 33554432
  234.        WS_EX_NOACTIVATE = 67108864
  235.        '#End If
  236.  
  237.    End Enum
  238.  
  239. #End Region
  240.  
  241. #Region " Public Methods "
  242.  
  243.    ''' <summary>
  244.    ''' Set the state of a window by an HWND.
  245.    ''' </summary>
  246.    ''' <param name="WindowHandle">A handle to the window.</param>
  247.    ''' <param name="WindowStyle">The Style of the window.</param>
  248.    ''' <returns><c>true</c> if the function succeeds, <c>false</c> otherwise.</returns>
  249.    Friend Shared Function SetWindowStyle(ByVal WindowHandle As IntPtr,
  250.                                          ByVal WindowStyle As WindowStyles) As Boolean
  251.  
  252.        Return NativeMethods.SetWindowLongPtr(WindowHandle, WindowLongFlags.GWL_STYLE, WindowStyle)
  253.  
  254.    End Function
  255.  
  256.    ''' <summary>
  257.    ''' Set the state of a window by a process name.
  258.    ''' </summary>
  259.    ''' <param name="ProcessName">The name of the process.</param>
  260.    ''' <param name="WindowStyle">The Style of the window.</param>
  261.    ''' <param name="Recursivity">If set to <c>false</c>, only the first process instance will be processed.</param>
  262.    Friend Shared Sub SetWindowStyle(ByVal ProcessName As String,
  263.                                     ByVal WindowStyle As WindowStyles,
  264.                                     Optional ByVal Recursivity As Boolean = False)
  265.  
  266.        If ProcessName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) Then
  267.            ProcessName = ProcessName.Remove(ProcessName.Length - ".exe".Length)
  268.        End If
  269.  
  270.        Dim pHandle As IntPtr = IntPtr.Zero
  271.        Dim pID As Integer = 0I
  272.  
  273.        Dim Processes As Process() = Process.GetProcessesByName(ProcessName)
  274.  
  275.        ' If any process matching the name is found then...
  276.        If Processes.Count = 0 Then
  277.            Exit Sub
  278.        End If
  279.  
  280.        For Each p As Process In Processes
  281.  
  282.            ' If Window is visible then...
  283.            If p.MainWindowHandle <> IntPtr.Zero Then
  284.                SetWindowStyle(p.MainWindowHandle, WindowStyle)
  285.  
  286.            Else ' Window is hidden
  287.  
  288.                ' Check all open windows (not only the process we are looking),
  289.                ' begining from the child of the desktop, phandle = IntPtr.Zero initialy.
  290.                While pID <> p.Id ' Check all windows.
  291.  
  292.                    ' Get child handle of window who's handle is "pHandle".
  293.                    pHandle = NativeMethods.FindWindowEx(IntPtr.Zero, pHandle, Nothing, Nothing)
  294.  
  295.                    ' Get ProcessId from "pHandle".
  296.                    NativeMethods.GetWindowThreadProcessId(pHandle, pID)
  297.  
  298.                    ' If the ProcessId matches the "pID" then...
  299.                    If pID = p.Id Then
  300.  
  301.                        NativeMethods.SetWindowLongPtr(pHandle, WindowLongFlags.GWL_STYLE, WindowStyle)
  302.  
  303.                        If Not Recursivity Then
  304.                            Exit For
  305.                        End If
  306.  
  307.                    End If
  308.  
  309.                End While
  310.  
  311.            End If
  312.  
  313.        Next p
  314.  
  315.    End Sub
  316.  
  317. #End Region
  318.  
  319. End Class
  320.  


SetWindowState.vb
Código
  1. ' ***********************************************************************
  2. ' Author           : Elektro
  3. ' Last Modified On : 10-02-2014
  4. ' ***********************************************************************
  5. ' <copyright file="SetWindowState.vb" company="Elektro Studios">
  6. '     Copyright (c) Elektro Studios. All rights reserved.
  7. ' </copyright>
  8. ' ***********************************************************************
  9.  
  10. #Region " Usage Examples "
  11.  
  12. 'Dim HWND As IntPtr = Process.GetProcessesByName("devenv").First.MainWindowHandle
  13. '
  14. 'SetWindowState.SetWindowState(HWND, SetWindowState.WindowState.Hide)
  15. 'SetWindowState.SetWindowState("devenv", SetWindowState.WindowState.Restore, Recursivity:=False)
  16.  
  17. #End Region
  18.  
  19. #Region " Imports "
  20.  
  21. Imports System.Runtime.InteropServices
  22.  
  23. #End Region
  24.  
  25. ''' <summary>
  26. ''' Sets the state of a window.
  27. ''' </summary>
  28. Public NotInheritable Class SetWindowState
  29.  
  30. #Region " P/Invoke "
  31.  
  32.    ''' <summary>
  33.    ''' Platform Invocation methods (P/Invoke), access unmanaged code.
  34.    ''' This class does not suppress stack walks for unmanaged code permission.
  35.    ''' <see cref="System.Security.SuppressUnmanagedCodeSecurityAttribute"/>  must not be applied to this class.
  36.    ''' This class is for methods that can be used anywhere because a stack walk will be performed.
  37.    ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/ms182161.aspx
  38.    ''' </summary>
  39.    Protected NotInheritable Class NativeMethods
  40.  
  41. #Region " Methods "
  42.  
  43.        ''' <summary>
  44.        ''' Retrieves a handle to the top-level window whose class name and window name match the specified strings.
  45.        ''' This function does not search child windows.
  46.        ''' This function does not perform a case-sensitive search.
  47.        ''' To search child windows, beginning with a specified child window, use the FindWindowEx function.
  48.        ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499%28v=vs.85%29.aspx
  49.        ''' </summary>
  50.        ''' <param name="lpClassName">The class name.
  51.        ''' If this parameter is NULL, it finds any window whose title matches the lpWindowName parameter.</param>
  52.        ''' <param name="lpWindowName">The window name (the window's title).
  53.        ''' If this parameter is NULL, all window names match.</param>
  54.        ''' <returns>If the function succeeds, the return value is a handle to the window that has the specified class name and window name.
  55.        ''' If the function fails, the return value is NULL.</returns>
  56.        <DllImport("user32.dll", SetLastError:=False, CharSet:=CharSet.Auto, BestFitMapping:=False)>
  57.        Friend Shared Function FindWindow(
  58.           ByVal lpClassName As String,
  59.           ByVal lpWindowName As String
  60.        ) As IntPtr
  61.        End Function
  62.  
  63.        ''' <summary>
  64.        ''' Retrieves a handle to a window whose class name and window name match the specified strings.
  65.        ''' The function searches child windows, beginning with the one following the specified child window.
  66.        ''' This function does not perform a case-sensitive search.
  67.        ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633500%28v=vs.85%29.aspx
  68.        ''' </summary>
  69.        ''' <param name="hwndParent">
  70.        ''' A handle to the parent window whose child windows are to be searched.
  71.        ''' If hwndParent is NULL, the function uses the desktop window as the parent window.
  72.        ''' The function searches among windows that are child windows of the desktop.
  73.        ''' </param>
  74.        ''' <param name="hwndChildAfter">
  75.        ''' A handle to a child window.
  76.        ''' The search begins with the next child window in the Z order.
  77.        ''' The child window must be a direct child window of hwndParent, not just a descendant window.
  78.        ''' If hwndChildAfter is NULL, the search begins with the first child window of hwndParent.
  79.        ''' </param>
  80.        ''' <param name="strClassName">
  81.        ''' The window class name.
  82.        ''' </param>
  83.        ''' <param name="strWindowName">
  84.        ''' The window name (the window's title).
  85.        ''' If this parameter is NULL, all window names match.
  86.        ''' </param>
  87.        ''' <returns>
  88.        ''' If the function succeeds, the return value is a handle to the window that has the specified class and window names.
  89.        ''' If the function fails, the return value is NULL.
  90.        ''' </returns>
  91.        <DllImport("User32.dll", SetLastError:=False, CharSet:=CharSet.Auto, BestFitMapping:=False)>
  92.        Friend Shared Function FindWindowEx(
  93.           ByVal hwndParent As IntPtr,
  94.           ByVal hwndChildAfter As IntPtr,
  95.           ByVal strClassName As String,
  96.           ByVal strWindowName As String
  97.        ) As IntPtr
  98.        End Function
  99.  
  100.        ''' <summary>
  101.        ''' Retrieves the identifier of the thread that created the specified window
  102.        ''' and, optionally, the identifier of the process that created the window.
  103.        ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633522%28v=vs.85%29.aspx
  104.        ''' </summary>
  105.        ''' <param name="hWnd">A handle to the window.</param>
  106.        ''' <param name="ProcessId">
  107.        ''' A pointer to a variable that receives the process identifier.
  108.        ''' If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the variable;
  109.        ''' otherwise, it does not.
  110.        ''' </param>
  111.        ''' <returns>The identifier of the thread that created the window.</returns>
  112.        <DllImport("user32.dll")>
  113.        Friend Shared Function GetWindowThreadProcessId(
  114.            ByVal hWnd As IntPtr,
  115.            ByRef ProcessId As Integer
  116.        ) As Integer
  117.        End Function
  118.  
  119.        ''' <summary>
  120.        ''' Sets the specified window's show state.
  121.        ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85%29.aspx
  122.        ''' </summary>
  123.        ''' <param name="hwnd">A handle to the window.</param>
  124.        ''' <param name="nCmdShow">Controls how the window is to be shown.</param>
  125.        ''' <returns><c>true</c> if the function succeeds, <c>false</c> otherwise.</returns>
  126.        <DllImport("User32", SetLastError:=False)>
  127.        Friend Shared Function ShowWindow(
  128.           ByVal hwnd As IntPtr,
  129.           ByVal nCmdShow As WindowState
  130.        ) As Boolean
  131.        End Function
  132.  
  133. #End Region
  134.  
  135.    End Class
  136.  
  137. #End Region
  138.  
  139. #Region " Enumerations "
  140.  
  141.    ''' <summary>
  142.    ''' Controls how the window is to be shown.
  143.    ''' MSDN Documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548%28v=vs.85%29.aspx
  144.    ''' </summary>
  145.    Friend Enum WindowState As Integer
  146.  
  147.        ''' <summary>
  148.        ''' Hides the window and activates another window.
  149.        ''' </summary>
  150.        Hide = 0I
  151.  
  152.        ''' <summary>
  153.        ''' Activates and displays a window.
  154.        ''' If the window is minimized or maximized, the system restores it to its original size and position.
  155.        ''' An application should specify this flag when displaying the window for the first time.
  156.        ''' </summary>
  157.        Normal = 1I
  158.  
  159.        ''' <summary>
  160.        ''' Activates the window and displays it as a minimized window.
  161.        ''' </summary>
  162.        ShowMinimized = 2I
  163.  
  164.        ''' <summary>
  165.        ''' Maximizes the specified window.
  166.        ''' </summary>
  167.        Maximize = 3I
  168.  
  169.        ''' <summary>
  170.        ''' Activates the window and displays it as a maximized window.
  171.        ''' </summary>      
  172.        ShowMaximized = Maximize
  173.  
  174.        ''' <summary>
  175.        ''' Displays a window in its most recent size and position.
  176.        ''' This value is similar to <see cref="WindowState.Normal"/>, except the window is not actived.
  177.        ''' </summary>
  178.        ShowNoActivate = 4I
  179.  
  180.        ''' <summary>
  181.        ''' Activates the window and displays it in its current size and position.
  182.        ''' </summary>
  183.        Show = 5I
  184.  
  185.        ''' <summary>
  186.        ''' Minimizes the specified window and activates the next top-level window in the Z order.
  187.        ''' </summary>
  188.        Minimize = 6I
  189.  
  190.        ''' <summary>
  191.        ''' Displays the window as a minimized window.
  192.        ''' This value is similar to <see cref="WindowState.ShowMinimized"/>, except the window is not activated.
  193.        ''' </summary>
  194.        ShowMinNoActive = 7I
  195.  
  196.        ''' <summary>
  197.        ''' Displays the window in its current size and position.
  198.        ''' This value is similar to <see cref="WindowState.Show"/>, except the window is not activated.
  199.        ''' </summary>
  200.        ShowNA = 8I
  201.  
  202.        ''' <summary>
  203.        ''' Activates and displays the window.
  204.        ''' If the window is minimized or maximized, the system restores it to its original size and position.
  205.        ''' An application should specify this flag when restoring a minimized window.
  206.        ''' </summary>
  207.        Restore = 9I
  208.  
  209.        ''' <summary>
  210.        ''' Sets the show state based on the SW_* value specified in the STARTUPINFO structure
  211.        ''' passed to the CreateProcess function by the program that started the application.
  212.        ''' </summary>
  213.        ShowDefault = 10I
  214.  
  215.        ''' <summary>
  216.        ''' <b>Windows 2000/XP:</b>
  217.        ''' Minimizes a window, even if the thread that owns the window is not responding.
  218.        ''' This flag should only be used when minimizing windows from a different thread.
  219.        ''' </summary>
  220.        ForceMinimize = 11I
  221.  
  222.    End Enum
  223.  
  224. #End Region
  225.  
  226. #Region " Public Methods "
  227.  
  228.    ''' <summary>
  229.    ''' Set the state of a window by an HWND.
  230.    ''' </summary>
  231.    ''' <param name="WindowHandle">A handle to the window.</param>
  232.    ''' <param name="WindowState">The state of the window.</param>
  233.    ''' <returns><c>true</c> if the function succeeds, <c>false</c> otherwise.</returns>
  234.    Friend Shared Function SetWindowState(ByVal WindowHandle As IntPtr,
  235.                                          ByVal WindowState As WindowState) As Boolean
  236.  
  237.        Return NativeMethods.ShowWindow(WindowHandle, WindowState)
  238.  
  239.    End Function
  240.  
  241.    ''' <summary>
  242.    ''' Set the state of a window by a process name.
  243.    ''' </summary>
  244.    ''' <param name="ProcessName">The name of the process.</param>
  245.    ''' <param name="WindowState">The state of the window.</param>
  246.    ''' <param name="Recursivity">If set to <c>false</c>, only the first process instance will be processed.</param>
  247.    Friend Shared Sub SetWindowState(ByVal ProcessName As String,
  248.                                     ByVal WindowState As WindowState,
  249.                                     Optional ByVal Recursivity As Boolean = False)
  250.  
  251.        If ProcessName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) Then
  252.            ProcessName = ProcessName.Remove(ProcessName.Length - ".exe".Length)
  253.        End If
  254.  
  255.        Dim pHandle As IntPtr = IntPtr.Zero
  256.        Dim pID As Integer = 0I
  257.  
  258.        Dim Processes As Process() = Process.GetProcessesByName(ProcessName)
  259.  
  260.        ' If any process matching the name is found then...
  261.        If Processes.Count = 0 Then
  262.            Exit Sub
  263.        End If
  264.  
  265.        For Each p As Process In Processes
  266.  
  267.            ' If Window is visible then...
  268.            If p.MainWindowHandle <> IntPtr.Zero Then
  269.                SetWindowState(p.MainWindowHandle, WindowState)
  270.  
  271.            Else ' Window is hidden
  272.  
  273.                ' Check all open windows (not only the process we are looking),
  274.                ' begining from the child of the desktop, phandle = IntPtr.Zero initialy.
  275.                While pID <> p.Id ' Check all windows.
  276.  
  277.                    ' Get child handle of window who's handle is "pHandle".
  278.                    pHandle = NativeMethods.FindWindowEx(IntPtr.Zero, pHandle, Nothing, Nothing)
  279.  
  280.                    ' Get ProcessId from "pHandle".
  281.                    NativeMethods.GetWindowThreadProcessId(pHandle, pID)
  282.  
  283.                    ' If the ProcessId matches the "pID" then...
  284.                    If pID = p.Id Then
  285.  
  286.                        NativeMethods.ShowWindow(pHandle, WindowState)
  287.  
  288.                        If Not Recursivity Then
  289.                            Exit For
  290.                        End If
  291.  
  292.                    End If
  293.  
  294.                End While
  295.  
  296.            End If
  297.  
  298.        Next p
  299.  
  300.    End Sub
  301.  
  302. #End Region
  303.  
  304. End Class
  305.  


   Paso 2 : Agregamos el Siguiente Código  su Proyecto. (En el Evento Load Si es Posible)

Código
  1. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2.        FullScreenEmulation("ProcessName")
  3.    End Sub
  4.  
  5.    Private Sub FullScreenEmulation(ByVal ProcessName As String)
  6.        If ProcessName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) Then ProcessName = ProcessName.Remove(ProcessName.Length - ".exe".Length)
  7.        Dim HWND As IntPtr = Process.GetProcessesByName(ProcessName).First.MainWindowHandle
  8.        SetWindowStyle.SetWindowStyle(HWND, SetWindowStyle.WindowStyles.WS_BORDER)
  9.        SetWindowState.SetWindowState(HWND, SetWindowState.WindowState.Maximize)
  10.    End Sub

Con esto ya tendríamos a nuestro Juego que estaba en modo ventana, Ahora en Pantalla Completa. (Falsa) , y Podemos Superponer Nuestra Aplicación encima del Juego Deseado.

Gracias A @Elektro por su clase SetWindowState.vb.

 

Imagen de Final De un Juego en modo Ventana, Forzado a Pantalla Completa (En este caso es Halo CE [Direcx9]):




PD: Se puede Superponer Perfectamente! Con el Juego en modo "FullScreen" !

Comenten xD.




En línea



Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines