//定義全局外部函數
Function long FindWindowA (String lpClassName , String lpWindowName ) Library "user32.dll"
Function boolean IsWindow (Long hwnd ) Library "user32.dll"
string ls_a,ls_b
long ll_handle
run("calc.exe",Maximized!)
ls_a="calc"
ls_b="小算盤"
for li_loop= 1 to 100000
ll_handle = FindWindowA(ls_a,ls_b)
yield()
if ll_handle <> 0 then
exit
end if
next
自动解压语句:run(C:\Program Files\WinRAR\WinRAR.exe x D:\接收邮件附件\*.rar D:\解压附件\)
自动压缩稍为麻烦点:下面给你一个我自己做的压缩过程,仅供参考:
listbox my_listbox
my_listbox = create listbox
parent.OpenUserObject(my_listbox,0,0)
my_listbox.reset( )
my_listbox.dirlist(ls_fkxx,16)
int a,i
a = my_listbox.totalitems( )
string ls_text
//判断文件夹中有无子文件夹
if a = 1 then
messagebox("提示:","你所指定的文件夹:[ "+ls_fkxx+" ]中没有要压缩的子文件夹或文件。")
return
else
for i = 1 to a
ls_text = my_listbox.text( i )
if ls_text <> '[..]' and left(ls_text,1) = '[' then
l_dir = left(right(ls_text,len(ls_text) - 1),len(right(ls_text,len(ls_text) - 1)) - 1)
ysml = ls_rar_path+"\WinRAR.exe a -ep -r0 "+ls_fkys+l_dir+".rar "+ls_fkxx+l_dir+"\*.*"
elseif match(ls_text,'.') = true and left(ls_text,1) <> '[' then
l_dir = ls_text
ysml = ls_rar_path+"\WinRAR.exe a -ep -r0 "+ls_fkys+l_dir+".rar "+ls_fkxx+l_dir+"\*.*"
end if
// 用外部程序来控制RUN的进程
st_3.text = "正在创建压缩文件: "+l_dir+".rar"
ulong ll_handle
int li_loop
SetPointer(HourGlass!)
//最小化执行
run(ysml, Minimized!)
//循环到窗口打开,根据程序执行打开所需的时间设定li_loop的循环次数,可预留长一些。
for li_loop= 1 to 10000
ll_handle = FindWindowA("tty","正在创建压缩文件 "+l_dir+".rar")
st_4.text = string(ll_handle)
yield() //函数作用详见“PB技巧”中《Pb中Yield()函数的使用》
if ll_handle <> 0 then
exit
end if
next
//一直循环到窗口关闭
Do While isWindow(ll_handle)
Yield()
Loop
next
st_3.text = "压缩无毕!"
if messagebox("提示:","已完成压缩,选择“确定”系统将清空存放各部门返馈信息的文件夹以便下月用来存放新的返馈信息,你要清空吗?",Exclamation!, OKCancel!, 2) = 1 then
fu_deletefolder(ls_fkxx,parent,"")
end if
end if