|
論壇說明 |
歡迎您來到『史萊姆論壇』 ^___^ 您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的! 請點擊這裡:『註冊成為我們的一份子!』 |
|
主題工具 | 顯示模式 |
2006-04-02, 09:34 AM | #1 |
榮譽會員
|
電子圖書自動翻頁抓屏軟體BookCapture v0.9 (AutoIt指令碼語言編寫)
前一陣下了幾本書生網的電子圖書,因為一個月後要過期,所以我用autoIt配合Hypersnap抓圖把其中一本存為JPG,但是發現兩個軟體配合比較麻煩,於是決定自己寫一個軟體。然後就有了Bookcapture。前後斷斷續續寫了5天。歡迎大家使 用並提出意見。軟體在中文winxp with sp2執行通過,我想在中文win2000/2003/xp下面都應該沒有問題。
使用注意事項:翻頁模式為超星圖書格式或者滑鼠點擊時,在截圖程序中不要移動滑鼠。在任何模式下截圖完畢之前,請不要切換到別的程序。 涉及到的AutoIt指令碼方法:GUI創設,資料輸入用戶介面,Radio選項判斷,外部Dll使用,滑鼠當前坐標抽取,Ini文件讀寫,傳送鍵盤按鍵和滑鼠按鍵,鍵盤按鍵監聽。 這只是一個非常簡單的軟體,介面也很簡單。 如果有下一版的話,考慮加入如下改進: 1.增加滑鼠選項截圖區域並將區域可視化。 2.增加更改抓圖區域的功能。 3.更多的圖像儲存格式。 README.txt 1.Bookcaupture是一個電子圖書自動翻頁抓圖軟體。 2.對於書生網電子圖書和超星電子圖書能夠自動啟動閱讀器視窗翻頁,其他閱讀器支持滑鼠翻頁,需要手動式將滑鼠定位在翻頁圖示上。 3.用T鍵確定抓圖區域左上角,B鍵確定抓圖區域右下腳。 4.儲存格式為JPG,JPG圖像品質可調,儲存路徑可選。 5.截圖之前,請自行將閱讀器縮放到合適比例和方向。 6.本軟體為綠色軟體。 7.本軟體為免費軟體,歡迎在網際網路上傳播。 8.軟體執行環境:win2000/2003/xp ;Author toopooo@******&bbs ;Contact Information bookcapture@hotmail.com #include <GUIConstants.au3> #include <Constants.au3> #include <file.au3> #Include <Misc.au3> Global $header = "BookCapture" Global $version = "V0.9 - 2006.03.26" Global $state = 1 Global $timer = 1 Global $booktype Global $windowtitle Global $click = 0 Global $imageleft,$imagetop,$bottomx,$bottomy,$destdir,$quality,$intermission,$period While $state == 1 opt("TrayIconHide",0) opt("TrayAutoPause", 0) $tempintermission = IniRead("bookcapture.ini", "config", "intermission", "") $tempperiod = IniRead("bookcapture.ini", "config", "period", "") $tempbookname = IniRead("bookcapture.ini", "config", "bookname", "") $tempquality = IniRead("bookcapture.ini", "config", "quality", "") $tempdir = IniRead("bookcapture.ini", "config", "destdir", "") If $tempdir ="" Then $destdir = @ScriptDir Else $destdir = $tempdir EndIf If $tempquality ="" Then $quality = 75 Else $quality = $tempquality EndIf If $tempintermission ="" Then $intermission = 2 Else $intermission = $tempintermission EndIf If $tempperiod ="" Then $period = 1 Else $period = $tempperiod EndIf GUICreate($header & $version, 380, 280, -1, -1, -1) GUICtrlCreateLabel("翻頁延遲時間(秒)", 20, 15) $q1 = GUICtrlCreateInput($intermission, 20, 30, 50, 16) GUICtrlCreateLabel("抓屏次數", 160, 15) $q2 = GUICtrlCreateInput($period, 160, 30 , 50, 16) GUICtrlCreateLabel("JPG截圖品質(1-100)", 260, 15) $q4 = GUICtrlCreateInput($quality, 260, 30, 30, 16) GUICtrlCreateLabel("請選項電子圖書翻頁方式", 20, 70) $radio1 = GUICtrlCreateRadio ("PageDown", 20,90, 90, 20) GUICtrlSetState ($radio1,$GUI_CHECKED) $radio2 = GUICtrlCreateRadio ("超星電子圖書", 120, 90, 90, 20) $radio3 = GUICtrlCreateRadio ("滑鼠點擊", 230, 90, 90, 20) GUICtrlCreateLabel("輸入書名(作為圖像檔案名前綴)", 20, 125) $q3 = GUICtrlCreateInput($tempbookname, 20,140,250,20) GUICtrlCreateLabel("請選項圖像文件儲存路徑(預設值為當前路徑)", 20, 165) $q5 = GUICtrlCreateInput($destdir,20,180,250,20) $dirbutton = GUICtrlCreateButton("...",290,180,30,22) GUICtrlCreateLabel("如果確定後閱讀器視窗沒有自動啟動,請手動式切換到閱讀器介面,",20,210,-1) GUICtrlCreateLabel("點擊確定開始抓屏。注意閱讀器不要選縮放工具",20,230,-1) $okbutton = GUICtrlCreateButton("確定", 160, 250,60,25) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $dirbutton Then $destdir = FileSelectFolder("請選項儲存路徑", "", 1) GUICtrlCreateInput($destdir,20,180,250,20) EndIf If $msg = $okbutton Then If BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED Then $booktype = 1 $windowtitle = "閱讀器" Elseif BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED Then $booktype = 2 $windowtitle = "超星" Elseif BitAND(GUICtrlRead($radio3), $GUI_CHECKED) = $GUI_CHECKED Then $booktype = 3 $windowtitle = "" Sleep(5000) EndIf $intermission = GUICtrlRead($q1) $period = GUICtrlRead($q2) $bookname = GUICtrlRead($q3) $quality = GUICtrlRead($q4) $seconds = $intermission*1000 IniWrite("bookcapture.ini","config","intermission",$intermission) IniWrite("bookcapture.ini","config","period",$period) IniWrite("bookcapture.ini","config","bookname",$bookname) IniWrite("bookcapture.ini","config","quality",$quality) IniWrite("bookcapture.ini", "config", "destdir", $destdir) ; MsgBox(0,"Booktype",$booktype) ExitLoop ElseIf $msg = $GUI_EVENT_CLOSE Then MsgBox(0,"","謝謝使用BookCapture") $state = 0 Exit EndIf WEnd GUIDelete() If ( $windowtitle <> "" ) Then WinActivate($windowtitle,"") MouseClick("left",@DesktopWidth/2,@DesktopHeight/2) EndIf MsgBox(0,"注意","如果閱讀器視窗未能啟動,請先將閱讀器視窗啟動到最上方然後返回本視窗點擊確定。") MsgBox(0,"注意","請在抓圖區域的左上角點擊T鍵,右下角點擊B鍵。如果你使用了滑鼠翻頁功能,請將滑鼠放在閱讀器翻頁按鈕或者圖示上。") While 1 If _IsPressed(54) = 1 Then $pos1 = MouseGetPos() $imageleft = $pos1[0] $imagetop = $pos1[1] ; MsgBox(0, "Mouse x,y:", $imageleft & "," & $imagetop) ElseIf _IsPressed(42) = 1 Then $pos2 = MouseGetPos() $bottomx = $pos2[0] $bottomy = $pos2[1] ; MsgBox(0, "Mouse x,y:", $bottomx & "," & $bottomy) ExitLoop EndIf WEnd $regionwidth = $bottomx - $imageleft $regionheight = $bottomy - $imagetop ;MsgBox(0,"test","left=" & $imageleft & ",top=" & $imagetop & ",width=" & $regionwidth & ", height=" & $regionheight) Sleep(500) Do $filename = StringFormat ( "%05d",$timer) DllCall("captdll.dll", "int", "CaptureRegion", "str", $destdir & "\" & $bookname & $fileName & ".jpg", "int", $imageleft, "int", $imagetop, "int", $regionwidth, "int", $regionheight, "int", $quality) Sleep(500) Nextpage() sleep($seconds) $timer = $timer + 1 Until $timer > $period ;DllClose("user32.dll") MsgBox(0,"完成", "工作完成!剛才總共抓取了" & $period & "個頁面") $goahead = MsgBox(4,"下一步","是否繼續下一本書?") If ( $goahead = 7 ) Then $state = 0 EndIf WEnd Exit 0 Func Nextpage() if $booktype = 1 Then send("{PGDN}") Elseif $booktype = 2 Then Send("!b") Send("g") Send("n") Else MouseClick("left") EndIf EndFunc所上傳圖片 |
__________________ |
|
送花文章: 3,
|