This is great ! Thank you so much. I'm almost there with the full script (I think). I need some help in completing it. I'll attach it at the end but a full outline of what I'm trying to achieve might be useful.
I first check that a specific window is active. I have then defined a reload and a key to run the script. I then check for a specific icon on the screen. If it is present I them go in to a second loop (which is most of the script you have helped build so far). The script then reads a log file and checks for two conditional parameters (the word seed and the last 2 digits of the number that comes directly after "seed"). If the conditional parameters are meet an alert sound plays and the script is paused. All these parts are working as expected.
If the conditional parameters aren't meet initially, then an else clause is triggered. The else clause needs to do several things
- Create a new instance via several mouse and keyboard strokes (hence the click and ctrl+click sections). This works as expected (I've used the same code elsewhere), however
- It also needs to re-read the log file each time a new instance is created to see if there is now a conditional match. If there is a match, the alert sound sound play and the script pause again, until it's restarted
This is where I'm currently stuck. I'm not sure if I just repeat the loop, read code again or I need to do something else. I also need to make sure I don't re-read an existing entry that matches the conditionals when I restart the script or create an infinite loop in this section either. Any help to finish this would be greatly appreciated. Here's the code so far
Code: Select all
#IfWinActive, WindowsName ;specific window must be open
\::reload ;reload key
$[:: ;press [ key to kick script off
loop
{
pixelGetColor, pixel1, 282, 56, RGB ;on screen co-ordinates for icon
sleep 530
if pixel1 = 0xFCD79D ;if icon present then go to next loop
{
Loop, Read, C:\C:\AHk\Scripts\TestLogFile2.txt ; Read log file. Only need last line with "seed" and the last two digits of the number on same line ending in "00"
if InStr(A_LoopReadLine, "seed")
{
if Substr(A_LoopReadLine, -1) = "00"
run, c:\AHk\Scripts\English.mp3 ; play specific sound
pause ; pause script for other actions
}
else ; if seed number doesn't end in "00" loop the activites below until a match in the log file is found. Then play sound and pause script as above
click, 1816, 1032 ;mouse co-ordinatesco-ordinates
sleep 500
send ^{click, 654, 647} ;ctrl+click for new instance
sleep 500
click, 781, 698 ;select from menu co-ordinates
sleep 400
; read file and check for conditionals. Another loop ?
; if a match
; run, c:\AHk\Scripts\English.mp3 ; play specific sound
; pause ; pause script for other actions
}
else
sleep 120
}
return