再接再厉,完成一半,只差一步就可以模拟网站登录了!吹版请看看代码哪里问题,谢谢!
还是接着昨天那个在FORM中显示出了登录页面,然后我找了些模拟键盘输入的资料,现在用户名和密码可以通过剪切板结合模拟键盘CTRL V输入,但就是不知为何会忽略第一次置入剪切板的内容,只CTRL V了第二次剪切板的内容。of = CREATEOBJECT("webForm")
of.visible=.t.
READ EVENTS
RETURN
DEFINE CLASS webForm AS Form
ShowWindow = 2
WindowState = 2
ADD OBJECT WB AS Olecontrol WITH Width=this.width,Height=this.height,Anchor=15,OleClass="Shell.Explorer.2",Visible=.T.
ADD OBJECT tmrlogin as timer with interval=1000
PROCEDURE tmrlogin.timer
this.Enabled=.f.
mykeybd(0x09)
mykeybd(0x09)
mykeybd(0x09)
mykeybd(0x09)
_cliptext='qiuxingce@'
DO ctrlV
mykeybd(0x09)
mykeybd(0x09)
_cliptext='Chairman1106'
DO ctrlV
mykeybd(13)
ENDPROC
PROCEDURE UnLoad
CLEAR EVENTS
ENDPROC
PROCEDURE Init
this.WB.Silent = .T.
this.WB.Navigate("https://tjebook.)
ENDPROC
PROCEDURE resize
this.WB.width=this.width
this.WB.height=this.Height
ENDPROC
ENDDEFINE
FUNCTION mykeybd(Virtual_Key as Integer)
PRIVATE Virtual_Key &&键盘虚拟值,请参阅列表。
DECLARE keybd_event IN user32; &&键盘模拟API
SHORT bVk,; &&表示虚拟键值,其取值范围为1-254。
SHORT bScan,; &&该值为0
INTEGER dwFlags,; &&0按下,2弹起
INTEGER dwExtraInfo &&关于操作的附加说明,一般为0
DECLARE INTEGER MapVirtualKey IN user32;
INTEGER VK,;
INTEGER VI
DECLARE Sleep IN kernel32 INTEGER dwMilliseconds
= keybd_event(Virtual_Key, MapVirtualKey(Virtual_Key,0), 0, 0)
sleep(100)&&按键延时
= keybd_event(Virtual_Key, MapVirtualKey(Virtual_Key,0), 2, 0)
ENDFUNC
PROCEDURE ctrlV
Declare keybd_event In Win32API Short bVk,Short bScan,Integer dwFlags, Integer deExtraInfo
keybd_event(17, 0, 0, 0)
keybd_event(Asc('V'), 0, 0, 0)
keybd_event(Asc('V'), 0, 2, 0)
keybd_event(17, 0, 2, 0)
ENDPROC