Jump to content

Recommended Posts

Posted

Hey everyone

Can inputboxes (e.g. $string=inputbox(etc.)) be mutlined? If so, how do I make them?

If not, what would be the best input method for a user to enter a multilined string without the use of a GUI edit box?

Thanks :)

Posted

multilined string without the use of a GUI edit box?

just create a GUI with an edit :) There is no other way...

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted (edited)

InputBox can only have 254 characters. However the Inputbox is a normal GUI with GUICtrlCreateInput so no they can't be multilined (atleast not the input, the message can if you use @crlf)

But you can make a custom Inputbox with a GUICtrlCreateEdit instead and some buttons.

But since you said without editbox you can always use a file and read from it :)

Edit: damn Andy were faster

Edited by Pain
Posted

@aommaster

#Include <EditConstants.au3>

GuiCreate("GUI",400,400)
GuiCtrlCreateEdit("Edit",5,5,390,390,$ES_MULTILINE)
GuiSetState()

While 1
Sleep(250)
WEnd

Cheers, FireFox.

Posted

Hmm.. so would the best way be by creating a child window with a multiline edit box, and pass the variable back to the main program once the user has completed the input?

Posted (edited)

ClipGet

Doesn't suit my purpose, because the user has to input a custom set of lines that aren't copied from the clipboard Edited by aommaster
Posted

@aommaster

#Include <EditConstants.au3>

GuiCreate("GUI",400,400)
GuiCtrlCreateEdit("Edit",5,5,390,390,$ES_MULTILINE)
GuiSetState()

While 1
Sleep(250)
WEnd

Cheers, FireFox.

Hi Firefox!

Didn't see your reply until I posted mine. Thanks for your code :)

Posted

Doesn't suit my purpose, because the user has to input a custom set of lines that aren't copied from the clipboard

I have several scripts that prompt the user to enter data into a certain app - then either the user puts it into the clipboard or the script gets it from the edit control. It comes in handy if the info needs to retain formatting.

...but like you said - it might not work for your needs. You just really limited the options when you said no GUI :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Posted

...but like you said - it might not work for your needs. You just really limited the options when you said no GUI :-)

Yeah.. reason I wanted to avoid a GUI window is because this script is already running from a GUI, and because I'm not too comfortable with GUI coding just yes (I can only do the basic things such as define a control and make it do stuff, as well as read and write to it), I'm afraid that creating a child window would be a one way ticket to disaster :)

Oh well, here goes nothing... another new learning experience for me.

Thanks everyone!

Posted (edited)

This should work just like inputbox:

$sText = ''
For $i = 0 To 5000
    $sText &= Chr(Random(65, 90, 1))
Next
MsgBox(0, '', _MLInputBox("Testbox", "Test", $sText, 0, 800, -1, -1) & @error)
InputBox("t", "")
;===============================================================================
;
; Function Name:   _MLInputBox(
; Description::    Multiline Inputbox
; Parameter(s):    same as Inputbox, but without Psswordchar
; Requirement(s):
; Return Value(s): same as InputBox
; Author(s):       Oscar, Prog@ndy
;
;===============================================================================
;
Func _MLInputBox($title, $prompt, $Default = "", $width = 0, $height = 0, $left = Default, $top = Default, $timeOut = 0, $hWnd = 0)
    Local $OnEventMode = Opt('GUIOnEventMode', 0)
    Local $text = ""
    If $width < 400 Then $width = 400
    If $height < 330 Then $height = 330
    Local $widthAddition = $width-400
    Local $heightAddition = $height-330
    Local $error = 0
    Local $hGui = GUICreate($title, $width, $height, $left, $top, 0x00C00000+0x00080000,0,$hWnd)
    If @error Then
        $error = 3
    Else
        GUICtrlCreateLabel($prompt, 5, 5, 390, 90)
        If @error Then $error = 3
        Local $Edit = GUICtrlCreateEdit($Default, 5, 105, 390+$widthAddition, 190+$heightAddition)
        If @error Then $error = 3
        Local $hOK = GUICtrlCreateButton('&OK', 70, 300+$heightAddition, 80, 25)
        If @error Then $error = 3
        Local $htime = GUICtrlCreateLabel('', 170, 305+$heightAddition, 50, 20)
        If @error Then $error = 3
        Local $hCancel = GUICtrlCreateButton('&Cancel', 230, 300+$heightAddition, 80, 25)
        If @error Then $error = 3
        GUISetState(@SW_SHOW, $hGui)
        If @error Then $error = 3
        Local $timer = TimerInit(), $s1, $s2, $msg
        Do
            $msg = GUIGetMsg(1)
            If $msg[1] = $hGui Then
            Switch $msg[0]
                Case 0xFFFFFFFD, $hCancel ; 0xFFFFFFFD = $GUI_EVENT_CLOSE
                    $error = 1
                    ExitLoop
                Case $hOK
                    ExitLoop
            EndSwitch
            EndIf


            If $timeOut > 0 And TimerDiff($timer) >= $timeOut Then $error = 2
            $s1 = Round(($timeOut - TimerDiff($timer)) / 1000)
            If $timeOut And $s1 <> $s2 Then
                GUICtrlSetData($htime, $s1 & "s")
                $s2 = $s1
            EndIf
        Until $error

        If Not $error Then $text = GUICtrlRead($Edit)
        GUIDelete($hGui)
        Opt('GUIOnEventMode', $OnEventMode)
    EndIf
    SetError($error)
    Return $text
EndFunc   ;==>_MLInputBox
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...