XY16 Posted July 22, 2011 Posted July 22, 2011 hi guys, i have a bit of a problem. i need to collect input larger than 254 characters from an input box. as the autoit built-in inputbox() function doesn't do this, i've been looking for a replacement. i can't find one anywhere, so i am posting here to ask for help. i am unable to design one my self because i am fully blind and have serious trouble with gui's. so my question is, would someone be kind enough to post a script that accepts the title and text parameters of the normal inputbox function? i have no need for the other parameters. thanks in advance. Please note: If you plan on submitting any code snippits to my posts, please refrain from using the code tags as i use a screen reader and can't read the code properly, let alone copy it the way it should be.Thanks for your understanding.Best regardsXY16
sleepydvdr Posted July 22, 2011 Posted July 22, 2011 #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $inputBox = GUICreate("Input Box", 341, 164, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) $EditBox = GUICtrlCreateEdit("", 16, 32, 305, 89) GUICtrlSetData(-1, "") $OK = GUICtrlCreateButton("OK", 72, 128, 75, 25) $Cancel = GUICtrlCreateButton("Cancel", 185, 128, 71, 25) $Label1 = GUICtrlCreateLabel("Please enter your input below:", 16, 8, 305, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($inputBox) ExitLoop Case $OK $userInput = GUICtrlRead($EditBox) Results() ; This line just gives a messagebox repeating what you typed Case $Cancel GUIDelete($inputBox) ExitLoop EndSwitch WEnd Func Results() MsgBox(0, "Results", "Your input was: " & $userInput) EndFunc #include <ByteMe.au3>
XY16 Posted July 22, 2011 Author Posted July 22, 2011 thank you very much for your prompt response. i have tested the provided script and it works fine. i know this is a bit much to ask given your already provided help, but could you possibly post an updated version that accepts the title and text parameters please? thank you. Please note: If you plan on submitting any code snippits to my posts, please refrain from using the code tags as i use a screen reader and can't read the code properly, let alone copy it the way it should be.Thanks for your understanding.Best regardsXY16
XY16 Posted July 22, 2011 Author Posted July 22, 2011 i don't need the modifications made now, i did it my self. i only asked because i didn't think it'd be so simple, but looking through the code i was able to adjust it accordingly. thanks again. Please note: If you plan on submitting any code snippits to my posts, please refrain from using the code tags as i use a screen reader and can't read the code properly, let alone copy it the way it should be.Thanks for your understanding.Best regardsXY16
GEOSoft Posted July 22, 2011 Posted July 22, 2011 (edited) I see sleepydvdr is very busy today so I'll just jump in and change it to a function #Include <ButtonConstants.au3> #Include <EditConstants.au3> #Include <GUIConstantsEx.au3> #Include <StaticConstants.au3> #Include <WindowsConstants.au3> _InputBox("Input Box", "Please enter your input below:") Func _InputBox($str_Title, $str_Text) $inputBox = GUICreate($str_Title, 341, 164, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS)) $EditBox = GUICtrlCreateEdit("", 16, 32, 305, 89) GUICtrlSetData(-1, "") $OK = GUICtrlCreateButton("OK", 72, 128, 75, 25) $Cancel = GUICtrlCreateButton("Cancel", 185, 128, 71, 25) $Label1 = GUICtrlCreateLabel($str_Text, 16, 8, 305, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($inputBox) ExitLoop Case $OK $userInput = GUICtrlRead($EditBox) Results($userInput) ; This line just gives a messagebox repeating what you typed Case $Cancel GUIDelete($inputBox) ExitLoop EndSwitch WEnd EndFunc ;==>_InputBox Func Results($sInput) MsgBox(0, "Results", "Your input was: " & $sInput) EndFunc ;==>Results Edit: Too late again. Glad you got it fixed. Edited July 22, 2011 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
sleepydvdr Posted July 22, 2011 Posted July 22, 2011 Actually, I have been working on this. I have never made a #include before, so this is my first one. Download this file:Download Here If you cannot download it, let me know and I will post the code.The usage is simple: It accepts a title, a message and an input. All you have to do is download and unzip it and for each script #include it in your script. Here is an example of it in action:#include <NewInputBox.au3>$test = _NewInputBox("This is a test", "Enter something", "This is some default text I enter.")MsgBox(0, "", $test) #include <ByteMe.au3>
lansti Posted August 3, 2011 Posted August 3, 2011 Hi guys, lovely script... I want done some modifications expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $s_uDefault Func _NewInputBox($s_uTitle, $s_uPrompt, $s_uDefault, $s_init) $inputBox = GUICreate($s_uTitle, 341, 264, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) GUICtrlSetData(-1, "Input Box") $EditBox = GUICtrlCreateEdit($s_uDefault, 16, 132, 305, 89) [b]$init = GUICtrlCreateInput($s_init, 76, 90 ,100,20) [/b]$OK = GUICtrlCreateButton("OK", 72, 228, 75, 25) $Cancel = GUICtrlCreateButton("Cancel", 185, 228, 71, 25) $Label1 = GUICtrlCreateLabel($s_uPrompt, 16, 8, 305, 117) [b]$initialer = GUICtrlCreateLabel("Avsender: ", 16, 90, 100, 45) [/b] GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($inputBox) ExitLoop Case $OK $s_uDefault = GUICtrlRead($EditBox) [b]$s_init = GUICtrlRead($init)[/b] ;$s_uDefault = GUICtrlRead($initialer & $init & @LF & @LF & $EditBox) Return ($s_init & $s_uDefault) GUIDelete($inputBox) ExitLoop Case $Cancel GUIDelete($inputBox) ExitLoop EndSwitch WEnd EndFunc I have bolded out my modifications. What i need, is that a user should input their initials and a text, in two different inputboxes. When the click OK, i want the function to return the initials and the text. #include <NewInputBox.au3> $EnvVarUser = "" $Feilmelding = _NewInputBox("Send Error messages", "Whats wrong, please describe.", "", $Envvaruser) $s_FromAddress = $EnvVarUser & "@domain.com" It seems that my variable $EnvVarUser do not get what I do input in the function. How do i return both $s_uDefault and $s_init from function back to my application? Best regards
GEOSoft Posted August 3, 2011 Posted August 3, 2011 (edited) Is this in a separate function? If not then where are you "Returning to? Change that Return to a MsgBox (or if testing in SciTe you can use a ConsoleWrite) for testing to see if you have the correct data.EDIT:Punct error Edited August 3, 2011 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
lansti Posted August 4, 2011 Posted August 4, 2011 I have a support application where users can report a problem. Todays solution contains a lot of inputboxes, and if i can use 2 inputboxes in the same GUI, that returns it's values back to my support application. In this matter i need the values that users implement into: $EditBox = GUICtrlCreateEdit($s_uDefault, 16, 132, 305, 89) $init = GUICtrlCreateInput($s_init, 76, 90 ,100,20)
lansti Posted August 4, 2011 Posted August 4, 2011 Here is the part of the application that are using this function: expandcollapse popup;====================================================== $versjon = "7.5" ;====================================================== #Include <Constants.au3> #Include<file.au3> #include <ScreenCapture.au3> #NoTrayIcon Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Local $hBmp #Include<file.au3> ;====================================================== $MsgTitle = "Support " ;$EnvVarUser = EnvGet("USERNAME") $EnvVarUser = "" $EnvVarPC = EnvGet("COMPUTERNAME") $EnvProfAllUser = EnvGet("public") $EnvVarProgFiles = EnvGet("ProgramFiles(x86)") $s_FileError = "" $s_SmtpServer = "smtp.domain.com ; address for the smtp-server to use - REQUIRED $s_FromName = "" ; name from who the email was sent $s_ToAddress = "supportmail@domain.com" ; destination address of the email - REQUIRED $s_Subject = "Support mail" ; subject from the email - can be anything you want it to be $as_Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail $s_AttachFiles = "" ; the file you want to attach- leave blank if not needed $s_CcAddress = "" ; address for cc - leave blank if not needed $s_BccAddress = "" ; address for bcc - leave blank if not needed $s_Username = "******" ; username for the account used from where the mail gets sent - Optional (Needed for eg GMail) $s_Password = "********" ; password for the account used from where the mail gets sent - Optional (Needed for eg GMail) $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $CompCom = RegRead("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\lanmanserver\parameters", "srvcomment") TraySetIcon("AVID.ICO") TraySetToolTip("Version: " & $versjon) Opt("TrayMenuMode",1) ; Standard tray meny objekter (Script Paused/Exit) vises ikke. $FeilmeldingItem = TrayCreateItem("Send Feilmelding") TrayCreateItem("") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop ;===================================================================== ; Mail med Feilmelding ;===================================================================== Case $msg = $FeilmeldingItem #include <NewInputBox.au3> $Feilmelding = _NewInputBox("Send Error messages", "Whats wrong, please describe.", "", $Envvaruser) MsgBox(0, "", $EnvVarUser) ;$EnvVarUser = InputBox($MsgTitle, "Dine initialer?"& @LF & @LF, "Legg inn dine initialer slik at avid administrator ser hvem som sender meldingen", "",150,120) $s_FromAddress = $EnvVarUser & "@domain.com" ; address from where the mail should come $i = 0 $FW = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 78) $FH = DllCall("user32.dll", "int", "GetSystemMetrics", "int", 79) $ExtendedWidth = $FW[0] $ExtendedHeight = $FH[0] If FileExists(@TempDir & "SupportMail.jpg") Then FileDelete(@TempDir & "SupportMail.jpg") Do ;===================================================================== ;Print Screen 1(Left) ;===================================================================== If ($i = 0) Then $hBmp =_ScreenCapture_Capture("", 0, 0, @DesktopWidth, @DesktopHeight) $PicStamp = "Support_"& $i & "_" & $EnvVarPC & "_" & @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN & @SEC _ScreenCapture_SaveImage (@TempDir & $PicStamp & ".jpg", $hBmp) If FileExists(@TempDir & $PicStamp & ".jpg") Then $s_AttachFiles2 = (@TempDir & $PicStamp & ".jpg") Else $s_FileError = "NB: Skjermdump kunne ikke sendes som vedlegg fra " & $EnvVarPC & "!!" $s_AttachFiles2 = "" EndIf EndIf ;===================================================================== ;Print Screen 2(Right) ;===================================================================== If ($i = 1) Then $hBmp =_ScreenCapture_Capture("", @DesktopWidth, 0, $ExtendedWidth, $ExtendedHeight) $PicStamp = "Support_"& $i & "_" & $EnvVarPC & "_" & @YEAR & @MON & @MDAY & "_" & @HOUR & @MIN & @SEC _ScreenCapture_SaveImage (@TempDir & $PicStamp & ".jpg", $hBmp) If FileExists(@TempDir & $PicStamp & ".jpg") Then $s_AttachFiles3 = (@TempDir & $PicStamp & ".jpg") Else $s_FileError = "NB: Skjermdump kunne ikke sendes som vedlegg fra " & $EnvVarPC & "!!" $s_AttachFiles3 = "" EndIf EndIf $i = $i + 1 until $i=2 ;$EnvVarUser = InputBox($MsgTitle, "Dine initialer?"& @LF & @LF, "INITIALER", "",150,120) ;$Feilmelding = InputBox($MsgTitle, "Hva er galt? Skriv inn kort beskrivelse av feilen, evt. feilmeldingen:"& @LF & "(AVID eventlogg og skjermdump blir automatisk lagt til mailen)"& @LF & @LF & "Avsender: "& $EnvVarUser , "Feilen er at....", "",600,170) If @error Then Else $s_Subject = $Feilmelding $s_ToAddress = "supportmail@domain.com Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") If FileExists($EnvProfAllUser & "\public documents\" & $A_Type & "\FatalErrorReports\EVENTLOG.LOG") Then $s_AttachFiles1 = ($EnvProfAllUser & "\public documents\" & $A_Type & "\FatalErrorReports\EVENTLOG.LOG") ElseIf FileExists($LogFile) Then $s_AttachFiles1 = ($LogFile & ";") Else $s_FileError = "NB: EVENTLOG.LOG fantes ikke på " & $EnvVarPC & "!!" $s_AttachFiles1 = "" EndIf $s_AttachFiles = $s_AttachFiles1 & ";" & $s_AttachFiles2 & ";" & $s_AttachFiles3 $s_Subject = "Feilmelding fra redigeringsrom (" & $EnvVarPC & ")" $as_Body = "Feil på redigeringsrom!" & @LF & @LF & "Maskinnavn: " & $EnvVarPC & @LF & "Rom: " & $CompCom & @LF & @LF & "Feilbeskrivelse: "& $Feilmelding & @LF & @LF & "Hilsen" & @LF & $EnvVarUser &@LF &@LF & $s_FileError $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl) If @error Then MsgBox(0,$MsgTitle, "Feil ved sending av mail."& @LF &"Feilkode:" & @error & @LF &"Rc:" & $rc) EndIf EndIf ExitLoop EndSelect WEnd Exit And when you are using this function, you might see what i need. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $s_uDefault Func _NewInputBox($s_uTitle, $s_uPrompt, $s_uDefault, $s_init) $inputBox = GUICreate($s_uTitle, 341, 264, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) GUICtrlSetData(-1, "Input Box") $EditBox = GUICtrlCreateEdit($s_uDefault, 16, 132, 305, 89) $init = GUICtrlCreateInput($s_init, 76, 90 ,100,20) $OK = GUICtrlCreateButton("OK", 72, 228, 75, 25) $Cancel = GUICtrlCreateButton("Cancel", 185, 228, 71, 25) $Label1 = GUICtrlCreateLabel($s_uPrompt, 16, 8, 305, 117) $initialer = GUICtrlCreateLabel("Avsender: ", 16, 90, 100, 45) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($inputBox) ExitLoop Case $OK $s_uDefault = GUICtrlRead($EditBox) $s_init = GUICtrlRead($init) ;$s_uDefault = GUICtrlRead($initialer & $init & @LF & @LF & $EditBox) Return ($s_init) GUIDelete($inputBox) ExitLoop Case $Cancel GUIDelete($inputBox) ExitLoop EndSwitch WEnd EndFunc
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