Jump to content

Controlls 4 .txt//How do arrays work?


Recommended Posts

Today I tryed to learn using controll commands with handle, and classname.

There is a File I need to open(Serverlist.cs) is need to open and replace a string in line 41 column 47 (stringlengh=10) string="RunUO TC"

Until now the script doesnt work, it sends the right string,. but it does not,.. find,.. edit or mark in anyway the string it need to find!!

IS THERE ANY OPTION TO REPLACE??

Motivation: i´d like to change much more .cs with notepad(or in an atherway) currently

Is there any Option to Replace strings or Edit files like this without opening them?

(I tryed it with fileread/filewriteline, Stringreplace,Stringregexpreplace)

The Script looks like this:

$b=@ComputerName&"-Server"

$a=@ProgramFilesDir&"\Spiele\UltimaOnline\"&$b

$a1="ServerList.cs";["using System;"]

;;;(This should be an array,. but i dont know how to define and work with);;;

run("notepad.exe "&$a1,$a&"\scripts\misc\",@SW_MAXIMIZE)

WinWaitActive($a1,"using System;")

$a2=ControlGetHandle($a1,"using System;","Edit1")

$a3=ControlCommand($a1,"using System;","[CLASS:Edit; INSTANCE:1]","Findstring",'"RunUO TC"')

MsgBox(1,"msgbox",$a3)

;(the msgbox ist just for seeing, what scrit does with$a3);

Perhaps you can find me? In deeply hope: Undead harlequin

ps.: I´m german,. I think the problems are some translatingmistakes in the german Hlpfile. But my english is worse(as you can probably see;-))

Perhaps you try to answer in a easy way,. just for blondes;-) Big Thanks

Lg Gabriel

RunUOServerPaket.au3

Link to comment
Share on other sites

Hmm now i found my mistakes:

controlcommand("title","text","controlid","SELECTSTRING","Runuo TC"

doesnt work becouse the Control is a notepad!!!???? "edit" not Listbox or Combobox

BUT i dont have eaven a answer wich i can understand;-)

4 Now it works with controlsend(i think,.. did not test it,. but it seams pure logik)

is there andy beter,. faster and more effectful option with same effect????

PLEAS HELP ME:-) thanks

Link to comment
Share on other sites

Hmm now i found my mistakes:

controlcommand("title","text","controlid","SELECTSTRING","Runuo TC"

doesnt work becouse the Control is a notepad!!!???? "edit" not Listbox or Combobox

BUT i dont have eaven a answer wich i can understand;-)

4 Now it works with controlsend(i think,.. did not test it,. but it seams pure logik)

is there andy beter,. faster and more effectful option with same effect????

PLEAS HELP ME:-) thanks

I'm sure I don't completely understand what you want to do, but it seems to involve manipulating a text file in Notepad? There is really no reason to involve Notepad. This can be done entirely in memory with no graphical display required.

1. Read the file into a string (or an array as dbzfanatic suggested)

2. Modify the string or array contents

3. Write the result back to a file (or the same file, if desired)

Automating editing tasks in the Notepad GUI can certainly be done, but that's the hard way.

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 2 weeks later...

I'm sure I don't completely understand what you want to do, but it seems to involve manipulating a text file in Notepad? There is really no reason to involve Notepad. This can be done entirely in memory with no graphical display required.

1. Read the file into a string (or an array as dbzfanatic suggested)

2. Modify the string or array contents

3. Write the result back to a file (or the same file, if desired)

Automating editing tasks in the Notepad GUI can certainly be done, but that's the hard way.

:)

Hrm, I did it this way:

CODE

For $count1=0 to 2

;$toward="{down}"

select

case $b[$count1][6]=true

run("notepad.exe "&$b[$count1][0],$b[$count1][8],@SW_HIDE)

WinWaitActive($b[$count1][0],$b[$count1][1])

For $arrayY=2 to 4

For $count2=0 to $b[$count1][$arrayY]

Controlsend($b[$count1][0],$b[$count1][1],$b[$count1][7],$twrd[$arrayY-2])

Select

;#cs Case $count2=$b[$count1][$arrayY] ContinueLoop

Select

case $arrayY=2

$toward="{right}"

case $arrayY=3

$toward="{del}"

;#ce

case $arrayY=4

ControlSend($b[$count1][0],$b[$count1][1],$b[$count1][7],$b[$count1][5],1)

;xEndSelect

EndSelect

Next

Next

EndSelect

Next

----------------------------

I´m not sure if this is faster, but the Files are so big!! to edit upload them as string,.. and editing them, i think this could use tomuch "active store?"

Or is it better in your way?

Edited by UndeadHarlequin
Link to comment
Share on other sites

Hi m8,

I've made this:

#Include <File.au3>

$file = FileOpenDialog("File to modify", "c:\", "CS File (*.cs)", 1)

$linetoread = FileReadLine($file, 47)
$modify = StringReplace($linetoread , "(stringlengh=10)", "RunUO TC")
_FileWriteToLine($file, 47, $modify, 1)

I hope it helps,

Cheers

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

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...