Jump to content
Macro Express Forums

Saving Integer variables to an .ini file

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.


If you toggle the direct editor using the last icon to the left of your script, then you can replace




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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...