Sign in to follow this  
Followers 0
Newtoai

1-key user input

7 posts in this topic

My question may appear dumb, please excuse me it's my first programming day with AI.

AI, as AHK, allows for an input box. In AHK, there is a timeout for this input box, AND if this timeout is reached, any user input is preserved notwithstanding, while in AI, it is not!

Let me explain: You do an input box with a 2 seconds-timeout. The user enters a single character, let's say a "k". In AHK, the input box disappears after these 2 seconds, and the entered "k" is preserved and can be processed in your script, e.g. for chosing the alternative "k" (or a, b, c... z, of course) without needing to do a menu for this (at this time I do not know yet to do a menu I have to say, but I know how to do case programming).

In AI, that cannot be done, since when the input box disappears with its 2 second timeout time, there isn't but an error message, the entered "k" (or any other character) is not preserved.

This is the ONLY advantage of AHK in my opinion over AI, but on my first programming day, it already bothers me to not have such an "intelligent" input box in AI,as there is in AHK. Where's the interest of it?

I would so much like to have the possibility to give the user the chance to enter short file names, 1-digit ones in one macro, 2-digit ones in another one, without having to press "Enter" afterwards, which indeed is a complete nuisance whenever the length of user input is predetermined.

Thus my question: Is there any possibility to intercept, at a determined position in your script, any user input of fixed length, other then presenting a menu or presenting an input box, forcing entering the info and then pressing Enter?

Share this post


Link to post
Share on other sites



Newtoai,

Proof of concept - press the button and you have 2 secs to enter what you want in the input: :)

#include <GUIConstantsEx.au3>

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

$hInput = GUICtrlCreateInput("", 10, 10, 200, 20)
GUICtrlSetState(-1, $GUI_HIDE)

$hButton = GUICtrlCreateButton("Go", 10, 50, 80, 30)

$hLabel = GUICtrlCreateLabel("", 10, 100, 200, 20)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            GUICtrlSetData($hLabel, "")
            GUICtrlSetState($hButton, $GUI_DISABLE)
            GUICtrlSetState($hInput, BitOR($GUI_SHOW, $GUI_FOCUS))
            $iBegin = TimerInit()
            While TimerDiff($iBegin) < 2000
                $sText = GUICtrlRead($hInput)
            WEnd
            GUICtrlSetState($hInput, $GUI_HIDE)
            GUICtrlSetState($hButton, $GUI_ENABLE)
            GUICtrlSetData($hLabel, $sText)
    EndSwitch

WEnd

Please ask if you have any questions. ;)

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

#4 ·  Posted (edited)

To Jos,

Thank you very much, 3 minutes for answering. But since I said I don't know yet how to do menus, in fact I don't know the GUI functions yet - of course I need to make acquaintance with them in the end!

To Melba23,

Thank you VERY VERY much, it's incredible, your help here, in fact just some minutes ago I discovered your tremendous script regarding "RunWait List files in all directories[ASAP]"; fellow users were very impressed with it, to say the least, it's totally overwhelming!

And what's for me, I'll thorougly dissect your little script you did for me, without bothering you now with dumb questions, but I'll thank you again in some days when it'll be working in my script (and I'll publish it, with your code in it, in order to show you're work is deeply appreciated).

Thank you again, at this time, without you here, AI wouldn't be but a quarter of what it is with you on board!

Edited by Newtoai

Share this post


Link to post
Share on other sites

To Jos,

Thank you very much, 3 minutes for answering. But since I said I don't know yet how to do menus, in fact I don't know the GUI functions yet - of course I need to make acquaintance with them in the end!

That is why we have a nice helpfile with many examples... but Melba23 still needed to "finger exercising" today so he coded for you.

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Jos,

You're certainly an advanced programmer, so you understand all those help file details, since you have the "great picture" in order to position those bits in context and in perspective; I haven't got that general knowledge yet: how could I have. Thus, those descriptions and examples in the GUI part of the function reference, etc. ain't of that much practical use to a beginner. And thus, the little script of Melba23 - written in some 12 minutes, including reading my post: sheer incredible! - allows me for DIVING into these examples, having something SPECIFIC to compare with, and to better understand.

Thus, for beginners, it's always the problem that elaborate info, on their own, "naked", isn't useful yet to them, and in order to become useful for them, there has to be a little bit "pushing", a little bit SPECIFIC help, to overcome that barrier between basics and advanced subjects -

and I think, Melba23 did that for me - my script will show I have no intention just to put his script into mine, but I'll try to do something better suited to my needs, but by ingurgitating his specific material showing to me how to proceed.

That's invaluable, whereas your kind answer was lightning-fast before all. No pun intended, thank you, really, this forum is incredibly active and responsive, I've never seen such a thing, and I'm very thankful for this!

Share this post


Link to post
Share on other sites

Newtoai,

Thank you for your kind words, but there many others here who deserve such praise a great deal more than I do. ;)

You might find the excellent tutorials that you will find here and here give you the PUSH you feel you need to get started with AutoIt. :)

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

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