![]() |
#1
|
|||
|
|||
![]()
good day
a have a macro, which has invoke by 2 keys (Q and W) from Corel Draw X3. I am bind macro with this keys. Does anyone know how to define WHAT exactly (key "Q" or key "W" or mouse event) has called macro ? May be last key in keyboard buffer or last event or something else. |
#2
|
||||
|
||||
![]()
Hi.
I'm not sure. I know the API GetKeyState() can get a current key state. There should be other ways to go about finding out. If you set W and Q to run different Subs that each perform it's needed function is the usual way to go. -John |
#3
|
|||
|
|||
![]()
Thank you for answer
Whether exists a possibility to set a program keyboard interceptor (event handler) to track key events and run macro upon pressing wanted keys (Q and W) ? |
#4
|
||||
|
||||
![]()
Hi.
Maybe you can get of to a start with this. Put this in a module. Code:
Option Explicit Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer Const W As Integer = &H57 Const Q As Integer = &H51 Sub saveKey() Dim keyW As Boolean, keyQ As Boolean, theKey As String If GetKeyState(W) < 0 Then keyW = True Else keyW = False If GetKeyState(W) < 0 Then keyQ = True Else keyQ = False If keyW = True Then theKey = "W" End If If keyQ = True Then theKey = "Q" End If SaveSetting "myApp", "Pref", "last_saved_key", theKey End Sub Code:
Private Sub GlobalMacroStorage_SelectionChange() myModule.saveKey End Sub -John |
#5
|
|||
|
|||
![]()
Hello
Great idea with GMS_SelectionChange ! Well, frankly handling of Q and W was a prototype of new macro. I am trying write a universal macro (draft code below), which invokes by L,R,T,B,C,E-keys and working so: - if it selected greather than one objects then selected objects just aligns, like common Corel Draw align operations; - if one object selected then - if it textshape then activates text alignment (Left, Right, Centered, fulljusTify etc.) - if edit node mode then node alignment (Left, Right, Top, Bottom) Main routine Code:
sub LRTBCE_handler(ByVar KeyCode as long) dim CurSelection as ShapeRange dim AlignMode as byte const cdrAnyShape = 255 select case KeyCode L: AlignMode = 1 R: AlignMode = 2 T: ... 3 B: ... 4 C: ... 5 E: ... 6 end select set CurSelection = ActiveSelectionRange select case CurSelection.Count case 0 exit sub ' no selection case 1 if CurSelection.Shape(1).Type = cdrTextShape then AlingProc cdrTextShape, alignmode exit sub end if If (ActiveShape.Type <> cdrCurveShape) Or (ActiveTool <> 22) Then _ exit sub AlignProc cdrCurveShape, alignmode case else AlignProc cdrAnyhape, alignmode end case end sub private sub alignproc(cdrShapeType as integer, aligntype as byte) const txtalign as array(cdrLeftAlignment, cdrRightAlignment, _ cdrFullJustify, cdrCenterAlignment... ' textalignment ways select case cdrShapeType case cdrTextShape ... 'text alignment txtalign(aligntype) case cdrCurveShape ... ' node align case else ... ' align some objects end select end sub |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|