AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: February 27th, 2010, 6:58 pm 
Offline

Joined: February 27th, 2010, 6:51 pm
Posts: 6
hi

I'm new here

I'm in a hurry, and I found this application, and I think it's great!

congratulations for making something like this free of charge and open source, seriously

I need to do something that I guess has to be easy, but I was searching through here and I cannot find the way to do it. I'm gonna really play aroud with this because it has so many uses, but right now I'm in a hurry, so if anyone can help me, I'm gonna be really greatefull

I need to do a script that makes the mouse click at an specific place of the screen at i.e. 5 PM. and then click somewhere else at 6 PM. and that covering all 24 hours of the day

it's important that I'm able to specify the exact clock time, and not do a "X amount of seconds later" kind of script

thanks for your help!!

Javier


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 1:14 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
Welcome to the forum,

Quote:
I'm in a hurry
That could be a problem, sometimes you don't get an answer for a few hours, maybe 24 hehe

Quote:
I need to do a script that makes the mouse click at an specific place of the screen at i.e. 5 PM. and then click somewhere else at 6 PM. and that covering all 24 hours of the day

it's important that I'm able to specify the exact clock time, and not do a "X amount of seconds later" kind of script


AutoHotkey has built-in varaibles that provide the sript writer access to the current time and date information, as accurate as the clock on othe taskbar. http://www.autohotkey.com/docs/Variables.htm#date

Here is a tested, very rudamentary script, that also indicates Mouse x & y

Code:
  ; Please review ---> http://www.autohotkey.com/docs/commands/MouseClick.htm
  ; Please review ---> http://www.autohotkey.com/docs/commands/CoordMode.htm

#singleinstance force
#Persistent

CoordMode, ToolTip, screen
CoordMode, Mouse, screen


settimer, WatchCursor, 100   ; show the current mouse location

first_click:
mx=117
my=131

      ; use 24 hour format ==>  12pm is 12, 1pm is 13, 12am is 0
T_Hour=16
T_Min=13
T_Sec=02
settimer, alarm_clock1, 500
return

alarm_clock1:
if (T_Hour=A_Hour) && (T_Min=A_Min) && (T_Sec=A_Sec)
{
  MouseClick,, mX, mY,, 10
  msgbox,,, Click #1 happend, 1
  settimer, alarm_clock1, off
  goto second_click
}
return

second_click:
mx=193
my=131
;T_Hour=15   ; no change
;T_Min=49   ; no change
T_Sec+=10   ; 10 seconds later (within same minute)

settimer, alarm_clock2, 500
return

alarm_clock2:
if (T_Hour=A_Hour) && (T_Min=A_Min) && (T_Sec=A_Sec)
{
  MouseClick,, mX, mY,, 10
  msgbox,,, Click #2 happend, 1
  settimer, alarm_clock2, off
  goto done
}
return

done:
msgbox Both clicks have be sent.`nPress OK to exit script...
exitapp

WatchCursor:
MouseGetPos, xpos, ypos
ToolTip, X %xpos%  Y %ypos% , xpos+50, y
return


esc::exitapp ; in case of emergency press escape


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 1:31 am 
Offline

Joined: February 27th, 2010, 6:51 pm
Posts: 6
hi Leef_me

thank you very much for your answer

eventually figured out myself, but yesterday I was feeling very ill, and I was afraid I could not be able to do it

but I have made a really rudimentary script that makes exactly what I need it to do

here it is

Code:
Loop
{
    if(FoundPos:=RegExMatch(A_Now,NeedleRegEx "2010......00..") = 1)
    {
       Click 102, 375
       Sleep 90000
    }

    if(FoundPos:=RegExMatch(A_Now,NeedleRegEx "2010......10..") = 1)
    {
       Click 127, 374
       Sleep 90000
    }

    if(FoundPos:=RegExMatch(A_Now,NeedleRegEx "2010......20..") = 1)
    {
       Click 159, 374
       Sleep 90000
    }

    if(FoundPos:=RegExMatch(A_Now,NeedleRegEx "2010......30..") = 1)
    {
       Click 186, 374
       Sleep 90000
    }

    if(FoundPos:=RegExMatch(A_Now,NeedleRegEx "2010......40..") = 1)
    {
       Click 214, 374
       Sleep 90000
    }

    if(FoundPos:=RegExMatch(A_Now,NeedleRegEx "2010......50..") = 1)
    {
       Click 240, 374
       Sleep 90000
    }

    Sleep 10000
}


in this one, all I do is that every ten minutes, the script makes a click in an specific spot on the screen, waits 90 seconds, and then starts running again cheking every ten seconds, until it matches another *almost* exact hour (seconds are no issue here). and it runs endlessly till I close the program.

I tested it and it works like a charm (it's really simple). I'm gonna change it so it makes that every hour instead of every ten minutes.

perhapps i wasn't really clear in what I need it, but it's letting a computer running by itself with a program open in full screen, and this script it's making a click in different options every hour (here, every ten minutes).

the idea is that the computer is gonna be running by itself doing this for like 2 months. I suppose AutoHotkey is a really stable piece of software, right?

thanks for your help, really


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 1st, 2010, 1:43 am 
Offline

Joined: November 26th, 2009, 3:00 am
Posts: 13
jjplano wrote:
it's important that I'm able to specify the exact clock time, and not do a "X amount of seconds later" kind of script


It's pretty inefficient to do it with sleep. The best way would be to use the built in timer and just set it up to launch at a specific time.

For example, instead of using a timer that will run in X seconds, you can make a function which looks like the following:

Code:
RunTimerAtTime(hour, minute, second, myLabel) {
  ; seconds = requested time - current time (you'll need to find a function that calculates this for you)
  ; set up a timer to run in <seconds> seconds and launch <myLabel>
}


Internally though, it is using a run in X seconds timer (which is built into the autohotkey language), however you are 'hiding' this fact by always calling the function instead of dealing with timers directly.

Code:
RunTimerAtTime(0, 20, 00, "myLabel")

myLabel:
  Click 102, 375
  RunTimerAtTime(1, 0, 0, "myLabel2")
return

myLabel2:
  Click 127, 263
  ; etc.
return



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 2:33 am 
Offline

Joined: February 27th, 2010, 6:51 pm
Posts: 6
hi senseful

thanks for your answer

I'm trying to understand how to make that function, but I can't

I'm really rusty at programming, I haven't do any real programming in like 8 years, more or less :(

it's almost a miracle that I came up with that simple code up there lol

and I know it's inefficient, but at least it's working

I need something that can work 24/7, so even do sleep isn't the best, isn't your version doing something close to that? freeze 'till it reachs that exact time?

thanks for your help

ps: sorry for my english


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 2:51 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
@ jjplano,
Glad you go what you needed.

>>until it matches another *almost* exact hour (seconds are no issue here).
I was under the impression you wanted something more precise.
Oh well, I had fun. :wink:

Quote:
perhapps i wasn't really clear in what I need it, but it's letting a computer running by itself with a program open in full screen, and this script it's making a click in different options every hour (here, every ten minutes).

the idea is that the computer is gonna be running by itself doing this for like 2 months.
I had that feeling. I've had to do stuff like that.

May I suggest reading the following topics very carefully.
http://www.autohotkey.com/docs/commands/Click.htm
http://www.autohotkey.com/docs/commands/CoordMode.htm

Quote:
I suppose AutoHotkey is a really stable piece of software, right?
It has appeared stable to me, YMMV. I can't use the 'really' adjective yet, even though I [joined: 08 Apr 2009]

May I suggest that you get as much run time as you can before the appointed date ?

May I further suggest that you could write a quick audit program to verify the usefulness of your timer program.
For one thread, I wrote a quick qui that used an image of the original program "full size" as the stand-in.
You could make it fullscreen and log the mouse clicks vs time.

Code:
Gui, -SysMenu ; no system menu, min/max buttons
Gui -Caption ; no border
Gui, Margin ,0,0
;Gui, Margin ,20,20

gui, add, picture,  vpic gpic, Panel.bmp ; replace with your application image
;gui, add, button, w200 h200 vpic gpic
gui, show
;gui, show, x200 y200 w200 h200
;msgbox
;gui, hide
return

pic:
mousegetpos,x,y
;msgbox,,, %A_GuiEvent% X%X% Y%Y%, 1
tooltip %A_GuiEvent% X%X% Y%Y%

return

f12::reload

esc::exitapp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 4:44 am 
Offline

Joined: February 27th, 2010, 6:51 pm
Posts: 6
hi Leef_me

thanks for your suggestions, I'm gonna read all that to see if I can improve this script

I have a question:

I have found that, even do the program I need to be operated by the script is in fullscreen, and no other window is over THAT portion of the maximazed window in wich I'm moving the mouse and go clicking, if a window is in fact over the maximazed one, and the mouse cursor is over that one, the coordinates are interpreted to be of the not maximized window, instead of the whole screen

so the mouse does the clicking in the coordinates of the window and not on the coordinated of the screen

is there a way to make that a certain program is on top before doing the clicking?

thanks in advance


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 5:19 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
May I suggest reading the following topics very carefully.
http://www.autohotkey.com/docs/commands/Click.htm
http://www.autohotkey.com/docs/commands/CoordMode.htm <-------------
Code:
#singleinstance force
#Persistent

if 1   ; change to 1 for relative to active window or 0 for screen <-------
{
  CoordMode, ToolTip, Relative
  CoordMode, Mouse, Relative
  CoordMode, Pixel, Relative
  msgbox ,,,relative,1
}
else
{
  CoordMode, ToolTip, screen
  CoordMode, Mouse, screen
  CoordMode, Pixel, screen
  msgbox ,,,screen,1
}

SetTimer, WatchCursor, 100
return

WatchCursor:
MouseGetPos, xpos, ypos, id, control
WinGetTitle, title, ahk_id %id%
WinGetClass, class, ahk_id %id%
ToolTip, X%xpos% Y%ypos%`nahk_id:%id%`nahk_class:%class%`ntitle:%title%`nControl:%control%
return


esc:: exitapp ; in case of emergency hit escape to exit


#a:: msgbox   X%xpos% Y%ypos%`nahk_id:%id%`nahk_class:%class%`ntitle:%title%`nControl:%control%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 5:45 am 
Offline

Joined: February 27th, 2010, 6:51 pm
Posts: 6
leef, thanks

but I noted that perhapps I can encounter problems if a window opens on top the maximized window, exactly over the area I'm working

so even if I set the coordinates to the screen instead of a window, something can go wrong

that's why I want to know if there's a way to assure that the window I need can be on top before doing any clicks

with CoordMode (if I understand correctly) I have no way of assure that, but I can be wrong (please have in mind that I landed on this application/forum yesterday)

thanks for your answers do, I really appreciate it


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 5:49 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
See also: ControlClick command

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 1st, 2010, 6:04 am 
Offline

Joined: February 27th, 2010, 6:51 pm
Posts: 6
MasterFocus wrote:
See also: ControlClick command


thanks MasterFocus, that's exactly what I needed

well, its working inefficiently but pretty decent lol

I can start testing tomorrow and go improving the code in the next few days

thank you all for all your help, very appreciated


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], chaosad, jrav and 23 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