# How to â€œclickâ€ on the screen at scheduled time with Ruby?

**URL:** <https://www.ruby-forum.com/t/how-to-a-oeclicka-on-the-screen-at-scheduled-time-with-ruby/170436>\
**Category:** Ruby\
**Created:** [June 17, 2009, 4:34pm UTC](https://www.ruby-forum.com/t/how-to-a-oeclicka-on-the-screen-at-scheduled-time-with-ruby/170436 "2009-06-17T16:34:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [June 17, 2009, 4:34pm UTC](https://www.ruby-forum.com/t/how-to-a-oeclicka-on-the-screen-at-scheduled-time-with-ruby/170436/1 "2009-06-17T16:34:36Z")

</div>

Using Ruby, can I write a program, probably calling Win32 API, to  
“click” on the screen at scheduled time, like every 1 hour?

Details:

This is for experimentation – and can the clicking be effective on  
Flash content as well as any element on screen? It can be nice if the  
program can record where on screen the click needs to happen, or at  
least draw a red dot on the screen to show where it is clicking on.

Can the click be targeted towards a window or is it only a general pixel  
on the screen? What if some virus scanning program pops up and the click  
is at the wrong window? (although if the program clicks on the white  
space of a window first, then it can bring that window to the foreground  
first).

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [June 17, 2009, 8:34pm UTC](https://www.ruby-forum.com/t/how-to-a-oeclicka-on-the-screen-at-scheduled-time-with-ruby/170436/2 "2009-06-17T20:34:44Z")

</div>

You use HWND FindWindow() to get the window.

You need to read Scripted GUI Testing with Ruby. It tells you how to do  
all this.

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [June 17, 2009, 8:48pm UTC](https://www.ruby-forum.com/t/how-to-a-oeclicka-on-the-screen-at-scheduled-time-with-ruby/170436/3 "2009-06-17T20:48:41Z")

</div>

Mike S. wrote:

> You use HWND FindWindow() to get the window.
> 
> You need to read Scripted GUI Testing with Ruby. It tells you how to do  
> all this.

Oh it is a book huh?

> **[Scripted GUI Testing With Ruby (Pragmatic Programmers): Dees, Ian:...](https://www.amazon.com/Scripted-Testing-Ruby-Pragmatic-Programmers/dp/1934356182)**
>
> Scripted GUI Testing With Ruby (Pragmatic Programmers) \[Dees, Ian\] on Amazon.com. \*FREE\* shipping on qualifying offers. Scripted GUI Testing With Ruby (Pragmatic Programmers)

by the way someone was suggesting

> **[Selenium](https://www.selenium.dev/)**
>
> Selenium automates browsers. That's it!

I wonder if that is a pretty good solution too?

---

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [June 18, 2009, 10:51am UTC](https://www.ruby-forum.com/t/how-to-a-oeclicka-on-the-screen-at-scheduled-time-with-ruby/170436/4 "2009-06-18T10:51:03Z")

</div>

Jian L. wrote:

> by the way someone was suggesting
> 
> [Selenium](http://seleniumhq.org/projects/remote-control/)
> 
> I wonder if that is a pretty good solution too?

The book also cover Selenium. Selenium I think is for web applications  
whereas your first question was about native Windows GUI applications.

The book also covers Linux GUI situations.
