Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

send key to other process ?!

43 views
Skip to first unread message

fatfat

unread,
Feb 5, 2012, 10:18:38 AM2/5/12
to
Hi all,

is it possible to send key from one xharbour exe to any other process (or
other xharbour exe) ?!

Thanks

Saulius

unread,
Feb 5, 2012, 1:03:34 PM2/5/12
to
Hi fatfat,

> is it possible to send key from one xharbour exe to any other process (or
> other xharbour exe) ?!

yes, but these things are OS dependent

Best regards,
Saulius


Rainer Berning

unread,
Feb 5, 2012, 2:29:40 PM2/5/12
to
I use autoit , give it a try.


"fatfat" <fat...@fatfat.com> schrieb im Newsbeitrag
news:jgm6kg$9ek$1...@dont-email.me...

dlzc

unread,
Feb 5, 2012, 4:30:22 PM2/5/12
to
Dear fatfat:
I believe WinAPI permits pushing keystrokes into the system keyboard
buffer, maybe even our own internal keyboard functions do this. Just
have to be sure you don't enter any input routines to lose them
again...

David A. Smith

fatfat

unread,
Feb 6, 2012, 12:48:17 AM2/6/12
to
can have more details ?!

Thanks

"Rainer Berning" 在郵件張貼內容主旨
4f2ed88c$0$6547$9b4e...@newsspool4.arcor-online.net 中撰寫...

fatfat

unread,
Feb 6, 2012, 12:48:38 AM2/6/12
to
how to support from windows xp/7 ?!
Thanks


"Saulius" 在郵件張貼內容主旨 jgmg9h$ggc$1...@speranza.aioe.org 中撰寫...

Rainer Berning

unread,
Feb 6, 2012, 2:44:11 AM2/6/12
to
have a look at
http://www.autoitscript.com/autoit3/

Rainer Berning


"fatfat" <fat...@fatfat.com> schrieb im Newsbeitrag
news:jgnpj4$ha9$1...@dont-email.me...

Saulius

unread,
Feb 6, 2012, 6:44:17 AM2/6/12
to
> how to support from windows xp/7 ?!

#include 'inkey.ch'

#define NOTEPAD

Proc Main()
Local cTitle, cControl, nKey, lSender, lSucc

#ifdef NOTEPAD
__run('start notepad')
cTitle := 'Untitled - Notepad'
cControl := 'Edit'
lSender := .t.
#else
//make copy of program.exe to program0.exe
cTitle := hb_Argv(0)
cTitle := SubStr(cTitle, Rat('\', cTitle) +1)
cTitle := Left(cTitle, At('.', cTitle) -1)
lSender := Right(cTitle, 1) # '0'
cTitle := if(lSender, cTitle +'0', Left(cTitle, Len(cTitle) -1))
#endif

if lSender
? 'Sending to "' +if(cTitle == Nil, 'ourselves', cTitle) +'"...'
else
? 'Waiting from "' +cTitle +'"...'
endif
While (nKey := INKEY(0)) # K_ESC
? if(lSender, 'send', 'receive') +if(nKey < 32, ' <' +Ltrim(Str(nKey)) +'>', ' "' +Chr(nKey) +'"')
if lSender
if nKey > 48 .and. nKey < 54 //keys 1..5
lSucc := SendKeys({'one', 'two', 'three', 'four', 'five'}[nKey -48], cTitle, cControl)
else
lSucc := SendKeys(nKey, cTitle, cControl)
endif
if !lSucc
?? ' --- no receiver!'
endif
endif
end
Return

#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"

HB_FUNC( SENDKEYS )
{
HANDLE WndHandle = ISCHAR(2) ? FindWindow( NULL, hb_parc( 2 ) ) : GetForegroundWindow();
BOOL bSuccess = FALSE;

if( WndHandle )
{
if( ISCHAR(3) )
WndHandle = FindWindowEx( WndHandle, 0, hb_parc( 3 ), NULL );

if( WndHandle )
{
if( ISNUM(1) )
SendMessage( WndHandle, WM_CHAR, hb_parni( 1 ), 1 );
else
{
const char *pStr = hb_parc( 1 );
size_t sPos, sLen = hb_parclen( 1 );

for( sPos = 0; sPos < sLen; sPos++ )
SendMessage( WndHandle, WM_CHAR, pStr[sPos], 1 );
}
bSuccess = TRUE;
}
}
hb_retl( bSuccess );
}
#pragma ENDDUMP

Best regards,
Saulius


fatfat

unread,
Feb 6, 2012, 7:32:06 AM2/6/12
to
thanks a lot
it works great ...


"Saulius" 在郵件張貼內容主旨 jgoeec$h77$1...@speranza.aioe.org 中撰寫...

fatfat

unread,
Feb 6, 2012, 7:55:24 AM2/6/12
to
but can't get it work if enter the title of a xharbour console exe e.g.
test.exe
Thanks


"Saulius" 在郵件張貼內容主旨 jgoeec$h77$1...@speranza.aioe.org 中撰寫...

Saulius

unread,
Feb 6, 2012, 9:10:33 AM2/6/12
to
> but can't get it work if enter the title of a xharbour console exe e.g. test.exe

Specified string must case-insensitive match window's title.


fatfat

unread,
Feb 6, 2012, 11:46:27 AM2/6/12
to
try already but not successful
Thanks

"Saulius" 在郵件張貼內容主旨 jgon0o$718$1...@speranza.aioe.org 中撰寫...

fatfat

unread,
Feb 7, 2012, 7:09:57 AM2/7/12
to
got the solution by using findwindowex.c and sendmessage.c routuine for
console model problem
thank

"dlzc" 在郵件張貼內容主旨
e7f31731-58fc-437b...@p12g2000yqe.googlegroups.com 中撰寫...

fatfat

unread,
Feb 7, 2012, 7:10:29 AM2/7/12
to
got the solution by using findwindowex.c and sendmessage.c routuine for
console mode program
thank

"Saulius" 在郵件張貼內容主旨 jgon0o$718$1...@speranza.aioe.org 中撰寫...
0 new messages