sd333221 Posted August 11, 2006 Posted August 11, 2006 Somehow, Blockinput doesn't work for interrupting a key if it's already pressed... Here is a example: #include <string.au3> #include <Misc.au3> HotKeySet("{SPACE}", "Input") HotKeySet("{ESC}", "ESC") While 1 Sleep(100) WEnd Func Input() HotKeySet('{SPACE}') ;DISABLE HOTKEY Send('{SPACE}') ;SEND SPACE KEY Sleep(500) ;FOR 500MS blockinput( 1 ) ;BLOCK ALL INPUTS, SPACEBAR CAN'T BE TRIGGERED NOW Sleep(1000) If _IsPressed('20') Then ;IF SPACEBAR IS STILL PRESSED!!! MsgBox(0, 'Damn', 'Tony is right, the Spacebar is still pressed, but you can' & "'" & 't control it....!', 5) ;THEN GIVE ERROR EndIf blockinput(0) ;UNBLOCK NOW... HotKeySet('{SPACE}', 'Input') ;RE-ENABLE THE FUNCTION EndFunc Func ESC() EXIT EndFunc I want to interrupt the Spacebar (if it's being held down) after 500ms for 1000ms, but while the input is blocked, the Spacebar is still pressed (check exemple, the msgbox triggers) Any solutions to get _IsPressed to NULL? Thank you (It keeps the key Pressed... i just need _IsPressed('20') becoming FALSE)
Moderators SmOke_N Posted August 11, 2006 Moderators Posted August 11, 2006 You and your friend are mistaken, if you could send a key, you could stop this message box without having to do ctrl+alt+delete.#include <misc.au3> HotKeySet('{space}', 'Input') While 1 Sleep(1000) WEnd Func Input() HotKeySet('{SPACE}') ;DISABLE HOTKEY Send('{SPACE}') ;SEND SPACE KEY Sleep(500) ;FOR 500MS blockinput( 1 ) ;BLOCK ALL INPUTS, SPACEBAR CAN'T BE TRIGGERED NOW Sleep(1000) MsgBox(0,'','') blockinput(0) ;UNBLOCK NOW... While _IsPressed(20) Sleep(10) WEnd HotKeySet('{SPACE}', 'Input') ;RE-ENABLE THE FUNCTION EndFuncThe While/WEnd should trap the space bar if it is still held down after the function. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now