emulate CTRL+V

Post Reply
Natter
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

emulate CTRL+V

Post by Natter »

How to emulate CTRL+V ?
User avatar
karinha
Posts: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: emulate CTRL+V

Post by karinha »

Complete, pls:

Code: Select all | Expand

   oWnd:bKeyDown := { | nKey | StdKey( nKey ) }

FUNCTION StdKey( nKey )

   DO CASE
   CASE nKey == 65 .AND. GetKeyState( VK_CONTROL ) // Crtl + A
      CreateInfoArticulo()
   CASE nKey == 38 .AND. GetKeyState( VK_CONTROL ) // Ctrl + Down
      NextEmpresa()
   CASE nKey == 40 .AND. GetKeyState( VK_CONTROL ) // Ctrl + Up
      PriorEmpresa()
   CASE nKey == 48 .AND. GetKeyState( VK_CONTROL ) // Ctrl + 0
      dbDialog()
   END CASE

RETURN NIL
 
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Natter
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

Re: emulate CTRL+V

Post by Natter »

karinha, I was asking how to emulate pressing CTRL+V
Like this

Code: Select all | Expand

SendMessage( hWn, WM_KEYDOWN, 8, 0) //left ctrl
SendMessage( hWn, WM_KEYDOWN, asc("V"), 0)
SendMessage( hWn, WM_KEYUP, 8, 0) //left ctrl
SendMessage( hWn, WM_KEYUP, asc("V"), 0)
This option does not work
User avatar
karinha
Posts: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: emulate CTRL+V

Post by karinha »

PostMsg( WM_KEYDOWN, ASC("V" ) ??

Something like that?

Code: Select all | Expand

oCbx1:bKeydown := {| nkey | COM_KEY( nKey ) }

FUNCTION COM_KEY_U( nKey )

   IF nKey = VK_RETURN

      QKeyboard( Chr( VK_TAB ), oCbx2:hWnd )

   ENDIF

RETURN NIL

FUNCTION QKeyboard( TECLA, hWndCtl )

   IF hWndCtl == Nil

      hWndCtl := getactivewindow()

   END

   SetFocus( hWndCtl )

   Postmessage( hWndCtl, WM_KEYDOWN, Asc( TECLA ) )

RETURN NIL
 
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
Giovany Vecchi
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: emulate CTRL+V

Post by Giovany Vecchi »

Try using WScript

Code: Select all | Expand

lc_oShell := tOleAuto():New( "WScript.Shell" )
lc_oShell:SendKeys("^V")
 
User avatar
karinha
Posts: 7885
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Contact:

Re: emulate CTRL+V

Post by karinha »

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
Armando
Posts: 3248
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México
Contact:

Re: emulate CTRL+V

Post by Armando »

Natter:
Natter wrote:How to emulate CTRL+V ?
It is advisable to indicate the destination of the emulation, Dlg or Get

Code: Select all | Expand

oDlg:PostMsg(WM_KEYDOWN,ASC("V"),0)
 
I hope these can help you

With best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
nageswaragunupudi
Posts: 10691
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: emulate CTRL+V

Post by nageswaragunupudi »

Giovany Vecchi wrote:Try using WScript

Code: Select all | Expand

lc_oShell := tOleAuto():New( "WScript.Shell" )
lc_oShell:SendKeys("^V")
 
Thanks. This is working for me.

This is my test:

Code: Select all | Expand

#include "fivewin.ch"

#define WM_PASTE           770

function Main()

   local oDlg, oBar, oGet
   local cText := Space( 100 )

   SetGetColorFocus()
   DEFINE DIALOG oDlg SIZE 400,200 PIXEL TRUEPIXEL

   DEFINE BUTTONBAR oBar OF oDlg SIZE 100,40 2007
   DEFINE BUTTON OF oBar PROMPT "CtrlV" CENTER ;
      ACTION ( oGet:SetFocus(), ;
      TOleAuto():New( "WScript.Shell" ):SendKeys( "^V" ) )
   DEFINE BUTTON OF oBar PROMPT "Paste" CENTER ;
      ACTION SendMessage( oGet:hWnd, WM_PASTE, 0, 0 )
   DEFINE BUTTON OF oBar PROMPT "Clear" CENTER ;
      ACTION oGet:cText := Space( 100 )

   //
   @ 100,20 GET oGet VAR cText SIZE 360,24 PIXEL OF oDlg

   ACTIVATE DIALOG oDlg CENTERED

return nil
Image
Regards

G. N. Rao.
Hyderabad, India
Post Reply