Jump to content
Sign in to follow this  
bartekd

Gui Control Edit loop by line

Recommended Posts

bartekd

OK, so I am creating a psexec gui from scratch (I know there are a couple on this forum, but i want to create my own). as you probably know, you can make the script reference a computers.txt file and run it against those computers. This is what I wanted to do instead

Create a gui control edit so I can put the list of computers in this edit and it will run one at a time. (I can use the runwait command and put the full command line for PSEXEC for each computer name)

I already have created teh GUI that has a Input box that I use for one computer. But instead I would prefer to use a Edit and run it for multiple computers on just one depending on how many lines are in the edit.

I have looked at the help file and was thinking of creating an array that is created from the data in the edit. Then I would loop from this array and for each computer.

If any one has a way to do this, or any suggestions, please let me know.

thanks in advance

Share this post


Link to post
Share on other sites
CodyBarrett

_GUICtrlEdit_GetLineCount

Share this post


Link to post
Share on other sites
bartekd

thanks, but now how do i loop each line of the edit?

Share this post


Link to post
Share on other sites
CodyBarrett

this is just for the edit control.. im not sure what you want with the other copmuters...

$i1=_GUICtrlEdit_GetLineCount ($EDIT)
For $i2=1 to $i1[0]
  $i1[$i2] = 'example' 
   ;sets EACH line to 'example'
   ;or do whatever you need to do in the loop
  guictrlsetdata ($EDIT, $i1[$i2])
next

Share this post


Link to post
Share on other sites
bartekd

gives me the following error

=> Subscript used with non-Array variable.:

For $i2=1 to $i1[0]

For $i2=1 to $i1^ ERROR

Share this post


Link to post
Share on other sites
bartekd

In the loop, what I want to do is this. What is written on the line, I want to make a variable = that line.

For example if in the edit this is what is there.

WK001

WK002

WK003

WK004

First it will do the first line. So $Computername = 'WK001'

after that, it will go to the next line, where $Computername = 'WK002'

ETC...

See what I mean?

Share this post


Link to post
Share on other sites
CodyBarrett

#Include <GuiEdit.au3>
#Include <String.au3>
$i1 = Stringsplit ($EDIT, @CRLF) ;this splits up the edit into EACH line.. and all you have to do is $i1[1] = 'something' (this is the FIRST line...)
For $i2=1 to $i1[0]   
 msgbox (0, '',  _GUICtrlEdit_GetLine($EDIT, $i1[$i2]))
nextoÝ÷ ÚÚò¶­9®¶­sb4æ6ÇVFRfÇCµ7G&æræS2fwC°¢b33c¶Ò7G&æw7ÆBb33c´TDBÂ5$Äb·F27ÆG2WFRVFBçFòT4ÆæRââæBÆÂ÷RfRFòFò2b33c¶³ÒÒb33·6öÖWFærb33²F22FRd%5BÆæRâââ¤f÷"b33c¶#ÓFòb33c¶³Ò¢×6v&÷Âb33²b33²Âb33c¶²b33c¶%Ò¦æW@

Edited by CodyBarrett

Share this post


Link to post
Share on other sites
bartekd

Nice, that almost works. There are 2 things, I had to put GUICtrlRead($EDIT1) otherwise it didn't return any data. also, for some reason even though there are more then one line in the edit, it just returns the first line, over and over again.

Share this post


Link to post
Share on other sites
CodyBarrett

#Include <String.au3>
#Include <array.au3>
$EDIT=guictrlread ($iedit)
$i1 = Stringsplit ($EDIT, @CRLF)
_arraydisplay ($i1)
For $i2=1 to $i1[0]   
 msgbox (0, '', $i1[$i2]))
next

try this ^.it might be the @CRLF ... mayeb replace it with @CR or @LF...

Share this post


Link to post
Share on other sites
bartekd

Almost perfect. the only issue now is there is a extra enter between each space.

For exmple my edit is

wk001

wk002

wk003

and the array shows

wk001

wk002

wk003

and the msg box would be,

'wk001'

''

'wk002'

''

'wk003'

''

etc, you know why that would be?

Share this post


Link to post
Share on other sites
bartekd

actually, you were right, instead of using @crlf, use either @cr or @lf. Thanks allot for your help, its much appreciated.

Share this post


Link to post
Share on other sites
CodyBarrett

Share this post


Link to post
Share on other sites
bartekd

I have one small issue. The script isn't working if I am doing it for multiple computers that I am pulling from the log file. So instead of a msg box, i outputed the results of the computer name to a txt file. What I see is a small little square next to each of the computer names (each line in the edit) except for the last line. What I suspect is that each enter is putting something after the computer name.

Any ideas on how to remove this?

Share this post


Link to post
Share on other sites
bartekd

Nevermind, I figured it out.

For each line, I just replaced @crlf, @cr and @lf with "". That seems to work.

$StationNow = $i1[$i2]

$StationNow = StringReplace($StationNow, @CRLF,"")

$StationNow = StringReplace($StationNow, @CR,"")

$StationNow = StringReplace($StationNow, @LF,"")

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.