用模拟键盘设计可以实现
我用这此代码实现了小键盘控制的功能,你的功能可以通过其它按键来实现,你可以一试
$PBExportHeader$u_sp_keypresser.sru
$PBExportComments$模拟按键
forward
global type u_sp_keypresser from nonvisualobject
end type
end forward
global type u_sp_keypresser from nonvisualobject
end type
global u_sp_keypresser u_sp_keypresser
type prototypes
subroutine keybd_event(uint bVk,uint bScan,long dwFlags,long dwExtraInfo ) library 'user32.dll'
end prototypes
forward prototypes
public function integer key (string as_key)
public function integer press (string as_key)
public function integer release (string as_Key)
public subroutine numkey (keycode key)
end prototypes
public function integer key (string as_key);//
// 功能:模拟按键
//
this.press(as_Key)
this.release(as_Key)
return 1
end function
public function integer press (string as_key);//
// 功能:模拟按下键
//
int li_Ascii
li_Ascii = Asc(as_Key)
keybd_event(li_Ascii, 0, 0, 0)
return 1
end function
public function integer release (string as_Key);//
// 功能:模拟释放键
//
int li_Ascii
li_Ascii = Asc(as_Key)
keybd_event(li_Ascii, 0, 2, 0)
return 1
end function
public subroutine numkey (keycode key);String ls_KeyASC
Choose Case Key
Case key1!,keynumpad1!
ls_KeyASC = "1"
Case key2!,keynumpad2!
ls_KeyASC = "2"
Case key3!,keynumpad3!
ls_KeyASC = "3"
Case key4!,keynumpad4!
ls_KeyASC = "4"
Case key5!,keynumpad5!
ls_KeyASC = "5"
Case key6!,keynumpad6!
ls_KeyASC = "6"
Case key7!,keynumpad7!
ls_KeyASC = "7"
Case key8!,keynumpad8!
ls_KeyASC = "8"
Case key9!,keynumpad9!
ls_KeyASC = "9"
Case key0!,keynumpad0!
ls_KeyASC = "10"
Case keyenter!
ls_KeyASC = "enter"
End Choose
key(ls_KeyASC)
end subroutine
on u_sp_keypresser.create
TriggerEvent( this, "constructor" )
end on
on u_sp_keypresser.destroy
TriggerEvent( this, "destructor" )
end on