Page 1 of 1

emulate CTRL+V

Posted: Wed Nov 13, 2024 6:55 pm
by Natter
How to emulate CTRL+V ?

Re: emulate CTRL+V

Posted: Wed Nov 13, 2024 9:05 pm
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.

Re: emulate CTRL+V

Posted: Thu Nov 14, 2024 8:21 am
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

Re: emulate CTRL+V

Posted: Thu Nov 14, 2024 2:44 pm
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.

Re: emulate CTRL+V

Posted: Sun Nov 17, 2024 1:43 pm
by Giovany Vecchi
Try using WScript

Code: Select all | Expand

lc_oShell := tOleAuto():New( "WScript.Shell" )
lc_oShell:SendKeys("^V")
 

Re: emulate CTRL+V

Posted: Sun Nov 17, 2024 4:18 pm
by karinha

Re: emulate CTRL+V

Posted: Sun Nov 17, 2024 4:57 pm
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

Re: emulate CTRL+V

Posted: Sun Nov 17, 2024 5:14 pm
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