Jump to content

Recommended Posts

Posted

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 :whistle:

(It keeps the key Pressed... i just need _IsPressed('20') becoming FALSE)

  • Moderators
Posted

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
EndFunc
The 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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...