我的A键不灵了,想做个内存驻留程序通过其它键的组合来代替(100分)

T

Teny

Unregistered / Unconfirmed
GUEST, unregistred user!
我的A键坏了,想做个内存驻留程序通过其它键的组合来代替,
如在任何情况下敲B+X键时等于A键,包括各种输入法、文字编辑软件、绘图软件等,
总之代替键就等于A键。请问如何做?
 
可以做到!
做一個系統熱鍵!如ctrl+b
在這個事件裡發送一個按鍵A就可以了…!
具體的自已去搜索一下數據庫!
因為我要下班了!:)
 
To Teny
给你谢了个例子,看看吧

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure SendKey(const mKey: Word; mShiftState: TShiftState;
mCount: Integer = 1);
const
cExtended: set of Byte = [VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT, VK_HOME,
VK_END, VK_PRIOR, VK_NEXT, VK_INSERT, VK_DELETE];

procedure pKeyboardEvent(mKey, mScanCode: Byte; mFlags: Longint);
var
vKeyboardMsg: TMsg;
begin
keybd_event(mKey, mScanCode, mFlags, 0);
while PeekMessage(vKeyboardMsg, 0, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE) do
begin
TranslateMessage(vKeyboardMsg);
DispatchMessage(vKeyboardMsg);
end;
end;

procedure pSendKeyDown(mKey: Word; mGenUpMsg: Boolean);
var
vScanCode: Byte;
vNumState: Boolean;
vKeyBoardState: TKeyboardState;
begin
if (mKey = VK_NUMLOCK) then begin
vNumState := ByteBool(GetKeyState(VK_NUMLOCK) and 1);
GetKeyBoardState(vKeyBoardState);
if vNumState then
vKeyBoardState[VK_NUMLOCK] := (vKeyBoardState[VK_NUMLOCK] and not 1)
else vKeyBoardState[VK_NUMLOCK] := (vKeyBoardState[VK_NUMLOCK] or 1);
SetKeyBoardState(vKeyBoardState);
Exit;
end;

vScanCode := Lo(MapVirtualKey(mKey, 0));
if (mKey in cExtended) then begin
pKeyboardEvent(mKey, vScanCode, KEYEVENTF_EXTENDEDKEY);
if mGenUpMsg then
pKeyboardEvent(mKey, vScanCode,
KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP)
end else begin
pKeyboardEvent(mKey, vScanCode, 0);
if mGenUpMsg then pKeyboardEvent(mKey, vScanCode, KEYEVENTF_KEYUP);
end;
end;
procedure pSendKeyUp(mKey: Word);
var
vScanCode: Byte;
begin
vScanCode := Lo(MapVirtualKey(mKey, 0));
if mKey in cExtended then
pKeyboardEvent(mKey, vScanCode, KEYEVENTF_EXTENDEDKEY and KEYEVENTF_KEYUP)
else pKeyboardEvent(mKey, vScanCode, KEYEVENTF_KEYUP);
end;

var
I: Integer;
begin
for I := 1 to mCount do begin
if ssShift in mShiftState then pSendKeyDown(VK_SHIFT, False);
if ssCtrl in mShiftState then pSendKeyDown(VK_CONTROL, False);
if ssAlt in mShiftState then pSendKeyDown(VK_MENU, False);
pSendKeyDown(mKey, True);
if ssShift in mShiftState then pSendKeyUp(VK_SHIFT);
if ssCtrl in mShiftState then pSendKeyUp(VK_CONTROL);
if ssAlt in mShiftState then pSendKeyUp(VK_MENU);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SendKey(VK_F4, [ssAlt]);
end;
end.
 
我现在出差在非洲,资料不好找,上网速度了慢,哪位能帮我大致写一下代码吗?
 
to 老人家:
谢谢你,老人家!我先试试。
 
买个键盘只要20元钱啊。

程序是可以实现(偶不会),但是那多麻烦啊,会让你养成一个坏习惯的。
下次要按A的时候就想着按组合键。
 
to del520:
我说了我现在出差在非洲,键盘不好买,况且坏的是笔记本电脑的A键
 
是笔记本电脑就麻烦了,在键盘里用Alt键加小键盘的65可以代替A,Alt加小键盘的97可以代替a

 
楼上说的是asc码的输入啊。

不过,还是编个小程序吧,用小键盘不方便。
 
你有螺丝刀么?你有铅笔么?
硬件修理简单呵呵呵三片搞定
打开键盘,擦铅笔粉,装好键盘
用微软的输入法呀,或者把这个贴自上的Aa拷贝几个放到桌面上ctrl+c ctrl+v
写程序?您老人家看来还是有时间,聊天?还是做什么????
 
呵呵,非洲,你的硬盘也快了,我同事去过,修过两个。
 
顶部