Jump to content

Bored, Made this game.


AzKay
 Share

Recommended Posts

#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

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
Link to comment
Share on other sites

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- #
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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

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