Jump to content
Macro Express Forums

Multiple clipboards


Recommended Posts

Here is the scenario. I have a spreadsheet I need 4 different cells copied from. I need to paste them into another form. Instead of doing these 1 by 1, I am trying to make a series of macros that would let me save clipboard to a variable using ctrl1, then paste that variable using alt1. The idea is that I can get all 4 cells of data saved into variables to paste into the other form. like this: Click into cell b1, hit ctrl 1. Click into f1, hit ctrl 2. h1, ctrl3. l1, ctrl 4. Then I would go to my other form select filed, alt1. Next field, alt 2 and so on.

 

When I try to do this, it will kind of work for the first one, but when I save the variable in the 2nd macro, it overwrites the data and I lose the data from variable %T[1]%.

 

I need to be able to save 4 text variables for use in the text type macro to "paste" the info from each variable.

 

Or some other way to accomplish this.

 

Thanks in advance - I hope this made some sense.

Link to comment
Share on other sites

How about using a single macro to copy all four cells:

 

Manually click into cell B1

Ctrl-1 to start macro

    Macro types Ctrl-c to copy the cell into clipboard

    Macro saves clipboard to T[1] variable

    Macro types ESC to exit from copy mode

    Macro types ArrowRight several times to get to cell F1

 

    Macro types Ctrl-c to copy the cell into clipboard

    Macro saves clipboard to [T2] variable

    Macro types ESC to exit from copy mode

    Macro types ArrowRight several times to get to cell H1

 

    Continue with similar coding until the four cells have been copied into T[1] through T[4]

 

Likewise, your second macro can type T[1] into the cell you manually select, navigate by typing ArrowRight to the next cell, type T[2] into that cell, and so on.  Let the two macros do the navigation from cell to cell, rather than you doing it manually.

 

Link to comment
Share on other sites

Ctrl + 1:

 

Clipboard Empty
Text Type (Simulate Keystrokes): <CONTROL>c
Variable Set String %Clip1% from the clipboard contents
Variable Save: Save Text Variables
Beep

<CLIPBOARD EMPTY/>
<TEXT TYPE Action="0" Text="<CONTROL>c"/>
<VARIABLE SET STRING Option="\x02" Destination="%Clip1%" NoEmbeddedVars="FALSE"/>
<VARIABLE SAVE Option="\x01"/>
<BEEP/>

 

Alt + 1:

 

Variable Restore: Restore Text Variables
Text Type (Simulate Keystrokes): %Clip1%

<VARIABLE RESTORE Option="\x01"/>
<TEXT TYPE Action="0" Text="%Clip1%"/>

 

Then clone the two macros for Ctrl + 2 and Alt + 2, and so on.

 

You'll need to rename the variable in each macro to reflect which "clipboard" it uses, e.g., %Clip2%, %Clip3%, etc.

Link to comment
Share on other sites

The solution I posted reserves one variable per "clipboard": %Clip1%, %Clip2%, %Clip3%, etc. The macro that saves the variable %Clip2% doesn't do anything to %Clip1%, %Clip3%, etc. Each clipboard variable is independent of the other clipboards.

 

The first time I tested my scripts, saving a "clipboard" did delete others. It was a bug. I inadvertently mixed up my variable names.

 

How about sharing your code?

Link to comment
Share on other sites

ctrl-1

 

<CLIPBOARD EMPTY/>
<TEXT TYPE Action="0" Text="<CONTROL>c"/>
<VARIABLE SET STRING Option="\x02" Destination="%Clip1%" NoEmbeddedVars="TRUE"/>
<VARIABLE SAVE Option="\x01"/>
<BEEP/>
 

 

alt-1

 

<VARIABLE RESTORE Option="\x01"/>
<TEXT TYPE Action="0" Text="%Clip1%"/>

 

 

ctrl-2

 

<CLIPBOARD EMPTY/>
<TEXT TYPE Action="0" Text="<CONTROL>c"/>
<VARIABLE SET STRING Option="\x02" Destination="%Clip2%" NoEmbeddedVars="TRUE"/>
<VARIABLE SAVE Option="\x01"/>
<BEEP/>

 

 

alt-2

 

<VARIABLE RESTORE Option="\x01"/>
<TEXT TYPE Action="0" Text="%Clip2%"/>

Link to comment
Share on other sites

If you wrote the ctrl-1 macro, then copied it to make the ctrl-2 macro, then ctrl-2 will still contain variable %Clip1% with a null value.  So when ctrl-2 saves the variables, %Clip2% will be saved correctly, but %Clip1% will be saved as null, and subsequently restored as null.  So ctrl-2 will in fact wipe out %Clip1%.  Likewise, running macro ctrl-3 will wipe out %Clip1% and %Clip2%, ctrl-4 will wipe out %Clip1% and %Clip2% and %Clip3%, and so on. 

 

Click on the Variables tab in your ctrl-x macros and if there are "unauthorized" %Clip-x% variables, delete them. 

 

If you coded all the ctrl-x macros from scratch, then ignore everything I said. 

Link to comment
Share on other sites

rberq is correct. Copying these macros can lead to variable-mush. Do what he says: go to the Variable tab in all of the Ctrl+ macros and make sure there is only one text variable for each.

 

But the scripts were still failing occasionally for me. Adding longish delays in the Alt+ macros seemed to help. Ditto for using a clipboard copy command instead of simulating Ctrl + C.

 

I added the right arrow key to the Ctrl+ macros to make it clearer that a copy operation had occurred.

 

Ctrl + 1:

Clipboard Empty
Clipboard Copy
Text Type (Simulate Keystrokes): <ARROW RIGHT>
Variable Set String %Clip1% from the clipboard contents
Variable Save: Save Text Variables
Beep: Save Text Variables

<CLIPBOARD EMPTY/>
<CLIPBOARD COPY/>
<TEXT TYPE Action="0" Text="<ARROW RIGHT>"/>
<VARIABLE SET STRING Option="\x02" Destination="%Clip1%" NoEmbeddedVars="FALSE"/>
<VARIABLE SAVE Option="\x01"/>
<BEEP/>

 

Alt + 1:

 

Variable Restore: Restore Text Variables
Delay: 300 milliseconds
Text Type (Simulate Keystrokes): %Clip1%

<VARIABLE RESTORE Option="\x01"/>
<DELAY Flags="\x02" Time="300"/>
<TEXT TYPE Action="0" Text="%Clip1%"/>

 

Link to comment
Share on other sites

9 hours ago, acantor said:
Variable Restore: Restore Text Variables
Delay: 300 milliseconds
Text Type (Simulate Keystrokes): %Clip1%

I like your idea of the right arrow key as a visual cue.  Also putting a delay after the Clipboard Copy, lest the set-string-from-clipboard should happen before the clipboard has been populated. 

 

However, I would be shocked and dismayed if ME requires an explicit delay after a Restore Variables command.  (Though I confess I haven't tested it.)  If there is a timing problem, perhaps a longer Keystroke Speed command would make the typing more reliable. 

Link to comment
Share on other sites

9 hours ago, rberq said:

  If there is a timing problem, perhaps a longer Keystroke Speed command would make the typing more reliable. 

 

I was able to prove (to myself, anyways) that the restore instruction needed time before the variable was available.

 

I wish it wasn't so. Maybe a delay isn't necessary on a faster computer. The Windows 10 machine I bought 1.5 years ago is a bit pokey.

Link to comment
Share on other sites

Just now, acantor said:

 

I was able to prove (to myself, anyways) that the restore instruction needed time before the variable was available.

 

I wish it wasn't so. Maybe a delay isn't necessary on a faster computer. The Windows 10 machine I bought 1.5 years ago is a bit pokey.

I removed all delays in mine and it's working great. I'm on a beefed up Gen 3 Thinkpad X1 though.

 

Seriously folks - thanks for the input. Loving this!

Link to comment
Share on other sites

4 hours ago, acantor said:

I was able to prove (to myself, anyways) that the restore instruction needed time before the variable was available.

Maybe a difference in ME versions?  I am running ME Pro 4.9.1.1.  I can't make it fail, saving and restoring many million-byte variables and immediately checking the result of the restore, with no delay allowed. 

 

<COMMENT Value="Make lots of big variables to be saved and restored"/>
<VARIABLE SET STRING Option="\x00" Destination="%many_bytes%" Value="a" NoEmbeddedVars="FALSE"/>
<REPEAT START Start="1" Step="1" Count="20" Save="FALSE"/>
<VARIABLE MODIFY STRING Option="\x07" Destination="%many_bytes%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<END REPEAT/>
<TEXT BOX DISPLAY Title="Diagnostics" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 many_bytes = %many_bytes%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="1195" Height="483" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%a%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%b%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%c%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%d%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%e%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%f%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%g%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%h%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%i%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%j%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%k%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%l%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%m%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%n%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%o%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%p%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%q%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%r%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%s%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%t%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%u%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%v%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%w%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%x%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%y%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%z%" Variable="%many_bytes%" NoEmbeddedVars="FALSE"/>
<COMMENT Value=" "/>
<VARIABLE SET INTEGER Option="\x0D" Destination="%length%" Text_Variable="%z%"/>
<TEXT BOX DISPLAY Title="Diagnostics" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 length of z = %length%\r\n\\par z = %many_bytes%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="1195" Height="483" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0" _ENABLED="FALSE"/>
<COMMENT Value="Make two variables to be tested "/>
<VARIABLE SET STRING Option="\x00" Destination="%clip1%" Value="clip1" NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%clip2%" Value="clip2" NoEmbeddedVars="FALSE"/>
<COMMENT Value=" "/>
<VARIABLE SAVE Option="\x00"/>
<COMMENT Value=" "/>
<VARIABLE SET STRING Option="\x00" Destination="%clip1%" Value="     " NoEmbeddedVars="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%clip2%" Value="     " NoEmbeddedVars="FALSE"/>
<VARIABLE RESTORE Option="\x01"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%clip2%" Variable="%clip1%" NoEmbeddedVars="FALSE"/>
<COMMENT Value=" "/>
<TEXT BOX DISPLAY Title="Diagnostics" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 clip1=%clip1%\r\n\\par clip2=%clip2%\\f1 \r\n\\par \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
<COMMENT Value=" "/>
<MACRO RETURN/>

 

 

Link to comment
Share on other sites

I suppose this could be a Macro Express version issue. I'm using MEP 6.something.

 

But I suspect my computer is to blame, which may be the slowest PC I've ever owned. Many window- and application-specific macros don't fire if I activate them immediately after opening a window or application. Heavens to Betsy, I've never seen such misbehaviour in a macro!

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

×
×
  • Create New...