The current inputbox allows for a default entry which can then be accepted or changed by the user, but that default string then is selected which means the user must first press Home or End or some arrow-key, before they can change that default string; otherwise, the default string vanishes.
Often, the user will need to do just some minor enhancements to the default string, e.g. just ADD something to it, but wants to preserve that string, and the need to press arrow/Home/End keys is a nuisance then.
I need this, again and again, for additions AFTER the string, but many users will probably need it for additions BEFORE the default string.
Since the default string is the LAST attribute of the inputbox command, it is easy to add another, also not obligatory attribute to the command, so this will not affect existing scripts.
I propose the following codes:
inputbox, ... , defaultstring, NEWdefaultstringprocesscode
attribute is absent or its value is 0: as before, i.e. the string is selected (with cursor at last position; for "completeness", "3" could mean "as before but cursor position 1", but real use cases would probably be inexistant)
1: string not selected, insertion-cursor at position 1, i.e. before the string
2: string not selected, insertion-cursor at last position, i.e. after the string
This way, for 1 and 2, additions could be entered right away, without taking your hands from the core keyboard keys, which currently is not possible yet.
Better Inputbox?
Re: Better Inputbox?
Try writing your own. Or change the following to your liking:
Code: Select all
Loop {
Answer := BetterInputBox(, "Prompt", "some text", Mod(A_Index, 2) - 1)
IfEqual, Answer, InputBoxCancel, Break
MsgBox, %Answer%
}
ExitApp
;-------------------------------------------------------------------------------
BetterInputBox(Title := "", Prompt := "", Default := "", Pos := -1) {
;-------------------------------------------------------------------------------
; Title is the title for the BetterInputBox GUI
; Prompt is the text that is displayed
; (optional) Default is shown in the edit control
; (optional) Pos is the position of the text insertion point
; Pos = 0 => at the start of the string
; Pos = 1 => after the first character of the string
; Pos = -1 => at the end of the string
;---------------------------------------------------------------------------
static Result ; used as a GUI control variable
; create GUI
Gui, BetterInputBox: New, +LastFound, %Title%
Gui, Color, CCFFCC
Gui, Margin, 30, 18
Gui, Add, Text,, %Prompt%
Gui, Add, Edit, w290 vResult hWndhResult, %Default%
Gui, Add, Button, x80 w80 Default, OK
Gui, Add, Button, x+m wp, Cancel
; main loop
Gui, Show
SendMessage, 0xB1, %Pos%, %Pos%,, ahk_id %hResult% ; EM_SETSEL
WinWaitClose
Return, Result
;-----------------------------------
; event handlers
;-----------------------------------
BetterInputBoxGuiClose: ; {Alt+F4} pressed, [X] clicked
BetterInputBoxGuiEscape: ; {Esc} pressed
BetterInputBoxButtonCancel: ; "Cancel" button
Result := "InputBoxCancel"
Gui, Destroy
Return
BetterInputBoxButtonOK: ; "OK" button
Gui, Submit ; get Result from GUI
Gui, Destroy
Return
}
Re: Better Inputbox?
I disagree, and I consider myself quite good at being lazy.Often, the user will need to do just some minor enhancements to the default string, e.g. just ADD something to it, but wants to preserve that string, and the need to press arrow/Home/End keys is a nuisance then.
If the script author decides that the cursor should start at the beginning or the end, anyone wishing to replace the whole text will need to select or delete it first, which takes more than a single key-press.
Wherever the author decides the caret should start, anyone wishing to modify the text at any other position will still need to move it.
Not true. That would break this script:Since the default string is the LAST attribute of the inputbox command, it is easy to add another, also not obligatory attribute to the command, so this will not affect existing scripts.
Code: Select all
InputBox, OutputVar, Title, Prompt, , , , , , , , Hello, world!
Who is online
Users browsing this forum: No registered users and 31 guests