Page 1 of 1

How to stop this script working when a key has been clicked and activate again when clicked again

Posted: 22 Apr 2023, 18:17
by jeffdavies_123
Basically need to stop this script from working when a key is clicked and start working again when clicked again

Code: Select all

gosub generateNewRandom ;Generate initial random number

*~$LButton::
numClicks--
if(numClicks==0){
    Click
    gosub generateNewRandom ;Generate subsequent random numbers
}
return


generateNewRandom:
Random, numClicks , 1, 11 ;Adjust these values as needed
return 

[Mod action: Topic moved from "Ask for Help (v2)" since this is v1 code.]

Re: How to stop this script working when a key has been clicked and activate again when clicked again

Posted: 22 Apr 2023, 23:19
by ananthuthilakan
this will do the trick

Code: Select all

gosub generateNewRandom ;Generate initial random number

t::  ; ---> the hotkey you want
toggle:=!toggle
return

*~$LButton::
if (toggle)
return
numClicks--
if(numClicks==0){
    Click
    gosub generateNewRandom ;Generate subsequent random numbers
}
return


generateNewRandom:
Random, numClicks , 1, 11 ;Adjust these values as needed
return 


Re: How to stop this script working when a key has been clicked and activate again when clicked again

Posted: 22 Apr 2023, 23:33
by ananthuthilakan
this will also do the trick

Code: Select all

gosub generateNewRandom ;Generate initial random number

t::  ; ---> the hotkey you want
toggle:=!toggle
return

#if (toggle=1)

*~$LButton::
numClicks--
if(numClicks==0){
    Click
    gosub generateNewRandom ;Generate subsequent random numbers
}
return

#if

generateNewRandom:
Random, numClicks , 1, 11 ;Adjust these values as needed
return