Jump to content

Ispressed..!


Recommended Posts

hi..,

I need your help to know what should i use to limit key presses..

if "1" is pressed for five times then "1" will get blocked..

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Link to comment
Share on other sites

everytime the key gets pressed have it write to an ini file, and when that key reaches 5 times, have it ignore it when it presses the key and do nothing

something to the effect of this:

#Include <Misc.au3>
$sFile = @ScriptDir & "\testing.ini"
$dll = DllOpen("user32.dll")
$cnt = 0
$read = IniRead ($sFile , "One Key" , "Pressed" , 0)
If $read = 5 Then
    
ElseIf _IsPressed(31 , $dll)
;~   extra code here
    $cnt = $cnt + 1
    IniWrite($sFile , "One Key" , "Pressed" , $cnt)
EndIf

Edit: I've used something to the effect of this to limit how many times u can attempt a password

Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Link to comment
Share on other sites

I think he wants to block key after 5key press, not to do nothing :lmao:

Cheers, FireFox.

Hey Thanks for your fast replies.. :think:

FireFox Got my point.. exactly what i want to do.. :)

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Link to comment
Share on other sites

Ohh really..!!

Thank you soo much Firefox(Don't Know your Name :))

And I'm Gonna take a look on limit input udf.. =)

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Link to comment
Share on other sites

Hey Thanks for your fast replies.. :lmao:

FireFox Got my point.. exactly what i want to do.. :)

#Include <Misc.au3>
$dll = DllOpen("user32.dll")

Dim $keys[10][3] = [[30,0,0],[31,0,1],[32,0,2],[33,0,3],[34,0,4],[35,0,5],[36,0,6],[37,0,7],[38,0,8],[39,0,9]]

While 1
    For $i = 0 To UBound($keys)-1
        If _IsPressed($keys[$i][0],$dll) Then
            If $keys[$i][1] >= 5 Then
                ;TrayTip("",$keys[$i][2] & " should disable here!",1)
                HotKeySet($keys[$i][2],"KeyDisabled")
            Else
                $keys[$i][1] = $keys[$i][1]+1
                TrayTip("",$keys[$i][2] & " is pressed " & $keys[$i][1] & " times!",1)
            EndIf
        Else
            ;TrayTip("","No key is pressed!",1)
        EndIf
    Next
    Sleep(100)
WEnd

Func KeyDisabled()
    TrayTip("","Sorry Bout Your Luck.. This Key's Disabled!",1)
EndFunc

Func OnAutoitExit()
    DLLClose($dll)
EndFunc

Try this. I'm guess you'll want to stick a timer in there.. maybe setup another entry in the array for the timer stat.. and after a certain amount of time reset the counter.

Link to comment
Share on other sites

#Include <Misc.au3>
$dll = DllOpen("user32.dll")

Dim $keys[10][3] = [[30,0,0],[31,0,1],[32,0,2],[33,0,3],[34,0,4],[35,0,5],[36,0,6],[37,0,7],[38,0,8],[39,0,9]]

While 1
    For $i = 0 To UBound($keys)-1
        If _IsPressed($keys[$i][0],$dll) Then
            If $keys[$i][1] >= 5 Then
                ;TrayTip("",$keys[$i][2] & " should disable here!",1)
                HotKeySet($keys[$i][2],"KeyDisabled")
            Else
                $keys[$i][1] = $keys[$i][1]+1
                TrayTip("",$keys[$i][2] & " is pressed " & $keys[$i][1] & " times!",1)
            EndIf
        Else
            ;TrayTip("","No key is pressed!",1)
        EndIf
    Next
    Sleep(100)
WEnd

Func KeyDisabled()
    TrayTip("","Sorry Bout Your Luck.. This Key's Disabled!",1)
EndFunc

Func OnAutoitExit()
    DLLClose($dll)
EndFunc

Try this. I'm guess you'll want to stick a timer in there.. maybe setup another entry in the array for the timer stat.. and after a certain amount of time reset the counter.

Hey Buddy your solution is good enough for me..

Thank you soo much man..!!

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Link to comment
Share on other sites

Hey i still have some confusion. I just want to disabled "1" after 5 presses not all keys.. =)

I know i have to modify:

Dim $keys[10][3] = [[30,0,0],[31,0,1],[32,0,2],[33,0,3],[34,0,4],[35,0,5],[36,0,6],[37,0,7],[38,0,8],[39,0,9]]

But i don't know anything about arrays. =S

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Link to comment
Share on other sites

What is this obsession with IsPressed ???? :)

Here's a very simple way to do exactly what the OP wanted:

HotKeySet("{1}","KeyPressed")

$iHold = 0

While 1
    Sleep(100)
WEnd

Func KeyPressed()
    $iHold += 1
    If $iHold > 5 Then Return
    HotKeySet(@HotKeyPressed)
    Send(@HotKeyPressed)
    HotKeySet(@HotKeyPressed,"KeyPressed")
EndFunc

[EDIT] s --> i

Edited by andybiochem
- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
Link to comment
Share on other sites

Hey i still have some confusion. I just want to disabled "1" after 5 presses not all keys.. =)

I know i have to modify:

Dim $keys[10][3] = [[30,0,0],[31,0,1],[32,0,2],[33,0,3],[34,0,4],[35,0,5],[36,0,6],[37,0,7],[38,0,8],[39,0,9]]

But i don't know anything about arrays. =S

Oh. Thought it was more than one key.

Dim $keys[1][3] = [[31,0,1]]

That'd prolly do it.. or use the hotkey method posted by andybiochem.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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