Page 1 of 1

EntryForm() - easy, custom InputBox, data entry forms

Posted: 13 Sep 2014, 09:07
by Coco
EntryForm()

Requires AHK v1.1+ OR v2.0-a053+


Syntax: ef := EntryForm( form, fields* )

Return Value: { "event": [ OK, Cancel, Close, Escape, Timeout ], "output": [ field1 , field2 ... ] }

Parameters: see Parameters

Example:

Code: Select all

#Include <EntryForm>

form := "
(Join`s C
-c 'EntryForm Test'                               ; window caption/title
-ico cmd.exe,0                                    ; window icon
x0 y0 w600                                        ; window position
fEntryForm_Callback                               ; callback function
)"

fields := [ "
(Join`s C
-p 'Single-line input field:'                      ; prompt
-d 'Default text'                                  ; default text
)", "
(Join`s C
-p 'Multi-line input field with select file/folder buttons:'
-fnt ';s10 cBlue,Consolas'
-tt 'A tooltip may be attached to the input field' ; tooltip
-fs 'm3,C:\Program Files\AutoHotkey'               ; select file button
-ds 'C:\,3,Select a folder:'                       ; select folder button
-Wrap +HScroll r5                                  ; standard options
)", "
(Join`s C
-p 'Password (customized prompt font):'
-fnt 's10 cRed;s10 Italic,Segoe UI'                 ; font
-cb 'Password must be atleast 8 chars <- Cuebanner' ; cuebanner
Password
)", "
(Join`s C
-p 'ComboBox:' *CB                                 ; ComboBox input field
-d 'Red||Blue|Yellow|Green|Orange|Purple'          ; use -d for control's text
)", "
(Join`s C
-p 'DropDownList:' *DDL                            ; DDL input field
-d 'Red|Blue|Yellow||Green|Orange|Purple'
)", "
(Join`s C
-p 'Choose item (uses ListBox control):' *LB       ; ListBox input field
-d 'Item 1|Item 2||Item 3|Item 4|Item 5|Item 6'
r3
)", "
(Join`s C
-p 'Set Date (uses DateTime control):' *DT         ; DateTime input field
)", "
(Join`s C
-p 'Input field with attached UpDown control:'
-ud 'Range1-20 Wrap'                               ; UpDown options
)" ]

EntryForm(form, fields*)
return

EntryForm_Callback(ef) {
	out := "Event: " . ef.event . "`n"
	for i, contents in ef.output
		out .= "`nField " . i . ": " . contents
	MsgBox %out%
}
Screenshot:

Image

Source: On GitHub

Re: EntryForm() - easy, custom InputBox, data entry forms

Posted: 13 Sep 2014, 10:48
by joedf
Very interesting! I must try it, I will post feedback when i can :D

Re: EntryForm() - easy, custom InputBox, data entry forms

Posted: 14 Sep 2014, 00:18
by Coco
joedf wrote:Very interesting! I must try it, I will post feedback when i can :D
Cool, this is a rewrite of a script (turned abandonware) I wrote a while back.

Re: EntryForm() - easy, custom InputBox, data entry forms

Posted: 17 Sep 2014, 02:34
by joedf
EntryForm() : InputBox with raindows :rainbow:

Re: EntryForm() - easy, custom InputBox, data entry forms

Posted: 19 Sep 2014, 12:12
by Coco
Update:
  • Added option to define a callback function
  • Added option to specify a different input field control other than an Edit control(default). The following controls are supported: ComboBox, DropDownList, ListBox and DateTime
  • Some changes here and there
Example script and screenshot updated in OP

Re: EntryForm() - easy, custom InputBox, data entry forms

Posted: 09 Nov 2014, 19:50
by mviens
Hi Coco,

I apologize for not testing this out until now. Everything is looking very good, especially compared to InputBoxEx.

However, using the provided example, I am finding one bug. The "File Select" icon does not execute. Everything else seems to be working as intended. Could you look at this? I did download the latest version from your GitHub page.

Mike V.

Re: EntryForm() - easy, custom InputBox, data entry forms

Posted: 09 Nov 2014, 20:08
by mviens
Here are some additional features that would be very useful:
  • Support for label and input control on same row, with all input controls left-aligned
  • Support for vertical scrolling if too many input controls are to be displayed (ie: maximum form height)
  • Support for radio buttons
  • Support for checkboxes
  • Support for UPPER, lower, numeric, alphanumeric, or regex input values
  • Support to dynamically add/delete rows of edit controls (via + button or - button).
  • Support for re-ordering of the input controls via up/down arrow buttons
  • Support for arrayed values
What I mean by "arrayed values" is have an input field have multiple input controls, such as:

Column 1: ________ Type: _________
Column 2: ________ Type: _________
Column 3: ________ Type: _________

Where "Column #:" and "Type:" are labels provided, and the first input control would be an edit, whereas the second would be a DDL. Obviously, this is just an example of what I would need, so supporting any input control type is desired here. Also, the # portion of the label should be auto-incremented.

For the return value(s) in the multi-input mode, instead of:

Code: Select all

out := {
    "event":  [ OK, Cancel, Close, Escape, Timeout ], // [string] either of these
    "output": [ field1, field2, ... ] // array containing the output of each input field
}
It would be something like:

Code: Select all

out := {
    "event":  [ OK, Cancel, Close, Escape, Timeout ], // [string] either of these
    "output": [ 
        "field1": {"name": "some value", "type": "a selected value"},
        "field2": {"name": "some other value", "type": "another selected value"},
        ... 
        ] // array containing the output of each input field
}
That way the output could be referenced like:

Code: Select all

output.field1.name
output.field1.type
Both the name and type variable names would need to be supplied in the config, so they should not be hard-coded.

Thank you so much for the great work you have already put into creating this. Know that it is definitely being used "out in the world".

Re: EntryForm() - easy, custom InputBox, data entry forms

Posted: 10 Nov 2014, 08:23
by Coco
mviens wrote:However, using the provided example, I am finding one bug. The "File Select" icon does not execute. Everything else seems to be working as intended. Could you look at this? I did download the latest version from your GitHub page.
Is it a problem w/ the icon or is the "File Select" dialog not showing up at all? If it's the former, it could be the dll and/or icon number w/c should be easy to fix(I only tested this on Win 7). Otherwise, for the latter, I could create separate branches for AHK v1.1+ and v2. I had to implement FileSelectFile/FileSelectFolder manually to support both AHK versions. Providing separate versions will reduce the code size and would possibly fix the issue while I try to fix it for the current version. I would still maintain the current version as the master branch though.
mviens wrote:
  • Support for label and input control on same row, with all input controls left-aligned
  • Support for vertical scrolling if too many input controls are to be displayed (ie: maximum form height)
  • Support for radio buttons
  • Support for checkboxes
  • Support for arrayed values
I'll see what I can come up with.
mviens wrote:Support for UPPER, lower, numeric, alphanumeric, or regex input values
(for the ones italicized)I believe common Edit control options are supported. What do you mean by regex input values? Restriction of input based on a RegEx pattern?

A possible solution for easy extensibility, is to provide an API so that users can extend the features the way they want it...

I'm also considering doing a HTML-based(using Shell.Explorer, just like AHK's installer) version, which should make dynamic layout more easier and should also solve the ScrollBar support. It could also support theming via CSS...

I'll be working on the issues first before I move forward with the new features as I don't want to smother up the code by altering lines here and there w/o having a clear direction moving forward. I appreciate your feedback and suggestions. Thank you.:)

Re: EntryForm() - easy, custom InputBox, data entry forms

Posted: 29 Mar 2016, 19:58
by mviens
Coco,

I guess replying 1.5 years later is better than never doing so... :shock: I would still love to see some improvements to this code and would be happy to volunteer my time and effort to help you build this up.

I have finally looked at the file select issue some more. The code is failing on the line that does the DllCall to "comdlg32". Here is the failing line:

Code: Select all

if !DllCall("comdlg32\" . ( InStr(opt, "S") ? "GetSaveFileName" : "GetOpenFileName" ), "Ptr", &OPENFILENAME) {
Because this never executes (or fails to execute properly), the code immediately returns, preventing anything else from happening. The dialog is never shown. This happens on Windows 7, Windows 8, Windows Server 2012 and Windows 10.