Powershell UI Automation on Console Foxpro Application

255 Views Asked by At

I can't seem to get this code to work on a console foxpro application. Is there anything that I'm missing. I've tested this code on other applications and it works.

    ipmo "D:\WASP\WASP.dll"
    Select-Window "ntvdm" | Set-WindowActive  | Select-Control | Send-Keys "r"

foxpro app

When i press "r" on the keyboard, the app accepts the input but when I run this code, it does not.

Thank you very much.

1

There are 1 best solutions below

0
On

I just tried using WASP with your code against calculator and it seems to work correctly.

You might want to try using this:

[void][System.Reflection.Assembly]::LoadWithPartialName("'Microsoft.VisualBasic")
[Microsoft.VisualBasic.Interaction]::AppActivate((ps ntvdm).MainWindowTitle)
[void][System.Reflection.Assembly]::LoadWithPartialName("'System.Windows.Forms")
[System.Windows.Forms.SendKeys]::SendWait("{R}")

Btw, make sure your app is indeed having process name ntvdm this might cause of a problem. This way you are doing about the same thing. If you are having some performance issues you could add some waiting, i.e Sleep -m 50 between every line.