Jump to content
Sign in to follow this  
johnmcloud

[SOLVED] Number of lines in a EditBox?

Recommended Posts

johnmcloud

Hi guys, i have this script:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 248, 180)
$Edit = GUICtrlCreateEdit("", 8, 8, 233, 121)
$Button = GUICtrlCreateButton("Verify", 8, 136, 233, 33)
GUISetState(@SW_SHOW)

GUICtrlSetData($Edit, "Number of lines (0)" & @CRLF & "Test1" & @CRLF & "Test2")

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button
   $FinalList = StringSplit(GUICtrlRead($Edit), @CR)
   For $i = 2 To $FinalList[0]
    MsgBox(64, "Verify", $FinalList[$i])
   Next
EndSwitch
WEnd

I can't find a way for count the number of lines in a EditBox. I have see:

_FileCountLines()

FileReadLine

But i can't apply directy to a EditBox without write them on a file and then EditBox read it.

How to solve this?

Thanks ;)

Edited by johnmcloud

Share this post


Link to post
Share on other sites
water

Doesn't $FinalList[0] give you the number of lines? If not try to use

$FinalList = StringSplit(GUICtrlRead($Edit), @CR, 1)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
johnmcloud

Yes, but there is a problem:

How to write the number of files without losing the data. There is a way to write the first line of a editbox without lose Test1 e Test2?

Share this post


Link to post
Share on other sites
water

FileWrite("C:temptest.txt", $FinalList[1])?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
johnmcloud

I don't want to write on a file ;)

if I wanted to write to the file I used _FileCountLines()

The goal is:

1) GUICtrlSetData write the data ( Test1 e Test2 )

2) I'll read the value and check the number of line with $FinalList[0]

3) GUICtrlSetData write the number of files ( $FinalList[0] ) and the data ( Test1 e Test2 ) on the EditBox [That's the problem]

All this at startup of the GUI

Edited by johnmcloud

Share this post


Link to post
Share on other sites
johnmcloud

lol, i have the solution by myself:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 248, 180)
$Edit = GUICtrlCreateEdit("", 8, 8, 233, 121)
$Button = GUICtrlCreateButton("Verify", 8, 136, 233, 33)
GUISetState(@SW_SHOW)

$Test = "Test1" & @CRLF & "Test2" & @CRLF & "Test3" & @CRLF & "Test4"
GUICtrlSetData($Edit, $Test)
$FinalList = StringSplit(GUICtrlRead($Edit), @CR, 1)
GUICtrlSetData($Edit, "Number of lines ( " & $FinalList[0] & ")" & @CRLF & $Test)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button
   $FinalList = StringSplit(GUICtrlRead($Edit), @CR)
   For $i = 2 To $FinalList[0]
    MsgBox(64, "Verify", $FinalList[$i])
   Next
EndSwitch
WEnd

Thanks water for support ;)

Edited by johnmcloud

Share this post


Link to post
Share on other sites
UEZ

What about _GUICtrlEdit_GetLineCount() function?

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Similar Content

    • vin1
      By vin1
      i have a script that let you type text then give a random result on an output box, writes the result on a text file and tries to add the result text to an edit box but doesn't support multiple lines. I want the script to add lines of results on the edit box (as a log of results)
      #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <File.au3> #include <Date.au3> Global $result1s[3]=["one", "two", "three"] _Main() Func _Main() Local $button1 Local $output, $die, $msg, $results1 Local $file = FileOpen("test.txt", 1) Local $g_idEdit GUICreate("test", 600, 400, -1, -1) $button1 = GUICtrlCreateButton("Result", 432, 350, 80, 40) $sText = $results1 $edit = GUICtrlCreateEdit($sText & @CRLF & $sText & @CRLF & $sText, 60, 50, 450, 300, BitOr($GUI_SS_DEFAULT_EDIT, $ES_READONLY)) $output1 = GUICtrlCreateInput("", 60, 30, 450, 20, BitOR($ES_CENTER, $ES_READONLY)) $g_idEdit = GUICtrlCreateEdit("", 60, 10, 450, 20, $SS_LEFT) $die = GUICtrlCreateLabel("", 700, 500, 700, 20, $SS_SUNKEN) GUICtrlSetFont($output, 8, 800, "", "Verdana") GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $button1 $results1 = Random(1, 2, 1) GUICtrlSetData($output1, $result1s[$results1]) GUICtrlSetData($edit, $result1s[$results1]) $read1 = GUICtrlRead($output1) FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &GUICtrlRead($g_idEdit)) FileWriteLine($file, _NowDate()& " " & _nowTime() & " " &$read1) EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc ;==>_Main  
       

    • aiter
      By aiter
      I am trying to get an image showing through a edit box.  I am only successful in making the edit box totally transparent
      #include-once #include <GUIConstants.au3> #include <GDIPlus.au3> #include <WinAPISys.au3> #include <colorconstants.au3> ;WS_EX_TRANSPARENT $gui = GUICreate("", 1000, 800, -1, -1, -1 , $WS_EX_LAYERED) ; use layered to get _winapi_setlay... to work $pic = GUICtrlCreatePic("c:\Program Files (x86)\AutoIt3\Examples\GUI\Merlin.gif", 0,0,1000, 800) GUICtrlSetState(-1, $GUI_DISABLE) $edit = GUICtrlCreateEdit("First line" & @CRLF, 176, 32,200,600) GUICtrlSetBkColor(-1,$COLOR_YELLOW) _WinAPI_SetLayeredWindowAttributes($gui,$COLOR_YELLOW,199) ; 199 is alpha (transparency level) GUISetState(@SW_SHOW,$gui) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else EndSelect WEnd Exit Func Terminate() exit(0) EndFunc So I am making the edit box's background yellow then using the _WINAPI_SetLayeredWIndowAttributes command to make the yellow disappear (which it does), but the alpha level is supposed to give a bit of opaqueness to it, but its not, just making it totally transparent.  The alpha level is in fact affecting the window itself and not the edit box. I only want the edit box to be partially transparent.
      Help appreciated.
       
    • hcI
      By hcI
      Hello everyone !
      I'm making a little password generator with save function.
      And i would like to set a line limit at 25.
      For my script, the user have to enter a name in "$input1" and click on the button "$btn_save" to display it in the editbox "$edit1".
      The user can't edit himself because the edit box have $ES_READONLY
      If someone know how, Thanks you !
       
      PS: I've already looked in the help and didn't find anything..
    • olmanRvr
      By olmanRvr
      I want to show or hide a edit control depending if a radio button is checked or not.The following Autoit code appears semantically ok but not working.Can anyone please help?
      thanks
      olmar
      While 1 $nMsg = GUIGetMsg() $isradioChk=GUICtrlRead($radio_AbsP);checked=1,not checked=4 Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $isradioChk If $isradioChk<==1 Then GUICtrlSetState($edit_AbsP,$GUI_SHOW) GUICtrlSetState($edit_RelP,$GUI_HIDE) Else GUICtrlSetState($edit_AbsP,$GUI_HIDE) GUICtrlSetState($edit_RelP,$GUI_SHOW) EndIf Case $usrPrefs EndSwitch WEnd  
    • ssah8
      By ssah8
      So im creating a bot that logs in on a website. The website got a dropdown menu, and I have to choose the right one to login (Student)
      #include <IE.au3>
      #inculude <Inet.au3>
      $oIE = _IECreate("https://sms14.schoolsoft.se/engelska/jsp/Login.jsp?eventMessage=ERR_Not_Logged_In")
      $Name = _IEGetObjByName($oIE, "ssusername")
      $Pass = _IEGetObjByName($oIE, "sspassword")
      $dropdown = _IEGetObjByName($oIE, "usertype")
      _IEPropertySet($Name, 'innerText', 'censored')
      _IEPropertySet($Pass, 'innerText', 'censored')
      _IEPropertySet($dropdown, 'innerText', 'Student') <------ How do I make the dropdown list select "Student"?
       
      Website: https://sms14.schoolsoft.se/engelska/jsp/Login.jsp?eventMessage=ERR_Not_Logged_In
×