les quería comentar que al final lo termine solucionando con un proceso asincrónico.
les dejo parte del 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