question

Manny-0680 avatar image
0 Votes"
Manny-0680 asked aj-47 commented

Use Powershell to automate a windows program

Hi

I have a windows program to download stock prices. There is no command line version of it. Is it possible to use Powershell to do the following:

  1. start program

  2. press download button or alt button plus d

  3. wait (for program to download prices) this can take about 5 minutes or so

  4. press close button

  5. exit program

If yes, how would I do it?

Thank you

windows-server-powershell
· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RichMatheisen-8856. Can you please help me with this? I got this far:

 Start-Process -FilePath "program path"
 $ProcId = (Get-Process program_name).id
 Sleep -Seconds 60  # give the program 1 minute to open
 $wshell = new-object -com wscript.shell
 $wshell.AppActivate("program_name")
 $wshell.Sendkeys("%d")
 Sleep -Seconds 600 # give the program 10 minutes to finish the download
 # select Convert button
 #$wshell.Sendkeys("%c")
 #Sleep -Seconds 600 # give the program 10 minutes to convert the data to CSV
 Stop-Process $ProcId

0 Votes 0 ·

There is a button called "Convert" that doesn't appear to be accessible via keyboard shortcuts. I have to use my mouse to select it. Is there a way to select that button by searching for the text "Convert". Once found then press enter? Thank you

0 Votes 0 ·

Using the "tab" key to navigate to that button doesn't work? Arrow keys? Is there a default key, like "enter" that would activate that key?

If it's a web page you can probably see exactly what's on the page, either with a program like Fiddler or by "screen scraping" (there are a good number of results in a web search for "powershell screen scrape").

If it's an executable I think you'd have to get contents of the window. It used to be pretty easy to do with character-based applications. I expect it's a lot harder to do with graphics.

0 Votes 0 ·
Show more comments

I suspect the application goes to a Web service/URL to get prices?
How about you explore invoke-webRequest cmdlet and export downloaded prices to a file

0 Votes 0 ·

0 Answers