Jump to content
Sign in to follow this  
atomman

how to record the order in which buttons are clicked?

Recommended Posts

atomman

i need to record the order in which buttons are pushed, then preform a function based on that order. i think i need to use $Array[]=$var, but i'm having trouble figuring out how.

example...

$Button1 does $1

$Button2 does $2

$Button3 does $3

so if buttons are clicked in the order: 2,1,3 then i need do something like this...

$Button4 does $2 & $1 & $3

so i think i need to...

$Array[1]=$1

$Array[2]=$2

$Array[3]=$3

but how do i get from there to '$Button4 = $2 & $1 & $3' ?

Share this post


Link to post
Share on other sites
erezlevi

i need to record the order in which buttons are pushed, then preform a function based on that order. i think i need to use $Array[]=$var, but i'm having trouble figuring out how.

example...

$Button1 does $1

$Button2 does $2

$Button3 does $3

so if buttons are clicked in the order: 2,1,3 then i need do something like this...

$Button4 does $2 & $1 & $3

so i think i need to...

$Array[1]=$1

$Array[2]=$2

$Array[3]=$3

but how do i get from there to '$Button4 = $2 & $1 & $3' ?

hi, try using Select and the Case within it. what ever you do, do not exit ( exit the loop ). use a while before it while $i=0 and Wend at the and.

Share this post


Link to post
Share on other sites
atomman

thanks, but i think i found a much simpler way. i'll post back with example if it works. i appreciate the your response though!

Share this post


Link to post
Share on other sites
erezlevi

thanks, but i think i found a much simpler way. i'll post back with example if it works. i appreciate the your response though!

ok, i wrote this hope it can help you:

#include <Array.au3>
#include <GUIConstants.au3>
#AutoIt3Wrapper_run_debug_mode=Y
Local $m1,$m2,$m3
$i=1
$Array=_ArrayCreate ($m1,$m2,$m3)
GUICreate ("erez")
$button1=GUICtrlCreateButton ("1",0,10)
$button2=GUICtrlCreateButton ("2",0,30)
$button3=guictrlcreatebutton ("3",0,50)
guisetstate()

While 1
$msg = GUIGetMsg ()

    Select
        case $msg = $button1
            _ArrayInsert ($Array,$i,"1")
            $i=$i+1
        case $msg = $button2
            _ArrayInsert ($Array,$i,"2")
            $i=$i+1
        case $msg = $button3
            _ArrayInsert ($Array,$i,"3")
            $i=$i+1
    EndSelect


If $i=4 Then ExitLoop

If $msg = $GUI_EVENT_CLOSE then Exit
        
WEnd
$array2=_ArrayDisplay ($Array,"erez")
$m5=$Array[1]
$m6=$Array[2]
$m7=$Array[3]
MsgBox (0,"pressed on",$m5&$m6&$m7)

Share this post


Link to post
Share on other sites
atomman

that's a little different than what i did :D

EDIT: silly me - should've been this...

Case Button1
  $Order = ($Order & $Do1)

Case Button2
    $Order = ($Order & $Do2)

Case Button3
    $Order = ($Order & $Do3)

Case Button4
    MsgBox(0,"",$Order)
Edited by atomman

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.