Jump to content

Recommended Posts

Posted

#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- #
Posted

Nope, Its still able to hold down space.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Posted

_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]

Posted (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 by someone
While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Posted

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

Well, That doesnt work too well.

1, The first time you run it, it wont work

2, It doesnt work too right. In the long run.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Posted

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

Posted

I didnt need control over the message box. Lol.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Posted (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 by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Posted

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- #
Posted

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 again

Regards,

RK

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Posted

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

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
×
×
  • Create New...