API Hot Key call in VB program to activate another resident program 
Author Message
 API Hot Key call in VB program to activate another resident program

Hello,

I have a screen print utility that resides in memory, that has a hot key
assigned (currently Cntl+Shift+S) that when pressed, captures the active
window and either prints it, saves it to a bitmap file or stores it on the
clipboard as a bitmap.  Would anyone know the procedure to configure a
command button on a Visual Basic form to simulate this function?  I tried
using the "ImmSimulateHotKey" function API call, but every time I command
button is pressed, the result flag from the function is 0.  The current code
I tried is below.  Thanks in advance.

bb

-----------------------

Private Declare Function ImmSimulateHotKey Lib "imm32.dll" _
                         (ByVal hwnd As Long, _
                          ByVal dw As Long) As Long
Private Const VK_CONTROL As Long = &H11
Private Const VK_SHIFT  As Long = &H10
Private Const VK_LETTER_S  As Long = 115
Private Const VK_HOTKEY  As Long = VK_CONTROL + VK_SHIFT + VK_LETTER_S

Private Sub cmdHK_Click()
  Dim I As Integer
  I = ImmSimulateHotKey(Me.hwnd, VK_HOTKEY)
  txtResults = Str(I)
End Sub



Fri, 07 Mar 2003 03:00:00 GMT  
 API Hot Key call in VB program to activate another resident program

Bryan,

Quote:
>Would anyone know the procedure to configure a
>command button on a Visual Basic form to simulate this function?

I'd try the keybd_event or SendInput APIs. I'm not sure it'll work,
but it's worth a try.

Matt

============================================

  CodeHound - Free VB Search Engine
  http://www.codehound.com



Fri, 07 Mar 2003 03:00:00 GMT  
 API Hot Key call in VB program to activate another resident program

Matt, that's exactly what I did.  I discovered the solution last night and
it worked great.  My final solution follows.  Thanks for the tip.
-------------------
Private Declare Sub keybd_event Lib "user32" _
                   (ByVal bVk As Byte, _
                    ByVal bScan As Byte, _
                    ByVal dwFlags As Long, _
                    ByVal dwExtraInfo As Long)
Private Const VK_SHIFT = &H10
Private Const VK_CONTROL = &H11
Private Const KEYEVENTF_KEYUP = &H2
'

Private Sub mnuPrint_Click()
  keybd_event VK_SHIFT, 0, 0, 0
  keybd_event VK_CONTROL, 0, 0, 0
  keybd_event Asc("S"), 0, 0, 0
  keybd_event Asc("S"), 0, KEYEVENTF_KEYUP, 0
  keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0
  keybd_event VK_SHIFT, 0, KEYEVENTF_KEYUP, 0
End Sub


Quote:
> Bryan,

> >Would anyone know the procedure to configure a
> >command button on a Visual Basic form to simulate this function?

> I'd try the keybd_event or SendInput APIs. I'm not sure it'll work,
> but it's worth a try.

> Matt

> ============================================

>   CodeHound - Free VB Search Engine
>   http://www.codehound.com



Sat, 08 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Activating a procedure in a vb app using a hot key combination

2. Activating a procedure in a vb app using a hot key combination

3. calling a VB program from another VB program

4. Calling A VB Program From another VB Program

5. Activate hot keys

6. Making a VB Memory Resident Program?

7. Activate application w/ hot key

8. Outside call to activate a program

9. Call non-Microsoft programs from VB program

10. seeing what api calls are called from a program

11. QBASIC program --> VB program using API

12. Resident program name

 

 
Powered by phpBB® Forum Software