Jump to content

How to simulate "enter' in GUICreateInput ?


Recommended Posts

http://http://img163.imageshack.us/img163/7282/guiedit.png

I'm new to GUI and trying to create a simple GUI for calculation purpose.

I would like to know how to simulate "calc now' when keyboard "enter" is hit at the GUICreateInput field as shown by the pic shown above.

#include <GUIConstantsEx.au3>
Opt("TrayIconDebug", 1)
Opt('MustDeclareVars', 1)

DIM $CurrentTHK, $CurrentDT, $msg, $Warn, $NewDT, $thkDIFF, $comp
DIM $Parent1, $Exit1, $calnow, $exceed

$Parent1= GUICreate("Compensator calculator", 290, 190) 

GUICtrlCreateLabel("Enter Current thk:",10, 10)
GUICtrlCreateLabel("E.g. 529 (470 to 530) ",150, 10)
GUICtrlCreateInput ("5",100,7,40,20); thk input

GUICtrlCreateLabel("Enter Current DT:",10, 45)
GUICtrlCreateLabel("Spec (11.5 to 14.5s)",150, 45)
GUICtrlCreateInput ("1",100,40,40,20); DT input

GUICtrlCreateLabel("Compensated DT:",10, 85)

$calnow=GUICtrlCreateButton("Calc now", 70, 150, 60); ctrl id=10
$Exit1 = GUICtrlCreateButton("Exit", 150, 150, 60); ctrl id=11

GUISetState(@SW_SHOW)

While 1
  $msg = GUIGetMsg()

Select
Case $msg = $calnow
        $CurrentTHK=GUICtrlRead (5); input field for thk
        $CurrentDT=GUICtrlRead (8); input field for deptime

        $NewDT=500/$CurrentTHK*($CurrentDT+2)-2
        $NewDT=Round ( $NewDT, 1 )
        $thkDIFF=Abs ( $CurrentDT-$NewDT )
        $comp=Round ( $thkDIFF*0.75,1)

    If $CurrentTHK>500 then 
            $NewDT=$CurrentDT-$comp
                    
                    If $NewDT<11.50 then 
                        GUICtrlCreateLabel($NewDT,100,85)
                        GUICtrlSetColor(-1, 0xff0000);red font for new DT
                        $exceed="Note: New DT is lower than the minimal,"&@crlf&"out of range!"
                        $Warn=GUICtrlCreateLabel($exceed,80,105); 12
                        GUICtrlSetColor(-1, 0xFF00FF)                   ;pink warning font
                        GUICtrlCreateLabel("",140,85,140,15); clear clipboard message
                        ClipPut ("")
                    EndIf
            
            If $NewDT>11.50 and $NewDT<14.50 then 
            GUICtrlCreateLabel($NewDT,100,85)
            GUICtrlSetColor(-1, 0x0000FF)                   ; Blue font 
            GUICtrlCreateLabel ("",80,105,140,15); clear clipboard copied message
            GUICtrlCreateLabel("(New DT copied to clipboard)",135,85)
            ;; clear warning message
            GUICtrlCreateLabel ("",80,105,200,30); clear pink warning message
            ClipPut ($NewDT)
            EndIf
    Else
        $NewDT=$CurrentDT+$comp
        
        If $NewDT>14.50 then 
            GUICtrlCreateLabel($NewDT,100,85)
            GUICtrlSetColor(-1, 0xff0000); red font for new DT
            $exceed="Note: New DT is higher than the maximum,"&@crlf&"out of range!"
            GUICtrlCreateLabel($exceed,80,105)
            GUICtrlSetColor(-1, 0xff0000)                   ; Red warning font
            GUICtrlCreateLabel("",135,85,140,15); clear clipboard copied message
            ClipPut ("")
        EndIf
        
        If $NewDT>11.50 and $NewDT<14.50 then 
        GUICtrlCreateLabel($NewDT,100,85)
        GUICtrlSetColor(-1, 0x0000FF); Blue font 
        GUICtrlCreateLabel ("",80,105,200,40); clear clipboard copied message
        GUICtrlCreateLabel("(New DT copied to clipboard)",135,85)
        ClipPut ($NewDT)
        EndIf
    
    EndIf

Case $msg = $Exit1
        exitloop

Case $msg = $GUI_EVENT_CLOSE
      MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...",4)
      ExitLoop
    EndSelect
WEnd
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...