Jump to content

Default to Enter Key


Go to solution Solved by DW1,

Recommended Posts

There are two areas where I need my GUI to default to the "Enter/Submit/Total" buttons on their respective GUI's. I haven't found a way to make that happen. If I've missed something obvious, like a help file, please point me that direction. I've been stuck on this for a few days now and its the LAST feature request before I can lunch this. I tried to use _IsPressed to Cue the same commands, which is nasty looking and sloppy, but if that's the final answer and I've just done something wrong then that's fine too. I do plan on posting the full code on the example scripts for general use/review when I'm done. Thanks in advance for your time/help with this.

#region ### START Koda GUI section ### 
;Form=C:\Documents and Settings\Administrator\Desktop\Doug's AutoIT\Dev\TigerTool\TimeDateAdjust.kxf
    Local $TmpDate = _NowDate()
    Local $Hour = @HOUR
    If $Hour < 10 Then
        $Hour = String($Hour)
        $Hour = StringMid($Hour, "2", "1")
    EndIf
    Local $Minute = @MIN
    Local $AMorPM = "PM"
    $Form1 = GUICreate("Time", 275, 280, 192, 114)
    $MonthCal1 = GUICtrlCreateMonthCal($TmpDate, 24, 64, 225, 175)
    $HourInput = GUICtrlCreateCombo($Hour, 24, 24, 57, 21, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12")
    $Label1 = GUICtrlCreateLabel("Hours", 24, 8, 32, 17)
    $MinuteInput = GUICtrlCreateCombo($Minute, 104, 24, 57, 21, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "00|05|10|15|20|25|30|35|40|45|50|55")
    $Label2 = GUICtrlCreateLabel("Minutes", 104, 8, 41, 17)
    $Label3 = GUICtrlCreateLabel("AM/PM", 184, 8, 41, 17)
    $Combo9 = GUICtrlCreateCombo("AM", 184, 24, 65, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    GUICtrlSetData(-1, "PM")
    $UpDown1 = GUICtrlCreateUpdown($HourInput)
    $UpDown2 = GUICtrlCreateUpdown($MinuteInput)
    $Button17 = GUICtrlCreateButton("Submit", 24, 245, 225, 25)
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###
    Local $hDLL = DllOpen("user32.dll")
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($Form1)
                ExitLoop
            Case $Button17
                GUISetState(@SW_HIDE)
                $CapsLockTest = _GetCapsLock()
                If $CapsLockTest = 1 Then
                    Send("{CAPSLOCK OFF}")
                    $CapsLockReSet = 1
                EndIf
                $TmpHour = GUICtrlRead($HourInput)
                $TmpMinute = GUICtrlRead($MinuteInput)
                $TmpAMorPM = GUICtrlRead($Combo9)
                $TmpDate = GUICtrlRead($MonthCal1)
                $TmpDate = StringMid($TmpDate, "6", "2") & "-" & StringMid($TmpDate, "9", "2") & "-" & StringMid($TmpDate, "1", "4")
                If $TmpHour < 10 Then
                    $TmpHour = "0" & $TmpHour
                EndIf
                Sleep(50)
                Send($TmpDate & "---" & $TmpHour & ":" & $TmpMinute & " " & $TmpAMorPM & "--" & $TechName & "{ENTER}{ENTER}Hrs- {ENTER}{ENTER}{ENTER}{ENTER}{UP}{UP}{UP}{UP}{UP}")
                GUIDelete($Form1)
                If $CapsLockReSet = 1 Then
                    Send("{CAPSLOCK ON}")
                    $CapsLockReSet = 0
                EndIf
                ExitLoop
                If _IsPressed("0D", $hDLL) Then
                    ConsoleWrite("test test test test" & @CRLF)
                    GUISetState(@SW_HIDE)
                    $CapsLockTest = _GetCapsLock()
                    If $CapsLockTest = 1 Then
                        Send("{CAPSLOCK OFF}")
                        $CapsLockReSet = 1
                    EndIf
                    $TmpHour = GUICtrlRead($HourInput)
                    $TmpMinute = GUICtrlRead($MinuteInput)
                    $TmpAMorPM = GUICtrlRead($Combo9)
                    $TmpDate = GUICtrlRead($MonthCal1)
                    $TmpDate = StringMid($TmpDate, "6", "2") & "-" & StringMid($TmpDate, "9", "2") & "-" & StringMid($TmpDate, "1", "4")
                    If $TmpHour < 10 Then
                        $TmpHour = "0" & $TmpHour
                    EndIf
                    Sleep(50)
                    Send($TmpDate & "---" & $TmpHour & ":" & $TmpMinute & " " & $TmpAMorPM & "--" & $TechName & "{ENTER}{ENTER}Hrs- {ENTER}{ENTER}{ENTER}{ENTER}{UP}{UP}{UP}{UP}{UP}")
                    GUIDelete($Form1)
                    If $CapsLockReSet = 1 Then
                        Send("{CAPSLOCK ON}")
                        $CapsLockReSet = 0
                    EndIf
                EndIf
                ExitLoop
        EndSwitch
    WEnd

Thanks for your time

 

Link to comment
Share on other sites

  • Moderators

JayHawkfl,

There are several ways to get a button set to default to "Press on Enter" - the $BS_DEFPUSHBUTTON style, the $GUI_DEFBUTTON state, and linking it to an Accelerator key. :)

I seem to remember that you can only have one button styled as the default per GUI (or even script), so as you seem to want several instances you might want to look at the style or the Accelerator key options (I would use the latter myself). Give it a go and see what you can come up with - you know where we are if you run into difficulties. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Thank you so much everyone, for the answer and the quick replies, means SO MUCH that I can get this pushed out to everyone today. I'll post the full script on the example boards later today :)

EDIT: Just had the oppurtunity to try it and that worked perfectly! THANK YOU THANK YOU THANK YOU :thumbsup:  

Edited by JayHawkfl

Thanks for your time

 

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

×
×
  • Create New...