我编写了单点登录系统,可以制动填写用户名密码:
oie = CreateObject("InternetExplorer.Application")
oie.Top=0
oie.Left=0
oie.Height=898
oie.Width=1430
oie.MenuBar=.t. &&窗口是否有菜单。
oie.StatusBar=.t.
&&显示IE对象 状态栏
oie.Navigate(b.url)
&& "http://10.90.144.7"
"http://10.90.150.11:89"
oie.FullScreen=.F.
&&全屏显示
oie.ToolBar=.t.
&&显示IE对象工具栏
oie.Visible=.t.
&& 窗口是否可见;
oie.AddressBar=.t.
&&显示IE对象 地址栏
oie.Resizable=.t.
&&设置IE对象 大小是否可以被改动
=SetForegroundWindow(oie.hWnd)
&& IE10,不在此加此语句,在选择“系统界面”后面打开网页,IE6在前面打开。
zzz=""
do while oie.busy .or. oie.ReadyState#4
&&此法可行!
zzz=zzz+transform(oie.ReadyState)
enddo
ChengGongDaKai=len(zzz)<25000 .or."33" $ zzz
&&成功打开
if ChengGongDaKai
Jv_Bing_str=Jv_bing_str+transform(xt_sb)+"_"+transform(oie.hWnd)+","
if !No_hum_mm
=sleep(2000+1000*delay)
=SetForegroundWindow(oie.hWnd)
if .not.zjsr
MOUSEEVENTF_LEFTDOWN=0x2
MOUSEEVENTF_LEFTUP=0x4
MOUSEEVENTF_MIDDLEDOWN=0x20
MOUSEEVENTF_MIDDLEUP=0x40
MOUSEEVENTF_MOVE=0x1
MOUSEEVENTF_ABSOLUTE=0x8000
MOUSEEVENTF_RIGHTDOWN=0x8
MOUSEEVENTF_RIGHTUP=0x10
Xmus=mus_x
Ymus=mus_y
*在鼠标坐标系统中,不管什么分辨率屏幕在水平和垂直方向上均匀分割成65535×65535个单元
=mouse_event(MOUSEEVENTF_ABSOLUTE+MOUSEEVENTF_MOVE,Xmus,Ymus,0,0) &&移动鼠标到绝对位置29800,29600
=mouse_event(MOUSEEVENTF_LEFTDOWN+MOUSEEVENTF_LEFTUP,0,0,0,0)
&&单击左键(按下再松开的组合)
=Sleep(100)
=mouse_event(MOUSEEVENTF_LEFTDOWN+MOUSEEVENTF_LEFTUP,0,0,0,0)
&&单击左键(按下再松开的组合)
*=mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0)
*=mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0)
*=Sleep(100)
do Tab_Enter_sr.prg with Q_Tab_s
endif
keybd_event(17, 0, 0, 0)
&&ctr 是 17 或 0X11(十六进制11)Shift键:16 TAB键:9。 模拟ctr_A A字母要大写,输出的是小写的。
keybd_event(Asc('A'), 0, 0, 0)
=Sleep(8)
keybd_event(Asc('A'), 0, 2, 0)
keybd_event(17, 0, 2, 0)
*for ii=1 to 20
*keybd_event(8, 0, 0, 0) && BackSpace退格键是:8
*=Sleep(8)
*keybd_event(8, 0, 2, 0)
*keybd_event(46, 0, 0, 0) && Delete 键是46
*=Sleep(8)
*keybd_event(46, 0, 2, 0)
*endfor
*_ClipText=alltrim(a.xt_hum)
*keybd_event(17, 0, 0, 0)
&&ctr 是 17 或 0X11(十六进制11)Shift键:16 TAB键:9。 模拟ctr_V。
*keybd_event(Asc('V'), 0, 0, 0)
*= Sleep(8)
*keybd_event(Asc('V'), 0, 2, 0)
*keybd_event(17, 0, 2, 0)
do hum_mm_sr with alltrim(a.xt_hum)
keybd_event(9, 0, 0, 0)
=Sleep (5)
keybd_event(9, 0, 2, 0)
keybd_event(17, 0, 0, 0)
&&ctr 是 17 或 0X11(十六进制11)Shift键:16 TAB键:9。 模拟ctr_A。
keybd_event(Asc('A'), 0, 0, 0)
=Sleep(8)
keybd_event(Asc('A'), 0, 2, 0)
keybd_event(17, 0, 2, 0)
*for ii=1 to 20
*keybd_event(8, 0, 0, 0) && BackSpace退格键是:8
*= Sleep(8)
*keybd_event(8, 0, 2, 0)
*keybd_event(46, 0, 0, 0) && Delete 键是46
*= Sleep(8)
*keybd_event(46, 0, 2, 0)
*endfor
*_ClipText=alltrim(a.xt_mm)
*keybd_event(17, 0, 0, 0)
*keybd_event(Asc('V'), 0, 0, 0)
*= Sleep(5)
*keybd_event(Asc('V'), 0, 2, 0)
*keybd_event(17, 0, 2, 0)
*_ClipText=""
&&往系统剪切板中放入字串,以便用Ctr+V复制。
do hum_mm_sr with alltrim(a.xt_mm)
do Tab_Enter_sr.prg with H_Tab_s
if yn_yzm
keybd_event(9, 0, 0, 0)
=Sleep(5)
keybd_event(9, 0, 2, 0)
* =messagebox("请按确定之后,在验证码栏输入本系统的验证码!",0+48,"系统提示您:")
* wait windows "请在验证码栏输入本系统的验证码!" nowait
else
keybd_event(13, 0, 0, 0)
&&最后的回车键Enter:13。
=Sleep(5)
keybd_event(13, 0, 2, 0)
endif
endif
else
oie.quit()
=messagebox("无法打开:“"+alltrim(b.xt_mc)+"”的服务网页!"+chr(13)+chr(13)+"请检查网络连接、或本系统的状态是否正常。",0+48,"系统提示您:") &&48 改为16 是错误提示!
endif
endif
else
ShowWindow(JBNoClose_BXT,1)
&&此语句不能少!
SetForegroundWindow(JBNoClose_BXT) &&激活窗口
hum_mm_sr.prg 代码如下:
parameters str_c
clear typeahead
do while len(str_c)>0
str_c1=left(str_c,1)
do case
case str_c1 $ "abcdefghijklmnopqrstuvwxyz"
keybd_event(Asc(upper(str_c1)), 0, 0, 0)
=sleep(8)
keybd_event(Asc(upper(str_c1)), 0, 2, 0)
case str_c1 $ "0123456789"
keybd_event(Asc(str_c1), 0, 0, 0)
=sleep(8)
keybd_event(Asc(str_c1), 0, 2, 0)
case str_c1 $ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
keybd_event(16, 0, 0, 0)
keybd_event(Asc(str_c1), 0, 0, 0)
=sleep(8)
keybd_event(Asc(str_c1), 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1=" "
keybd_event(32, 0, 0, 0)
=sleep(8)
keybd_event(32, 0, 2, 0)
case str_c1="`"
keybd_event(192, 0, 0, 0)
=sleep(8)
keybd_event(192, 0, 2, 0)
case str_c1="-"
keybd_event(189, 0, 0, 0)
=sleep(8)
keybd_event(189, 0, 2, 0)
case str_c1="="
keybd_event(187, 0, 0, 0)
=sleep(8)
keybd_event(187, 0, 2, 0)
case str_c1="\"
keybd_event(220, 0, 0, 0)
=sleep(8)
keybd_event(220, 0, 2, 0)
case str_c1="["
keybd_event(219, 0, 0, 0)
=sleep(8)
keybd_event(219, 0, 2, 0)
case str_c1="]"
keybd_event(221, 0, 0, 0)
=sleep(8)
keybd_event(221, 0, 2, 0)
case str_c1=";"
keybd_event(186, 0, 0, 0)
=sleep(8)
keybd_event(186, 0, 2, 0)
case str_c1="'"
keybd_event(222, 0, 0, 0)
=sleep(8)
keybd_event(222, 0, 2, 0)
case str_c1=","
keybd_event(188, 0, 0, 0)
=sleep(8)
keybd_event(188, 0, 2, 0)
case str_c1="."
keybd_event(190, 0, 0, 0)
=sleep(8)
keybd_event(190, 0, 2, 0)
case str_c1="/"
keybd_event(191, 0, 0, 0)
=sleep(8)
keybd_event(191, 0, 2, 0)
case str_c1="~"
keybd_event(16, 0, 0, 0)
keybd_event(192, 0, 0, 0)
=sleep(8)
keybd_event(192, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="_"
keybd_event(16, 0, 0, 0)
keybd_event(189, 0, 0, 0)
=sleep(8)
keybd_event(189, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="+"
keybd_event(16, 0, 0, 0)
keybd_event(187, 0, 0, 0)
=sleep(8)
keybd_event(187, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="|"
keybd_event(16, 0, 0, 0)
keybd_event(220, 0, 0, 0)
=sleep(8)
keybd_event(220, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="{"
keybd_event(16, 0, 0, 0)
keybd_event(219, 0, 0, 0)
=sleep(8)
keybd_event(219, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="}"
keybd_event(16, 0, 0, 0)
keybd_event(221, 0, 0, 0)
=sleep(8)
keybd_event(221, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1=":"
keybd_event(16, 0, 0, 0)
keybd_event(186, 0, 0, 0)
=sleep(8)
keybd_event(186, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1='"'
keybd_event(16, 0, 0, 0)
keybd_event(222, 0, 0, 0)
=sleep(8)
keybd_event(222, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="<"
keybd_event(16, 0, 0, 0)
keybd_event(188, 0, 0, 0)
=sleep(8)
keybd_event(188, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1=">"
keybd_event(16, 0, 0, 0)
keybd_event(190, 0, 0, 0)
=sleep(8)
keybd_event(190, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="?"
keybd_event(16, 0, 0, 0)
keybd_event(191, 0, 0, 0)
=sleep(8)
keybd_event(191, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="!"
keybd_event(16, 0, 0, 0)
keybd_event(49, 0, 0, 0)
=sleep(8)
keybd_event(49, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="@"
keybd_event(16, 0, 0, 0)
keybd_event(50, 0, 0, 0)
=sleep(8)
keybd_event(50, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="#"
keybd_event(16, 0, 0, 0)
keybd_event(51, 0, 0, 0)
=sleep(8)
keybd_event(51, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="$"
keybd_event(16, 0, 0, 0)
keybd_event(52, 0, 0, 0)
=sleep(8)
keybd_event(52, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="%"
keybd_event(16, 0, 0, 0)
keybd_event(53, 0, 0, 0)
=sleep(8)
keybd_event(53, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="^"
keybd_event(16, 0, 0, 0)
keybd_event(54, 0, 0, 0)
=sleep(8)
keybd_event(54, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="&"
keybd_event(16, 0, 0, 0)
keybd_event(55, 0, 0, 0)
keybd_event(55, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="*"
keybd_event(16, 0, 0, 0)
keybd_event(56, 0, 0, 0)
=sleep(8)
keybd_event(56, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1="("
keybd_event(16, 0, 0, 0)
keybd_event(57, 0, 0, 0)
=sleep(8)
keybd_event(57, 0, 2, 0)
keybd_event(16, 0, 2, 0)
case str_c1=")"
keybd_event(16, 0, 0, 0)
keybd_event(48, 0, 0, 0)
=sleep(8)
keybd_event(48, 0, 2, 0)
keybd_event(16, 0, 2, 0)
endcase
str_c=substr(str_c,2,50)
enddo
return