Jump to content

Sequential button pressed command


icadea
 Share

Recommended Posts

#include <GUIConstants.au3>

   
    $Form1 = GUICreate("Form1", 462, 95, 213, 130)
    GUISetBkColor(0x000000)
    $Button1 = GUICtrlCreateButton("", 8, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x008000)
    $Button2 = GUICtrlCreateButton("", 96, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x0000FF)
    $Button3 = GUICtrlCreateButton("", 184, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x800080)
    $Button4 = GUICtrlCreateButton("", 272, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0xFFFF00)
    $Button5 = GUICtrlCreateButton("", 360, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0xFF0000)
    $Button6 = GUICtrlCreateButton("x", 440, 72, 17, 17, 0)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUISetState(@SW_SHOW)

Hi all, I made script at the location here http://www.autoitscript.com/forum/index.php?showtopic=57935

and found there is a problem as the gui is being recreated each steps.

Is there a simple way of getting the button pressed in sequence and logging the action(like password).

Example,

1) Button1 --> Button2 --> Button 3 --> Button 4 --> This sequence will give access to the rest of the script

2) If any one of the sequence above is broken, it will reset to the beginning.

Something like keyin password but this is done using correct button pressed in sequence. I tried Ispressed command in the forum but looks like i'm doing it wrong.

Kindly guide me.

thanks

Link to comment
Share on other sites

#include <GUIConstants.au3>

   
    $Form1 = GUICreate("Form1", 462, 95, 213, 130)
    GUISetBkColor(0x000000)
    $Button1 = GUICtrlCreateButton("", 8, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x008000)
    $Button2 = GUICtrlCreateButton("", 96, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x0000FF)
    $Button3 = GUICtrlCreateButton("", 184, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0x800080)
    $Button4 = GUICtrlCreateButton("", 272, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0xFFFF00)
    $Button5 = GUICtrlCreateButton("", 360, 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, 0xFF0000)
    $Button6 = GUICtrlCreateButton("x", 440, 72, 17, 17, 0)
    GUICtrlSetBkColor(-1, 0xFFFFFF)
    GUISetState(@SW_SHOW)

Hi all, I made script at the location here http://www.autoitscript.com/forum/index.php?showtopic=57935

and found there is a problem as the gui is being recreated each steps.

Is there a simple way of getting the button pressed in sequence and logging the action(like password).

Example,

1) Button1 --> Button2 --> Button 3 --> Button 4 --> This sequence will give access to the rest of the script

2) If any one of the sequence above is broken, it will reset to the beginning.

Something like keyin password but this is done using correct button pressed in sequence. I tried Ispressed command in the forum but looks like i'm doing it wrong.

Kindly guide me.

thanks

Something like this maybe

$Pass = "1562";the button sequence
$Sequ = "";the sequenc of the buttons pressed so far

while 1

 $msg = guigetmsg()
  switch $msg
   case $button 1
       SetSEq(1,$pass,$seq)
  case $button2
       SetSeq(2,$pass,$seq)
.
.
.
 Case $GUI_EVENT_CLOSE
   exitloop
  EndSwitch


wend


Func SetSeq($num,$sp,ByRef $ss)

 $Ss &= $num
 if Stringleft($sp,stringlen($ss) <> $ss then
  $ss = '';must start sequence again
  return -1;sequence is incorrect
 endif

 if $ss = $sp then return 1;sequence is complete and correct

return 0;seq ok so far but not complete

endfunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Or in event mode:

#include <GUIConstants.au3>

Opt("GuiOnEventMode", 1)

Global $sKeySeq = ""
Global $sCode = "13524"
Global $avButtons[7]
Global $avColors[7] = [0x000000, 0x008000, 0x0000FF, 0x800080, 0xFFFF00, 0xFF0000, 0xFFFFFF]

$Form1 = GUICreate("Form1", 462, 95, 213, 130)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
GUISetBkColor($avColors[0])

For $n = 1 To 5
    $avButtons[$n] = GUICtrlCreateButton("", 8 + (88 * ($n - 1)), 16, 81, 49, 0)
    GUICtrlSetBkColor(-1, $avColors[$n])
    GUICtrlSetOnEvent(-1, "_ButtonHit")
Next

$avButtons[6] = GUICtrlCreateButton("x", 440, 72, 17, 17)
GUICtrlSetBkColor(-1, $avColors[6])
GUICtrlSetOnEvent(-1, "_Quit")

GUISetState(@SW_SHOW)

While 1
    Sleep(20)
WEnd

Func _ButtonHit()
    For $n = 1 To 5
        If $avButtons[$n] = @GUI_CtrlId Then
            $sKeySeq &= String($n)
            ExitLoop
        EndIf
    Next
    
    ; Test the entered code
    If StringLen($sKeySeq) = StringLen($sCode) Then
        If $sKeySeq = $sCode Then
            MsgBox(64, "Ta Da!", "Code verified!")
        Else
            MsgBox(16, "BZZZzzzzt!", "Wrong!  Try again...")
        EndIf
        $sKeySeq = ""
    EndIf
EndFunc   ;==>_ButtonHit

Func _Quit()
    Exit
EndFunc   ;==>_Quit

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I can't get the damn thing to let me through Psalty, I clicked 1,3,5,2,4.

Nevermind, i'm running 3.2.8.1 with double button event issue. (How did the developers let that one through?)

Edited by weaponx
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...