How can I assign shortcuts to my macro with VBA code?
I don't know if the CorelDRAW API provides any way to do that programmatically.
If I understand correctly, user-defined keyboard shortcuts are defined in the workspace.xml file. That file is stored in the "content" folder in the workspace .cdws file, which is a .zip archive.
If one understands enough about the structure of that .xml file, then one can carry out some workspace customization by manually editing that file. The same sort of editing could of course be done using code.
As an example, for the sub named, "Zoom_to_Selection_Plus", this entry is where CorelDRAW assigns the GUID to the sub:
<itemData guid="5cea53d9-584c-4943-9b21-bcad88b131bd" dynamicCommand="JQ_Zoom_to_Selection_Plus.JQ.Zoom_to_Selection_Plus" dynamicCategory="2cc24a3e-fe24-4708-9a74-9c75406eebcd" userCaption="Zoom to Selection Plus" userToolTip="Zoom to Selection Plus" icon="guid://68f65d36-12fe-41d4-be38-7eb43990e56e"/>
Somewhere else in the same file, in the "main" modifier key table, this entry assigns "F4" as the shortcut key for that macro:
<keySequence itemRef="5cea53d9-584c-4943-9b21-bcad88b131bd"> <key>VK_F4</key> </keySequence>
I don't do all of my workspace customization that way. I usually do it using CorelDRAW's normal workspace customization methods. However, there are some places - the Status Bar, for example - where I find it easier to customize by manually editing the workspace.xml file.
let me give this a try
my macros are in a gms file, does copying the gms from one machine to
another changes the GUID code?
I think that the GUID information is all in the workspace, not in the .GMS file.
In the example I posted, in that workspace, CorelDRAW has assigned 5cea53d9-584c-4943-9b21-bcad88b131bd to that macro sub (project, module, and procedure). So, that GUID can be used elsewhere to refer to that sub.
CorelDRAW can assign more than one GUID to the same macro sub, and that can make it more difficult to figure out what is going on in the workspace.xml file.
I do some work manually to keep my workspace.xml file "clean" and easier to work with. That includes adding comments to the code to mark things when I know what they are.
is there a way i can assign my own GUID to my macro without letting
coreldraw generating it for me?
because it seems the guid assigned by coreldraw to macro differ from
machine to machine