Hello, new to this forum and AutoIt, this is my first attempt at creating a script in order to perform the role of a rather monotonous task.
After much trial and error I have nearly succeeded in completing this 'bot', I am at the point where the script will search for a pixel colour and click on that pixel repetedly in order to defeat the target. My intention was to perform a PixelSearch in multiple ranges, the idea being that I could prioritise targets closer to me and attack only them, as opposed to the cursor randomly clicking every pixel it found of a paticular colour as it did when I first started making this script today. So far this appears to work, however I encountered another problem, being that the script was only attacking things when they came close to me, so I divided all the PixelSearch into their own loops, and if the desired pixel wasn't found to move onto the next loop (or rather increase the scan range). Now my problem is as far as I know that once this script has run once it does not run again, the result being that I attack a target only once, and it seems since I introduced the loops that it often will not attack at all, although I suspect this might be because PixelSearch isn't scanning as often as is therefore missing my defined colour.
As I am typing this I have thought of another question which could invalidate all my work so far, the way I have set these loops up, am I correct in saying that if PixelSearch found pixels at a greater distance from me, is it just as likely to click on those pixels or will it click on the one's closest to me first (or rather the one's within the smallest given range)
The question I originally started this topic for was ... is it possible to create an infinite loop that will run the 5 other loops. With the purpose of this script being able to run, doing what I intended it to do for an indefinate amount of time?
My apologies if I have rambled but I have not slept in 40 hours.
Many thanks in advance.
; Declare Variables
$atk = 0
; ToolTip displaying function keys
Tooltip("HOME = On/Off END = Exit", 0, 0)
; List of command keys
If Not WinActive("Soma Mythological Biography", "") Then WinActivate("Soma Mythological Biography", "")
HotKeySet("{HOME}", "atkBrics")
HotKeySet("{END}", "exitNow")
WinWaitActive("Soma Mythological Biography", "")
; Scan range loops
While True
If $atk = 1 Then
$coord1 = PixelSearch(320,264,482,368,0x6B5142,5)
If NOT @error Then
MouseClick("left", $coord1[0], $coord1[1], 1, 0)
Sleep(50)
If $coord1 = @error Then ExitLoop
EndIf
EndIf
WEnd
While True
If $atk = 1 Then
$coord2 = PixelSearch(239,193,556,448,0x6B5142,5)
If NOT @error Then
MouseClick("left", $coord2[0], $coord2[1], 1, 0)
Sleep(50)
If $coord2 = @error Then ExitLoop
EndIf
EndIf
WEnd
While True
If $atk=1 Then
$coord3 = PixelSearch(144,128,645,456,0x6B5142,5)
If NOT @error Then
MouseClick("left", $coord3[0], $coord3[1], 1, 0)
Sleep(50)
If $coord3 = @error Then ExitLoop
EndIf
EndIf
WEnd
While True
If $atk = 1 Then
$coord4 = PixelSearch(56,63,757,525,0x6B5142,5)
If NOT @error Then
MouseClick("left", $coord4[0], $coord4[1], 1, 0)
Sleep(50)
If $coord4 = @error Then ExitLoop
EndIf
EndIf
WEnd
While True
If $atk = 1 Then
$coord5 = PixelSearch(3,23,779,548,0x6B5142,5)
If NOT @error Then
MouseClick("left", $coord5[0], $coord5[1], 1, 0)
Sleep(50)
If $coord5 = @error Then ExitLoop
EndIf
EndIf
WEnd
; Functions
; On/Off atkBrics():
Func atkBrics()
If $atk = 0 Then
$atk = 1
Tooltip("Auto attacking Brics (HOME to disable)", 0, 0)
Else
$atk = 0
Tooltip("HOME = On/Off END = Exit", 0, 0)
EndIf
EndFunc
; Exit
Func exitNow()
Exit
EndFunc