AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

mouseclick to be random, but within a certain range

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
random mouseclick?
Guest





PostPosted: Fri Jul 18, 2008 9:46 pm    Post subject: mouseclick to be random, but within a certain range Reply with quote

i have used AHK for a while... maybe a year or so

i would like to know how to make a random click.
this is what i would want, but i dont know why it wont work or how to get it to work:

Code:

loop
click random [,100 ,150], [,100 ,150]
sleep random [,1000 ,1500]

$F1::
break




basically. what i want it to do, is click randomly in the x, y coordinates but within a certain range (so the x coordinate is always between 100 and 150 in this case, but it will be random)
then i want it to sleep random...
the i want F1 key to break the loop


is there any ways possible to do this? ive tried variables and failed. Please help Smile
Back to top
Dannymet



Joined: 18 Jul 2008
Posts: 7

PostPosted: Fri Jul 18, 2008 10:02 pm    Post subject: Reply with quote

im the same user.. didnt realise i wasnt logged in
Code:


x = random [,100 ,150]
y = random [,100 ,150]
s = random [,1000 ,1500]

Click %x% %y%
sleep, %s%
Click %x% %y%
sleep, %s%
Click %x% %y%



i just tried this and it wont work Sad




so.. what i want the script to do is this:


Code:

click 124, 135
sleep, 1258
click 117, 126
sleep, 1352


and continue clicking in random x and y locations between the numbers 100 and 150, and sleeping between clicks with the sleep delay random between 1000 and 1500

then f1 to terminate it clicking..


Last edited by Dannymet on Fri Jul 18, 2008 10:07 pm; edited 1 time in total
Back to top
View user's profile Send private message
infogulch



Joined: 27 Mar 2008
Posts: 127
Location: KC, MO

PostPosted: Fri Jul 18, 2008 10:03 pm    Post subject: Reply with quote

try:
Code:

RandClick(50, 100, 3)

RandClick(X, Y, rand)
{ ; obeys current mouse CoordMode !!
   Random, RandX, -rand, rand
   Random, RandY, -rand, rand
   MouseClick, Left, X+RandX, Y+RandY
}


CoordMode
Random
MouseClick
Functions
_________________
Back to top
View user's profile Send private message
Dannymet



Joined: 18 Jul 2008
Posts: 7

PostPosted: Fri Jul 18, 2008 10:08 pm    Post subject: Reply with quote

what about the 1000ms to 1500ms delay.. and the f1 key to terminate? Smile

and thanks a lot for your help already



edit: im really sorry if im being a noob at this stuff.. but i only know the basic stuff.. like clicking left and right keys and stuff


i only really know html very well Sad



edit again: although i am very good at observing code and the ways it works Very Happy

Code:


RandSleep(1000, 250)

RandSleep(sleep, rand)
{
   Random, Randsleep, -rand, rand
   Sleep, sleep+Randsleep
}


thats for random sleep Very Happy



edit again:::

theres a bit of a bug with my random sleep code.. sometimes it doesnt wait 1000 +250 random... it clicks again instantly :S
Back to top
View user's profile Send private message
infogulch



Joined: 27 Mar 2008
Posts: 127
Location: KC, MO

PostPosted: Fri Jul 18, 2008 10:48 pm    Post subject: Reply with quote

actually, that would be 1000 ± 250 sleep

i don't know why that wouldn't work, but
Code:
RandSleep(1000, 1500)

RandSleep(Min, Max)
{
    Random, RandSleep, Min, Max
    Sleep RandSleep
}
might be better (btw, use the [ code][ /code] tags for code, plz Smile )

i didn't integerate randsleep into this: (neither are tested)
Code:

F1::
   ToggleVar := !ToggleVar
   SetTimer, ClickRand, -10 ;do it in a new thread, otherwise this won't be callable a second time
return

F12::
   ExitApp ;just in case there's a problem

ClickRand:
   loop
   {
      If !ToggleVar
         Break
      Random, RandSleep, 1000, 1500
      Sleep, RandSleep
      
      RandClick(100, 100, 50)
   }
return

RandClick(X, Y, rand)
{
; this is different from the function posted above.
; the above did + AND - rand, this just does 0-rand (all positive)
; so X & Y should be the top left of the square of where you want to click
   Random, RandX, 0, rand
   Random, RandY, 0, rand
   MouseClick, Left, X+RandX, Y+RandY
}

_________________
Back to top
View user's profile Send private message
Dannymet



Joined: 18 Jul 2008
Posts: 7

PostPosted: Fri Jul 18, 2008 11:03 pm    Post subject: Reply with quote

thankyou soo much. That last script does EXACTLY what i want it to do. Its got random sleep and everything Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group