Jump to content
Macro Express Forums

Registry Values


Recommended Posts

Ok experts! You guys have all convinced me to abandon Save/Restore Variables as often as possible replacing them with Read/Write Registry commands.

 

I played with it all week-end at home and have converted the majority of my macros at work (successfully). I feel pretty good about it all, but I just ran into a bit of a snag.

 

I've never liked Windows Clipboards (in fact I've never learned how to use them effectively, and am often annoyed by the built-in pop-up showing me just how many clipboards I've used).

 

So, from the dawn of time (ie when I first started using ME many years ago), I've always used ME and the Save/Restore function for multiple clipboards.

 

Example Copy Macro:

Variable Restore: Restore All Variables
Clipboard Copy
Delay: .8 seconds
Variable Set String %cb[1]% from the clipboard contents
Variable Save: Save Text Variables

Example Paste Macro

Variable Restore: Restore Text Variables
Variable Modify String: Save %cb[1]% to the clipboard
Clipboard Paste

Under ME3, I had %T81% through %T90% (Ctrl/Alt+1 through Ctrl/Alt+0) dedicated to these clipboards.

 

I've decided to change these to Registry Read/Writes.

Write:

<CLIPBOARD COPY/>
<VARIABLE SET STRING Option="\x02" Destination="%cb%"/>
<WRITE REGISTRY VALUE Key="HKEY_CURRENT_CONFIG\\MEVariables\\Clipboards\\Clipboard001" Destination="%cb%"/>

Read:

<READ REGISTRY VALUE Key="HKEY_CURRENT_CONFIG\\MEVariables\\Clipboards\\Clipboard001" Destination="%cb%"/>
<TEXT TYPE Action="1" Text="%cb%"/>

 

And I'm having some inconsistent results. Is there a time-factor to consider? From my understanding, the macro should not move from the Read command to the Text Type command until the contents of the Registry value have been set to the destination variable... and yet sometimes (not terribly often, but often enough) the macro runs, Forrest pops up, but nothing gets typed or pasted (I've tried both options). I even added a 1 second delay after the Read value to test the consistency (I couldn't imagine it actually taking a full second to read it, though) and still had problems.

 

Ironically, I ended up using a basic non-macro "copy and paste" in order to get the code pasted above, since the Registry commands weren't working right.

 

Any advice on what I might be doing wrong before I finish converting all 10 of my clipboards?

Link to comment
Share on other sites

I'm not sure that replacing your clipboard variables with registry values will do much for you. After all, you're still using Clipboard Copy - and a chain is as weak as its weakest link! IMHO, it's that Clipboard Copy command in your penultimate code block that is failing - and you're not checking that it's copied anything to the clipboard (in other words, it's the same old problem).

Link to comment
Share on other sites

I'm not sure that replacing your clipboard variables with registry values will do much for you. After all, you're still using Clipboard Copy - and a chain is as weak as its weakest link! IMHO, it's that Clipboard Copy command in your penultimate code block that is failing - and you're not checking that it's copied anything to the clipboard (in other words, it's the same old problem).

Based on what I gave you above, I'd agree with you. However, I noticed the problem when I had built the macro with a more complicated sequence designed to make certain the clipboard was not empty (see this thread: Clipboard Copy Usage Inquiry). I simplified it in this thread simply because it wasn't working in either build, and this one is easier to look at.

 

I'll keep playing with it... hopefully it'll dawn on me just exactly what I'm doing wrong.

Link to comment
Share on other sites

Any advice on what I might be doing wrong before I finish converting all 10 of my clipboards?

 

Steve, have you peeked into the registry to see if your key value is being populated with the correct values after a Clipboard copy/Registry write? Similarly, have you verified your variable %cb% is correctly populated at runtime? If both of those are accurate, then Paul's probably right about the clipboard being the weak link.

 

Other fundamental troubleshooting questions:

  • * Is text the only thing on the clipboard?
    * Are there any CR/LFs tagging along on the clipboard? (I'm not sure how the Registry would interpret a CR/LF in a string value; could that choke the macro?)
    * Are you copying from only one source (e.g., MS Word), or are there multiple programs from which you use your multi-clipboard? Is there one specific program for which your macro fails?
    * Alternately, take the same text value that works in one program, and use it in the other programs from which you copy/paste. It may be program specific.
    * Your copy/paste uses %cb% as an array, but you don't have the array for the Registry read/write commands. Problem?

Ok experts! You guys have all convinced me to abandon Save/Restore Variables as often as possible replacing them with Read/Write Registry commands.

 

I've been using ME (and MEP now) since 2001 as an inexpensive and powerful tool for software test automation. (I even quit a job over Macro Express; long story...) Most of my Registry use has been keeping count of test iterations, last values parsed, and innumerable conditional flags for runtime. You've already pushed beyond the envelope of my experience with the combination of clipboard and registry.

 

Although I cannot think of any examples offhand, I'm sure there have been occasions in my macro scripts where the Registry commands didn't work the way I intended. I'd try a different set of macro commands and finally achieve my intended result.

 

That, for me, is one of the sweetest things about ME: usually there's numerous ways to perform a task with ME, and if one don't work, the next one will.

 

For the record, though, I never intended to lead you to believe the Registry commands were the silver bullet to saving/restoring variables. :rolleyes: Just a robust method for when I really need to save important variables between runs.

Link to comment
Share on other sites

Jim,

 

Thank you for your detailed response. I'll touch on your points and let you know what my experience is:

 

Steve, have you peeked into the registry to see if your key value is being populated with the correct values after a Clipboard copy/Registry write?

Initially, I wanted to respond "Yes, I checked." But in reality I don't think I have. I will do that when I get a chance to toy with it again.

 

Are there any CR/LFs tagging along on the clipboard? (I'm not sure how the Registry would interpret a CR/LF in a string value; could that choke the macro?)

Yes, sometimes there are CR/LFs involved. But sometimes it works and sometimes it doesn't. Also, sometimes, when it doesn't work, there are not CR/LFs. So this one seems to be a dead-end <_<

 

Are you copying from only one source (e.g., MS Word), or are there multiple programs from which you use your multi-clipboard? Is there one specific program for which your macro fails?

Actually, the first time I noticed it, I was using it to copy command-lines from MEP Script Editor. When that wasn't working, I tried MEP Direct Editor. Continued failure and I tested from Notepad, and finally have also had problems within this PGM forum text box. So it would appear to not be directly related to the program being copied from/pasted into.

 

Your copy/paste uses %cb% as an array, but you don't have the array for the Registry read/write commands. Problem?

The %cb% shown as an array is the "old" way, when I was using Save/Restore. That way I had %cb[1]% through %cb[10]% (assigned respectively to Ctrl+1 through Ctrl+0).

 

Using the registry values to save the clipboard contents, I don't need the array, since each macro will call from a different value: \Clipboard001 through \Clipboard010 and assign the value to %cb%. If I needed to pull more than one at once for a macro, then in that macro I could just assign each needed \Clipboardxxx to a specific variable defined in that particular macro (possibly making the %cb% into an array again for that specific macro. But as far as the basic Copy/Paste functions (Ctrl+1 / Alt+1) I don't need arrays anymore. As I understand it.

 

OT

As a side not - relatively off topic to this particular discussion, but relevant in that I just experienced it, my %cb% variable has just crapped out on me the way %acctnumber% did on some of my other macros yesterday (see: MEP Not Recognizing Custom Variable Names!!!!).

Link to comment
Share on other sites

Steve, have you peeked into the registry to see if your key value is being populated with the correct values after a Clipboard copy/Registry write? Similarly, have you verified your variable %cb% is correctly populated at runtime? If both of those are accurate, then Paul's probably right about the clipboard being the weak link.

 

Ok, I think I've figured out that the problem is almost certainly not the registry Read/Write combination.

 

* I rebuilt my "check if clipboard is empty" sequence. I then tacked a delay and a Read Registry command followed by a Text Box Display (using a unique Variable) onto the end of the copy macro.

 

The clipboard is definitely copying and saving successfully to the Registry.

 

* I started running the corresponding Paste macro with limited success (75%).

 

The text saved was simple: "Test"

 

Very consistently, if I ran the macro 4 times, Forrest would appear 4 times, but the word Test would only paste 3 times to Notepad.

 

* Thinking it might simply be a matter of the "Alt" portion of the macro launch, I inserted a Text Box display between the Read Registry command and the Text Type command to display the contents of the variable being used. Again, 4 runs, 4 Text Boxes indicating the Read command had assigned the correct information to the variable, but only 3 times did the text actually paste into Notepad.

 

* Assuming there must be an active-window issue, I added two additional commands: I set the active window title to a variable, at the start of the macro, and then added an "Activate Window" macro before the paste command. Exact same fail-rate.

 

I'm about to test "Simulate Keystrokes" rather than "use clipboard to paste", though I hate to do that.

 

Edit

<sigh> Simulate Keystrokes appears to work 100% of the time. Assigning the variable to the clipboard, and then using the Clipboard Paste command results in failure as often as using the Text Type command set to Use Clipboard... this is extremely disappointing (sometimes I have a lot of text to paste, and simulating keystrokes, though fast, is not a paste).

 

Oh well. At least the macro works :)!

Link to comment
Share on other sites

I've never liked Windows Clipboards (in fact I've never learned how to use them effectively, and am often annoyed by the built-in pop-up showing me just how many clipboards I've used).
Hello! Here's your problem! What you have just described is not the Windows Clipboard! Windows clipboard will never pop anything up. In fact it sounds like the old Office Clipboard. I bet you have an old copy of MS Office on your machine. If it is Office clipboard will totally screw with you and in ways much like you are describing. I advise you disable ti immediately. http://support.microsoft.com/kb/207438 And if you do not have the Office Clipboard then it's some other clipboard utility you need to get rid of! Personally I use ClipMate and it seems to work pretty well with MEP.

 

Also as far as reads and writes from the clipboard I do an enormous amount on many machines and have never witnessed a variable not being propagated from the reg because I was moving to fast. I'm certain that flow control has been designed in to avoid this.

 

Also I would suggest you not use the HKCC but rather the HKCU.

Link to comment
Share on other sites

Hello! Here's your problem! What you have just described is not the Windows Clipboard! Windows clipboard will never pop anything up. In fact it sounds like the old Office Clipboard. I bet you have an old copy of MS Office on your machine. If it is Office clipboard will totally screw with you and in ways much like you are describing. I advise you disable ti immediately. http://support.microsoft.com/kb/207438 And if you do not have the Office Clipboard then it's some other clipboard utility you need to get rid of! Personally I use ClipMate and it seems to work pretty well with MEP.
Ah, I wasn't sure what the built-in clipboard was called. I just know I hate it, so I disabled it ages ago in favor of my ME clipboards.

 

Also as far as reads and writes from the clipboard I do an enormous amount on many machines and have never witnessed a variable not being propagated from the reg because I was moving to fast. I'm certain that flow control has been designed in to avoid this.
Yup, the problem is somewhere in my clipboard commands, or in the clipboard function of my OS altogether (about to start a new thread about it).

 

Also I would suggest you not use the HKCC but rather the HKCU.
Oh CRAP!!!! That's where I thought I was putting it! DAGGUMIT!!! Now I'm going to have to go through and move everything. I'm such a bone-head!!! :blink:
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.

Guest
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.

Loading...
×
×
  • Create New...