AutoHotkey Community

It is currently May 27th, 2012, 12:28 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: January 29th, 2009, 4:01 am 
Offline

Joined: January 28th, 2009, 12:15 am
Posts: 7
Sorry i'm new here and just havent found how do this ridiculously simple task... all i need to do is to periodically click on a specific program button.. this button is always on the same location i only need a script that clicks on it about every 5 mins or so.. also the window that holds the button might be minimized some times so it would need to activate/maximize it too, i guess...

Please help a newbie here :oops:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 4:32 am 
Offline

Joined: September 28th, 2007, 3:56 am
Posts: 279
Location: New York
If you want something like this you will need to provide the title of the window and the coordinates of the button. Both of which can be found using AutoIt3 Window Spy which is included in the AHK installation. You could also find the control ID of the button through window spy instead of clicking it would be a controlclick. Then you wouldn't need to activate or maximize the window, it would activate the button "behind the scenes"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 8:06 pm 
Offline

Joined: January 28th, 2009, 12:15 am
Posts: 7
Thanks for replying!
Well about that i do have the coordinates of the button and the window title, though the title varies a little bit some times (can use a wildcard there?)...

For the control thing this what i could get from the button with Window Spy:

ClassNN: Button34
Text: 再読込 (it's japanese)
Color: 0xE7EFF7 (Blue=E7 Green=EF Red=F7)

I would really appreciate if you or someone could give me an example script of how this could be done (don't need to have the real coordinates/title i would fill in those myself) :oops:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 9:06 pm 
Offline
User avatar

Joined: May 29th, 2008, 4:51 am
Posts: 186
Start -> Programs -> AutoHotKey -> AutoScriptWriter (recorder)

Record what you want clicked. Save the script & then modify for a timer!


Code:
Sleep, 5000 ;this would wait for 5 seconds

_________________
~BigVent


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 29th, 2009, 10:09 pm 
Offline

Joined: September 28th, 2007, 3:56 am
Posts: 279
Location: New York
BigVent wrote:
Start -> Programs -> AutoHotKey -> AutoScriptWriter (recorder)

Record what you want clicked. Save the script & then modify for a timer!


Code:
Sleep, 5000 ;this would wait for 5 seconds


This is fine to get started but he mentioned that sometimes the window is minimized and may need to be restored.

I guess you could record it with the window minimized that way it would maximize the window every time. I don't know, it works but it's ugly and unreliable. It's up to you, you can either use the quick way or write it and have it be covert and not interrupt your other processes. Meaning you will still have control of your mouse and screen.

If you want it to run in the backround you could do this:
Code:
Loop, 1000
{
  ControlClick, Button34, WinTitle,, Left,, NA
}


The 1000 is 1000 mS therefore one second, that means the button will be clicked every second. You can change that to the time you need. If you change the red text to the title of the window containing the button then it should work. You can get the window title from window spy as well. Also, so you are aware, the NA means it will not activate the window so you won't even know it's doing it but it will be. I prefer to write all my programs this way if possible, otherwise every time it went to click it would open the window and click the button. This way, you can work on your computer normally and the mouse isn't gong to go crazy.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2009, 4:10 am 
Offline

Joined: January 28th, 2009, 12:15 am
Posts: 7
I got it working! :D
At first i tried the loop that ribbs mentioned but it crashed my program... then i found that the value after the loop command is the number of times it will execute not the time between iterations :shock: so i inserted the sleep command that BigVent mentioned and works great!

Code:
Loop, 1000 ; Lots of iterations
{
 Sleep, 60000 ; 1 min between iterations
 ControlClick, Button25, Window title,, Left,, NA ; and here can be just part of the actual title :)
}


Thanks for the help guys!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 30th, 2009, 9:45 pm 
Offline

Joined: September 28th, 2007, 3:56 am
Posts: 279
Location: New York
oh man! I'm sorry, I put loop, 1000. That's going to loop 1000 times, for some reason I put that instead of Sleep 1000. You got it right but in case you want to change it, you can remove the 1000 so it will loop until you turn it off. Otherwise, it will loop 1000 times and stop. (that would be after 6000 seconds or 100 minutes)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], chaosad, Exabot [Bot], Google Feedfetcher, jrav, Yahoo [Bot] and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group