Jump to content

using arrow keys on UpDown control?


Mic
 Share

Recommended Posts

  • Moderators

Mic,

Your question is unclear - what exactly are you trying to do? :huh:

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

I guess I'm old too :-) - trying to get the arrow keys to increment/decrement value of the UpDown control when it is selected. Have #include <UpDownConstants.au3> and $UDS_ARROWKEYS but the arrow keys are not altering control.

Link to comment
Share on other sites

  • Moderators

Mic,

The easiest way is to use _IsPressed: :)

#include <GUIConstantsEx.au3>
#include <Misc.au3>

Local $hDLL = DllOpen("user32.dll")

$hGUI = GUICreate("Test", 500, 500)

$cInput = GUICtrlCreateInput(100, 10, 10, 200, 20)
GUICtrlCreateUpdown($cInput)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            DllClose($hDLL)
            Exit
    EndSwitch

    If _IsPressed("26", $hDLL) Then ; Up
        GUICtrlSetData($cInput, GUICtrlRead($cInput) + 1)
        Sleep(100)
    ElseIf _IsPressed("28", $hDLL) Then ; Down
        GUICtrlSetData($cInput, GUICtrlRead($cInput) - 1)
        Sleep(100)
    EndIf
WEnd
Good enough - or do we have to get fancy? ;)

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

 

The easiest way is to use _IsPressed:

Or else using $UDS_ARROWKEYS

#include <GUIConstantsEx.au3>
#include <UpdownConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$cInput = GUICtrlCreateInput(100, 10, 10, 200, 20)
GUICtrlCreateUpdown($cInput, $UDS_ARROWKEYS)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

[EDIT] I kept leaving in the DLL stuff...

Edited by mrider

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Link to comment
Share on other sites

I vote that should be default behavior, and you should have to specify $UDS_NoArrowKeys

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Moderators

mrider,

Nice catch - learnt something new (again)! :thumbsup:

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

Thanks for the working examples. I am using $UDS_ARROWKEYS from within ISN AutoIt Studio where arrow keys are not changing control values .... the working example will allow me to debug this - thanks again!

Link to comment
Share on other sites

removing ISN from the equation for the moment and using the $cinput example above, I can set the default with

    GUICtrlSetData($cinput, 5)

but 

   GUICtrlSetLimit( $cinput, 30, 0)

does not set the max and min for this control ... it's 'cos I'm old, right? :-)

 

   

Link to comment
Share on other sites

That fails because you are setting the limit on the input box, not the up/down control.

BAD:

#include <GUIConstantsEx.au3>
#include <UpdownConstants.au3>
$hGUI = GUICreate("Test", 500, 500)
$cInput = GUICtrlCreateInput(10, 10, 10, 200, 20)
GUICtrlCreateUpdown($cInput, $UDS_ARROWKEYS)
GUICtrlSetLimit($cInput, 30)
GUICtrlCreateButton("Button", 10, 60)

GUISetState()
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

GOOD:

#include <GUIConstantsEx.au3>
#include <UpdownConstants.au3>
$hGUI = GUICreate("Test", 500, 500)
$cInput = GUICtrlCreateInput(10, 10, 10, 200, 20)
GUICtrlCreateUpdown($cInput, $UDS_ARROWKEYS)
GUICtrlSetLimit(-1, 30)
GUICtrlCreateButton("Button", 10, 60)

GUISetState()
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Edited by mrider

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Link to comment
Share on other sites

Two other things to keep in mind:

  1. You might consider $ES_NUMBER as part of the style in the input field.
  2. GUICtrlSetLimit won't block direct input into the text field, you'll need to enforce that yourself.  Unless someone knows something about up/down controls that I don't - which is a distinct possibility.

A better version:

#include <GUIConstantsEx.au3>
#include <UpdownConstants.au3>
#include <GuiEdit.au3>


Global Const $MIN = 0
Global const $MAX = 30
$hGUI = GUICreate("Test", 500, 500)
$cInput = GUICtrlCreateInput("10", 10, 10, 200, 20, $ES_NUMBER)
GUICtrlCreateUpdown($cInput, BitOR($UDS_ARROWKEYS, $UDS_NOTHOUSANDS))
GUICtrlSetLimit(-1, $MAX, $MIN)

GUISetState()
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    Local $value = Number(GUICtrlRead($cInput))
    If $value < $MIN Then
        GUICtrlSetData($cInput, $MIN)
    ElseIf $value > $MAX Then
        GUICtrlSetData($cInput, $MAX)
    EndIf
WEnd

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

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