Jump to content

Delete text from .ini file using script


Solomon
 Share

Recommended Posts

Is there a way to get an .au3 script to remove a section of a line of text from an .ini file?

Im creating a script that will start my media player, play a certain playlist, and then load a .wav file occasionally. My media player - 1by1 - uses a .ini file to store settings, such as location, window size, etc. It also stores the name and the location of the last used file. When reopening, 1by1 will automatically move to this last played file. I can edit the .ini file manually, and remove these 2 "markers", and the player will revert to the last known location as being the directory it resides in. Knowing this, I can use the MouseClick function to open the playlist correctly.

However, if I use 1by1 in the meantie, to play music, the locations that the MouseClick's need to be clicking on alter.

I have the following script, that loads 1by1 and starts the playlist playing, assuming the markers mentioned earlier are missing.

Run("E:\1by1\1by1.exe")
MouseClick("left", 33, 123)
MouseClick("left", 52, 107)
MouseClick("left", 105, 135)
MouseClick("left", 314, 89)
MouseClick("left", 314, 89, 2)

I need to learn how to add a section to the script, previous to that mentioned, to remove the necessary lines from the .ini file, to restore 1by1 to its "virgin" state.

Ive looked on Google, but (strangely enough :o ) most of the results talk about editing the script itself, not using a script to edit a text file.

If anyone could point me in the direction of a website where I can learn how to do this, Id be most appreciative. B)

Link to comment
Share on other sites

why not just use the read line, write line functions?

[quote]If whenever you feel small, useless, offended, depressed, and just generally upset always remember......you were once the fastest and most vicious sperm out of hundreds of millions![/quote]

Link to comment
Share on other sites

why not just use the read line, write line functions?

Would they allow me to choose the line that I want to edit?

Ive got part of it working now. The values are being removed properly. What Im trying to do now is edit the X and Y aviz values automatically, so the 1by1 window is in the correct place. Below is a sample from the 1by1.ini file that Im trying to get edited.

[1by1]
window_x=12
window_y=15

and below is thew code from the script.

IniWrite("e:\1by1\1by1.ini", "1by1", "window_x" "1")
IniWrite("e:\1by1\1by1.ini", "1by1", "window_y" "1")

Im trying to get the script to write the X and Y values to both be 1, so the 1by1 window opens in the top left of the screen. When I run the script, though, I get the message "Error in expression".

IniWrite("e:\1by1\1by1.ini", "1by1", "window_x" "1")
IniWrite("e:\1by1\1by1.ini", "1by1", ^ERROR

Any thoughts on what Im doing wrong?

Link to comment
Share on other sites

IniWrite("e:\1by1\1by1.ini", "1by1", "window_x" "1")
IniWrite("e:\1by1\1by1.ini", "1by1", ^ERROR

Any thoughts on what Im doing wrong?

There is missing comma between "window_x" and "1""

IniWrite("e:\1by1\1by1.ini", "1by1", "window_x", "1")

And you should use value 0 instead of 1 for X,Y (left, top)

for opening window in the left top corner of the screen B)

Edited by Zedna
Link to comment
Share on other sites

There is missing comma between "window_x" and "1""

Thanks man! Thats so simple (kinda like me, apparently). :graduated:

IniWrite("e:\1by1\1by1.ini", "1by1", "window_x", "1")

And you should use value 0 instead of 1 for X,Y (left, top)

for opening window in the left top corner of the screen B)

Duly noted. Thanks. :o
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...