| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Os/2 Window |
>@MSGID: 1:3618/7 2e8f76a3
>@CHRS: IBMPC 2
> How can I send a "keyboard stroke" to another OS/2 process?
I can't think of
>a decent way to do this in Full Screen or a window. Must be an easy way?
>I'd also like to go the other way: I would like to send anything the program
>has coming out of stdout and send it to a pipe. Peter Fitzsimmons did this
>with Maxpipe, but going to a com port if memory serves me correct. I'd need
>it from a PIPE so I could pick it up in another process.
Ed,
You can duplicate the handle for stdin to accept i/o from a pipe like this:
/* server.c */
#define INCL_DOS
#include
#include
#define PIPESIZE 4096
#define OBJBUFLEN 100
int main(USHORT argc, PCHAR argv[], PCHAR envp[]) {
HFILE MyIn=0, SaveMyIn=-1, PipeRead, PipeWrite;
char ObjNameBuf[OBJBUFLEN], buf[PIPESIZE];
ULONG ExecFlags=EXEC_ASYNC, byteswritten=0, bytesread=0;
RESULTCODES clientrc;
/* initialize buffer to 0's */
memset(&buf,'\0',PIPESIZE);
/* save handle to stdin */
DosDupHandle(MyIn,&SaveMyIn);
/* replace stdin with pipe */
DosCreatePipe(&PipeRead,&PipeWrite,PIPESIZE);
DosDupHandle(PipeRead,&MyIn);
/* launch client program */
DosExecPgm(ObjNameBuf,OBJBUFLEN,ExecFlags,NULL,
NULL,&clientrc,"client.exe");
/* restore stdin */
DosDupHandle(SaveMyIn,&MyIn);
/* send the client a message. Client reads it from stdin */
DosWrite(PipeWrite,"Hello, Client.\n",15,&byteswritten);
/* clean up */
DosSleep(2000);
DosClose(PipeRead);
DosClose(PipeWrite);
return(0);
}
/***** end of server.c *************/
/* client.c */
#define INCL_DOS
#include
#include
int main(USHORT argc, PCHAR argv[],PCHAR envp[]) {
char buf1[100];
/* this guy just does a regular scanf from what he thinks is stdin */
scanf("%[^\n",buf1);
printf("%s\n",buf1);
return(0);
}
/******* end of client.c **************/
___
* MR/2 2.05 NR * billyoc{at}netcom.com
--- QScan v1.12b / 01-0164
* Origin: PandA's Den BBS * Danvers, MA * 508-750-0250 * Node 1 (1:330/204)SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 410 413 SEEN-BY: 711/430 807 808 809 934 942 949 712/353 623 713/888 800/1 @PATH: 330/204 176 3615/50 229/2 12/2442 711/409 54/54 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.