Flashcards game with AHK Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Guill
Posts: 139
Joined: 09 Jun 2016, 22:00

Flashcards game with AHK

11 Sep 2019, 13:32

Hi guys,

I would like to know if it is possible to make a kind of FlashCards game with AHK.

For example, from the following list, for English-Spanish words:

House - Casa
Tree - Árbol
Sun - Sol

I would like random words to appear (example, Tree), and by pressing a hotkey (ex. F1), you can see the back of the card (árbol). By pressing the hotkey again (eg F1), or perhaps another, it propose a new word, and so on.

Someone asked a few days ago for something similar, but only for random words to appear. I guess it would be modify a little, to obtain my goal.

Thanks in advance.



Code: Select all


#SingleInstance force
#NoEnv


WordList := [ "mi", "mimi", "mami", "merendero", "moligerar", "mariachi" ]

RepeatCheck = 0

WordGui:
{
	;Generate random word
	Random, WordNum, 1, WordList.MaxIndex()
	;Avoid repeating a word 2 times in a row
	if (RepeatCheck = WordNum)
		Goto, WordGui
	RepeatCheck = %WordNum%
   
	;Create GUI
 Gui, -MinimizeBox -MaximizeBox
Gui, Color, 995b0dq
 Gui, Font, s46, Times New Roman
Gui, -MinimizeBox -MaximizeBox
 Gui, Add, Text, cF7F305, % WordList[WordNum]

 Gui, Add, Button, W100 cCFF305 Default gButtonOK32, OK



	Gui, Show,, Speech Test
	return
}   
   
ButtonOK32:
{
	Gui, Destroy
	Goto, WordGui
}


Return


AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Flashcards game with AHK

11 Sep 2019, 16:34

if you add

q::

on top of ButtonOK32: it will change every time you hit q

The back and front idea can be implemented using an associative array
Guill
Posts: 139
Joined: 09 Jun 2016, 22:00

Re: Flashcards game with AHK

11 Sep 2019, 16:45

AHKStudent wrote:
11 Sep 2019, 16:34
if you add

q::

on top of ButtonOK32: it will change every time you hit q

The back and front idea can be implemented using an associative array


Thank you AHKStudent,

but I can't do the script by myself.
My knowledge in AHK is very elementary.
Guill
Posts: 139
Joined: 09 Jun 2016, 22:00

Re: Flashcards game with AHK

11 Sep 2019, 23:40

I am much closer to reaching my goal.
But I need to solve two problems:

1. I found how to make it work for key-values, but I don't know how use both words (strings).

2. I dont know how get random results.

Does anyone know how?


Code: Select all


#!j::
; array := {house: casa, tree: árbol, sun: sol} ; DOES'NT WORK


array := {house: 1, tree: 2, sun: 3}


Guik3:
Gui k3: Color, 995b0d
Gui k3: -MinimizeBox -MaximizeBox
Gui k3: Font,bold s32, Arial,
Gui k3: Add, text,cF7F305,  
(
%key%
)
Gui k3: Font,bold s9
Gui k3: Add, Button, gBoton_k3 W80 Default, OK
Gui k3: Show,, FLASHCARDS GAME
SoundPlay, *-1
Gui k3: +LastFound
Return

Boton_k3:
Gui, Destroy
Goto Guik4


Guik4:
Gui k4: Color, 427d47
Gui k4: -MinimizeBox -MaximizeBox
Gui k4: Font,bold s32, Arial,
Gui k4: Add, text,cF7F305,  
(
%value%
)
Gui k4: Font,bold s9
Gui k4: Add, Button, gBoton_k4 W80 Default, OK
Gui k4: Show,, FLASHCARDS GAME
SoundPlay, *-1
Gui k4: +LastFound
Return

Boton_k4:
Gui, Destroy
Goto #!j

Return

AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Flashcards game with AHK  Topic is solved

12 Sep 2019, 02:33

Try this

Code: Select all

#MaxThreadsPerHotkey 2
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
Gui Font, s14 Bold
Gui Add, Text, x164 y81 w147 h182 +0x200 Center +0x400000 vWdGame, Q To Start
Gui Font
Gui Show, w481 h381, Window
array := {} 
FlashG := []
array := {house: "casa", tree: "árbol", sun: "sol", bread: "pan", that: "que", water: "agua", nada: "nothing", gracias: "Thank You", hola: "hello"} 
for k, v in array
   FlashG.Insert(k)
Return

q::
Toggle := !Toggle ; big thanks to Andromon
loop, {
   if Toggle
   {
   Random, FG, 1, FlashG.length()
   if (FG = StoreRand) ; prevent same word to show twice in  a row
      Continue
   StoreRand := FG
   GuiControl, Hide, WdGame ; flash effect 
   sleep, 50
   GuiControl, Show, WdGame
   GuiControl, +cRed, WdGame ; font color change
   GuiControl,, WdGame, % FAnswer := FlashG[FG]
   break
   }
   else
   {
   GuiControl, Hide, WdGame
   sleep, 50
   GuiControl, Show, WdGame
   GuiControl, +cGreen, WdGame
   GuiControl,, WdGame, % array[FAnswer]
   break
   }
}
return
GuiClose:
ExitApp
Guill
Posts: 139
Joined: 09 Jun 2016, 22:00

Re: Flashcards game with AHK

12 Sep 2019, 07:09

Thank you very much!!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: filipemb, Google [Bot], Rohwedder and 265 guests