Hi,
In my script I have a BlockInput, on
But for example if my script is blocked between the BlockInput, on and BlockInput, off, I need to reboot my computer to regain accessibility.
So my question:
How to do to have the BlockInput active just for 10 seconds for example?
Disable BlockInput after 10 sec
Re: Disable BlockInput after 10 sec
Add this function and its associated subroutine to your script. Then when you want to block input for 10 seconds, just call TimedBlockInput(10). Just make sure that if your program ends before the 10 seconds are up that you've turned BlockInput off before it exits.
Code: Select all
TimedBlockInput(seconds)
{
BlockInput, On
msec := 1000 * seconds
SetTimer, BlockInputOff, -%msec%
}
BlockInputOff:
BlockInput, Off
return
Re: Disable BlockInput after 10 sec
Thanks boiler, I will test this tomorrow.
Re: Disable BlockInput after 10 sec
Ctrl+Alt+Del should still work and let you close the script without rebooting ... ( win 7 tested )ozzii wrote:I need to reboot my computer to regain accessibility.
Sry Boiler but I don't like labels =p
Code: Select all
TimedBlockInput(seconds, unblock := False) {
if(unblock) {
BlockInput Off
}
else {
BlockInput On
msec := 1000 * seconds
fn := Func("TimedBlockInput").Bind(0, True)
SetTimer % fn, -%msec%
}
}
Re: Disable BlockInput after 10 sec
Thanks,
I have a question.
When when I use this,
the msgbox OFF appeared instantly after the ON.
I don't have my 10 seconds wait !
I have a question.
When when I use this,
Code: Select all
TimedBlockInput(10)
TimedBlockInput(seconds)
{
msgbox ,,,ON,1
msec := 1000 * seconds
SetTimer, BlockInputOff, -%msec%
}
BlockInputOff:
msgbox ,,,OFF,1
BlockInput, Off
return
I don't have my 10 seconds wait !
Re: Disable BlockInput after 10 sec
That's because you have not structured your code correctly by marking the end of your auto-execute section with a return (see documentation). So after it executed the function call, it proceeded to execute the next available line, which is the MsgBox after the BlockInputOff label.
You also need to let the program exist for at least 110 seconds after making the function call to give the timer a chance to complete the 10 second countdown. This is correctly structured and waits 15 seconds before ending the program.
You also need to let the program exist for at least 110 seconds after making the function call to give the timer a chance to complete the 10 second countdown. This is correctly structured and waits 15 seconds before ending the program.
Code: Select all
TimedBlockInput(10)
Sleep, 15000
return
TimedBlockInput(seconds)
{
msgbox ,,,ON,1
msec := 1000 * seconds
SetTimer, BlockInputOff, -%msec%
}
BlockInputOff:
msgbox ,,,OFF,1
BlockInput, Off
return
Last edited by boiler on 15 Mar 2017, 04:00, edited 1 time in total.
Re: Disable BlockInput after 10 sec
Already tried, but I have just the ON, no OFF message
Re: Disable BlockInput after 10 sec
See the edit above. Your program exits before 10 seconds are up.
Re: Disable BlockInput after 10 sec
Thanks boiler for the explanation