Jump to content

Write to ini from textbox/ then recall info


Recommended Posts

ok noob here again. After reading the help file, searching the forums, and using the autoit 123. I am trying to write to ini file.

I want to create a box.

Have the user enter mouseclick cords.

write those values to a ini file .

then when they are using the program recall those cords from the ini file.

ex:

$answer = InputBox("Word Writer", "Please use the window info to find the location of box 1a. Enter those here", "", "", _

-1, -1, 0, 0, IniWrite("C:\Users\Main\Desktop\ESB\windowinfo.ini", "",))

IniWrite("C:\Users\Main\Desktop\ESB\windoinfo.ini", "",) :(

then recall the info as needed

ie:

MouseClick("left",info from ini file here,1) :mellow:

hope this makes sense.

thx

cue

Link to comment
Share on other sites

You are using incorrectly InputBox, IniRead and IniWrite.

Please read about these and pay attention to the number of parameters.

$answer = InputBox("Word Writer", "Please use the window info to find the location of box 1a. Enter those here", "", "",-1, -1, 0, 0)
IniWrite("C:\Users\Main\Desktop\ESB\windowinfo.ini", "SectionNameHere","keyNameHere", $answer)

To read the info:

IniRead("C:\Users\Main\Desktop\ESB\windowinfo.ini", "SectionNameHere", "keyNameHere", "")

Pay attention to whatever is written in the help file under these functions.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

This, http://www.autoitscript.com/forum/index.php?showtopic=110880, does similar to what you're wanting to do I think. Take a look at it to see if it would help and if any questions arise, ask away.

Edited by snowmaker

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

ok i see what you are saying, but my question is, How do i get it from the inputbox to the ini file?

I have read it a few times, I see where to write it to an ini from a textbox, or inputbox.

I kind of understand about the mouseclick part. But it is the begining of it i am confused on.

I'm not ask it for being written for me, just where to find additional examples. Cant learn by having others do it for e =)

Thx again

Cue

Link to comment
Share on other sites

To read the info:

IniRead("C:\Users\Main\Desktop\ESB\windowinfo.ini", "SectionNameHere", "keyNameHere", "")

Pay attention to whatever is written in the help file under these functions.

ok but how do i get that info entered into MouseClick("left",THIS PART HERE,1)

again look through the help files, and my brain doesnt seem to be working correctly.

Would apprecieate any help with examples, or where to find the info.

Thx again

Cue

Link to comment
Share on other sites

Post #2, by enaiman, is a pretty good example how to get $answer to a .ini file.

Edit: I think I see where you're stuck, hold on and I'll post a .ini file that my script reads, that'll help you I think..

Another Edit:

[Value]
Traditional, Freight Train Tabs, Chords, Lyrics - Mozilla Firefox=701,134,199,377

This is a snip from mousetrap.ini. 199,377 are the [0] and [1] parameters (x,y position) returned from WinGetPos. IniReadSection gets that info from the ini file.

Edited by snowmaker

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

ok here is what i have

first section

$answer = InputBox("Word Writer", "Please use the window info to find the location of box 1a. Enter those here", "", "",-1, -1, 0, 0)

IniWrite("C:\Users\Main\Desktop\ESB\windowinfo.ini", "Box1","Account#", $answer)

local $Box1

$Box1 = IniRead( "C:\Users\Main\Desktop\ESB\windowinfo.ini", "Box1","Account#")

MouseClick("left", $Box1, 1)

where as a normal mouseclick would look like:

MouseClick("left", 927,296, 1)

i want it to move to the correct window position to where the account# goes. the screen position would be 927,296. But i want it to read the position from the ini file, and that is where i am stuck. Reason: it changes on each screen. so it will move the mouse to the right position and then left click on it. And i have not been able to figure it out :(

Any ideas or help would be appreciated. Thx

Cue

Edited by cueclub
Link to comment
Share on other sites

looked at it, and i dont see where it would help in this situation.

Maybe it cant be done. edit: and if it cant there is no point in me moving forward with the rest of this.

trying to get the "Key" from an ini section inputed to a mouseclick command as cords.

lemme try again.

$acct1 = IniRead( "C:\Users\Main\Desktop\ESB\windowinfo.ini", "Box1","Account#")

MouseClick("left", $acct1, 1)

is the code i have written. In the mouse click line where " $acct1" is I want it to pull the key" account# out of the ini

but in this case the KEY is a set of window positions.

I have tried a few different things, and have yet to find a solution.

Edited by cueclub
Link to comment
Share on other sites

ok here is what i have tried now :

$var = IniRead("C:\Users\Main\Desktop\ESB\windowinfo.ini", "Box 1","Account #", default)

MsgBox(4096, "", "Key: " & $var )

and it gives me the correct # I am looking for. which is 222,214

so.... I tried to do it like this:

$var = IniRead("C:\Users\Main\Desktop\ESB\windowinfo.ini", "Box 1","Account #", default)

Mouseclick("left", & $var, 1)

and it gives me this:

C:\Users\Main\Desktop\ESB\test code.au3 (13) : ==> Error in expression.:

MouseClick( "left", & $var)

MouseClick( "left", ^ ERROR

>Exit code: 1 Time: 0.219

SO...... back to doing this :):(

Link to comment
Share on other sites

Don't need the & before $var in MouseClick( "left", & $var)

Edit:

I got this to work with MouseMove, it'll probably work with MouseClick too.

$var = "100,100"
$array = StringSplit($var, ",")
MouseMove($array[1], $array[2])
Edited by snowmaker

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

Edit:

I got this to work with MouseMove, it'll probably work with MouseClick too.

$var = "100,100"
$array = StringSplit($var, ",")
MouseMove($array[0], $array[1])

Tried this example, is it supposed to move the mouse all the way to the left of the screen?

And the same problem remains, how do i get the $var to read from an ini file?

note: I tried changing the $var in your example to "726,363" to point around the middle of my screen, Is that not what it's purpose is? When i had changed it, it still went all the way left but more towards the bottom.

And if i had not said so already snowmaker, thanks for your help and patience.

Cue

Link to comment
Share on other sites

I just chose 100,100 to see if would work, it moved my mouse cursor to the left too, but I was satisfied to see the cursor move instead of getting a syntax error. For reading try IniReadSection. See the help file for right syntax of it. As far as help, I hope I'm not confusing you more, and I'm probably making this issue more difficult as I'm not much of a coder.. I'm about to head out the door to get a radiator for my car, good luck, somebody else will jump in I'm sure to help you out.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

thanks again, i tried the inireadsection before, and it would not give me the exact key, just a list of everything in that section. so i moved back to iniread, seemed more direct for me. And like i said thanks for your help. This is my first time doing anything like this, as if no one can tell, but I am determined to make it work. lol

Thanks again, and if anyone else has any ideas please, please, please post them. I am willing to try ALMOST anything.

Cua

Link to comment
Share on other sites

How is your ini file set up currently, and what is your updated code?

it shouldn't be too hard to find a way to make it work.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

Here is a copy of my INI file:

[box 1]

B1 =721,363 < for starting box position cords ie :x/y

[info Box]

B2 =972,364 < box#2 starting poition cords

Name =Jane Doe << names have been changed to protect the innocent

Account# =4444325

Here is a copy of the code itself. well parts of it, the only part i am stuck on.

$answer1 = InputBox("ESB", "Please use the window info tool to find the location of box# 1. Enter those here ie: xxxx,xxx", "", "")

IniWrite("C:\Users\Main\Desktop\ESB\windowinfo.ini", "Box 1","B1", $answer)

so when i put the cords in lets say 721,363 it writes it to the ini as it should.

Now for the tricky part,

MouseClick("left",21,363,1)

Sleep(950)

is how it would lok , but i want to automate it

to lets say:

IniRead("C:\Users\Main\Desktop\ESB\windowinfo.ini", "Box 1","B1", $answer)

MouseClick("left", $answer, 1)

So all I am trying to do is get the answer from the ini key and put it in the mouseClick line without having to edit the script itself.

And since all of our computers are diff sizes then all i would have to do is enter some window cords in a box and be done with it. it would save them and call them up when being used. :(

This is the only place i am stuck, And it is prob something so easy that my 3 yr old could prob figure out lol.

Thanks for any help, sorry if i am repeating myself.

Cue aka Clueless

Link to comment
Share on other sites

maybe instead of trying to fit both coordinates into 1 key...

$answer1 = InputBox("ESB", "Please use the window info tool to find the X location of box# 1. Enter it here ie: xxxx", "", "")
IniWrite("C:\Users\Main\Desktop\ESB\windowinfo.ini", "Box 1","B1", $answer1)

$answer2 = InputBox("ESB", "Please use the window info tool to find the Y location of box# 1. Enter it here ie: xxxx", "", "")
IniWrite("C:\Users\Main\Desktop\ESB\windowinfo.ini", "Box 1","B2", $answer2)

$x=IniRead("C:\Users\Main\Desktop\ESB\windowinfo.ini", "Box 1","B1", $answer1)

$y=IniRead("C:\Users\Main\Desktop\ESB\windowinfo.ini", "Box 1","B2", $answer2)
MouseClick("left", $x,$y, 1)

I noticed a couple things, you first define the coordinates as $answer1, but then later try to call $answer

and

Assign a variable to your ini read, you will use this variable for your mouseclick.

010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Link to comment
Share on other sites

MouseClick("left", $answer, 1) won't work the way you want; this isntruction is equivalent to telling "click at $answer and 1" - your variable won't subsitute 2 parameters but only 1.

You have 2 ways of solving this:

- listen to kaotkbliss and store the values in 2 different keys

- don't use the value from the ini file directly but split it first

$answer = "500, 500"
$coords = StringSplit($answer, ",")
$x_coord = StringStripWS($coords[1], 8)
$y_coord = StringStripWS($coords[2], 8)
MouseClick("left", $x_coord, $y_coord, 1)

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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