FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour CTRL+C+C
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
CTRL+C+C
Posted: Mon Mar 08, 2010 04: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

Marco Boschi
info@marcoboschi.it
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: CTRL+C+C
Posted: 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
Marco Boschi
info@marcoboschi.it
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: CTRL+C+C
Posted: Tue Mar 09, 2010 10:21 AM
Try to release VK_CONTROL after its use:

Code (fw): Select all Collapse
SetStateKey( VK_CONTROL, .F. )


Only a stub in the dark.

EMG
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: CTRL+C+C
Posted: Tue Mar 09, 2010 10:44 AM

Enrico,
in this way?

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

Thank You

Marco Boschi
info@marcoboschi.it
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: CTRL+C+C
Posted: Tue Mar 09, 2010 11:00 AM

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

EMG

Continue the discussion