Jump to content
Macro Express Forums

Send clipboard data as keystrokes - with tab key execution (RESOLVED)


Recommended Posts

I need to enter data in a Windows app (COBOL based). The app is designed such that tabbing is required to move from field to field for data entry in each field. I'd like to generate the data for the app from Excel, using VBA to send it to the clipboard. I can script the VBA such that both the data elements and some sort of tab key indicator are present, but what I can't figure out is how to get ME to interpret the tab key designator and write it to a macro, along with the data, and then play that macro into the COBOL app.

 

For example, I can create this line: {#key BACKSPACE#}{#key BACKSPACE#}{#key TAB#}72422346833{#key TAB#}WAW22080013{#key TAB#}{#key TAB#}{#key TAB#}{#key TAB#}1{#key TAB#}{#key TAB#}.

 

In the sample above, the keystroke indicators are from a different app, but hopefully self-explanatory.

 

With the above on the clipboard, I'd like to use a hot key, have ME import/process the data to convert the keystroke instruction to something ME understands, then replay the string of data with the proper keystrokes instead of literally typing out {#key , etc.

 

Can anyone provide at least some initial guidance? I can easily figure out how to send the clipboard data to keystrokes, but not with the special keys being used.

 

Edit: as an alternative to using the clipboard, I could use VBA to send the data to a text file, Excel file, or .csv file, but would still need to process it so ME could send the correct keystrokes.

Edited by frateg8r
Inquiry resolved
Link to comment
Share on other sites

I would export the data to a delimited file. I like a tab delimiter better than comma, but either will work. Then I would use the ASCII File Process command in MEP. So the text you want to enter in the fields would be in columns, then they tabs woudl exist in the Type Text command. 

Link to comment
Share on other sites

I'm not sure its this simple, but try this:

 

This macro takes whatever is in the clipboard, puts it into a variable, then converts the special characters to Macro Express's format, then "types" the converted text.  

{#key BACKSPACE#}{#key BACKSPACE#}{#key TAB#}72422346833{#key TAB#}WAW22080013{#key TAB#}{#key TAB#}{#key TAB#}{#key TAB#}1{#key TAB#}{#key TAB#}

is changed to

<BACKSPACE><BACKSPACE><TAB>72422346833<TAB>WAW22080013<TAB><TAB><TAB><TAB>1<TAB><TAB>

 

Variable Set String %text% from the clipboard contents
Variable Modify String: Replace "{#key BACKSPACE#}" in %text% with "<BACKSPACE>"
Variable Modify String: Replace "{#key TAB#}" in %text% with "<TAB>"
Text Type (Simulate Keystrokes): %text%

 

  • Like 1
Link to comment
Share on other sites

If you are producing the special key indicators via VBA, you could produce <TAB> in the first place, rather than {#key TAB#}.  Then your macro would be only two lines instead of four, because you would not need the Replace commands in the macro. 

Link to comment
Share on other sites

One can't type an actual tab in most MEP commands or dialogs, but they can be pasted in and exist as I pointed out in my link, so if there is an actual 0x09 coded character, I think MEP will type it with the Text Type command. 

Link to comment
Share on other sites

3 hours ago, Cory said:

One can't type an actual tab in most MEP commands or dialogs, but they can be pasted in and exist as I pointed out in my link, so if there is an actual 0x09 coded character, I think MEP will type it with the Text Type command. 

 

The example frateg8r gave just happened to have TAB and BACKSPACE, for which Macro Express has mnemonics <TAB> and <BACKSPACE> that can be typed.  For other special characters, the ASCII values can be inserted as you describe, and Macro Express will type them, or they can be embedded in text that will be properly interpreted by Notepad, etc.  Here's a list of several I have used for various reasons.
 
// BEL character ascii 7
Variable Set to ASCII Char 7 to %BEL%

 

// Escape character ascii 27
Variable Set to ASCII Char 27 to %ESC%

 

// Tab character ascii 9
Variable Set to ASCII Char 9 to %TAB%

 

// Line Feed (New Line) character ascii 10
Variable Set to ASCII Char 10 to %LINEFEED%

 

// Carriage Return character ascii 13
Variable Set to ASCII Char 13 to %CARRIAGERETURN%

 

// Carriage Return / Line Feed combination characters ascii 13 + ascii 10
Variable Set to ASCII Char 13 to %CRLF%
Variable Modify String %CRLF%: Append Text String Variable (%LINEFEED%)

 

// STX character ascii 2
Variable Set to ASCII Char 2 to %STX%

 

// ETX character ascii 3
Variable Set to ASCII Char 3 to %ETX%

 

// DC1 character ascii 17
Variable Set to ASCII Char 17 to %DC1%

 

// DC2 character ascii 18
Variable Set to ASCII Char 18 to %DC2%
 

 

  • Like 1
Link to comment
Share on other sites

Thank you all! I did change the VBA output to reflect the MEP variable names for the ASCII codes

%BACKSPACE%%tab%05708637764%tab%0122100090%tab%%tab%%tab%%tab%2%tab%%tab%

and set the TAB and BACKSPACE commands accordingly. Here's the winning script (I had to add a delay due to the COBOL app being a little on the slow side):

<VARIABLE SET TO ASCII CHAR Value="9" Destination="%Tab%"/>
<VARIABLE SET TO ASCII CHAR Value="8" Destination="%Backspace%"/>
<KEYSTROKE SPEED Delay="25"/>
<VARIABLE SET STRING Option="\x02" Destination="%AWBSTRING%" NoEmbeddedVars="FALSE"/>
<TEXT TYPE Action="0" Text="%AWBSTRING%"/>

I appreciate everyone's input - it got me on the right track!

Link to comment
Share on other sites

  • frateg8r changed the title to Send clipboard data as keystrokes - with tab key execution (RESOLVED)

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