Delphi 傳送按鍵

2021-04-03 02:19:21 字數 2144 閱讀 2864

const

extendedvkeys : set of byte =

[vk_up,vk_down,vk_left,vk_right,vk_home,vk_end,vk_prior, vk_next, vk_insert,vk_delete];

//傳送按鍵

procedure sendcardno(cardno:string);

vari :integer;

begin

for i:=1 to length(cardno) do

begin

sendkeydown(vkkeyscan(cardno[i]),1, false);

end;

end;

procedure sendkeysback(key:char);

begin

sendkeydown(vkkeyscan(key),1, false);

end;

procedure sendkeydown(vkey: byte;numtimes : word;genupmsg : boolean);

varcnt : word;

scancode : byte;

numstate : boolean;

keyboardstate : tkeyboardstate;

begin

if (vkey=vk_numlock) then

begin

numstate:=bytebool(getkeystate(vk_numlock) and 1);

getkeyboardstate(keyboardstate);

if numstate then

keyboardstate[vk_numlock]:=(keyboardstate[vk_numlock] and not 1)

else

keyboardstate[vk_numlock]:=(keyboardstate[vk_numlock] or 1);

setkeyboardstate(keyboardstate);

exit;

end;

scancode:=lo(mapvirtualkey(vkey,0));

for cnt:=1 to numtimes do

if (vkey in extendedvkeys)then

begin

keyboardevent( vkey, scancode, keyeventf_extendedkey);

if (genupmsg ) then

keyboardevent( vkey, scancode, keyeventf_extendedkey or keyeventf_keyup)

endelse

begin

keyboardevent(vkey, scancode, 0) ;

if (genupmsg) then

keyboardevent(vkey, scancode, keyeventf_keyup);

end;

end;

procedure keyboardevent(vkey, scancode : byte;flags : longint);

varkeyboardmsg : tmsg;

wait :boolean;

begin

wait :=true;

keybd_event(vkey, scancode, flags,0);

if (wait) then while (

peekmessage(keyboardmsg,0,wm_keyfirst, wm_keylast, pm_remove)) do

begin

translatemessage(keyboardmsg);

dispatchmessage( keyboardmsg);

end;

end;

procedure setcardlength(value: integer);

begin

cardlength:=value;

end;

procedure setsendkey(value: boolean);

begin

sendkey:=value;

end;

Delphi傳送郵件

首先在控制元件欄定位到 indy clients新增控制元件idsmtp 再定位到 indy misc新增控制元件idmessage 傳送郵件函式 procedure tform1.sendmail yyuser string yypass string begin tryidsmtp1.authe...

Delphi傳送郵件

首先在控制元件欄定位到 indy clients加入控制元件idsmtp 再定位到 indy misc加入控制元件idmessage 傳送郵件函式 procedure tform1.sendmail yyuser string yypass string begin tryidsmtp1.authe...

Delphi 切換滑鼠左右按鍵

要切換滑鼠按鈕可以呼叫 api swapmousebutton,但這個函式不會改變控制面板中的設定。下面的 通過修改登錄檔來實現這個功能 uses windows,registry const leftbutton 0 rightbutton 1 vauetoread swapmousebutton...

delphi鍵盤按鍵偽碼

常數名稱 十六進位制值 十進位制值 對應按鍵 vk lbutton 01 1 滑鼠的左鍵 vk rbutton 02 2 滑鼠的右鍵 vk cancel 03 3 contol break 執行 vk mbutton 04 4 滑鼠的中鍵 三按鍵滑鼠 vk back 08 8 backspace鍵 ...

delphi郵件定時傳送

unit smtp inte ce uses windows,messages,sysutils,variants,classes,graphics,controls,forms,dialogs,stdctrls,idbasecomponent,idcomponent,idtcpconnection...