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

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Función MoveWindow al abrir aplicación "firefox"
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Función MoveWindow al abrir aplicación "firefox"  (Leído 1,433 veces)
daniel.r.23

Desconectado Desconectado

Mensajes: 58


Ver Perfil
Función MoveWindow al abrir aplicación "firefox"
« en: 26 Octubre 2014, 08:53 am »

Buenas, en un tema anterior pedí ayuda a como ocultar una ventana de firefox a ese tema se le encontró solución pero no me sirvió para lo que yo necesitaba ya que cada ves que una aplicación externa utilizaba el navegador este se activaba y se mostraba de todas formas, por lo que el ShowWindow no me sirvió!.
Como solución utilicé el MoveWindow para mover el navegador a un puto el cual el usuario no pudiera hacer uso del mismo pero me encontré con un nuevo problema, cuando la aplicación que hace uso del navegador hace click en algún link, se abre una nueva ventana  en un punto que es visible para el usuario.
Hay alguna forma, algún método para que este si se abre, que aparezca en la posición de la primera pantalla del navegador???

Pensé en los procesos sincrónicos y siempre estar preguntando por los procesos de "firefox" para estar moviendo sus respectivas pantallas, pero no lo veo algo muy practico.  


En línea

daniel.r.23

Desconectado Desconectado

Mensajes: 58


Ver Perfil
Re: Función MoveWindow al abrir aplicación "firefox"
« Respuesta #1 en: 27 Octubre 2014, 05:05 am »

les quería comentar que al final lo termine solucionando con un proceso asincrónico.
les dejo parte del código:
Código:

Private Sub HideToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles HideToolStripMenuItem.Click
        Dim Width As Integer = My.Computer.Screen.Bounds.Width
        Dim Height As Integer = My.Computer.Screen.Bounds.Height
        Dim hWnd As IntPtr = FindWindowExW(IntPtr.Zero, IntPtr.Zero, "MozillaWindowClass", Nothing)
        While Not hWnd.Equals(IntPtr.Zero)
            Dim title As New System.Text.StringBuilder(256)
            GetWindowTextW(hWnd, title, 256)
            'ListBox1.Items.Add(title.ToString)
            If title.ToString.Contains("NeoBux") Then
                MoveWindow(hWnd, Width, Height, Width, Height, True)
            End If
            hWnd = FindWindowExW(IntPtr.Zero, hWnd, "MozillaWindowClass", Nothing)
        End While
        Try
            BackgroundWorker1.RunWorkerAsync()
        Catch ex As Exception
            If BackgroundWorker1.WorkerSupportsCancellation Then
                BackgroundWorker1.CancelAsync()
            End If
        End Try
        For Each item As ToolStripItem In Me.ContextMenuStrip1.Items
            If item.Text = "Hide" Then
                item.Visible = False
                ctrh = item
            End If
            If item.Text = "Show" Then
                item.Visible = True
            End If
        Next
    End Sub
    Private Sub ShowToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles ShowToolStripMenuItem.Click
        Dim hWnd As IntPtr = FindWindowExW(IntPtr.Zero, IntPtr.Zero, "MozillaWindowClass", Nothing)
        For Each item As ToolStripItem In Me.ContextMenuStrip1.Items
            If item.Text = "Show" Then
                item.Visible = False
                ctrh.Visible = True
                visible_ = True
                lx = 0
                ly = 0
            End If
        Next
        While Not hWnd.Equals(IntPtr.Zero)
            Dim title As New System.Text.StringBuilder(256)
            GetWindowTextW(hWnd, title, 256)
            If title.ToString.Contains("NeoBux") Then
                MoveWindow(hWnd, lx, ly, 512, 380, True)
                If lx = 0 Then
                    lx = 512
                ElseIf lx = 512 Then
                    lx = 0
                    ly += 380
                End If
            End If
            hWnd = FindWindowExW(IntPtr.Zero, hWnd, "MozillaWindowClass", Nothing)
        End While
        If BackgroundWorker1.IsBusy Then
            If BackgroundWorker1.WorkerSupportsCancellation Then
                BackgroundWorker1.CancelAsync()
            End If
        End If

    End Sub

    Private Sub BackgroundWorker1_DoWork(sender As System.Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Dim Width As Integer = My.Computer.Screen.Bounds.Width
        Dim Height As Integer = My.Computer.Screen.Bounds.Height
        While Not visible_
            Dim hWnd As IntPtr = FindWindowExW(IntPtr.Zero, IntPtr.Zero, "MozillaWindowClass", Nothing)
            While Not hWnd.Equals(IntPtr.Zero)
                Dim title As New System.Text.StringBuilder(256)
                GetWindowTextW(hWnd, title, 256)
                'ListBox1.Items.Add(title.ToString)
                If title.ToString.Contains("NeoBux") Then
                    MoveWindow(hWnd, Width, Height, Width, Height, True)
                End If
                hWnd = FindWindowExW(IntPtr.Zero, hWnd, "MozillaWindowClass", Nothing)
            End While
        End While
        visible_ = False
    End Sub
End Class


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