分享
 
 
 

“序列号输入助手”源代码

王朝delphi·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

<!--

body { font-family: "宋体"; font-size: 9pt;color: #000000 }

.u0 { font-family: "宋体"; font-size: 9pt;color: #FF0000 }

.u1 { font-family: "宋体"; font-size: 9pt;color: #008000 }

.u2 { font-family: "宋体"; font-size: 9pt;color: #000080 }

.u3 { font-family: "宋体"; font-size: 9pt;color: #000080 }

.u4 { font-family: "宋体"; font-size: 9pt;color: #000000 }

.u5 { font-family: "宋体"; font-size: 9pt; font-weight: bold;color: #0000FF }

.u6 { font-family: "宋体"; font-size: 9pt;color: #0000FF }

.u7 { font-family: "宋体"; font-size: 9pt;color: #000000 }

.u8 { font-family: "宋体"; font-size: 9pt;color: #000080 }

.u9 { font-family: "宋体"; font-size: 9pt;color: #000000 }

.u10 { font-family: "宋体"; font-size: 9pt;color: #000080 }

-->

/////////////////////////////////////////////////////////

// SnInput //

// //

// 作者:黄展宏 //

// QQ号:309654973 //

// 创建于:2005/06/23 //

// 修改于:2005/06/29 //

/////////////////////////////////////////////////////////

program SnInput;

{$APPTYPE GUI}

{$I-}

uses

Windows,

Messages,

SysUtils;

var

atom: Integer = 0;

hInst: Integer;

wc: TWndClassEx;

Msg: TMsg;

hFont: Integer = 0;

hMutex: Integer;

hWnd: Integer;

hEdit: Integer;

hCheckBox: Integer;

hTmpWnd: Integer;

const

ID_CHECKBOX = 100;

STR_INTERNALNAME = 'SnInputApplication';

STR_CHECKBOX = '将“-”(杠号)转为跳格键(Tab)。';

STR_HOTKEY = 'MyHotKey_OrochiHuang_2005.6.18';

STR_PRODUCT = '序列号输入助手 V0.1';

STR_TIPS = (#13#10 +

'使用说明:' + #13#10 +

'1、复制序列号。'#13#10 +

'2、将光标定位到序列号输入处。'#13#10 +

'3、按F10键。'#13#10 + #13#10 +

'“将‘-’(杠号)转为跳格键(Tab)”功能说明:' + #13#10 +

'因为有一些程序当输完一段序列号后,不会自动跳往下一格继续输入,导致把全部注册码输入在一个序列号段里,' +

'遇到这个种情况的话勾选它就对啦!' + #13#10 + #13#10 +

'作者:黄展宏' + #13#10 +

'Email:orochi_huang@126.com');

procedure MySendKeys(Keys: PChar);

procedure SendKeyDown(VKey: Byte);

var ScanCode: Byte;

begin

ScanCode := Lo(MapVirtualKey(VKey, 0));

keybd_event(VKey, ScanCode, 0, 0);

end;

procedure SendKeyUp(VKey: Byte);

var ScanCode: Byte;

begin

ScanCode := Lo(MapVirtualKey(VKey, 0));

keybd_event(VKey, ScanCode, KEYEVENTF_KEYUP, 0);

end;

function BitSet(BitTable, BitMask: Byte): Boolean;

begin

Result := ByteBool(BitTable and BitMask);

end;

var

L: Word;

I: Word;

MKey: Word;

ScanCode: Byte;

const

VKKEYSCANSHIFTON = $01;

VKKEYSCANCTRLON = $02;

VKKEYSCANALTON = $04;

begin

L := StrLen(Keys);

if L = 0 then Exit;

for I := 0 to L - 1 do

begin

MKey := vkKeyScan(Keys[I]);

if MKey <> $FFFF then

begin

ScanCode := Hi(MKey);

if BitSet(ScanCode, VKKEYSCANSHIFTON) then SendKeyDown(VK_SHIFT);

if BitSet(ScanCode, VKKEYSCANCTRLON) then SendKeyDown(VK_CONTROL);

if BitSet(ScanCode, VKKEYSCANALTON) then SendKeyDown(VK_MENU);

SendKeyDown(MKey);

SendKeyUp(MKey);

if BitSet(ScanCode, VKKEYSCANSHIFTON) then SendKeyUp(VK_SHIFT);

if BitSet(ScanCode, VKKEYSCANCTRLON) then SendKeyUp(VK_CONTROL);

if BitSet(ScanCode, VKKEYSCANALTON) then SendKeyUp(VK_MENU);

Sleep(15);

end;

end;

end;

procedure HotKey(hWnd: Integer; state: Boolean);

begin

if state then

begin

atom := GlobalFindATOM(STR_HOTKEY);

if atom = 0 then atom := GlobalAddATOM(STR_HOTKEY);

RegisterHotKey(hWnd, atom, 0, VK_F10);

end

else begin

if atom <> 0 then

begin

UnregisterHotKey(hWnd, atom);

GlobalDeleteATOM(atom);

atom := 0;

end;

end;

end;

function WndProc(hWnd: Integer; uMsg: Cardinal;

wParam, lParam: Integer): LRESULT; stdcall;

var

hData: Integer;

Keystr: string;

Position: Byte;

rc: TRect;

begin

Result := 0;

case uMsg of

WM_CTLCOLORSTATIC:

begin

if lParam = hEdit then

begin

SetBkColor(wParam, $FFFFFF);

Result := GetStockObject(WHITE_BRUSH);

end;

end;

WM_CREATE:

begin

HotKey(hWnd, True);

GetClientRect(hWnd, rc);

hEdit := CreateWindowEx(WS_EX_CLIENTEDGE, 'EDIT', STR_TIPS,

WS_BORDER or WS_CHILD or WS_VISIBLE or ES_READONLY or ES_MULTILINE or

WS_VSCROLL,

0, 30, rc.Right, rc.Bottom - 30, hWnd, 0, hInst, nil);

hCheckBox := CreateWindowEx(0, 'BUTTON', STR_CHECKBOX, WS_VISIBLE or

WS_CHILD or BS_AUTOCHECKBOX,

10, 10, 300, 20, hWnd, ID_CHECKBOX, hInst, nil);

hFont := CreateFont(12, 0, 0, 0, 0, 0, 0, 0,

DEFAULT_CHARSET, 0, 0, 0, 0, '宋体');

if hFont <> 0 then

begin

SendMessage(hEdit, WM_SETFONT, hFont, 0);

SendMessage(hCheckBox, WM_SETFONT, hFont, 0);

end;

end;

WM_HOTKEY:

begin

OpenClipboard(hWnd);

hData := GetClipboardData(CF_TEXT);

if hData <> 0 then

begin

Keystr := StrPas(PChar(GlobalLock(hData)));

Position := Pos('-', Keystr);

while Position > 0 do

begin

if SendMessage(hCheckBox, BM_GETCHECK, 0, 0) <> 0 then

Keystr[Position] := Char(VK_TAB)

else

Delete(KeyStr, Position, sizeof(keystr[Position]));

Position := Pos('-', Keystr);

end;

MySendKeys(PChar(KeyStr));

GlobalUnlock(hData);

end;

CloseClipboard;

end;

WM_DESTROY:

begin

if hFont <> 0 then

DeleteObject(hFont);

HotKey(hWnd, False);

PostQuitMessage(0);

end;

else

Result := DefWindowProc(hWnd, uMsg, wParam, lParam);

end;

end;

begin

hMutex := CreateMutex(nil, True, STR_PRODUCT);

if GetLastError = ERROR_ALREADY_EXISTS then

begin

hTmpWnd := FindWindow(STR_INTERNALNAME, nil);

if hTmpWnd <> 0 then

begin

if IsIconIc(hTmpWnd) then

ShowWindow(hTmpWnd, SW_NORMAL);

SetForegroundWindow(hTmpWnd);

ShowWindow(hTmpWnd, SW_SHOW);

end;

Exit;

end;

hInst := hInstance;

FillChar(wc, SizeOf(wc), 0);

with wc do

begin

cbSize := SizeOf(wc);

style := CS_HREDRAW or CS_VREDRAW;

lpfnWndProc := @WndProc;

hInstance := hInst;

hIcon := LoadIcon(0, IDI_APPLICATION);

hCursor := LoadCursor(0, IDC_ARROW);

hbrBackground := GetSysColorBrush(COLOR_BTNFACE);

lpszClassName := STR_INTERNALNAME;

end;

if RegisterClassEx(wc) = 0 then Exit;

hWnd := CreateWindowEx(0, wc.lpszClassName, STR_PRODUCT,

(*WS_OVERLAPPED or *)WS_MINIMIZEBOX or WS_CAPTiON or WS_SYSMENU,

Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), 320, 250,

0, 0, hInst, nil);

if hWnd = 0 then Exit;

ShowWindow(hWnd, SW_SHOW);

UpdateWindow(hWnd);

repeat

if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then

begin

TranslateMessage(Msg);

DispatchMessage(Msg);

end

else begin

;

end;

until Msg.message = WM_QUIT;

ReleaseMutex(hMutex);

CloseHandle(hMutex);

end.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有