代码拉取完成,页面将自动刷新
#!/bin/bash
#upload -- li [identify_code]
# |
# -- lo
# |
# -- fr
# |
# -- sl [sj|xq|tz]
# |
# -- wr [sb|ct|sr|at|qt|pt]
# |
# -- help
action=$1
para=$2
info_src=$3
quote_code=$3
content_type=$3
wid="" #栏目窗口
swid="" #shell窗口
dwid="" #上传文档窗口
gvim_wid="" #gvim窗口
g_upload_rec_dir="\/media\/kjj-18\/文档\/何一航文档\/科技局工作\/#局网站管理\/@上传记录"
cur_date=$(date +%Y年%m月%d日)
case $action in
"")
echo "type \"help\" for usage of upload command ..."
#用于测试的代码
# wid=`xdotool search --name "登录页"`
# xdotool key --window $wid shift+Tab
# xdotool key --window $wid shift+Home
# xdotool type --window $wid --delay 100 市科技局_管理员
# xdotool key --window $wid Tab
# xdotool type --window $wid kjj8663572
# xdotool key --window $wid Tab
# xdotool type --window $wid $para
# xdotool key --window $wid Return
# echo $PWD
;;
li) #登录
if [[ $para = "" ]]; then
echo "please type the identify code !!"
else
wid=`xdotool search --name "登录页"`
if [[ $wid = "" ]]; then
echo "login page not open ..."
exit 1
fi
xdotool key --window $wid shift+Tab
xdotool key --window $wid ctrl+a
#xdotool type --window $wid --delay 150 市科技局_管理员
echo "市科技局_管理员" | xclip -selection c
xdotool key --window $wid ctrl+v
xdotool key --window $wid Tab
xdotool type --window $wid kjj8663572
xdotool key --window $wid Tab
xdotool type --window $wid $para
xdotool key --window $wid Return
liloop=1
while [ true ]; do
wid=`xdotool search --name "内容管理新篇章"`
if [[ $wid != "" ]]; then
break
elif [ $liloop -eq 4 ]; then
echo "login page open failed ..."
exit 1
else
let "liloop++"
sleep 0.5
fi
done
xdotool windowactivate --sync $wid
sleep 2
xdotool mousemove 8 266 #资源库
sleep 0.1
xdotool click 1
xdotool mousemove 22 292 #十堰市科技局
sleep 0.1
xdotool click 1
xdotool mousemove 47 315 #新闻中心
sleep 0.1
xdotool click 1
#swid=`xdotool search --name "\/media\/share\/upload\/$cur_date"`
swid=`xdotool search --name "$g_upload_rec_dir\/$cur_date"`
if [[ $swid ]]; then
xdotool windowactivate --sync $swid
fi
fi
;; #登录
lo) #注销
wid=`xdotool search --name "内容管理新篇章"`
xdotool windowactivate $wid
xdotool mousemove 1662 166 #注销
sleep 0.1
xdotool click 1
xdotool key --window $wid ctrl+w
;;
fr) #用于重新输入验证码
wid=`xdotool search --name "Mozilla Firefox"`
xdotool key --window $wid Return
;;
sl) #选择栏目
wid=`xdotool search --name "内容管理新篇章"`
if [[ $wid = "" ]]; then
echo "select page not open ..."
exit 1
fi
xdotool windowactivate $wid
case $para in
sj) #市局工作动态
#wid=`xdotool search --name "内容管理新篇章"`
#xdotool windowactivate $wid
xdotool mousemove 119 337
sleep 0.1
;;
xq) #县市区工作动态
#wid=`xdotool search --name "内容管理新篇章"`
#xdotool windowactivate $wid
xdotool mousemove 119 377
sleep 0.1
;;
tz) #通知公告
#wid=`xdotool search --name "内容管理新篇章"`
#xdotool windowactivate $wid
xdotool mousemove 119 397
sleep 0.1
;;
*)
echo "select para error!!"
echo "select para:$para"
exit 1
;;
esac #case $para in
xdotool click 1
tloop=1
while [ true ]; do
xdotool type --window --sync $wid N
dwid=`xdotool search --name "文档新建"`
if [[ $dwid != "" ]]; then
break
elif [ $tloop -eq 10 ]; then
echo "upload page open timeout ..."
exit 1
else
let "tloop++"
sleep 0.5
fi
done
xdotool windowsize $dwid 100% 100%
gvim_wid=`xdotool search --name "GVIM"`
#xdotool windowactivate --sync $gvim_wid
;; #选择栏目
wr) #填写内容
dwid=`xdotool search --name "文档新建"`
if [[ $dwid = "" ]]; then
dwid=`xdotool search --name "文档编辑"`
if [[ $dwid = "" ]]; then
echo "upload page not open ..."
exit 1
fi
fi
if [[ $para != "qt" && $para != "pt" ]]; then
xdotool windowactivate --sync $dwid
fi
case $para in
sb) #标题
#dwid=`xdotool search --name "文档新建"`
#xdotool windowactivate --sync $dwid
#xdotool windowsize $dwid 100% 100%
xdotool mousemove 228 93
sleep 0.1
xdotool click 1
sleep 0.1
xdotool key --window $dwid ctrl+a
xdotool key --window $dwid ctrl+v
gvim_wid=`xdotool search --name "GVIM"`
#xdotool windowactivate --sync $gvim_wid
;;
ct) #正文
#dwid=`xdotool search --name "文档新建"`
#xdotool windowactivate --sync $dwid
xdotool mousemove 597 493 #点击正文输入框空白处
sleep 0.1
xdotool click 1
sleep 0.1
xdotool key --window $dwid ctrl+a
xdotool key --window $dwid ctrl+v
#去除空行
xdotool mousemove 326 962
sleep 0.1
xdotool click 1
sleep 0.1
#首行缩进
xdotool mousemove 399 962
sleep 0.1
xdotool click 1
sleep 0.1
if [[ $content_type = "tz" ]]; then
xdotool mousemove 597 493 #点击正文输入框空白处
sleep 0.1
xdotool click 1
sleep 0.1
xdotool key --window $dwid ctrl+Home
xdotool key --window $dwid --repeat 2 Delete #让通知开头的称呼顶格
xdotool key --window $dwid ctrl+End
xdotool mousemove 606 150 #日期右对齐
sleep 0.1
xdotool click 1
sleep 0.1
xdotool key --window $dwid Up
xdotool mousemove 606 150 #落款右对齐
sleep 0.1
xdotool click 1
sleep 0.1
fi
gvim_wid=`xdotool search --name "GVIM"`
#xdotool windowactivate --sync $gvim_wid
;;
sr) #来源
#dwid=`xdotool search --name "文档新建"`
#xdotool windowactivate --sync $dwid
xdotool mousemove 1480 190 #点击“基本属性”
sleep 0.1
xdotool click 1
sleep 0.1
xdotool mousemove 1582 604 #点击“来源”
sleep 0.1
xdotool click 1
sleep 0.1
xdotool key --window $dwid ctrl+a
if [[ $info_src != "" ]]; then
xdotool type --window $dwid --delay 100 $info_src
sleep 0.1
#echo $info_src | xsel -b
#xdotool key --window $dwid ctrl+v
xdotool key --window $dwid Down
#xdotool key --window $dwid Return
else
xdotool key --window $dwid ctrl+v
fi
gvim_wid=`xdotool search --name "GVIM"`
#xdotool windowactivate --sync $gvim_wid
;;
at) #作者
#dwid=`xdotool search --name "文档新建"`
#xdotool windowactivate --sync $dwid
xdotool mousemove 1582 604 #点击“来源”
sleep 0.1
xdotool click 1
sleep 0.1
xdotool key --window $dwid Tab
xdotool key --window $dwid ctrl+v
gvim_wid=`xdotool search --name "GVIM"`
#xdotool windowactivate --sync $gvim_wid
;;
qt) #引用
if [[ $quote_code = "" ]]; then
echo "quote code is empty ..."
exit 1
fi
#dwid=`xdotool search --name "文档新建"`
xdotool windowactivate --sync $dwid
xdotool mousemove 1666 703 #打开引用菜单
sleep 0.1
xdotool click 1
sleep 0.1
xdotool mousemove 984 466 #移动到合适位置后向下滚轮
sleep 0.5
xdotool click 5
#xdotool mousemove 671 617 #点开“党建工作”
xdotool mousemove 676 614 #点开“党建工作”
sleep 0.5
xdotool click 1
sleep 0.1
if [[ ${quote_code//[!t]/} = "t" ]]; then #引用到“图片新闻”
#xdotool mousemove 732 423
xdotool mousemove 738 419
sleep 0.1
xdotool click 1
sleep 0.1
fi
if [[ ${quote_code//[!d]/} = "d" ]]; then #引用到“机关党建”
#xdotool mousemove 733 637
xdotool mousemove 739 636
sleep 0.1
xdotool click 1
sleep 0.1
fi
if [[ ${quote_code//[!l]/} = "l" ]]; then #引用到“党风廉政”
#xdotool mousemove 732 663
xdotool mousemove 739 663
sleep 0.1
xdotool click 1
sleep 0.1
fi
if [[ ${quote_code//[!w]/} = "w" ]]; then #引用到“文明创建”
#xdotool mousemove 732 686
xdotool mousemove 739 686
sleep 0.1
xdotool click 1
sleep 0.1
fi
if [[ ${quote_code//[!d]/} = "d"
|| ${quote_code//[!l]/} = "l"
|| ${quote_code//[!j]/} = "j" ]]; then #为引用到“两学一做”或“进实体经济”做准备
xdotool click 5 #滚轮一次后,点开“专题专栏”
sleep 0.5
#xdotool mousemove 672 666
xdotool mousemove 678 655
sleep 0.1
xdotool click 1
sleep 0.1
xdotool click --repeat 5 5 #滚轮5次后,点开“两学一做”
#xdotool mousemove 693 519
xdotool mousemove 693 482
sleep 0.5
xdotool click 1
sleep 0.1
fi
if [[ ${quote_code//[!d]/} = "d"
|| ${quote_code//[!l]/} = "l" ]]; then #引用到“两学一做”
#xdotool mousemove 753 542 #点击“工作动态”
xdotool mousemove 754 502 #点击“工作动态”
sleep 0.1
xdotool click 1
sleep 0.1
fi
if [[ ${quote_code//[!j]/} = "j" ]]; then #引用到“进实体经济”
#xdotool mousemove 738 686 #点击“工作动态”
xdotool mousemove 739 649 #点击“工作动态”
sleep 0.1
xdotool click 1
sleep 0.1
fi
xdotool mousemove 790 800 #点击“确定”
sleep 0.1
xdotool click 1
sleep 0.1
#将引用类型改为“镜像引用”
xdotool mousemove 1569 628 #点击“作者”
sleep 0.1
xdotool click 1
sleep 0.1
loop=${#quote_code}
if [[ ${quote_code//[!d]/} = "d" || ${quote_code//[!l]/} = "l" ]]; then
let "loop++"
fi
while [ $loop -gt 0 ]; do
xdotool key --window $dwid Tab
sleep 0.2
xdotool key --window $dwid Down
let "loop--"
done
gvim_wid=`xdotool search --name "GVIM"`
#xdotool windowactivate --sync $gvim_wid
;; #引用
pt) #图片
pic_index=0
pic_dir=$(pwd)"/pic"
if [ ! -d $pic_dir ]; then
echo "photograph directory does not exist, check and try again ..."
exit 1
fi
pic_count=$(ls ${pic_dir} | wc -l)
if [ $pic_count -eq 0 ]; then
echo "no photographs ..."
exit 1
fi
txt_dir=$(pwd)"/txt"
txt_exist=0
if [ -d $txt_dir ]; then
txt_exist=1
fi
#dwid=`xdotool search --name "文档新建"`
xdotool windowactivate --sync $dwid
xdotool mousemove 597 493
sleep 0.1
xdotool click 1
sleep 0.1
xdotool key --window $dwid ctrl+Home
xdotool key --window $dwid Return
xdotool key --window $dwid Up
xdotool mousemove 583 152 #点击“居中”
sleep 0.1
xdotool click 1
sleep 0.1
#插入多张图片
while [ $pic_index -lt $pic_count ]; do
xdotool mousemove 442 130 #点击“插入图片”
sleep 0.1
xdotool click 1
sleep 0.5
eloop=1
xdotool mousemove 643 512 #点击“浏览”
while [ true ]; do
ewid=`xdotool search --name "编辑图片"`
if [[ $ewid != "" ]]; then
break
elif [ $eloop -eq 10 ]; then
echo "insert photo page open too slow ..."
exit 1
else
let "eloop++"
sleep 0.5
fi
done
xdotool key --window $dwid alt+Tab
sleep 0.1
xdotool click 1
sleep 0.5
xdotool key ctrl+f #打开待上传图片所在目录
echo ${pic_dir} | xclip -selection c
xdotool key ctrl+v
xdotool key BackSpace
xdotool key Return
if [ $pic_index -eq 0 ]; then
xdotool mousemove 1220 214 #展示详细信息
sleep 0.1
xdotool click 1
sleep 0.1
xdotool mousemove 1246 243 #将文件按类型排序
sleep 0.1
xdotool click 1
sleep 0.5
xdotool click 1
sleep 0.1
fi
xdotool mousemove 595 $(expr 270 + ${pic_index} \* 28)
sleep 0.1
xdotool click --repeat 2 1 #双击打开图片
xdotool mousemove 1033 481
sleep 0.1
xdotool click 1 #点击“打开”
sleep 0.8
if [ $txt_exist -eq 1 ]; then
xdotool key Return
fi
#如果不是最后一张照片,需要再按一次回车键
if [ $pic_index -ne $(expr ${pic_count} - 1) ];then
if [ $txt_exist -eq 1 ]; then
xdotool key Return
fi
fi
let "pic_index++"
if [ $pic_index -eq 13 ]; then
echo "photographs number out of range, upload stoped ..."
exit 1
fi
#echo "pic_index:$pic_index"
done
;; #图片
*)
echo "write para error!!"
;;
esac #case $para in
;; #填写内容
help) #帮助信息
echo "upload -- li [identify_code]"
echo " |"
echo " -- lo"
echo " |"
echo " -- fr"
echo " |"
echo " -- sl [sj|xq|tz]"
echo " |"
echo " -- wr [sb|ct|sr|at|qt|pt] qt:[t|d|l|w]"
echo " |"
echo " -- help"
;;
*) #错误处理
echo "action para error!!"
echo "action para:$action"
echo "type \"help\" for usage of upload command ..."
;;
esac #case $action in
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。