making random movements

Ask gaming related questions (AHK v1.1 and older)
WADInc
Posts: 4
Joined: 07 Jul 2014, 10:45

making random movements

07 Jul 2014, 10:53

ok rly need help not sure if the scripting im using is correct.

basicaly im trying to make the macro create a random position click within a set of coords would this be the correct scripting to use?

X = Algorithms.randomInteger(59,226)
Y = Algorithms.randomInteger(603,742)
XY = new Point(X, Y)
Click, (XY) Left, 1

or would it be somthing more like this

X = (59,226)
Y = (603,742)
XY = random(X, Y)
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: making random movements

07 Jul 2014, 14:18

The help file that comes with AutoHotkey shows the syntax to use and has examples. There is also a link at the top of this page to a list of commands and their documentation.

Code: Select all

; CoordMode, Mouse, Screen		; Optional

#a::	; Win+A hotkey
Random, xpos, 59, 226
Random, ypos, 603, 742
Click %xpos%, %ypos%
return
WADInc
Posts: 4
Joined: 07 Jul 2014, 10:45

Re: making random movements

07 Jul 2014, 18:26

well that aint workin for me or im doing it wrong to to me that looks lick ure tring to make it click 2 different positionsnot only that its just making me fly down the screen

wouldnt you be better

Random := "xpos, 59, 226"
Random := "ypos, 603, 742"
xypos := xpos " " ypos
Click := xypos " Left 1"

here ill show you where its supposed to be

FindsBB:
CoordMode, Pixel, Window
ImageSearch, FoundX, FoundY, 8, 71, 1373, 775, C:\Users\UKSAS\AppData\Roaming\MacroCreator\Screenshots\Screen_20140707122608.png
If ErrorLevel = 0
{
Goto, ShipStability
}
If ErrorLevel
{
Goto, Movement
}
ShipStability:
Click, 677, 570 Left, 1
Sleep, 10
Sleep, 800
VerificationOfBB:
CoordMode, Pixel, Window
ImageSearch, FoundX, FoundY, 8, 71, 1373, 775, C:\Users\UKSAS\AppData\Roaming\MacroCreator\Screenshots\Screen_20140707122608.png
If ErrorLevel = 0
Click, %FoundX%, %FoundY% Left, 1
Sleep, 1650
Goto, PauseToSearchForMoreBB
Movement:

//heres where it goes in

Random := "xpos, 59, 226"
Random := "ypos, 603, 742"
xypos := xpos " " ypos
Click := xypos " Left 1"

//rest of code

Sleep, 1000
Goto, FindsBB
PauseToSearchForMoreBB:
Sleep, 50
CoordMode, Pixel, Screen
ImageSearch, FoundX, FoundY, 8, 71, 1373, 775, *15 C:\Users\UKSAS\AppData\Roaming\MacroCreator\Screenshots\Screen_20140707122608.png
If ErrorLevel = 0
{
Goto, FindsBB
}
If ErrorLevel
{
Goto, CantFindBB
}
CantFindBB:
MsgBox, 16, Dumbass, "OMFG commander I cant find the BB RTFM"

i need the script to click random locations ithing a target area
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: making random movements

08 Jul 2014, 02:18

kon is just showing you the right syntex to use aka the way to write it to make it work...

the way you are trying to write it will not work

maybe you can try and do the Tutorial it just may help.
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
User avatar
joedf
Posts: 9000
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: making random movements

08 Jul 2014, 02:40

Yes, syntEx is really important. ;)
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: making random movements

08 Jul 2014, 03:52

Yes, yes thank you for that :)
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
WADInc
Posts: 4
Joined: 07 Jul 2014, 10:45

Re: making random movements

08 Jul 2014, 10:32

well i tryed that sytanx and it didnt work XD
User avatar
Grendahl
Posts: 170
Joined: 30 Sep 2013, 08:21

Re: making random movements

08 Jul 2014, 11:40

Try something like this instead...

Code: Select all

FindsBB:
	CoordMode, Pixel, Window
	ImageSearch, FoundX, FoundY, 8, 71, 1373, 775, C:\Users\UKSAS\AppData\Roaming\MacroCreator\Screenshots\Screen_20140707122608.png
	If(ErrorLevel = 0)
		Goto, ShipStability
	Goto, Movement
Return

ShipStability:
	Click, 677, 570 Left, 1
	Sleep, 10
	Sleep, 800
Return

VerificationOfBB:
	CoordMode, Pixel, Window
	ImageSearch, FoundX, FoundY, 8, 71, 1373, 775, C:\Users\UKSAS\AppData\Roaming\MacroCreator\Screenshots\Screen_20140707122608.png
	If ErrorLevel = 0
	Click, %FoundX%, %FoundY% Left, 1
	Sleep, 1650
	Goto, PauseToSearchForMoreBB
Return


Movement:
	xpos := rnd(59,226)
	ypos := rnd(603,742)
	MouseMove, %xpos%, %ypos%
	Click
	Sleep, 1000
	Goto, FindsBB
Return

PauseToSearchForMoreBB:
	Sleep, 50
	CoordMode, Pixel, Screen
	ImageSearch, FoundX, FoundY, 8, 71, 1373, 775, *15 C:\Users\UKSAS\AppData\Roaming\MacroCreator\Screenshots\Screen_20140707122608.png
	If(ErrorLevel = 0)
		Goto, FindsBB
	Goto, CantFindBB
Return

CantFindBB:
	MsgBox, 16, Dumbass, "OMFG commander I cant find the BB RTFM"
Return

;FUNCTIONS
/*	RND()
	Rnd() ; - A random float between 0.0 and 1.0 (many uses)
	Rnd(6) ; - A random integer between 1 and 6 (die roll)
	Rnd("") ; - New random seed (selected randomly)
	Rnd("", 12345) ; - New random seed (set explicitly)
	Rnd(50, 100) ; - Random integer between 50 and 100 (typical use)
*/
Rnd(a=0.0,b=1) {
   IfEqual,a,,Random,,% r := b = 1 ? Rnd(0,0xFFFFFFFF) : b ;%
   Else Random,r,a,b
   Return r
}
WADInc
Posts: 4
Joined: 07 Jul 2014, 10:45

Re: making random movements

08 Jul 2014, 17:34

now see thats how i see it grendal both the xpos and ypos should be seen as a veriable to which calls a random integer between the set numbers where as the mouse should call the variable itself.

ive still not gotten it to work lol altough im trying to work out where im going wrong

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 97 guests