process.start & fill app form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?ZXAu?=

    process.start & fill app form

    What is preferred method to start an app process and then fill in form fields?
    The following prog does not compile (b/c AppActivate does not have the
    correct param):
    ----------------------------------------------------------------------------------------
    Imports Microsoft.Visua lBasic
    Imports System.Windows. Forms
    Imports System.Diagnost ics
    Module Module1

    Sub Main()
    Dim proc As Process = Process.Start(" c:\app2020\app. EXE")
    AppActivate(pro c)
    SendKeys.SendWa it("22")
    End Sub
    End Module
  • Family Tree Mike

    #2
    Re: process.start & fill app form

    I doubt the application (app.exe) has had time to start by the time you try
    and activate it. Try a delay of a few seconds before activating it.

    "ep." <ep@discussions .microsoft.comw rote in message
    news:5AC3D2DA-341E-4080-91DE-5EA368138BC6@mi crosoft.com...
    What is preferred method to start an app process and then fill in form
    fields?
    The following prog does not compile (b/c AppActivate does not have the
    correct param):
    ----------------------------------------------------------------------------------------
    Imports Microsoft.Visua lBasic
    Imports System.Windows. Forms
    Imports System.Diagnost ics
    Module Module1
    >
    Sub Main()
    Dim proc As Process = Process.Start(" c:\app2020\app. EXE")
    AppActivate(pro c)
    SendKeys.SendWa it("22")
    End Sub
    End Module

    Comment

    • Family Tree Mike

      #3
      Re: process.start &amp; fill app form

      Sorry, but also the proc.Id should be passed to the AppActivate.

      "Family Tree Mike" <FamilyTreeMike @ThisOldHouse.c omwrote in message
      news:%23ox7fnYB JHA.4132@TK2MSF TNGP05.phx.gbl. ..
      >I doubt the application (app.exe) has had time to start by the time you try
      >and activate it. Try a delay of a few seconds before activating it.
      >
      "ep." <ep@discussions .microsoft.comw rote in message
      news:5AC3D2DA-341E-4080-91DE-5EA368138BC6@mi crosoft.com...
      >What is preferred method to start an app process and then fill in form
      >fields?
      >The following prog does not compile (b/c AppActivate does not have the
      >correct param):
      >----------------------------------------------------------------------------------------
      >Imports Microsoft.Visua lBasic
      >Imports System.Windows. Forms
      >Imports System.Diagnost ics
      >Module Module1
      >>
      >Sub Main()
      >Dim proc As Process = Process.Start(" c:\app2020\app. EXE")
      >AppActivate(pr oc)
      >SendKeys.SendW ait("22")
      >End Sub
      >End Module
      >

      Comment

      • kimiraikkonen

        #4
        Re: process.start &amp; fill app form

        On Aug 24, 4:12 am, ep. <e...@discussio ns.microsoft.co mwrote:
        What is preferred method to start an app process and then fill in form fields?
        The following prog does not compile (b/c AppActivate does not have the
        correct param):
        ----------------------------------------------------------------------------------------
        Imports Microsoft.Visua lBasic
        Imports System.Windows. Forms
        Imports System.Diagnost ics
        Module Module1
        >
        Sub Main()
        Dim proc As Process = Process.Start(" c:\app2020\app. EXE")
        AppActivate(pro c)
        SendKeys.SendWa it("22")
        End Sub
        End Module
        To make AppActivate work, you should pass processID(Integ er) or
        Title(String) as parameter, see notepad sample on MSDN:



        I would use that code at first sight, but i beleive it causes
        ProcessID not found exception because of a kind of timing error:
        ' You can use Process.Start
        Imports Microsoft.Visua lBasic
        Imports System.Windows. Forms
        Imports System.Diagnost ics
        Module Module1

        Sub Main()
        Dim ProcessID As Integer
        ProcessID = Process.Start(" c:\app2020\app. EXE").Id
        AppActivate(Pro cessID)
        SendKeys.SendWa it("22")
        End Sub
        End Module

        So, stick with the following using a timer control that demonstrates a
        WinForm app:

        ' ----Begin--------
        ' Note that before running app set timer's interval
        ' to a reasonable interval ike 1500 miliseconds
        ' or less or more as you wish in IDE.
        Imports System.diagnost ics
        Public Class Form1
        Dim ProcessID As Integer
        Sub RunProcess()
        ProcessID = Process.Start(" c:\app2020\app. EXE").Id
        End Sub

        'Eg: Call sub on a button_click event
        Private Sub Button1_Click(B yVal sender As System.Object, _
        ByVal e As System.EventArg s) Handles Button1.Click
        RunProcess()
        Timer1.Enabled = True
        End Sub

        Private Sub Timer1_Tick(ByV al sender As System.Object, _
        ByVal e As System.EventArg s) Handles Timer1.Tick
        'Now call AppActivate
        AppActivate(Pro cessID)
        SendKeys.SendWa it("22")
        Timer1.Enabled = False
        End Sub
        End Class
        '----End-------

        Hope this helps,

        Onur Güzel

        Comment

        • =?Utf-8?B?ZXAu?=

          #5
          Re: process.start &amp; fill app form

          This program sounds as though its what I need. It does not compile
          b/c there no main and no declaration for Timer1. I'm just an upstart
          visual basic programmer so I'm unclear on some of the basics.
          thx.,
          ep.

          "kimiraikko nen" wrote:
          On Aug 24, 4:12 am, ep. <e...@discussio ns.microsoft.co mwrote:
          What is preferred method to start an app process and then fill in form fields?
          The following prog does not compile (b/c AppActivate does not have the
          correct param):
          ----------------------------------------------------------------------------------------
          Imports Microsoft.Visua lBasic
          Imports System.Windows. Forms
          Imports System.Diagnost ics
          Module Module1

          Sub Main()
          Dim proc As Process = Process.Start(" c:\app2020\app. EXE")
          AppActivate(pro c)
          SendKeys.SendWa it("22")
          End Sub
          End Module
          >
          To make AppActivate work, you should pass processID(Integ er) or
          Title(String) as parameter, see notepad sample on MSDN:
          >

          >
          I would use that code at first sight, but i beleive it causes
          ProcessID not found exception because of a kind of timing error:
          ' You can use Process.Start
          Imports Microsoft.Visua lBasic
          Imports System.Windows. Forms
          Imports System.Diagnost ics
          Module Module1
          >
          Sub Main()
          Dim ProcessID As Integer
          ProcessID = Process.Start(" c:\app2020\app. EXE").Id
          AppActivate(Pro cessID)
          SendKeys.SendWa it("22")
          End Sub
          End Module
          >
          So, stick with the following using a timer control that demonstrates a
          WinForm app:
          >
          ' ----Begin--------
          ' Note that before running app set timer's interval
          ' to a reasonable interval ike 1500 miliseconds
          ' or less or more as you wish in IDE.
          Imports System.diagnost ics
          Public Class Form1
          Dim ProcessID As Integer
          Sub RunProcess()
          ProcessID = Process.Start(" c:\app2020\app. EXE").Id
          End Sub
          >
          'Eg: Call sub on a button_click event
          Private Sub Button1_Click(B yVal sender As System.Object, _
          ByVal e As System.EventArg s) Handles Button1.Click
          RunProcess()
          Timer1.Enabled = True
          End Sub
          >
          Private Sub Timer1_Tick(ByV al sender As System.Object, _
          ByVal e As System.EventArg s) Handles Timer1.Tick
          'Now call AppActivate
          AppActivate(Pro cessID)
          SendKeys.SendWa it("22")
          Timer1.Enabled = False
          End Sub
          End Class
          '----End-------
          >
          Hope this helps,
          >
          Onur Güzel
          >

          Comment

          • kimiraikkonen

            #6
            Re: process.start &amp; fill app form

            On Aug 25, 4:02 pm, ep. <e...@discussio ns.microsoft.co mwrote:
            This program sounds as though its what I need.  It does not compile
            b/c there no main and no declaration for Timer1.  I'm just an upstart
            visual basic programmer so I'm unclear on some of the basics.
            thx.,
            ep.
            >
            >
            >
            "kimiraikko nen" wrote:
            On Aug 24, 4:12 am, ep. <e...@discussio ns.microsoft.co mwrote:
            What is preferred method to start an app process and then fill in form fields?
            The following prog does not compile (b/c AppActivate does not have the
            correct param):
            ---------------------------------------------------------------------------­-------------
            Imports Microsoft.Visua lBasic
            Imports System.Windows. Forms
            Imports  System.Diagnost ics
            Module Module1
            >
            Sub Main()
            Dim proc As Process  = Process.Start(" c:\app2020\app. EXE")
            AppActivate(pro c)
            SendKeys.SendWa it("22")
            End Sub
            End Module
            >
            To make AppActivate work, you should pass processID(Integ er) or
            Title(String) as parameter, see notepad sample on MSDN:
            >>
            I would use that code at first sight, but i beleive it causes
            ProcessID not found exception because of a kind of timing error:
            ' You can use Process.Start
            Imports Microsoft.Visua lBasic
            Imports System.Windows. Forms
            Imports  System.Diagnost ics
            Module Module1
            >
            Sub Main()
            Dim ProcessID As Integer
            ProcessID = Process.Start(" c:\app2020\app. EXE").Id
            AppActivate(Pro cessID)
            SendKeys.SendWa it("22")
            End Sub
            End Module
            >
            So, stick with the following using a timer control that demonstrates a
            WinForm app:
            >
            ' ----Begin--------
            ' Note that before running app set timer's interval
            ' to a reasonable interval ike 1500 miliseconds
            ' or less or more as you wish in IDE.
            Imports System.diagnost ics
            Public Class Form1
            Dim ProcessID As Integer
            Sub RunProcess()
            ProcessID = Process.Start(" c:\app2020\app. EXE").Id
            End Sub
            >
            'Eg: Call sub on a button_click event
            Private Sub Button1_Click(B yVal sender As System.Object, _
            ByVal e As System.EventArg s) Handles Button1.Click
            RunProcess()
            Timer1.Enabled = True
            End Sub
            >
            Private Sub Timer1_Tick(ByV al sender As System.Object, _
            ByVal e As System.EventArg s) Handles Timer1.Tick
            'Now call AppActivate
            AppActivate(Pro cessID)
            SendKeys.SendWa it("22")
            Timer1.Enabled = False
            End Sub
            End Class
            '----End-------
            >
            Hope this helps,
            >
            Onur Güzel- Hide quoted text -
            >
            - Show quoted text -
            The last sample i've posted assumes that you have a Winform
            application and "Timer1" is placed on your form. As i tested on .NET
            2.0, it must work fine using with timer control and if you don't use
            timer, AppActivate function returns a kind of "Process ID not found"
            exception surprisingly. You'd better re-read my previous post/codes
            hoping to help you.

            Thanks,

            Onur Güzel

            Comment

            • =?Utf-8?B?ZXAu?=

              #7
              Re: process.start &amp; fill app form

              I've tried to follow the instructions from your previous posts. I think I've
              gotten
              most of it, but the correct syntax (so it compiles) is not so easy to program.
              I compiled the enclosed code attempt with the command line compiler
              (Framework.NET/v3.5) and received 6 or 7 syntax errors. What would you
              suggest I can do to fix these.
              -----------------------------------------------------------------------------------------
              '----Begin--------
              ' Note that before running app set timer's interval
              ' to a reasonable interval ike 1500 miliseconds
              ' or less or more as you wish in IDE.
              Imports Microsoft.Visua lBasic
              Imports System.Windows. Forms
              Imports System.Diagnost ics
              Module Module1
              Public Class Form1 Inherits System.Windows. Forms.Form
              Dim ProcessID As Integer
              Dim Timer1 As Timer
              Sub RunProcess()
              ProcessID = Process.Start(" c:\myapp.exe"). Id
              End Sub

              'Eg: Call sub on a button_click event
              Private Sub Button1_Click(B yVal sender As System.Object, _
              ByVal e As System.EventArg s) Handles Button1.Click
              RunProcess()
              Timer1.Enabled = True
              End Sub

              Private Sub Timer1_Tick(ByV al sender As System.Object, _
              ByVal e As System.EventArg s) Handles Timer1.Tick
              'Now call AppActivate
              AppActivate(Pro cessID)
              SendKeys.SendWa it("22")
              Timer1.Enabled = False
              End Sub

              End Class
              Public Sub Main()
              Application.Run (New Form1)
              End Sub
              End Module
              '----End-------

              Comment

              • kimiraikkonen

                #8
                Re: process.start &amp; fill app form

                On Sep 8, 6:13 am, ep. <e...@discussio ns.microsoft.co mwrote:
                I've tried to follow the instructions from your previous posts.  I think I've
                gotten
                most of it, but the correct syntax (so it compiles) is not so easy to program.
                I compiled the enclosed code attempt with the command line compiler
                (Framework.NET/v3.5) and received 6 or 7 syntax errors.  What would you
                suggest I can do to fix these.
                ---------------------------------------------------------------------------­--------------
                '----Begin--------
                ' Note that before running app set timer's interval
                ' to a reasonable interval ike 1500 miliseconds
                ' or less or more as you wish in IDE.
                Imports Microsoft.Visua lBasic
                Imports System.Windows. Forms
                Imports System.Diagnost ics
                Module Module1
                Public Class Form1 Inherits System.Windows. Forms.Form
                Dim ProcessID As Integer
                Dim Timer1 As Timer
                Sub RunProcess()
                ProcessID = Process.Start(" c:\myapp.exe"). Id
                End Sub
                >
                'Eg: Call sub on a button_click event
                Private Sub Button1_Click(B yVal sender As System.Object, _
                ByVal e As System.EventArg s) Handles Button1.Click
                RunProcess()
                Timer1.Enabled = True
                End Sub
                >
                Private Sub Timer1_Tick(ByV al sender As System.Object, _
                ByVal e As System.EventArg s) Handles Timer1.Tick
                'Now call AppActivate
                AppActivate(Pro cessID)
                SendKeys.SendWa it("22")
                Timer1.Enabled = False
                End Sub
                >
                End Class
                Public Sub Main()
                        Application.Run (New Form1)
                End Sub
                End Module
                '----End-------
                Try to compile as a new Winform project within VS IDE. As it seems you
                have tried to compile Winform objects from command-line
                compiler(VBC.ex e), it may require additional references explictly such
                as System.Windows. Forms etc.

                And if you still insist on compiling your winform project from command
                line, you can check this out:
                Articles about web development, engineering leadership, and some random personal ramblings


                Hope this helps,

                Onur Guzel

                Comment

                • =?Utf-8?B?ZXAu?=

                  #9
                  Re: process.start &amp; fill app form

                  I selected the IDE route with VB 2008 Express Edition. This time the
                  compilation
                  your code resulted in only one error:
                  "Handles clause requires a WithEvents variable defined in the containing
                  type or
                  one of its base types." What's this about?


                  Comment

                  • kimiraikkonen

                    #10
                    Re: process.start &amp; fill app form

                    On Sep 8, 8:29 pm, ep. <e...@discussio ns.microsoft.co mwrote:
                    I selected the IDE route with VB 2008 Express Edition. This time the
                    compilation
                    your code resulted in only one error:
                    "Handles clause requires a WithEvents variable defined in the containing
                    type or
                    one of its base types." What's this about?
                    For which object? Apparently, you need to add WithEvents keyword to
                    make object's events recognized by compiler. Assuming "WithEvents "
                    keyword is missing for Timer control(because you didn't tell the
                    object name), just place a Timer control from your toolbox and double-
                    click on it. WithEvents will be created automatically for you by VS in
                    Form1.Designer. vb file. Then place the code block of Timer in your
                    Form1.vb. That's all.

                    or insert the full syntax of "WithEvents " into your Form1.Designer. vb
                    file as follows:

                    Friend WithEvents Timer1 As System.Windows. Forms.Timer

                    ...do the same for button if required.

                    Hope this helps,

                    Onur Güzel

                    Comment

                    • =?Utf-8?B?ZXAu?=

                      #11
                      Re: process.start &amp; fill app form

                      I've gotten this prog to compile thanks to the feedback above. A little off
                      topic; is VB used a lot in the real world?

                      The prog w/ timer mostly runs. It does start the app, however I receiver an
                      error: "unrecogniz ed
                      process id" from the ActivateApp statement (even if the delay is 10 secs).
                      What's going on
                      with that?

                      Comment

                      • kimiraikkonen

                        #12
                        Re: process.start &amp; fill app form

                        On Sep 11, 7:35 pm, ep. <e...@discussio ns.microsoft.co mwrote:
                        I've gotten this prog to compile thanks to the feedback above.  A little off
                        topic; is VB used a lot in the real world?
                        Besides C++, VB.NET may be used widely especially at enterprise-level
                        as a .NET language combining with ADO.
                        The prog w/ timer mostly runs.  It does start the app, however I receiver an
                        error: "unrecogniz ed
                        process id" from the ActivateApp statement (even if the delay is 10 secs)..  
                        What's going on
                        with that?
                        Tried with "notepad.ex e" in a Winform app and sample works, don't know
                        how much time after your application needs to start and make sure you
                        set a reasonable interval value in properties window for Timer
                        control.

                        Onur Güzel

                        Comment

                        • =?Utf-8?B?ZXAu?=

                          #13
                          Re: process.start &amp; fill app form

                          1. Any cool vb application websites?
                          2. Regarding the app we've been discussing, is "process.st art" blocking or
                          non-blocking?


                          Comment

                          Working...