Flemingjp Posted July 15, 2011 Share Posted July 15, 2011 Hello everyone one, I'm making a script that records the co-ordinates of different features of a program. It will ask the user to place a marker on the required area (Say a text field) and record the var into .txt file. Then when another script is ran, it reads these and understands where to click. I'd use the AutoIT Window Info, but this program is Java based so it doesn't work :L So any help recording and reading var's from a txt file My Txt file is structured like this; UserPos = (0,0) (There are tabs between to keep it structured yet it doesn't show) PassPos = (0,0) RunPos = (0,0) SearchPos = (0,0) This is so it is user-friendly so others can modify them if necessary. Thanks Flemingjp Link to comment Share on other sites More sharing options...
jaberwacky Posted July 16, 2011 Share Posted July 16, 2011 Look into using StringBetween and StringSplit along with the file read functions. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Flemingjp Posted July 16, 2011 Author Share Posted July 16, 2011 Some explaining would help. Im only new :L Link to comment Share on other sites More sharing options...
jaberwacky Posted July 16, 2011 Share Posted July 16, 2011 Post any code you may have so far please. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Flemingjp Posted July 16, 2011 Author Share Posted July 16, 2011 The test .txt has the number - 500 written in it. $file = FileOpen("test.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf If $file = 1 Then $line = FileReadLine($file,1) MouseMove($file,100,75) EndIf FileClose($file) I think it's because the txt file is read as a string not a variable. If so how do i change this? Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 (edited) #Include <String.au3> $file = FileOpen("test.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf If $file = 1 Then $line = FileReadLine($file,1) $x = _stringbetween($line,"(",",") $y = _stringbetween($line,",",")") MouseMove($x[0],$y[0],75) EndIf FileClose($file)But you can use an ini file for that.. is much easier.Next time be more user-friendly and post a working code with the a working txt file. EDITED: Sorry i change the code because i mistake with the return type from the function. Edited July 16, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
Flemingjp Posted July 16, 2011 Author Share Posted July 16, 2011 Okay, i've gotten this far; #Include <String.au3> $file = FileOpen("test.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf If $file = 1 Then $UserPos = FileReadLine($file,3) $UserPosX = _stringbetween($UserPos,"(",",") $UserPosY = _stringbetween($UserPos,",",")") MouseMove($UserPosX[0],$UserPosY[0],5) sleep(100) MouseClick("left") Sleep(100) Send("^a") sleep(100) Send("{BS}") $UserName = FileReadLine($file,1) Send($UserName) sleep(100) $PassPos = FileReadLine($file,4) $PassPosX = _stringbetween($PassPos,"(",",") $PassPosY = _stringbetween($PassPos,",",")") MouseMove($PassPosX[0],$PassPosY[0],5) EndIf I get this error >"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\Jimmy\Desktop\Demo\FileReadLine.au3" C:\Users\Jimmy\Desktop\Demo\FileReadLine.au3 (14) : ==> Subscript used with non-Array variable.: MouseMove($UserPosX[0],$UserPosY[0],5) MouseMove($UserPosX^ ERROR >Exit code: 1 Time: 0.345 Any reasons why? Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 There`s no exist in the line $UserPos any ( or , so the _stringbetween() function send an error and not create the array.. post test.txt Link to comment Share on other sites More sharing options...
Flemingjp Posted July 16, 2011 Author Share Posted July 16, 2011 Expand more, i dont really understand. Its the same, compared to what your wrote; $line = FileReadLine($file,1) Could you also expand on what an exist is. I haven't come across this before. Thanks Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 (edited) Maybe this will help you, i write this example using an ini file. expandcollapse popupHotKeySet("{F1}", "_w1") ;F1 HotKeySet("{F2}", "_w2") ;F2 HotKeySet("{F3}", "_w3") ;F3 HotKeySet("{F4}", "_w4") ;F4 HotKeySet("{F5}", "_w5") ;F5 HotKeySet("+{F1}", "_r1") ;SHIFT + F1 HotKeySet("+{F2}", "_r2") ;SHIFT + F2 HotKeySet("+{F3}", "_r3") ;SHIFT + F3 HotKeySet("+{F4}", "_r4") ;SHIFT + F4 HotKeySet("+{F5}", "_r5") ;SHIFT + F5 HotKeySet("{ESC}", "_exit") ;ESC = exit MsgBox(0, "INSTRUCTIONS", "Press from F1 to F5 keys to save the mousepoition," & @CRLF & "and press SHIFT + F1-F5 to move the mouse to the saved position" & @CRLF & "Press ESC to exit") While True Sleep(1000) WEnd Func _w1() IniWrite("test.ini", "MouseCoords", "X1", MouseGetPos(0)) IniWrite("test.ini", "MouseCoords", "Y1", MouseGetPos(1)) EndFunc ;==>_w1 Func _w2() IniWrite("test.ini", "MouseCoords", "X2", MouseGetPos(0)) IniWrite("test.ini", "MouseCoords", "Y2", MouseGetPos(1)) EndFunc ;==>_w2 Func _w3() IniWrite("test.ini", "MouseCoords", "X3", MouseGetPos(0)) IniWrite("test.ini", "MouseCoords", "Y3", MouseGetPos(1)) EndFunc ;==>_w3 Func _w4() IniWrite("test.ini", "MouseCoords", "X4", MouseGetPos(0)) IniWrite("test.ini", "MouseCoords", "Y4", MouseGetPos(1)) EndFunc ;==>_w4 Func _w5() IniWrite("test.ini", "MouseCoords", "X5", MouseGetPos(0)) IniWrite("test.ini", "MouseCoords", "Y5", MouseGetPos(1)) EndFunc ;==>_w5 Func _r1() Local $x = IniRead("test.ini", "MouseCoords", "X1", MouseGetPos(0)) Local $y = IniRead("test.ini", "MouseCoords", "Y1", MouseGetPos(1)) MouseMove($x, $y) EndFunc ;==>_r1 Func _r2() Local $x = IniRead("test.ini", "MouseCoords", "X2", MouseGetPos(0)) Local $y = IniRead("test.ini", "MouseCoords", "Y2", MouseGetPos(1)) MouseMove($x, $y) EndFunc ;==>_r2 Func _r3() Local $x = IniRead("test.ini", "MouseCoords", "X3", MouseGetPos(0)) Local $y = IniRead("test.ini", "MouseCoords", "Y3", MouseGetPos(1)) MouseMove($x, $y) EndFunc ;==>_r3 Func _r4() Local $x = IniRead("test.ini", "MouseCoords", "X4", MouseGetPos(0)) Local $y = IniRead("test.ini", "MouseCoords", "Y4", MouseGetPos(1)) MouseMove($x, $y) EndFunc ;==>_r4 Func _r5() Local $x = IniRead("test.ini", "MouseCoords", "X5", MouseGetPos(0)) Local $y = IniRead("test.ini", "MouseCoords", "Y5", MouseGetPos(1)) MouseMove($x, $y) EndFunc ;==>_r5 Func _exit() Local $Inifile = IniReadSection("test.ini", "MouseCoords") ConsoleWrite("test.ini" & @CRLF & "[MouseCoords]" & @CRLF) For $i = 0 To UBound($Inifile) - 1 For $m = 0 To UBound($Inifile, 2) - 1 If $m = 0 Then ConsoleWrite($Inifile[$i][$m] & "=") If $m = 1 Then ConsoleWrite($Inifile[$i][$m] & @CRLF) Next Next ; FileDelete("test.ini") Exit EndFunc ;==>_exit Run it. and ask me if you doesn`t understand something.. is much easier. Edited July 16, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
Flemingjp Posted July 16, 2011 Author Share Posted July 16, 2011 (edited) Couldi use other buttons as my F keys dont function well. Laptop uses them for brightness control, media keys ect. Edited July 16, 2011 by Flemingjp Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 Could you supply a ini. file please so i can see how it is constructedYou don`t need an ini file.. the iniFunctions create one if you dont have it. Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 (edited) Couldi use other buttons as my F keys dont function well. Laptop uses them for brightness control, media keys ect.You can change the hotkey by your self... instead of "{F1}" put "1" or wherever the key you want..keep the "+" this means SHIFT Edited July 16, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
Flemingjp Posted July 16, 2011 Author Share Posted July 16, 2011 (edited) Thank you, i really understand it now You information was outstanding and help remarkable. Thanks, A True Help ! I can now tweak it to suit exactly what i need. Thank you again EDIT: ? After running a modified version of your script, the co-ordinates were wrong. Before posting i checked yours and the same results. Why is this. My script expandcollapse popupHotKeySet("{ENTER}", "_w1") MsgBox(0, "INSTRUCTIONS", "1. Open RsBuddy (DON'T LOG IN)" & @CRLF & "2. Place Cursor Over The UserName Text Field" & @CRLF & "3. Press Enter And Then The Ok Button") Func _w1() IniWrite("test.ini", "UserPos", "X", MouseGetPos(0)) IniWrite("test.ini", "UserPos", "Y", MouseGetPos(1)) EndFunc ;==>_w Sleep(250) ;------------------------------------------------------------------------------- ;------------------------------------------------------------------------------- HotKeySet("{ENTER}", "_w2") MsgBox(0, "INSTRUCTIONS", "1. Now Place Cursor Over The Password Field Below" & @CRLF & "2. Press Enter And Then Ok") Func _w2() IniWrite("test.ini", "PassPos", "X", MouseGetPos(0)) IniWrite("test.ini", "PassPos", "Y", MouseGetPos(1)) EndFunc ;==>_w Sleep(250) ;------------------------------------------------------------------------------- ;------------------------------------------------------------------------------- HotKeySet("{ENTER}", "_w3") MsgBox(0, "INSTRUCTIONS", "1. Now Place Cursor Over The Login Button Below" & @CRLF & "2. Press Enter And Then Ok") Func _w3() IniWrite("test.ini", "LoginPos", "X", MouseGetPos(0)) IniWrite("test.ini", "LoginPos", "Y", MouseGetPos(1)) EndFunc ;==> Sleep(250) Edited July 16, 2011 by Flemingjp Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 Thank you, i really understand it now You information was outstanding and help remarkable. Thanks, A True Help ! I can now tweak it to suit exactly what i need. Thank you again You`re welcome.. and remind that the ini files can be edited by a normal text editor, you only need to keep the format and folow some rules, that are described in the iniwrite help from autoit. Link to comment Share on other sites More sharing options...
Flemingjp Posted July 16, 2011 Author Share Posted July 16, 2011 Im getting false co-ordinates See post edit above ^ Link to comment Share on other sites More sharing options...
jaberwacky Posted July 16, 2011 Share Posted July 16, 2011 From the rsbuddy website: "Let our advanced cheating software play RuneScape for you: Automation from the world's most experienced in-game human simulation software programmers." Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 ? After running a modified version of your script, the co-ordinates were wrong. Before posting i checked yours and the same results. Why is this.I try my script and works fine.. for example if i get the position when the mouse is in the upper left corner of the screen and open the test.ini with the notepad i see that the value is 0 and 0. i also try in the right bottom corner and it gives me the resolution of the screen. this is working fine. also i try with your script (making some changes).... My script expandcollapse popupHotKeySet("{ENTER}", "_w1") MsgBox(0, "INSTRUCTIONS", "1. Open RsBuddy (DON'T LOG IN)" & @CRLF & "2. Place Cursor Over The UserName Text Field" & @CRLF & "3. Press Enter And Then The Ok Button") Func _w1() IniWrite("test.ini", "UserPos", "X", MouseGetPos(0)) IniWrite("test.ini", "UserPos", "Y", MouseGetPos(1)) EndFunc ;==>_w Sleep(250) ;------------------------------------------------------------------------------- ;------------------------------------------------------------------------------- HotKeySet("{ENTER}", "_w2") MsgBox(0, "INSTRUCTIONS", "1. Now Place Cursor Over The Password Field Below" & @CRLF & "2. Press Enter And Then Ok") Func _w2() IniWrite("test.ini", "PassPos", "X", MouseGetPos(0)) IniWrite("test.ini", "PassPos", "Y", MouseGetPos(1)) EndFunc ;==>_w Sleep(250) ;------------------------------------------------------------------------------- ;------------------------------------------------------------------------------- HotKeySet("{ENTER}", "_w3") MsgBox(0, "INSTRUCTIONS", "1. Now Place Cursor Over The Login Button Below" & @CRLF & "2. Press Enter And Then Ok") Func _w3() IniWrite("test.ini", "LoginPos", "X", MouseGetPos(0)) IniWrite("test.ini", "LoginPos", "Y", MouseGetPos(1)) EndFunc ;==> Sleep(250) The script close it self because don´t have any loop... so after the last sleep it ends.. for organization i always recomend(also the help file recomend) make the things in some order, the funcs at the end of the script. I added the loops and i check variable to know when exit the loop. expandcollapse popupHotKeySet("{ENTER}", "_w1") Global $check = true MsgBox(0, "INSTRUCTIONS", "1. Open RsBuddy (DON'T LOG IN)" & @CRLF & "2. Place Cursor Over The UserName Text Field" & @CRLF & "3. Press Enter And Then The Ok Button") While $check Sleep(250) WEnd $check = not $check ;------------------------------------------------------------------------------------------------------------------ HotKeySet("{ENTER}", "_w2") MsgBox(0, "INSTRUCTIONS", "1. Now Place Cursor Over The Password Field Below" & @CRLF & "2. Press Enter And Then Ok") While $check Sleep(250) WEnd $check = not $check ;------------------------------------------------------------------------------------------------------------------ HotKeySet("{ENTER}", "_w3") MsgBox(0, "INSTRUCTIONS", "1. Now Place Cursor Over The Login Button Below" & @CRLF & "2. Press Enter And Then Ok") While $check Sleep(250) WEnd $check = not $check ;---------------------------------------------------------FUNCTIONS-------------------------------------------------- Func _w1() IniWrite("test.ini", "UserPos", "X", MouseGetPos(0)) IniWrite("test.ini", "UserPos", "Y", MouseGetPos(1)) $check = not $check EndFunc ;==>_w Func _w2() IniWrite("test.ini", "PassPos", "X", MouseGetPos(0)) IniWrite("test.ini", "PassPos", "Y", MouseGetPos(1)) $check = not $check EndFunc ;==>_w Func _w3() IniWrite("test.ini", "LoginPos", "X", MouseGetPos(0)) IniWrite("test.ini", "LoginPos", "Y", MouseGetPos(1)) $check = not $check EndFunc ;==> I run this and works fine to me.. i attach the ini file results.. I press "enter" in the upperleft corner then in the rightbottom corner and for last in somewhere in the middle of the screen. [LoginPos] X=814 Y=512 [UserPos] X=0 Y=0 [PassPos] X=1679 Y=1049 Link to comment Share on other sites More sharing options...
monoscout999 Posted July 16, 2011 Share Posted July 16, 2011 (edited) From the rsbuddy website: "Let our advanced cheating software play RuneScape for you: Automation from the world's most experienced in-game human simulation software programmers."What is rsbuddy? @Flemingjp if you are trying to do some Game BOT or an automation tool for games, i can`t help you anymore. here in the forum we got rules, part of that rules are that we do not discuss about game automation here. sorry but it have a solid argument for that and i don`t want a teenager semi hackers forum here... there are other forums for that. Edited July 16, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
Flemingjp Posted July 16, 2011 Author Share Posted July 16, 2011 (edited) Well, its a tricky one this. Its not a DIRECT Game Bot. It launches a current one from an email or SMS. Yet i reckon its too risky and rule bending. I just think i'll end here EDIT; Is it just the discussion in the forum, so i can still develop it in AutoIt or should i go else where? Edited July 16, 2011 by Flemingjp Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now