Typing Master. AHK game

Post your working scripts, libraries and tools for AHK v1.1 and older
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Typing Master. AHK game

12 Mar 2018, 14:25

Hi, new AHK game. Check out how many words you can type per 2 minutes :)

Code: Select all

#SingleInstance, force
SetControlDelay, -1
SetBatchLines, -1 ; for delay precision

stopped := true
myScore = 0
global h_midiout := midiOutOpen(0)

Word_for_Use := ["diffluence","predeluded","gonopodial","escalation","graysville","hermosillo","primaquine","bounceably","creaseless","unstirring","bananaland","homebodies","fastuously","terreplein","effectible","irrigative","uncognized","cancelling","predescent","precontend","condensary","haddington","persistent","smudgeless","powerhouse","uncollared","reimplying","marginated","jutlandish","overharass","gramicidin","commonness","bolshevize","turtledove","supertotal","ijsselmeer","nonzonated","stereogram","alabastron","vocational","undejected","favourably","witchbroom","hammerlike","beneficent","myelinated","kalsominer","promptness","unembossed","miscutting","enduringly","drosophila","averrhoism","roquelaure","dodecanese","fathomless","timberwork","sepulchral","glomerulus","verulamium","lubricious","georgetown","cravatting","attingency","illustrate","antecessor","clarksdale","overargued","watercolor","perpetuate","subovarian","displuming","fumblingly","cicatriser","maupassant","nonbookish","hydrolysis","collotyped","garishness","protoplasm","tabescence","dhaulagiri","defunctive","redivision","shenanigan","evangeline","nonidyllic","continuous","unheralded","cognominal","sousaphone","unbespoken","nonspheric","drumbeater","extirpator","wellington","federalese","rgenopaque","infinitely"]
Rand_Number := RandChar()

gui, Color, 666633
gui, font, s50 Bold, Bauhaus 93
Gui, Add, Text, x250 y10 w150 BackgroundTrans E0x20 vTText, 02:00
Gui, Font
Gui, add, Text, x300 y+20, The new word is:
gui, font, s30, Britannic Bold
Gui, add, Text, x250 w400 y+20 vNew_Word, % Word_for_Use[Rand_Number]
gui, font
Gui, add, Text, x280 y+20, Type here ( Capital matters! ):
gui, font, s30, Britannic Bold
Gui, add, Edit, x150 y+20 w400 vMy_Word,
gui, font, 
gui, add, Edit, x10 y+20 w200 h180 vCorrect_Words ReadOnly,
gui, font, s30, Bauhaus 93
gui, add, Text, x+30, Your score:
Gui, add, Text, x+30 w60 vScore, 0
gui, font,
Gui, Add, Text, x260 y+50, To Reload the game, press PageDown
gui, show, w700 h500, Typing Master
Settimer, Stopwatch, 1000
Settimer, KeyStatus, 1000
gosub, Start_Time
return

KeyStatus:
GuiControlGet, new_input,, My_Word
GuiControlGet, old_word,, New_Word
if (new_input <> ""){
	stopped := false
	gosub, Start_Time
}
if (new_input == old_word){
	myScore++
	Score_Count(myScore)
	Correct_Word(old_word)
	Word_for_Use.Remove(Rand_Number)
	GuiControl, , My_Word,
	Rand_Number := RandChar()
	GuiControl,, New_Word, % Word_for_Use[Rand_Number]
}
return

Stopwatch:
timers += 1
if (timers = 120){
	GuiControl, , TText , % FormatSeconds(timers)
	GuiControl, Disable, My_Word
	GuiControl, , My_Word,
	stopped := true
	gosub, Start_Time
	Game_Over()
}
if (timers < 120)
	GuiControl, , TText , % FormatSeconds(timers)
return

Start_Time:
if(stopped = true){
	Settimer, Stopwatch, off
	NumberOfSeconds = 0
}
if(stopped = false)
	Settimer, Stopwatch, 1000
return

FormatSeconds(NumberOfSeconds)  ; Convert the specified number of seconds to hh:mm:ss format.
{
	global
    time = 19990101230200  ; *Midnight* of an arbitrary date.
    time += -%NumberOfSeconds%, seconds
    FormatTime, mmss, %time%, mm:ss
	if (NumberOfSeconds <= 109)
		NoteOn(9, 62, 127)
	if (NumberOfSeconds > 109)
		NoteOn(3, 52, 127)
	return mmss
}

RandChar()
{
	global
	Random, Rand, 1, % Word_for_Use.Length()
	return, Rand
}

Correct_Word(word)
{
	GuiControlGet, new_put,, Correct_Words, Text
	new_ver := word "`n" new_put
	GuiControl, , Correct_Words, % new_ver
	return
}

Score_Count(newScore)
{
	GuiControl, , Score, % newScore
	return
}

Game_Over()
{
	Sleep, 700
	NoteOn(2, 60, 127)
	sleep 100
	NoteOn(2, 62, 127)
	sleep 400
	NoteOn(2, 62, 127)
	sleep 200
	NoteOn(2, 71, 127)
}

midiOutOpen(uDeviceID = 1) { ; Open midi port for sending individual midi messages --> handle
   strh_midiout = 0000
   result := DllCall("winmm.dll\midiOutOpen", UInt,&strh_midiout, UInt,uDeviceID, UInt,0, UInt,0, UInt,0, UInt)
   If (result or ErrorLevel) {
      MsgBox There was an error opening the midi port.`nError code %result%`nErrorLevel = %ErrorLevel%
      Return -1
   }
   Return NumGet(&strh_midiout)
}

NoteOn(Channel, Note, Velocity) {
DllCall("winmm.dll\midiOutShortMsg", UInt, h_midiout, UInt, 0x90|Channel|(Note<<8)|(Velocity<<16), UInt)
}

PGDN::
Reload
return
User avatar
SpeedMaster
Posts: 494
Joined: 12 Nov 2016, 16:09

Re: Typing Master. AHK game

14 Mar 2018, 08:27

Works great for me. (win7 - ahk v1.124) Thanks ! :) :thumbup:

:!: Not easy to exit the game. Maybe you can add exit code to your script ...

Code: Select all

guiclose: 
~esc::exitapp 
return
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: Typing Master. AHK game

14 Mar 2018, 08:40

Nice work, my high score is 17 as of right now.
I do have quite a few changes I'd like to make, but I think I'll throw them your way later. I also suggest to use an ActiveX control as to not allow any other open scripts to cheat :)

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

guest3456
Posts: 3462
Joined: 09 Oct 2013, 10:31

Re: Typing Master. AHK game

14 Mar 2018, 14:47

38 first try, 45 second. these words are not easy.

but my normal Ctrl+W remapping to Ctrl+Backspace didn't work, and neither did normal Ctrl+Backspace. Ctrl+A worked though.

i'd also prefer some type of red flash or notice as soon as i typo and the word is wrong. but i've played so many typing games like this that i'm used to some other conveniences :)

good job

User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Typing Master. AHK game

14 Mar 2018, 15:25

- Something that I've experienced with my own scripts, the question of how long to make the delay. It appears to be 1 second, so sometimes it submits instantly, sometimes it seems a little delayed, which can confuse you because sometimes the delay is because you typoed.
- Also, are some words UK spelling, some words US spelling? Are all of the words real? Not that it matters, plus it makes it harder.
- Great game, thanks.
- I wrote a script that helped me do well at the game.

Code: Select all

q:: ;Typing Master assistance script
ControlGetText, vText, Static3, A
ControlSetText, Edit1, % vText, A
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
BGM
Posts: 507
Joined: 20 Nov 2013, 20:56
Contact:

Re: Typing Master. AHK game

14 Mar 2018, 18:28

I got a 37 first try. But I think I lost some time to the program. After I pushed enter to advance to the next word, it would hang for a moment before the next word appeared, but the timer continued.
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: Typing Master. AHK game

15 Mar 2018, 07:22

Nice one, thanks for sharing :wave:.
guest3456 wrote:38 first try, 45 second.
:o :shock:

Cheers.
euras
Posts: 429
Joined: 05 Nov 2015, 12:56

Re: Typing Master. AHK game

15 Mar 2018, 11:31

BGM wrote:I got a 37 first try. But I think I lost some time to the program. After I pushed enter to advance to the next word, it would hang for a moment before the next word appeared, but the timer continued.
You don't need to push enter to get next word, the next word will be generated automatically right after you typed the previous word right :)
User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: Typing Master. AHK game

16 Mar 2018, 08:11

I noticed a delay before generating the next word, that would have made it difficult to get 38 words in 2 minutes. I don't have a slow PC, I don't know what was wrong.
try it and see
...
guest3456
Posts: 3462
Joined: 09 Oct 2013, 10:31

Re: Typing Master. AHK game

16 Mar 2018, 11:20

the timer checks every second, not every keypress

User avatar
derz00
Posts: 497
Joined: 02 Feb 2016, 17:54
Location: Middle of the round cube
Contact:

Re: Typing Master. AHK game

16 Mar 2018, 17:15

ya sure enough.

Got 35. Too lazy to try again
try it and see
...
yoyo

Re: Typing Master. AHK game

19 Mar 2018, 07:05

nice game
i would add "record score"

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 76 guests