[au3]复制选择性粘贴文本到excel
案例:在一张网页上有许多你要复制的内容,但是你必须一个一个找到他们,然后一个一个复制出来粘贴到excel表格里。时间一长你的眼睛容易花,而且复制多了容易出错。
方法:当然有许多方法可以自动化的做这一件事情。网页上可以利用tg元素来获取,但是这个网页只能是google浏览器打开。
我们干脆偷个懒,直接复制全部内容,然后用程序来查找,根据表格要求进行输出。
思路:
把文本(网页上的或者是其他应用上的)整个复制下来,
输出给剪贴板
正则查找,生成新的文本文件
直接以tab单元形式输出到剪贴板
1 #include<Date.au3> 2 3 $starday = "2017/4/22" ;测试开始时间 4 $iDateCalc = _DateDiff('d', $starday, _NowCalc()) 5 If $iDateCalc < 360 And $iDateCalc >= 0 Then 6 Break(0) 7 Else 8 MsgBox(16, "警告:", "超过测试版本的使用期限,请到淘宝:“维尼熊的百宝箱”购买正式版本!") 9 Exit 10 EndIf 11 12 HotKeySet("{F9}", "qianniu") 13 HotKeySet('{ESC}', 'FNC_EXIT') 14 While 1 15 Sleep(100) 16 WEnd 17 ;~ if "microsof-fb686a"=$PublicIP then 18 19 Func qianniu() 20 Sleep(200) 21 Send("{CTRLDOWN}") 22 Sleep(100) 23 Send("a") 24 Sleep(100) 25 Send("c") 26 Sleep(100) 27 Send("{CTRLUP}") 28 29 30 $var = ClipGet() 31 32 If 0 = StringRegExp($var, '订单管理', 0) Then 33 Return MsgBox(16, "注意", "你没有粘贴飞牛冲值内容") 34 Else 35 $text2 = StringRegExp($var, '(\d{16,17})\r', 1) ;$text2[0] 36 ;$text4 =StringRegExp($var,'留言: \R(.+)',1) 37 $text4 = StringRegExp($var, '\D(\d{12})\D|\D(\d{8})\D', 3) 38 ;~ $text4 =StringRegExp($var,'\D(\d\d\d\d\d\d\d\d)|\D(\d\d\d\d\d\d\d\d\d\d\d\d)',1) 39 $text5 = StringRegExp($var, '实付:(.+)元', 1) ;$text2[0] 40 $text7 = StringRegExp($var, '(1\d\d\d\d\d\d\d\d\d\d)\D', 1);$text2[0] 41 $text1 = @MON & "月" & @MDAY & "日" 42 $text3 = "" 43 $text6 = "" 44 $text8 = "1235" 45 46 If 0 = StringRegExp($var, '(\d{16,17})\r', 0) Then 47 $txt2 = " " 48 Else 49 $txt2 = $text2[0] 50 EndIf 51 52 53 If 0 = StringRegExp($var, '\D(\d{12})\D|\D(\d{8})\D', 0) Then 54 $txt4 = " " 55 56 Else 57 $txt4 = "" 58 For $i = 0 To UBound($text4) - 1 59 $txt4 = $txt4 & " " 60 $txt4 = $txt4 & $text4[$i] 61 Next 62 63 64 EndIf 65 66 67 If 0 = StringRegExp($var, '实付:(.+)元', 0) Then 68 $txt5 = " " 69 Else 70 $txt5 = $text5[0] 71 EndIf 72 73 If 0 = StringRegExp($var, '(1\d\d\d\d\d\d\d\d\d\d)\D', 0) Then 74 $txt7 = " " 75 Else 76 $txt7 = $text7[0] 77 EndIf 78 79 80 81 ClipPut($text1 & " '" & $txt2 & " " & $text3 & " " & $txt4 & " " & $txt5 & " " & $text6 & " " & $txt7 & " " & $text8) 82 EndIf 83 Sleep(100) 84 EndFunc ;==>qianniu 85 86 87 Func FNC_EXIT() 88 Exit 0 89 EndFunc ;==>FNC_EXIT
程序操作:1、鼠标选中需要操作的界面,利用f9键,来完成程序操作。2、直接粘贴到表格里面,成为一行的内容
需要更多的定制脚本,请联系淘宝:维尼熊的百宝箱