Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mapkey to copy a text. 2

Status
Not open for further replies.

Aryanshome

Aerospace
Oct 7, 2009
8
0
0
US
How to create a mapkey which can copy a selected text? E.g. say I have xyz.asm as active model, Mapkey should do following tasks. File->Rename-> Copy Highlighted text(in New Name TextBox which will be "xyz")->Cancel button. File->Open->Change the type to Drawing(.drw)->paste already copied text(i.e. xyz)->Open button.

I guess this is very difficult. But I think it is possible, I'm trying with different options like using Windows batch file to copy and paste, not lucky so far. Hope to receive some of your responses.
 
Replies continue below

Recommended for you

Try looking at VB Script for windows. It can be run from the command line or dos bat file. If I remember correctly there were commands to access the clipboard contents.

You can also lookup Windows Script Host (WSH).

Stephen Seymour, PE
Seymour Engineering & Consulting Group
 
Even though this is not something I had in mind,(basically I wanted to figure out the way to trigger copy/paste using windows right click through ProE) but what you have presented is extremely innovative way to deal with some situation like example in my question. But I still believe there must be a way to trigger windows copy/paste option using bat file/vb script/java script.

Learned something new today,thanks Mehit!!!
 
Looks like there are not much options but I could achieve it using sendkey with VBScript, but still it is bit complicated as it is difficult to combine VBS and Mapkey, One of the reasons is pausing mapkey as and when required to run VBScript completely.
Even though this is not robust programming method, but works well in some cases.

This one will open the drawing of current model.



File name: OpenDrawing.vbs

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.SendKeys "%{TAB}", True
WshShell.SendKeys "%w"
WshShell.SendKeys "a"
WshShell.SendKeys "%f"
WshShell.SendKeys "r"
WshShell.SendKeys "^c"
WshShell.SendKeys "%{F4}"
WshShell.SendKeys "%f"
WshShell.SendKeys "O"
WshShell.SendKeys "^v"
WshShell.SendKeys ".drw"
WshShell.SendKeys "{ENTER}"

Mapkey to Run VBS file:-
mapkey(continued) @SYSTEM\@ echo off\nC:\\users\\xxx\\OpenDrawing.vbs\nexit;
 
Could you break your mapkey into two parts and then have the VB Script execute the second half of the mapkey. So for instance, your 1st mapkey does everything you need it to do up to and including the point where the vbscript file is launched. Then at the tail end of your vbscript file you could try executing a second mapkey using the sendkeys to complete the rest of the tasks you need.

Keep in mind that on problem with the sendkeys method is that the focus to the program you are sending the keystrokes to can be lost. This typically happens when MS Outlook pops up a message or something. I believe there is an app activate function in VB Script you can call ( I know this funciton is in VB6 and VB.net) to help maintain the focus of the proe window.

Stephen Seymour, PE
Seymour Engineering & Consulting Group
 
Status
Not open for further replies.
Back
Top