Anuin Posted March 8, 2004 Share Posted March 8, 2004 This is a tough question for me cause i have 0 programing knowledge, besides learning some auto it. Anyway, I was wondering if its possible to read a command or variable from a seperate file. IE. Have on one file: $a = $b and on the second file, store: $b = 54 what im trying to do is save mouse coordinates in a seperate file so that when the the script loads up again you dont have to re -input the coordinates again unless you want to. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 8, 2004 Developers Share Posted March 8, 2004 the best way to save info is probably saving it into a INI file. IniWrite("C:\Temp\myfile.ini", "section2", "key", "this is a new value") $var = IniRead("C:\Temp\myfile.ini", "section2", "key", "NotFound") MsgBox(4096, "Result", $var) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Anuin Posted March 8, 2004 Author Share Posted March 8, 2004 Thanks Man!!! Exactly what i was looking for. You saved me from a world of frustration Link to comment Share on other sites More sharing options...
Anuin Posted March 8, 2004 Author Share Posted March 8, 2004 I have another problem. Everything seems to be working fine, but cant get the mouse position to store mabe my code is wrong. Ive Tried $toolset = MsgBox(4, "Toolbar Settings", "Change the Toolbar Settings") If $toolset = 6 Then $pos1 = MouseGetPos() IniWrite("MouseSetting2.ini", "Mouse", "Mouse1", $pos1[0],$pos1[1]) EndIf $pos1 = iniread("MouseSetting2.ini", "Mouse", "Mouse1", ($pos1[0],$pos1[1]) ) MsgBox(4096, "Result", $pos1) And also: $toolset = MsgBox(4, "Toolbar Settings", "Change the Toolbar Settings") If $toolset = 6 Then $pos1 = MouseGetPos() IniWrite("MouseSetting2.ini", "Mouse", "Mouse1", $pos1) EndIf $pos1 = iniread("MouseSetting2.ini", "Mouse", "Mouse1", $pos1) MsgBox(4096, "Result", $pos1) Link to comment Share on other sites More sharing options...
Anuin Posted March 8, 2004 Author Share Posted March 8, 2004 Sorry made mistake. The firstone goes: $toolset = MsgBox(4, "Toolbar Settings", "Change the Toolbar Settings") If $toolset = 6 Then $pos1 = MouseGetPos() IniWrite("MouseSetting2.ini", "Mouse", "Mouse1", $pos1[0],$pos1[1]) EndIf $pos1 = iniread("MouseSetting2.ini", "Mouse", "Mouse1", $pos1[0],$pos1[1] ) MsgBox(4096, "Result", $pos1) And yes ive tried it with brackets as well Link to comment Share on other sites More sharing options...
scriptkitty Posted March 8, 2004 Share Posted March 8, 2004 (edited) Ini read and write use one bit of information, you placed in both $pos1[0] and $pos1[1] on the same line seperated by a comma, and thus not the correct number of parameters. $toolset = MsgBox(4, "Toolbar Settings", "Change the Toolbar Settings") If $toolset = 6 Then $pos1 = MouseGetPos() IniWrite("MouseSetting2.ini", "Mouse", "Mouse1", $pos1[0]) IniWrite("MouseSetting2.ini", "Mouse", "Mouse2", $pos1[1]) EndIf dim $pos1[2] $pos1[0] = iniread("MouseSetting2.ini", "Mouse", "Mouse1", 0 ) $pos1[1] = iniread("MouseSetting2.ini", "Mouse", "Mouse2", 0) MsgBox(4096, "Result", $pos1[0]&@CRLF&$pos1[1]) Edited March 8, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
GrahamS Posted March 8, 2004 Share Posted March 8, 2004 (edited) Ini files can only store one value per element, so use two elements, e.g. IniWrite("MouseSetting2.ini", "Mouse", "MouseX", $pos1[0]) IniWrite("MouseSetting2.ini", "Mouse", "MouseY", $pos1[1]) Edit: ScriptKitty got in there first, chiz Edited March 8, 2004 by GrahamS GrahamS Link to comment Share on other sites More sharing options...
Anuin Posted March 9, 2004 Author Share Posted March 9, 2004 Thanks Allot Guys, works like its supposta Link to comment Share on other sites More sharing options...
trids Posted March 9, 2004 Share Posted March 9, 2004 And then there's this idea (I got from TextPad I think? ) ..$pos1 = MouseGetPos() IniWrite("MouseSetting2.ini", "Mouse", "MouseXY", $pos1[0] & " " & $pos1[1])This means you can do a StringSplit when you read it back..$sPos = IniRead("MouseSetting2.ini", "Mouse", "MouseXY", "0 0") $aPos = StringSplit($sPos, " ")Granted, you're not saving any code for MouseGetPos, and you're only saving one line in the INI file ... but ... think how this technique works on say WinGetPos which has 4 items to store and read back Link to comment Share on other sites More sharing options...
scriptkitty Posted March 9, 2004 Share Posted March 9, 2004 Yea, one of the main reasons for an array is to be able to dynamically call out dimentions in an array. You can store InI files many ways. Here is a sloppy example, I personally would remove the first , but shown more simply in this example. $toolset = MsgBox(4, "Toolbar Settings", "Change the Toolbar Settings") If $toolset = 6 Then $pos1 = MouseGetPos() for $i=0 to 1 $pos=$pos&","&$pos1[$i] next IniWrite("MouseSetting2.ini", "Mouse", "Mouse1", $pos) EndIf $split=(iniread("MouseSetting2.ini", "Mouse", "Mouse1", 0 )) $pos1= StringSplit($split,","); shown in two lines only for ease of viewing. MsgBox(4096, "Result", $pos1[2]&@CRLF&$pos1[3]) AutoIt3, the MACGYVER Pocket Knife for computers. 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