Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Need to program a Left Mouse Click to run at a certain time


  • Please log in to reply
11 replies to this topic
hockeymatt
  • Guests
  • Last active:
  • Joined: --
I am interested to know if anyone knows how to run a Left Click option to run at a specific time.

Windows...can display a time frame of hundredths of seconds 01103466 or 01:10:34:66

Any ideas on having a Left Click hot key run at a specific time interval?

Assuming that the mouse has already been positioned, thus no worrying about x and y positioning.

Thanks,

Matt

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
If you want it at a specific time interval, over and over again, and not at a specific time of day, the below example will click every 60 seconds:
SetTimer, ClickTimer, 60000
return
ClickTimer:
MouseClick, left
return

However, if you want the click to happen at a specific time of day:
#persistent

TargetTime = 1400  ; run at 2pm, which is 1400.

StringLeft, TargetDateTime, A_Now, 8  ; Put just YYYYMMDD into the variable.
TargetDateTime = %TargetDateTime%%TargetTime%
TimeUntilTarget = %TargetDateTime%
TimeUntilTarget -= %A_Now%, seconds
if TimeUntilTarget < 0
{
     MsgBox The target time is already past!
     return
}
TimeUntilTarget *= 1000 ; Convert to milliseconds.
SetTimer, ClickTimer, %TimeUntilTarget%
return

ClickTimer:
SetTimer, ClickTimer, off  ; i.e. do only one click
MouseClick, left
return


ne1410is
  • Members
  • 4 posts
  • Last active: Jun 05 2015 11:45 PM
  • Joined: 24 Aug 2013

Chris. Thanks for the examples. 

Your exact time example solves most of my problems; but I need the mouse click to occur a few milliseconds earlier. I must be losing time in my computer or internet connection, so I think I need to mouse click a fraction of a second earlier. I can't find enough documentation on using milliseconds in scripts to make a such a small time adjustment. Any help would be appreciated.



scriptor
  • Members
  • 668 posts
  • Last active: Feb 15 2016 01:02 AM
  • Joined: 20 Jun 2013

SetTimer, ClickTimer, 60000
return
ClickTimer:
MouseClick, left
return

 

 

I can't get the above script to do anything- I run it and nothing happens. I've been having problems with all scripts involving timers actually - is there something I may not have installed prior to running the script?



Menixator
  • Members
  • 744 posts
  • Last active: Sep 01 2015 02:54 PM
  • Joined: 10 Jul 2013

I run it and nothing happens.


Actually, Something does happen. A Mouse Click is sent. You are saying that nothing happened because you don't see anything happening.



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
No, scriptor is right. You need to add #Persistent to prevent the script from exiting when return is encountered.

ne1410is, TimeUntilTarget contains the number of milliseconds until the timer should fire. Just use ordinary subtraction before calling SetTimer:
TimeUntilTarget -= 10  ; Fire 10ms earlier


ne1410is
  • Members
  • 4 posts
  • Last active: Jun 05 2015 11:45 PM
  • Joined: 24 Aug 2013

Thanks Lexikos.

 

I believe your instructions worked. At least, the mouse click executed just about when I expected. I used two computers this morning, one at -10ms and one at -50ms and was unsuccessful on both, as someone else got there before me.

 

I'm trying to purchase items on a website which opens for business at precisely 0800 each day. The highly desirable items are gone in a fraction of a second. A manual mouse click works fine for the lesser desirable items; but has less than 1% success rate on the more competitive items. I plan on increasing the milliseconds value until I arrive before the store doors open. I sync the computer clock and close unused applications to lower the CPU burden.

 

Any other ideas or suggestions would be greatly appreciated.

 

This is my current script after changing the milliseconds to -75, for tomorrow. Hopefully, I've incorporated your instructions correctly.

 

#persistent

TargetTime = 0800

 

StringLeft, TargetDateTime, A_Now, 8   ; Put just YYYYMMDD into the variable.
TargetDateTime = %TargetDateTime%%TargetTime%
TimeUntilTarget = %TargetDateTime%
TimeUntilTarget -= %A_Now%, seconds
if TimeUntilTarget < 0
{
     MsgBox The target time is already past!
     return
}
TimeUntilTarget *= 1000 ; Convert to milliseconds.
TimeUntilTarget -= 75
SetTimer, ClickTimer, %TimeUntilTarget%
return

ClickTimer:
SetTimer, ClickTimer, off  ; i.e. do only one click
MouseClick, left



exnius
  • Members
  • 28 posts
  • Last active: Jun 28 2014 01:48 AM
  • Joined: 10 Jul 2013

Is this useful for you?

 

http://www.autohotke...utofire-thread/



Gpoty
  • Members
  • 2 posts
  • Last active: Feb 03 2014 08:27 PM
  • Joined: 02 Feb 2014

Does anyone know how to fine tune the single mouse click script to click on 1/10 of a second ?

Scripts in exinus link above show timer to the round second. Can this script be edited to use tenths of a second of clock time.

Then a desktop clock upate to 10ths would be needed too I guess.

There are a few utilities out there that use computer clock to mouse click but they are to the second only.

Any help appreciated.

Thanks

Gpoty



Patrick
  • Members
  • 29 posts
  • Last active: Sep 16 2014 12:10 AM
  • Joined: 10 Aug 2013

Does anyone know how to fine tune the single mouse click script to click on 1/10 of a second ?

Scripts in exinus link above show timer to the round second. Can this script be edited to use tenths of a second of clock time.

 

I"m not sure I understand your question 100%. 

 

The Scripts in exinus' link are quicker than one per second.

All the time commands are per mili second (1/1000)

so the command

Sleep, 100

will pause the scrip 1/10 of a second.

Hope that helps.



Gpoty
  • Members
  • 2 posts
  • Last active: Feb 03 2014 08:27 PM
  • Joined: 02 Feb 2014

Thanks Patrick,

more easily expressed...

script..

 

T_Hour=16

T_Min=13

T_Sec=02

 

can the seconds be expressed at say T_Sec=02.5

As 2.5 sec will not appear in any clock, is 2.5 recognized as a halfway gap between 2 and 3 ?

 

Gpoty



creator676
  • Members
  • 1 posts
  • Last active: Nov 13 2015 09:53 PM
  • Joined: 13 Nov 2015

is it possible to get the mouse to click at a certain time of day down to a second also with it only activating once instead of repeatidly?