🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11833

Synthesizing keystrokes

#11833
From: Miguel Q Moraes
Date: Mon, 12 Jan 2004 14:32
26 lines
1761 bytes
I have two computers and only one keyboard/monitor/mouse and I use a KVM
switch to alternate between the two CPUs.
I can switch between them using the following keystrokes: (CTRL+ALT+SHIFT) +
(1 or 2) + (ENTER).
I want to be able to do that remotely, so I need to simulate these
keystrokes. I tried the following but it didn't work:

void sim_keystroke(void)
{
    keybd_event(VK_CONTROL, 0x1D, 0, 0);
    keybd_event(VK_MENU, 0x38, 0, 0);
    keybd_event(VK_SHIFT, 0x2A, 0, 0);
    keybd_event(VK_CONTROL, 0x1D, KEYEVENTF_KEYUP, 0);
    keybd_event(VK_SHIFT, 0x2A, KEYEVENTF_KEYUP, 0);
    keybd_event(VK_MENU, 0x38, KEYEVENTF_KEYUP, 0);
    keybd_event(0x31, 0x02, 0, 0);
    keybd_event(0x31, 0x02, KEYEVENTF_KEYUP, 0);
    keybd_event(VK_RETURN, 0x1C, KEYEVENTF_EXTENDEDKEY, 0);
    keybd_event(VK_RETURN, 0x1C, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY,
0);
}

How can I do that?

Thanks,
Miguel
Technical Details
Message-ID: <4002b020$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,14168aac82691d4,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-01-12 06:40:14 PST
From: "Miguel Q Moraes" <miguel@globaltrac.com.br>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Synthesizing keystrokes
Date: Mon, 12 Jan 2004 12:32:52 -0200
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 139.82.111.130
Message-ID: <4002b020$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1073917984 139.82.111.130 (12 Jan 2004 06:33:04 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail