Ragazzi chiedo scusa.
č la prima volta che realizzo un'applicazione in visual basic e quindi la domanda potra apparirvi anche banale
in pratica l'applicazione non fa altro che simulare la pressione della barra spaziatrice all'interno di un'applicazione esterna.
Il tutto funziona correttamente eccetto quando l'applicazione che deve ricevere il messaggio risulta iconizzata
come posso ovviare al problema.
Ringrazio tutti anticipatamente.
Di seguito il codice utilizzato

codice:
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim nomeFile As String
        Dim file As String
        Dim app() As String
        Dim startAutomatico As Integer
        file = My.Computer.FileSystem.ReadAllText("CFG.txt")
        app = file.Split(";")
        NumericUpDown4.Value = app(0)
        NumericUpDown3.Value = app(1)
        startAutomatico = app(2)
        TextBox1.Text = app(3)

        If (startAutomatico) Then
            Button1.Enabled = False
            NumericUpDown1.Enabled = False
            NumericUpDown2.Enabled = False
            NumericUpDown3.Enabled = False
            NumericUpDown4.Enabled = False
            Button3.Enabled = False
            Button4.Enabled = False
            Dim pid As Integer
            Dim p() As Process
            p = Process.GetProcessesByName("nomedelprocesso")
            If (p.Length = 0) Then
                pid = Shell(TextBox1.Text)
            Else
                pid = p(0).Id
            End If
            AppActivate(pid)
            My.Computer.Keyboard.SendKeys(" ", True)
            Timer1.Interval = (NumericUpDown3.Value * 60 * 1000) + (NumericUpDown4.Value * 3600 * 1000) + 1
            Timer1.Enabled = True
        End If
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub OpenFileDialog2_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog2.FileOk

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        NumericUpDown1.Enabled = True
        NumericUpDown2.Enabled = True
        NumericUpDown3.Enabled = True
        NumericUpDown4.Enabled = True

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        NumericUpDown1.Enabled = False
        NumericUpDown2.Enabled = False
        NumericUpDown3.Enabled = False
        NumericUpDown4.Enabled = False
        Timer1.Interval = (NumericUpDown3.Value * 60 * 1000) + (NumericUpDown4.Value * 3600 * 1000) + 1
    End Sub

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

        Button1.Enabled = False
        NumericUpDown1.Enabled = False
        NumericUpDown2.Enabled = False
        NumericUpDown3.Enabled = False
        NumericUpDown4.Enabled = False
        Button3.Enabled = False
        Button4.Enabled = False
        Dim pid As Integer
        Dim p() As Process
        p = Process.GetProcessesByName("nomedelprocesso")
        If (p.Length = 0) Then
            pid = Shell(TextBox1.Text)
        Else
            pid = p(0).Id
        End If
        AppActivate(pid)
        My.Computer.Keyboard.SendKeys(" ", True)
        Timer1.Enabled = True

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Button1.Enabled = True
        Button3.Enabled = True
        Button4.Enabled = True
        Timer1.Enabled = False
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        OpenFileDialog2.ShowDialog()
        TextBox1.Text = OpenFileDialog2.FileName
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim pid As Integer
        Dim p() As Process
        p = Process.GetProcessesByName("nomedelprocesso")
        If (p.Length = 0) Then
            pid = Shell(TextBox1.Text)
        Else
            pid = p(0).Id
        End If
        AppActivate(pid)
        My.Computer.Keyboard.SendKeys(" ", True)
    End Sub

    Private Sub NumericUpDown3_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown3.ValueChanged

    End Sub
End Class