AzKay Posted January 24, 2007 Share Posted January 24, 2007 #include <GUIConstants.au3> $Form1 = GUICreate("AForm1", 146, 98, 448, 296) $Button1 = GUICtrlCreateButton("AButton1", 8, 64, 129, 25, 0) $Label1 = GUICtrlCreateLabel("", 8, 8, 129, 49, BitOR($SS_CENTER,$SS_SUNKEN)) GUICtrlSetFont(-1, 24, 800, 0, "Comic Sans MS") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Pressed = 0 GUICtrlSetState($Button1, $GUI_DISABLE) HotKeySet("{SPACE}", "_TrackKey") For $i = 5 To 0 Step -1 GUICtrlSetData($Label1, $i) Sleep(1000) Next HotKeySet("{SPACE}") MsgBox(0, "", "Pressed Space " & $Pressed & " Times.") GUICtrlSetState($Button1, $GUI_ENABLE) EndSwitch WEnd Func _TrackKey() HotKeySet("{SPACE}") $Pressed = $Pressed + 1 HotKeySet("{SPACE}", "_TrackKey") EndFunc Run the script, click the button, then press space as many times as you can until the timer stops. Now, a messagebox will appear, with your score. Except, if you HOLD down spacebar, it does the same as pressing it. What should I do to stop them being able to hold space? # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
MHz Posted January 24, 2007 Share Posted January 24, 2007 Try some Sleep() in your TrackKey() function. Link to comment Share on other sites More sharing options...
AzKay Posted January 24, 2007 Author Share Posted January 24, 2007 Nope, Its still able to hold down space. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
Sardith Posted January 24, 2007 Share Posted January 24, 2007 _IsPressed ? [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font] Link to comment Share on other sites More sharing options...
someone Posted January 24, 2007 Share Posted January 24, 2007 (edited) I admit this is a bit sloppy but this works... #include <GUIConstants.au3> $Form1 = GUICreate("AForm1", 146, 98, 448, 296) $Button1 = GUICtrlCreateButton("AButton1", 8, 64, 129, 25, 0) $Label1 = GUICtrlCreateLabel("", 8, 8, 129, 49, BitOR($SS_CENTER,$SS_SUNKEN)) GUICtrlSetFont(-1, 24, 800, 0, "Comic Sans MS") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Pressed = -1 GUICtrlSetState($Button1, $GUI_DISABLE) For $i = 5 To 0 Step -1 GUICtrlSetData($Label1, $i) Sleep(1000) Next _TrackKey() MsgBox(0, "", "Pressed Space " & $Pressed & " Times.") GUICtrlSetState($Button1, $GUI_ENABLE) EndSwitch WEnd Func _TrackKey() $Pressed = $Pressed + 1 Sleep(100) HotKeySet("{SPACE}", "_TrackKey") EndFunc I say its sloppy because you have to set $Pressed to -1 initially.... also it only registers when you release space so holding it the whole time results in 0 presses EDIT: I have to stop coding on an empty stomach... I'm sorry I tested it by holding the key down the whole time... my mistake Edited January 24, 2007 by someone While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
AzKay Posted January 24, 2007 Author Share Posted January 24, 2007 I admit this is a bit sloppy but this works...#include <GUIConstants.au3> $Form1 = GUICreate("AForm1", 146, 98, 448, 296) $Button1 = GUICtrlCreateButton("AButton1", 8, 64, 129, 25, 0) $Label1 = GUICtrlCreateLabel("", 8, 8, 129, 49, BitOR($SS_CENTER,$SS_SUNKEN)) GUICtrlSetFont(-1, 24, 800, 0, "Comic Sans MS") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Pressed = -1 GUICtrlSetState($Button1, $GUI_DISABLE) For $i = 5 To 0 Step -1 GUICtrlSetData($Label1, $i) Sleep(1000) Next _TrackKey() MsgBox(0, "", "Pressed Space " & $Pressed & " Times.") GUICtrlSetState($Button1, $GUI_ENABLE) EndSwitch WEnd Func _TrackKey() $Pressed = $Pressed + 1 Sleep(100) HotKeySet("{SPACE}", "_TrackKey") EndFuncI say its sloppy because you have to set $Pressed to -1 initially.... also it only registers when you release space so holding it the whole time results in 0 pressesEDIT: I have to stop coding on an empty stomach... I'm sorry I tested it by holding the key down the whole time... my mistakeWell, That doesnt work too well.1, The first time you run it, it wont work2, It doesnt work too right. In the long run. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
rbhkamal Posted January 24, 2007 Share Posted January 24, 2007 This should give you a complete control over the message box. test.au3 Regards, RK "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
AzKay Posted January 24, 2007 Author Share Posted January 24, 2007 I didnt need control over the message box. Lol. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
rbhkamal Posted January 24, 2007 Share Posted January 24, 2007 (edited) I didnt need control over the message box. Lol.Didn't that fix your problem?Edit: Because the "OK" button is nolonger the default. Edited January 24, 2007 by rbhkamal "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
AzKay Posted January 24, 2007 Author Share Posted January 24, 2007 No, the problem was, when they hold down spacebar, its like cheating. Because it records being pressed, each time. So, Theyre score is false. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
rbhkamal Posted January 24, 2007 Share Posted January 24, 2007 No, the problem was, when they hold down spacebar, its like cheating. Because it records being pressed, each time. So, Theyre score is false.Oh.... lol!I'm sorry, I thought that the msgbox was closing becuase they are holding down the spacebar.Sorry againRegards,RK "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
AzKay Posted January 24, 2007 Author Share Posted January 24, 2007 # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
rbhkamal Posted January 24, 2007 Share Posted January 24, 2007 OK, Here is an idea... test.au3 Replace the return with exit if you want. Regards, RK "When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix Link to comment Share on other sites More sharing options...
AzKay Posted January 25, 2007 Author Share Posted January 25, 2007 Thanks # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
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