| presskey.mac by playj 2015
| Minor data validation and goto removal - 2016 - Incognito
| presses specific key for some time
| usage /presskey key timeinseconds ex. /presskey Q 5 600 will press Q every 5 seconds for 10 minutes
| defaults are key 1, delay 5 seconds, duration 1 hour
| Incognito Note - If using this to skillup a skill managed by MQ2Melee (i.e. Feign Death) MQ2Melee will intercept
| execution and return to evaluate the current iteration of the while loop. In the case of FD, it will auto-stand
| on FD failure and rentry will display time left on the timer by returning to execute the echo cmd, the line
| before the while loop. Good to know so you can plan ahead and see where re-entry occurs.
Sub Main
/declare MyKey string outer 1
/declare MyDelay int outer 50
/declare MyTimer timer outer 36000
/declare MacTime int outer
/if (${Defined[Param0]}) /varset MyKey ${Param0}
/if (${Defined[Param1]}) /varcalc MyDelay ${Param1}*10
/if (${Defined[Param2]}) /varcalc MyTimer ${Param2}*10
/varset MacTime ${Math.Calc[${MyTimer}\10]}
/if (!${Defined[Param0]} || !${Defined[Param1]} || !${Defined[Param2]}) {
/echo Using one of more default parameters
/echo To avoid defaults use Format: /mac presskey Key-to-Press Pause-in-Seconds Mac-Duration-Seconds
}
/echo Going to press ${MyKey} every ${Math.Calc[${MyDelay}\10]} seconds for ${Math.Calc[${MyTimer}\10]} seconds
/while (${MyTimer} != 0) {
/keypress ${MyKey}
/delay ${MyDelay}
}
/echo Mac has run for ${MacTime} seconds
/return