CTRL+C+C

CTRL+C+C

Postby MarcoBoschi » Mon Mar 08, 2010 4:31 pm

Hi,
I have to simulate pressing CTRL + C + C to send a string to another program that runs in the tray icon. I think that it perform polling and read from "office" clipboard.
Is it possible?
Thanks
Marco
User avatar
MarcoBoschi
 
Posts: 1018
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: CTRL+C+C

Postby MarcoBoschi » Tue Mar 09, 2010 10:12 am

From another thread

http://forums.fivetechsupport.com/viewtopic.php?p=90269#p90269
I fount the solution
It works
But there is a very big problem: after the phone call I have to restart the PC because the keypad locks. :?



#include "Fivewin.ch"

#define VK_LMENU 164
#define VK_A 65
STATIC oClp

FUNCTION MAIN()

LOCAL oDlg
LOCAL oBtn

LOCAL cNumber := SPACE(20)

DEFINE DIALOG oDlg
DEFINE CLIPBOARD oClp OF oDlg

@ 1, 1 GET cNumero

@ 2, 1 BUTTON oBtn PROMPT "Call"

// I perform a CTRL+C+C
oBtn:bAction = { || oClp:SetText( ALLTRIM(cNumero) ) , ;
SetStateKey( VK_CONTROL, .T. ) , ;
SetStateKey( ASC("C"), .T. ) , ;
HB_IDLESLEEP(1) , ;
SetStateKey( ASC("C"), .F. ) , ;
oClp:Clear() }

ACTIVATE DIALOG oDlg

RETURN NIL

#pragma begindump

#include <windows.h>
#include <hbapi.h>

HB_FUNC( SETSTATEKEY )
{
if( hb_parl(2) )
keybd_event( hb_parvnl(1), 0x45, KEYEVENTF_EXTENDEDKEY | 0, 0 );
else
keybd_event( hb_parvnl(1), 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
}

#pragma enddump
User avatar
MarcoBoschi
 
Posts: 1018
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: CTRL+C+C

Postby Enrico Maria Giordano » Tue Mar 09, 2010 10:21 am

Try to release VK_CONTROL after its use:

Code: Select all  Expand view
SetStateKey( VK_CONTROL, .F. )


Only a stub in the dark.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8356
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: CTRL+C+C

Postby MarcoBoschi » Tue Mar 09, 2010 10:44 am

Enrico,
in this way?

oBtn:bAction = { || oClp:SetText( ALLTRIM(cNumero) ) , ;
SetStateKey( VK_CONTROL, .T. ) , ;
SetStateKey( ASC("C"), .T. ) , ;
HB_IDLESLEEP(1) , ;
SetStateKey( ASC("C"), .T. ) , ;
SetStateKey( VK_CONTROL, .F. ) , ;
oClp:Clear() }

Thank You
User avatar
MarcoBoschi
 
Posts: 1018
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: CTRL+C+C

Postby Enrico Maria Giordano » Tue Mar 09, 2010 11:00 am

Yes. And try to release ASC( "C" ) key too.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8356
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 41 guests