Gui matching quiz?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
comalie
Posts: 7
Joined: 20 Jan 2020, 12:15

Gui matching quiz?

Post by comalie » 04 Dec 2021, 19:51

Hi > how would one produce a matching quiz on a gui like so
Image
:?: :?: :?: :?: :?:



If unclear, there is a need for

(a) each box in column A being linked to one in column B and when clicked in succession they remain checked - otherwise both get unchecked

(b) it being possible to repeat this process for all other pairs until all boxes are permachecked

If it is a lot of work to write from scratch I could provide the complete convoluted clusterfunhouse of an attempt I have been despairing over :!: :!: :!:

Thank yous :rainbow:

User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: Gui matching quiz?

Post by mikeyww » 04 Dec 2021, 21:36

Here are a few ideas.

Code: Select all

map := {a1: "b4", a2: "b3", a3: "b2", a4: "b1"}
Gui, Font, s10
Gui, Add, CheckBox,     va1 gCheck, a1
Gui, Add, CheckBox, x+m vb1 gCheck, b1
Gui, Add, CheckBox, xm  va2 gCheck, a2
Gui, Add, CheckBox, x+m vb2 gCheck, b2
Gui, Add, CheckBox, xm  va3 gCheck, a3
Gui, Add, CheckBox, x+m vb3 gCheck, b3
Gui, Add, CheckBox, xm  va4 gCheck, a4
Gui, Add, CheckBox, x+m vb4 gCheck, b4
enable(active := "a")
Gui, Show,, Matching
Return

Check:
Gui, Submit, NoHide
If !(%A_GuiControl%) {
 a := active = "a" ? "" : a
 Return
}
Switch active {
 Case "a": a := A_GuiControl
 Case "b": If (A_GuiControl != map[a]) {
            GuiControl,, %A_GuiControl%, 0
            GuiControl,, %a%, 0
           } Else SoundBeep, 1500
}
enable(active := active = "a" ? "b" : "a")
Return

enable(letter) {
 other := letter = "a" ? "b" : "a"
 Loop, 4 {
  GuiControl, Enable , %letter%%A_Index%
  GuiControl, Disable, %other%%A_Index%
 }
}

User avatar
comalie
Posts: 7
Joined: 20 Jan 2020, 12:15

Re: Gui matching quiz?

Post by comalie » 06 Dec 2021, 03:13

Thank you for your time mikeyww!

Unfortunately though AHK does not recognise "Switch active [" on line 53 :monkeysee:

But it's ok if you or anyone else doesn't feel like tweaking it, I could always set one up on a quiz site or app

gregster
Posts: 9001
Joined: 30 Sep 2013, 06:48

Re: Gui matching quiz?

Post by gregster » 06 Dec 2021, 03:23

comalie wrote:
06 Dec 2021, 03:13
Unfortunately though AHK does not recognise "Switch active [" on line 53 :monkeysee:
You could update your AHK version.

User avatar
comalie
Posts: 7
Joined: 20 Jan 2020, 12:15

Re: Gui matching quiz?

Post by comalie » 06 Dec 2021, 14:10

gregster wrote:
06 Dec 2021, 03:23
comalie wrote:
06 Dec 2021, 03:13
Unfortunately though AHK does not recognise "Switch active [" on line 53 :monkeysee:
You could update your AHK version.
I shall do that, thank you

Post Reply

Return to “Ask for Help (v1)”