Question

I would like to operate a (Windows) Desktop program. Because i use this on a daily basis to do some simple operaition. (Open a file PDF file, render it and save it in another folder).

I would like to do this by using somekind of service or script. I have been looking into VBscript to do this but i'm getting stuck at some operations that are normally done by users.

For example if i would like to open a file a user would go to File > Open and select the desired file. Off course the script could go to file and open but how do you select a certain file (the newest file in a certain folder).

Is it possible to have a piece of code to do these operations within a Desktop program or am i trying to do something impossible or maybe i'm using the wrong tools. Below a piece off testcode for what i'm trying to accomplish.

    Set WshShell = WScript.CreateObject("WScript.Shell")

    WshShell.Run """C:\Program Files (x86)\programname.exe"""
    wsh.sleep 1000 ' wait 1 second
    WshShell.AppActivate """Program name"""

    WshShell.SendKeys "^o" ' Open file

Any help is greatly appreaciated.

Was it helpful?

Solution

You are trying to control an application through its GUI, but it is not designed for that.

Having said that, I estimate this will be a nightmare if you do not use tools (or an app :-) ) explicitely created for that purpose, a la test robots like HP QTP or automation tools like Autoit http://www.autoitscript.com/site/autoit.

For example, if your application occasionally flushes the keyboard buffer, you might need to wait for some GUI event before sending the keystroke. This kind of synchronization is not accomplishable using vbscript only.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top