Jump to content

Activar janela Programa Externo


a3deluxe
Go to solution Solved by vikcch,

Recommended Posts

  • Solution

Se não sabes exactamente o titulo da janela podes usar como está no exemplo.....

caso contrario podes ir buscar o handle da janela com a api FindWindow

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr

Public Class Form1

Private Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hWnd As IntPtr) As Integer
Private Declare Function SetFocus Lib "user32.dll" (ByVal hWnd As IntPtr) As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

	For Each p As Process In Process.GetProcesses()

		'Debug.WriteLine(p.ProcessName)

		If p.ProcessName.Contains("DOSBox") Then
			SetForegroundWindow(p.MainWindowHandle)
			SetFocus(p.MainWindowHandle)
		End If
	Next

End Sub

End Class
Edited by vikcch
Link to comment
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
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.