Jump to content

AdlibEnable/Disable Problem


jfcby
 Share

Recommended Posts

Hi,

I'm tring to create a simple typing program to help me learn more about AutoScript programing.

First, how the program works: Select a lesson then type. When the data typed is correct then the label will display the typing speed.

I'm having three problems:

1. When I click the red x it want close the program.

2. After I select the lesson to type from the dropdown and type the first letter in the input box it want show up until I type it 2 to 3 times.

3. When I finish typing the lesson correctly my type seed flickers continuely at 0 and never changes.

How can these problems be fixed?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

AdLibE()

HotKeySet("{ESC}", "_Exit")

Global $Input, $tSpeed, $Exit, $hEdit

; config\config.txt
Local $title = "TypeTest"  
Global $tSpeed = "Type Speed "
$GUI = GUICreate($title, 500, 400, -1, -1, $WS_SYSMENU)

GUICtrlCreateLabel("Select Lesson:", 10, 225)
$Combo = GUICtrlCreateCombo('', 100, 225, 385, 100)
GUICtrlSetData(-1, "Type Test 1|Type Test 2|Type Test 3|Type Test 4")
GUICtrlCreateLabel("Click Start then start typing", 10, 255)
$Input = GUICtrlCreateInput("", 100, 280, 385, 20)
$Label = GUICtrlCreateLabel($tSpeed, 100, 310, 200) ; Typing Speed Time

GUISetState()
    
    
While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = -3 
            _Exit()
    EndSelect
WEnd

Func AdLibE()
    AdLibEnable("fStart",1)
EndFunc     ;AdLibE

Func AdLibD()
    AdlibDisable()
EndFunc     ;AdLibD

Func fStart()
    If GUICtrlRead($Input) > "" Then sType() 
EndFunc     ;Start

Func sType()
        AdLibD()
        ;GUICtrlSetData($Input, "")
        GUICtrlSetData($Label, $tSpeed)
        GUICtrlSetState($Input, $GUI_FOCUS)
        $x = TimerInit()
        Do
            $xx = TimerDiff($x)
        Until GUICtrlRead($Input) == GUICtrlRead($Combo)
        $xxx = Round($xx / 1000, 1)       
        GUICtrlSetData($Label, $tSpeed & $xxx & " seconds.")
         AdLibE()
        
EndFunc     ;sType
    
Func _Exit()
    Exit
EndFunc     ;_Exit

Thank yo for your help,

jfcby

Determined -- Devoted -- Delivered Make your mind up -- to seriously apply yourself -- accomplishing the desired results. **** A soft answer turneth away wrath: but grievous words stir up anger. Proverbs 15:1 KJB ****

Link to comment
Share on other sites

Nice Try... Maybe...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

HotKeySet("{ESC}", "_Exit")

Global $Input, $tSpeed, $Exit, $hEdit, $Start = 0, $x

; config\config.txt
Local $title = "TypeTest"
Global $tSpeed = "Type Speed "
$GUI = GUICreate($title, 500, 400, -1, -1, $WS_SYSMENU)

GUICtrlCreateLabel("Select Lesson:", 10, 225)
$Combo = GUICtrlCreateCombo('', 100, 225, 385, 100)
GUICtrlSetData(-1, "Type Test 1|Type Test 2|Type Test 3|Type Test 4")
GUICtrlCreateLabel("Click Start then start typing", 10, 255)
$Input = GUICtrlCreateInput("", 100, 280, 385, 20)
$Label = GUICtrlCreateLabel($tSpeed, 100, 310, 200) ; Typing Speed Time

GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = -3
            _Exit()
        Case $nMsg = $Input
            GUICtrlSetData($Input, "")
            GUICtrlSetData($Label, $tSpeed)
            $Start = 0
    EndSelect
    sType()
WEnd

Func sType()
    If GUICtrlRead($Input) = "" Then Return

    If $Start = 0 Then
        $x = TimerInit()
        $Start = 1
    EndIf

    If $Start = 1 And GUICtrlRead($Input) == GUICtrlRead($Combo) Then
        $xx = Round(TimerDiff($x) / 1000, 1)
        GUICtrlSetData($Label, $tSpeed & $xx & " seconds.")
        $Start = 2
    EndIf
EndFunc   ;==>sType

Func _Exit()
    Exit
EndFunc   ;==>_Exit

8)

EDIT; I was just running though it and found this

Case $nMsg = $Input

It should be

Case $nMsg = $Combo

....Hmmm, it shouldn't work but it does..??

Edited by Valuater

NEWHeader1.png

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...