Beaue Posted September 14, 2012 Report Share Posted September 14, 2012 Hi everyone, New to the forums, but I've been using MacEx Pro for about a year now and love it. I haven't needed to use the forums because the MacEx Help file is superb. Introductions aside, I've been trying to create a macro that will save mouse locations and pixel colors to an .ini file to be called upon later. Is there an easy way to do this? The only thing I've come up with is converting each integer variable to a string variable, then back again when I need to call them up. That just seems inefficient to me. Here's a sample of the script: <GET MOUSE POSITION Option="\x00" X="%N[3]%" Y="%N[4]%"/> <GET PIXEL COLOR Option="\x00" Rel_To_Screen="TRUE" Destination="%N[5]%"/> <VARIABLE MODIFY INTEGER Option="\x04" Destination="%N[3]%" Variable="%T[3]%"/> <VARIABLE MODIFY INTEGER Option="\x04" Destination="%N[4]%" Variable="%T[4]%"/> <VARIABLE MODIFY INTEGER Option="\x04" Destination="%N[5]%" Variable="%T[5]%"/> <VARIABLE MODIFY STRING Option="\x13" Destination="%T[3]%" Filename="%userprofile%\\Documents\\Macros\\MouseVariables.ini" Key="Location" Value="X" NoEmbeddedVars="FALSE"/> I only pasted the saving of the first variable to the .ini so you get the idea. If needed, I can attach an exported macro file, I just figured it was easier to copy and paste than to import/export. I did a search and couldn't find anything that seemed relevant to this topic, so I apologize if this has already been discussed in some form or another. Quote Link to comment Share on other sites More sharing options...
paul Posted September 14, 2012 Report Share Posted September 14, 2012 MEP is not like .net, so there's no reason to convert the integers to text before you write them to the .ini file, unless you want fixed length (only relevant if you're writing several values in a single line, in which case I'd separate them with commas or tabs). Quote Link to comment Share on other sites More sharing options...
Beaue Posted September 14, 2012 Author Report Share Posted September 14, 2012 Hi Paul, let me clarify: I would actually prefer not to convert the integers to text. The problem I am running into is that I don't see an option in the Variable Modify Integer command to save to an .ini file. I also do not see an option in the Variable Set Integer command to pull the variables from an .ini file. That is the only reason I was converting the integers to strings. Quote Link to comment Share on other sites More sharing options...
paul Posted September 15, 2012 Report Share Posted September 15, 2012 Sorry - I haven't used this feature and didn't realize the .ini file options were so inextricably tied to string variables. There is a way round this. It's a bit of a kludge, but does seem to work. Suppose this command: <VARIABLE MODIFY STRING Option="\x13" Destination="%T[3]%" Filename="%userprofile%\\Documents\\Macros\\MouseVariables.ini" Key="Location" Value="X" NoEmbeddedVars="FALSE"/>[/size] If you edit this and change %T[3]% to %N[3]%, you get an error message about the variable being of the wrong type. However... If you toggle the direct editor using the last icon to the left of your script, then you can replace Destination="%T[3]% with Destination="%N[3]% Toggle the direct editor again, and it works. BTW, I encourage you to use meaningful variable names instead of the old %t[3]% syntax because it makes later editing of the macro easier. Quote Link to comment Share on other sites More sharing options...
Beaue Posted September 18, 2012 Author Report Share Posted September 18, 2012 Hmm, that's an interesting work-around. Thanks Paul! I'll give that a try. Regarding the meaningful variable names - it is a good idea, but it would take a lot of time to re-work all the macros I use currently. I hadn't thought of doing it prior to now because I generally make the [section] and [Key] names meaningful for variables that I save to an .ini file, and on most of my macros (except the earliest) I have been commenting the macro file as I go so it is easier on future edits. I can always define meaningful variables for new macros and work my way back to the older ones when I find the time. Quote Link to comment Share on other sites More sharing options...
Beaue Posted September 18, 2012 Author Report Share Posted September 18, 2012 Update: It looks like this work-around works for the first variable, but it is only saving the first of the three to the .ini file. The other two variables aren't being saved. Oh well, it was worth a shot. Appreciate the effort. Quote Link to comment Share on other sites More sharing options...
paul Posted September 19, 2012 Report Share Posted September 19, 2012 Yes, you're right. I even tried it within a repeat loop, but that made no difference. Would writing to the registry work for you, as you can write any type of variable to the registry? Quote Link to comment Share on other sites More sharing options...
Cory Posted September 19, 2012 Report Share Posted September 19, 2012 Save them to the registry instead. MEP automatically sets the correct registry type based on variable type. I avoid INI files in all cases except networked instances where remote registry access is out of the question. The registry was designed as a much improved repository for settings like this many years ago. Take advantage of it. Quote Link to comment Share on other sites More sharing options...
Beaue Posted September 19, 2012 Author Report Share Posted September 19, 2012 Oooh, I hadn't thought of using the registry. Brilliant! I'll give that a go. Edit: Looks like it's working. Thanks guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.