Jump to content

Load all items from ListBox to file


Recommended Posts

hello I'm trying to move all listbox items to a file.

it works if there are few items.(~100 items)

if there are ~ 800 items, the result will be ~ 400-700 or 0

what am I doing wrong?

; Script Start - Add your code below here
#include <Constants.au3>
#include <Array.au3>
#include <GuiListBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

#RequireAdmin

$cHNW2 = WinActivate ("Symulacja NC")

 $cControlIDForti = ControlGetHandle($cHNW2, "" , "[CLASS:TListBox; INSTANCE:1]")

$cControlIDFortiCount = _GUICtrlListBox_GetCount($cControlIDForti) ; Items count in the ListBox
 MsgBox (0,"",$cControlIDFortiCount)

$file = FileOpen("E:\test.nc", 2)
For $i = 1 To $cControlIDFortiCount
      FileWrite($file, _GUICtrlListBox_GetText($cControlIDForti, $i))
      Filewrite($file,Chr(10)) 

Next

FileClose($file)

 

Link to comment
Share on other sites

_GUICtrlListBox_GetText is 0-based. And put some error handling in the loop.

For $i = 0 To $cControlIDFortiCount - 1
  $iRet = FileWrite($file, _GUICtrlListBox_GetText($cControlIDForti, $i) & @CRLF)
  ConsoleWrite ($i & " = " & $iRet & @CRLF)
Next

 

Link to comment
Share on other sites

...
810 = 1
811 = 1
812 = 1
813 = 1
>Exit code: 0    Time: 20.66

ok all lines loaded :)

I noticed that when I run the script in SciTe it works fine, but when I run the script from file MyScript.au3 or MyScript.exe then I don't get all the lines

Overall, that's enough for me, it's not a problem to turn on SciTe every time :)

Link to comment
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
 Share

  • Recently Browsing   0 members

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