Evolutionnext Posted March 9, 2022 Share Posted March 9, 2022 I control my Autoit script with a handheld QR-code reader, that contains specific commands in the text. It enters these as one text string (like keyboard entry) and then presses ENTER. The problem I have is, that the text is longer than 256 characters, so InputBox truncates it. Is there a way to extend the limit or ose another form of entry, without having to enter fragments of the text separately (which the barcode reader can not do)? Link to comment Share on other sites More sharing options...
Musashi Posted March 9, 2022 Share Posted March 9, 2022 16 minutes ago, Evolutionnext said: The problem I have is, that the text is longer than 256 characters, so InputBox truncates it Does it have to be an InputBox, or would GUICtrlCreateInput also be possible ? "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Danyfirex Posted March 9, 2022 Share Posted March 9, 2022 You could probably use a custom inputbox here. Saludos Musashi 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
spudw2k Posted March 10, 2022 Share Posted March 10, 2022 I don't seem to have the 256 char limit; seems to be about 30000 characters. What version of AutoIt are you using? Are you able to post a reproducer script so we can take a look? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Musashi Posted March 10, 2022 Share Posted March 10, 2022 At least in version 3.3.14.0 , which I (still) use, characters will be truncated. Local $sAnswer = InputBox("Input :", "QR-Code-Reader :", "", "", 600, 150) ; String to paste : ;1111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222233333333333333333333333333333333333333333333333333444444444444444444444444444444444444444444444444445555555555555555555555555555555555555555555555555566666666666666666666666666666666666666666666666666777777777777777777777777777777777777777777777777778888888888888888888888888888888888888888888888888899999999999999999999999999999999999999999999999999 MsgBox(4096, "InputBox Result :", $sAnswer) ConsoleWrite($sAnswer & @CRLF) ConsoleWrite("Length Answer = " & StringLen($sAnswer) & @CRLF) "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
pixelsearch Posted March 10, 2022 Share Posted March 10, 2022 (edited) As just wrote Musashi, the resulting string returned by InputBox is truncated when too long. You can probably type thousands of characters in the InputBox (I pasted 50 times "1234567890 " which is 50*11 length because of the space I added to separate the blocks, so it was 550 characters typed) and they where all in the box when controlling them (ctrl + right key moved from one block to the other, stop at 49, manually controlled the last one was 50th) But look at the result after validation : So max returned seems to be 255 (not 256 as stipulated by OP or 254 as read in the help file) ConsoleWrite also indicates 255. Tested on AutoIt 3.3.14.5 & 3.3.16.0 ConsoleWrite(">> StringLen($sResult) = " & StringLen($sResult) & @crlf) >> StringLen($sResult) = 255 Edited March 10, 2022 by pixelsearch Musashi 1 Link to comment Share on other sites More sharing options...
Musashi Posted March 10, 2022 Share Posted March 10, 2022 43 minutes ago, pixelsearch said: So max returned seems to be 255 (not 256 as stipulated by OP or 254 as read in the help file) Yes, I can confirm that as well . Since you also tested it with the latest versions of AutoIt, I am a bit surprised that @spudw2k wrote : 5 hours ago, spudw2k said: I don't seem to have the 256 char limit; seems to be about 30000 characters. pixelsearch 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
pixelsearch Posted March 10, 2022 Share Posted March 10, 2022 Maybe he didn't test the return value, but only the fact he could paste much more than 255 in the box ? He'll tell us... maybe Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 10, 2022 Moderators Share Posted March 10, 2022 Hi, Have you tried using _GUICtrlEdit_SetLimitText to set a higher limit? An input control is just a single-line edit control. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
pixelsearch Posted March 10, 2022 Share Posted March 10, 2022 Hi M23, Great idea. Let me try that on an InputBox, especially I already tried it successfully since 2018 in an edit control in RegExpQuickTester (LazyCat + w0uter + mLipok for preventing CPU overheat) : ; 26 dec 2018 : replaced GUICtrlSendMsg($ebTest, $EM_LIMITTEXT, -1, 0) from 5 nov 2018, with _GUICtrlEdit_SetLimitText($ebTest, -1) ; GUICtrlSendMsg($ebTest, $EM_LIMITTEXT, -1, 0) ; added to allow unlimited text size in edit control : ini file won't store this control anymore, a separate txt file will. _GUICtrlEdit_SetLimitText($ebTest, -1) ; 26 dec 2018, seems better than precedent Link to comment Share on other sites More sharing options...
pixelsearch Posted March 10, 2022 Share Posted March 10, 2022 (edited) I tried M23's idea with no success : how to retrieve the InputBox handle when InputBox is a blocking function ? I couldn't use AdlibRegister for that reason. As _GUICtrlEdit_SetLimitText requires a Control ID/Handle, it didn't work for me. Maybe someone will have another idea, that would be great ! The solution is probably to forget InputBox and use an input control, as suggested in several preceding posts. Edited March 10, 2022 by pixelsearch Link to comment Share on other sites More sharing options...
Musashi Posted March 10, 2022 Share Posted March 10, 2022 16 minutes ago, pixelsearch said: I tried M23's idea with no success : how to retrieve the InputBox handle when InputBox is a blocking function ? I couldn't use AdlibRegister for that reason. As _GUICtrlEdit_SetLimitText requires a Control ID/Handle, it didn't work for me. Maybe someone will have another idea, that would be great ! The solution is probably to forget InputBox and use an input control, as suggested in several preceding posts. I came to the same conclusion but was not brave enough to write it . With controls like GUICtrlCreateInput you have a handle/controlID and can use _GUICtrlEdit_SetLimitText without problems. With InputBox this corresponding access is missing (but I don't want to exclude that experts know a workaround for this). "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
pixelsearch Posted March 10, 2022 Share Posted March 10, 2022 (edited) Martin's script looks very interesting to check "live" what's currently being typed inside InputBox That guy often delivers nice scripts... well, that's the reason why they are MVPs Edited March 10, 2022 by pixelsearch typo Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 10, 2022 Moderators Share Posted March 10, 2022 Hi, Quote I came to the same conclusion but was not brave enough to write it Do not be afraid to say something in these cases - I am neither omniscient nor prone to retaliation! M23 Musashi and pixelsearch 1 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
pixelsearch Posted March 10, 2022 Share Posted March 10, 2022 (edited) Based on Martin's script, 330 char's returned, but well... not sure it's worthwhile to complicate it like this, when a simple input control would do it without timers & the whole register gang : ; Based on Martin's script : ; https://www.autoitscript.com/forum/topic/71070-inputbox-tecting-changes/?tab=comments#comment-520293 Global $answer2 Local $handle = DllCallbackRegister("_ReadIPBox", "int", "") Local $SetTimer = DllCall("User32.dll", "int", "SetTimer", _ "hwnd", 0, "int", 0, "int", 500, "ptr", DllCallbackGetPtr($handle))[0] Local $answer = InputBox("Question", "Where were you born?", "Planet Earth") DllCallbackFree($handle) DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $SetTimer) MsgBox(0, "InputBox 'fake return' (len = " & StringLen($answer2) & ")", $answer2) ;================ Func _ReadIPBox() If WinExists("Question") Then $answer2 = ControlCommand("Question","Where were you born?","Edit1","GetLine", 1) ; ConsoleWrite($answer2 & @CRLF) EndIf EndFunc Edited March 10, 2022 by pixelsearch Link to comment Share on other sites More sharing options...
Nine Posted March 10, 2022 Share Posted March 10, 2022 Here another way to interact with an input box : #include <WinAPISys.au3> #include <GuiEdit.au3> #include <WinAPIConstants.au3> #include <WinAPIProc.au3> Example() Func Example() Local $hProc = DllCallbackRegister(CbtHookProc, "int", "int;int;int") Global $hHook = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hProc), 0, _WinAPI_GetCurrentThreadId()) Local $iRet = InputBox("Test", "Test") ConsoleWrite(StringLen($iRet) & @CRLF) _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hProc) EndFunc ;==>Example Func CbtHookProc($nCode, $wParam, $lParam) If $nCode = 5 Then ; 5=HCBT_ACTIVATE $hWnd = HWnd($wParam) ControlSetText($hWnd, "", "Static1", "Cooler stuff here") ControlSetText($hWnd, "", "Button1", "Alright now") ControlSetText($hWnd, "", "Button2", "Forget it !") $hCtrl = ControlGetHandle($hWnd, "", "Edit1") ConsoleWrite($hWnd & "/" & $hCtrl & @CRLF) _GUICtrlEdit_SetLimitText($hCtrl, 500) ; does not work EndIf Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc ;==>CbtHookProc As you can see, we can modify pretty much everything we want, except the text limit (although the informations are exact as per au3info ). Which makes me say, that AutoIt truncates it to 255 characters (maybe because of its buffer size). It is in fact 256 (not 255) because you need to have a chr(0) at the end. pixelsearch and Musashi 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
pixelsearch Posted March 10, 2022 Share Posted March 10, 2022 (edited) That's impressive, bravo Nine I've never been "hooked" on this hook chain (it seems complicated !) but see how it allows to do great things in your script. I really should try it on some personal examples. If I got it right, it's not Jon's limitation, but that limitation of 255 chars seem to come directly from Microsoft InputBox, see what their link indicates concerning InputBox : The text box accepts only 255 characters. The return string is truncated to 254 characters Strange MS indicates 254 characters too, when all tests return 255 valid chars (as in my very 1st pic far above) Edited March 10, 2022 by pixelsearch Link to comment Share on other sites More sharing options...
Nine Posted March 10, 2022 Share Posted March 10, 2022 (edited) Yes you are right, that is a MS limitation (sorry AutoIt). Hooks are quite fun. You can achieve many things very elegantly since it based on event notifications. In fact, I just tested another way, very cool result (using your previous idea) Func CbtHookProc($nCode, $wParam, $lParam) If $nCode = 5 Then ; 5=HCBT_ACTIVATE $hWnd = HWnd($wParam) ControlSetText($hWnd, "", "Static1", "Cooler stuff here") ControlSetText($hWnd, "", "Button1", "Alright now") ControlSetText($hWnd, "", "Button2", "Forget it !") $hCtrl = ControlGetHandle($hWnd, "", "Edit1") ConsoleWrite($hWnd & "/" & $hCtrl & @CRLF) _GUICtrlEdit_SetLimitText($hCtrl, 500) ; does not work ElseIf $nCode = 4 Then ; HCBT_DESTROYWND $hWnd = HWnd($wParam) ConsoleWrite(StringLen(ControlGetText($hWnd, "" ,"Edit1")) & @CRLF) ; works perfect when user clicks OK EndIf Return _WinAPI_CallNextHookEx($hHook, $nCode, $wParam, $lParam) EndFunc ;==>CbtHookProc Edited March 10, 2022 by Nine Danyfirex 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
pixelsearch Posted March 10, 2022 Share Posted March 10, 2022 I added 2 lines ElseIf $nCode = 0 And @WDAY = 5 Then Return 1 ; no move/resize on Thursday's Link to comment Share on other sites More sharing options...
spudw2k Posted March 11, 2022 Share Posted March 11, 2022 18 hours ago, pixelsearch said: Maybe he didn't test the return value, but only the fact he could paste much more than 255 in the box ? He'll tell us... maybe Ah, yes. I assumed the limitation with filling the edit control. The result is indeed truncated to 255 characters. Interesting behavior. ControlGetText and _GUICTrlEdit_GetText seem to work fine. I wonder what method is being used to return the value. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now