Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Keystrokes to a program

Status
Not open for further replies.

fmrock

Programmer
Sep 5, 2006
510
US
We run a program called monitor.exe on a computer.

This program shows metric graphs, however it does not auto refresh when its running. We would like to create a little program that auto refreshes this.

This can be done by right clicking and selecting refresh chart or by

Alt+M selects the metrics tool bar menu, then Alt+E selects refresh chart.

Any help would be great. We can then schedule this little script to run every 10 mintues or something.
 
This is what I figured out so far.

Seems to work fine.

Code:
Set objShell = WScript.CreateObject("WScript.Shell")


Do Until Success = True
    Success = objShell.AppActivate("Process Monitor")
    Wscript.Sleep 1000

    If Success = False Then
	Msgbox "Cant Find Process Monitor"
    End if
Loop


objShell.AppActivate "Process Monitor"
Wscript.Sleep 100
objShell.SendKeys "%m"
Wscript.Sleep 100
objShell.SendKeys "{ENTER}"
 
your code may be ok, but it will not loop every 10 minutes. to do that you have to set up a loop (inifinite) to examine the minutes portion of the time() if the rightmost digit of the minutes is zero "0" then refresh your screen.
something like this.
Code:
z= "z"
a= "a"
do until z = a     ' this will never happen to ensure an 
   xtime = time()  ' infinite loop
   time_parts = split(xtime, ":")
   minutes = time_parts(1)   ' hh:mm:ss  
   if right(minutes, 1) = "0" then 
      ' do your operation refresh, sendkey, whatever
   end if
loop

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top