PotterHarry Posted October 12, 2015 Report Share Posted October 12, 2015 Hi there. I can't work this one out ... A macro creates registry keys and writes mouse coordinates into them: Get Mouse Position into (%N1%, %N99%) Relative to Screen Delay: 100 milliseconds Create Registry Key: HKEY_CLASSES_ROOT\._A ME VARIABLE_N1 Delay: 100 milliseconds Write Registry Value "%N1%" into HKEY_CLASSES_ROOT\._A ME VARIABLE_N1\ Delay: 100 milliseconds Create Registry Key: HKEY_CLASSES_ROOT\._A ME VARIABLE_N2 Delay: 100 milliseconds Write Registry Value "%N99%" into HKEY_CLASSES_ROOT\._A ME VARIABLE_N2 Delay: 100 milliseconds Text Box Display: Another macro reads the variables from the registry: Read Registry Value "HKEY_CLASSES_ROOT\._A ME VARIABLE_N1\" into %N1% Delay: 100 milliseconds Read Registry Value "HKEY_CLASSES_ROOT\._A ME VARIABLE_N2\" into %N2% Delay: 100 milliseconds Read Registry Value "HKEY_CLASSES_ROOT\._A ME VARIABLE_N3\" into %N3% Delay: 100 milliseconds Read Registry Value "HKEY_CLASSES_ROOT\._A ME VARIABLE_N4\" into %N4% Delay: 100 milliseconds Read Registry Value "HKEY_CLASSES_ROOT\._A ME VARIABLE_N5\" into %N5% Delay: 100 milliseconds Read Registry Value "HKEY_CLASSES_ROOT\._A ME VARIABLE_N6\" into %N6% Delay: 100 milliseconds Read Registry Value "HKEY_CLASSES_ROOT\._A ME VARIABLE_N7\" into %N7% Delay: 100 milliseconds Read Registry Value "HKEY_CLASSES_ROOT\._A ME VARIABLE_N8\" into %N8% Delay: 100 milliseconds Text Box Display: This is a typical result: 3260482316650501720599 The second value is always zero ?? By the way I used N99 to try to solve it .. no joy What could be happening? Thanks Ian Quote Link to comment Share on other sites More sharing options...
Cory Posted October 12, 2015 Report Share Posted October 12, 2015 First off you really should not be using the Classes Root. Second you should name you variables. Third you should use an array variable. Fourth export this to an MEX file and post it. It's too had to read your text and infer what's behind the scenes. P.S. You might want save them all as text separated with a deliminator into one registry value and split them later. Quote Link to comment Share on other sites More sharing options...
rberq Posted October 13, 2015 Report Share Posted October 13, 2015 Major puzzles like this usually have simple solutions that leave you slapping your forehead and saying "Duh!". This one has the appearance of a typing error in one of your commands, for example reading %N2% back from a registry key that doesn't exist because you mis-typed the name. Or a similar typing error in the Text Box Display command, like displaying /N2% instead of %N2%. I'm with Cory: post the actual macro code so we can help proofread it. Quote Link to comment Share on other sites More sharing options...
Cory Posted October 13, 2015 Report Share Posted October 13, 2015 PotterHarry I'd like to give you a tip. Post a sample file whenever you have something like this. And if you can use generic applications we all have to demonstrate the problem like Calculator or Notepad. I can't afford to spend a lot of time giving advice on this forum so I set limits. If you have a problem that requires me to spend a lot of time trying to understand what your problem is or writing your code in my MEP I'm less likely to have the time to help you. And it's just efficient. Thing of it this way. If 3 of us consider your problem and take time to write the code it's 3 times more than the overall time if you write the code. I'm not chastising you, I only want to help you help us so you can get answers faster. Quote Link to comment Share on other sites More sharing options...
Samrae Posted October 13, 2015 Report Share Posted October 13, 2015 PotterHarry: Your macro looks like it was written in Macro Express 3. Is that the case? Are you aware that this is the Macro Express Pro forum and there is a separate forum for Macro Express 3? You will get better help if you post in the correct forum. I echo Cory's comment. It seems dangerous to write to HKEY_CLASSES_ROOT. That area should be reserved for Windows. If you want the values to be accessible to only one user, write to the HKEY_CURRENT_USER area of the registry. Perhaps here: HKCU\Software\Macro Express Variables\ If you want the values to be accessible to every user of a specific computer, write to the HKEY_LOCAL_MACHINE area of the registry. Perhaps here: HKLM\Software\Macro Express Variables\ To help others help you, copy your macro to the clipboard and paste it into a quote box in this forum. To make it even easier, copy your macro using the Command Text menu option and paste it into a another quote box. It will look like this: <REGWINT:1:HKEY_CLASSES_ROOT\._A ME VARIABLE_N1><REGRINT:1:HKEY_CLASSES_ROOT\._A ME VARIABLE_N1> Write Registry Integer: "._A ME VARIABLE_N1" Read Registry Integer: "._A ME VARIABLE_N1" Putting macro commands in a quote box allows them to be copied and pasted into our macro files without formatting errors. If the macro appears in the forum text the wrapping and formatting make it difficult to copy and paste. You can also, as Cory suggested, attach a macro file, either a .mex or .mxe, to your post. Quote Link to comment Share on other sites More sharing options...
PotterHarry Posted October 13, 2015 Author Report Share Posted October 13, 2015 Hi thanks very much for all the informative replies! I take on board what you are saying and I don't feel chastised. I'm going to re-write using a different part of the registry (arrays are a little beyond me if I am honest and my requirements are fairly straightforward) BTW I am using the Pro version.. I have looked for obvious blunders and I can't see any. Anyhow I will post again shortly. Thank you all.. Quote Link to comment Share on other sites More sharing options...
Cory Posted October 15, 2015 Report Share Posted October 15, 2015 Do not be afraid of arrays, they are very simple. Consider I have a single string variable for state called %State%. One slot only, right. But what if I needed variables for every state. Well you could make %State1% %State2% %State3% and so on. Well guess what. That's essentially what an array is. But instead of defining 50 variables you define one array variable with 50 elements. Now if you want to make the 5th state California you simply assign it to %State[5]%. 5 is called the index. Now you can use that variable with the index as a pointer for any of the 50 slots. Quote Link to comment Share on other sites More sharing options...
PotterHarry Posted October 15, 2015 Author Report Share Posted October 15, 2015 Thanks Cory. I'm reading up on arrays! I can see they are less messy than defining lots of individual variables.. Chief suspect in my original post was perhaps a variable of the wrong type, but I'm going to need some time to reconstruct those macros. Quote Link to comment Share on other sites More sharing options...
Cory Posted October 18, 2015 Report Share Posted October 18, 2015 My advice to you is to only use arrays for a series of variables that are the same thing. Say for instance %ClientName% where you stuff many client names. Another useful way to think of them is like columns of data like you might have in Excel. MEP doesn't support multidimensional arrays but I actually think that's a blessing. Instead use multiple arrays to represent a table. Imagine you have a bunch of employees and you need columns for %EmployeeID%, %FirstName%, %LastName%, %DateOfBirth%, and %SSN%. So make 5 array variables. IE 1 integer, 3 string, and one DateTime array. Now you can reference a employee by the index (pointer). EG Might have a CSV file of 800 Employees. I can loop through the file using ASCII File Process and load the arrays by using an integer pointer that I increment each iteration. Now let's say I the user types in EmployeeID and I want to display their other data. All I need to do is iterate through EmployeeID incrementing an integer %Pointer% until I find a match. Let's say it was 337. Now I can pop up a message box with the contents "EID:%EmployeeID[%Pointer%]%: Name: %FirstName[%Pointer%]% %LastName[%Pointer%]% DoB:%DateOfBirth[%Pointer%]% SSN:%SSN[%Pointer%]%" which is the same as "EID:%EmployeeID[%337%]%: Name: %FirstName[%337%]% %LastName[%337%]% DoB:%DateOfBirth[%337%]% SSN:%SSN[%337%]%" which will appear something like "EID:456: Name: Cory Jackson DoB:8/19/1968 SSN:123-45-6789" Quote Link to comment Share on other sites More sharing options...
PotterHarry Posted October 18, 2015 Author Report Share Posted October 18, 2015 Thankyou. I have re-written some of my small macros using arrays for some variables. They are so much easier to read.. I am using one for pixel coordinates, and a different one for colour samples, and yes they are not that daunting once you give it a try! I've managed to streamline some of my clunky macros.. Thank you and best wishes.... Quote Link to comment Share on other sites More sharing options...
Cory Posted October 21, 2015 Report Share Posted October 21, 2015 You're welcome. I'm happy you made them work. 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.