# Win32ole - wait for action to complete

**URL:** <https://www.ruby-forum.com/t/win32ole-wait-for-action-to-complete/59705>\
**Category:** Ruby\
**Created:** [May 5, 2006, 5:30pm UTC](https://www.ruby-forum.com/t/win32ole-wait-for-action-to-complete/59705 "2006-05-05T17:30:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bungle77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c67d28/32.png) [@bungle77](https://www.ruby-forum.com/u/bungle77)\
**Post date:** [May 5, 2006, 5:30pm UTC](https://www.ruby-forum.com/t/win32ole-wait-for-action-to-complete/59705/1 "2006-05-05T17:30:29Z")

</div>

I have a script driving a proprietary Powerbuilder application via  
sendkeys. I am trying to time application processing time. My approach  
was grab start time, sendkeys to application, grab finish time and  
calculate the diff. However, my four seperate timing steps all print  
thier complete timestamps before the application is even done processing  
one step. In Marcus Tettmar’s MacroScheduler he has a WaitReady function  
that seems to do a good job waiting for the driven event to complete  
before continuing execution. I assumed this was making a call to an OLE  
function, but have not been able to find such a function. Is there a way  
to make my automation script behave in a synchronous fashion so that I  
can use it to get accurate timing? Is there a win32ole function for  
this? Or is Macroscheduler using its own function to provide this?

I would imagine such a routine could be created using win32event, but I  
am very new to Ruby and have no idea where to start to build such a  
thing. Would appreciate any input you can provide to set me in the right  
direction.

---

<div class="post-metadata">

**Author:** ![bungle77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c67d28/32.png) [@bungle77](https://www.ruby-forum.com/u/bungle77)\
**Post date:** [May 5, 2006, 7:22pm UTC](https://www.ruby-forum.com/t/win32ole-wait-for-action-to-complete/59705/2 "2006-05-05T19:22:57Z")

</div>

You could use WinBatch [http://winbatch.com](http://winbatch.com) for this.  
You could even call it from Ruby, if need be.

Regards,  
JJ

On 05-May-2006, at 11:30, Rich H. wrote:

> function, but have not been able to find such a function. Is there a
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

* * *

“America goes not abroad in search of monsters to destroy.” – John  
Quincy Adams

---

<div class="post-metadata">

**Author:** ![bungle77](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c67d28/32.png) [@bungle77](https://www.ruby-forum.com/u/bungle77)\
**Post date:** [May 5, 2006, 7:40pm UTC](https://www.ruby-forum.com/t/win32ole-wait-for-action-to-complete/59705/3 "2006-05-05T19:40:20Z")

</div>

Thanks. I’m trying to avoid using software I’ll have to license (part of  
my rationale for using Ruby for this in the first place vs. using  
WinBatch or similar). If this script works, I will want to distribute it  
to many machines.

John J. wrote:

> You could use WinBatch [http://winbatch.com](http://winbatch.com) for this.  
> You could even call it from Ruby, if need be.
> 
> Regards,  
> JJ
