Sign in to follow this  
Followers 0
Mic

using arrow keys on UpDown control?

12 posts in this topic

Have the #include and have setting vert or horz arrow keys for this control without success. Is there a working example of this? tia.

Share this post


Link to post
Share on other sites



Mic,

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

 

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
1 person likes this

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.

Share this post


Link to post
Share on other sites

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


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

Share this post


Link to post
Share on other sites

mrider,

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

Share this post


Link to post
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!

Share this post


Link to post
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? :-)

 

   

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Thanks for all the info - all works without ISN's attempt to automatically do this with "click and point" - am coding UpDowns manually.

Share this post


Link to post
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
Sign in to follow this  
Followers 0