diff --git a/README.md b/README.md index 9b0f7ae..2002123 100644 --- a/README.md +++ b/README.md @@ -305,20 +305,23 @@ Ctrl + F12 :檢索《國語辭典》 - Alt + Shift + \ (即 Alt + | ): 以選取的文字查找《國語辭典》若有結果,在其後加上注音括注,並加上檢索結果網址之超連結 - Alt + j 或 Alt + s :**單字**檢索《白雲深處人家·說文解字·圖像查閱》之字頭。檢索有結果後,直接點開藤花榭本以供檢覈(即會開出2個分頁。第2個--最後一個開啟的--是藤花榭本書頁圖。關閉後即回到第1個分頁,即可檢視站內所收諸版本該字頭所在之書頁圖)。(j = jie 《說文解字》的「解」,s :說 shuo 的 s) - Alt + shift + j 或 Alt + shift + s :以釋義內文檢索《白雲深處人家·說文解字·圖文檢索WFG版》。(j = jie 《說文解字》的「解」,s :說 shuo 的 s) +- Alt + v : **單字**檢索《異體字字典》並讀入其《說文》及網址資料以便引文。 - Alt + n : **單字**檢索《漢語多功能字庫》並取回其說文解釋欄位之值插入至插入點位置。 (n= 能 neng) - Alt + o : **單字**檢索[《說文解字》網站](https://www.shuowen.org/)並取回其解釋欄位及網址值插入至插入點位置。 (o= 說文解字 ShuoWen.ORG 的 O) - Ctrl + Alt + x : **單字**檢索《康熙字典網上版》(x = xi 熙) - Ctrl + d + s (按住 Ctrl 依序按d、s) :檢索《國學大師》(ds:大師 da-shi 的 d、s) - Alt + g : 以選取文字檢索Google - Alt + b : 以選取文字檢索百度(百度 baidu 的 b ) -- Alt + shift + , 即 ' Alt + < 或 Ctrl + Alt + F9 或 Alt + shift + F5 同在TextForCtext 的 Alt + , 與 Alt + F9 與 Alt + F5。《漢籍全文資料庫》或《中國哲學書電子化計劃》檢索《易》學關鍵字。蓋藉由本軟件介面作中介爾。 -- Alt + \` : 貼上複製之內容時檢查是否已經錄入,在注文前後加上圓括弧,並標識《易》學關鍵字 -- Alt + Shift + \` : 貼上複製自《漢籍全文資料庫》之內容時檢查是否已經錄入,在注文前後加上圓括弧,並標識《易》學關鍵字 - Alt + 1 : 貼上複製自《中國哲學書電子化計劃》(CTP)的文字版之內容並在注文前後加上圓括弧。 - Alt + 7 : 將文件中的異體字轉正體字 - Ctrl + Alt + = : 以選取的文字檢索 CTP 所收阮元《十三經注疏·周易正義》並在選取文字上加上該檢索結果頁面之超連結 - Alt + , : 以選取的文字檢索文件中第一段所載之 CTP 所收本網址,並在選取文字上加上該檢索結果頁面之超連結 +**以下功能,目前須先開啟TextForCtext才能使用。** 原理是以本軟件作為中介故。 +- Alt + shift + , 即 ' Alt + < 或 Ctrl + Alt + F9 或 Alt + shift + F5 同在TextForCtext 的 Alt + , 與 Alt + F9 與 Alt + F5。《漢籍全文資料庫》或《中國哲學書電子化計劃》檢索《易》學關鍵字。蓋藉由本軟件介面作中介爾。 +- Alt + \` : 貼上複製之內容時檢查是否已經錄入,在注文前後加上圓括弧,並標識《易》學關鍵字 +- Alt + Shift + \` : 貼上複製自《漢籍全文資料庫》之內容時檢查是否已經錄入,在注文前後加上圓括弧,並標識《易》學關鍵字 +> 若無標點則直接送去《古籍酷》自動標點 ## 快速鍵一覽: ### 在表單(操作介面視窗)任何位置按下: diff --git a/TextForCtextPortable.zip b/TextForCtextPortable.zip index 12b839e..4a5bc20 100644 Binary files a/TextForCtextPortable.zip and b/TextForCtextPortable.zip differ diff --git a/WordVBA/ClipBoardObject.bas b/WordVBA/ClipBoardObject.bas index 9a44d29..e678d93 100644 --- a/WordVBA/ClipBoardObject.bas +++ b/WordVBA/ClipBoardObject.bas @@ -10,7 +10,7 @@ Rem #If VBA7 Then #If Win64 Then ' 64줸 - Public Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hwnd As LongPtr) As Long + Public Declare PtrSafe Function OpenClipboard Lib "user32" (ByVal hWnd As LongPtr) As Long Public Declare PtrSafe Function EmptyClipboard Lib "user32" () As Long Public Declare PtrSafe Function CloseClipboard Lib "user32" () As Long Public Declare PtrSafe Function SetClipboardData Lib "user32" (ByVal uFormat As Long, ByVal hMem As LongPtr) As LongPtr @@ -23,7 +23,7 @@ Rem Public Declare PtrSafe Sub RtlMoveMemory Lib "kernel32" (ByVal Destination As LongPtr, ByVal Source As LongPtr, ByVal Length As LongPtr) #Else ' 32줸 - Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long + Public Declare Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long Public Declare Function EmptyClipboard Lib "user32" () As Long Public Declare Function CloseClipboard Lib "user32" () As Long Public Declare Function SetClipboardData Lib "user32" (ByVal uFormat As Long, ByVal hMem As Long) As Long diff --git a/WordVBA/Network.bas b/WordVBA/Network.bas index 2971eca..eb9d0bf 100644 --- a/WordVBA/Network.bas +++ b/WordVBA/Network.bas @@ -178,10 +178,15 @@ Sub Else .Collapse wdCollapseEnd End If - .InsertAfter ar(0) & VBA.Chr(13) + 'J^mne + .TypeText "AmnG" + .InsertAfter ar(0) & VBA.Chr(13) 'ar(0)=mne .Collapse wdCollapseEnd + If Selection.End = Selection.Document.Range.End - 1 Then + Selection.Document.Range.InsertParagraphAfter + End If .Font.Size = fontsize - .InsertAfter ar(1) + .InsertAfter ar(1) 'ӤJ} SystemSetup.contiUndo ur .Collapse wdCollapseStart With .Application @@ -227,10 +232,70 @@ Sub Else .Collapse wdCollapseEnd End If - .InsertAfter ar(0) & VBA.Chr(13) + .TypeText "AmnG" + .InsertAfter ar(0) & VBA.Chr(13) 'ar(0)=mne + .Collapse wdCollapseEnd + If Selection.End = Selection.Document.Range.End - 1 Then + Selection.Document.Range.InsertParagraphAfter + End If + .Font.Size = fontsize + .InsertAfter ar(1) 'J} + SystemSetup.contiUndo ur + .Collapse wdCollapseStart + With .Application + .Activate + With .ActiveWindow + If .WindowState = wdWindowStateMinimize Then + .WindowState = wdWindowStateNormal + .Activate + End If + End With + End With + End With + End If +End Sub +Sub drrè^仡κ}ȴJܴJIm() + Rem Alt + v ]v= r variants v^ + If Selection.Characters.Count > 1 Then + MsgBox "d1r", vbExclamation ', vbError + Exit Sub + End If + Dim ar As Variant, x As String + x = Selection.text + ar = SeleniumOP.LookupDictionary_of_ChineseCharacterVariants_RetrieveShuoWenData(x) + If ar(0) = vbNullString Then + word.Application.Activate + MsgBox "䤣AκFΧ睊FI", vbExclamation + With Selection.Application + .Activate + With .ActiveWindow + If .WindowState = wdWindowStateMinimize Then + .WindowState = wdWindowStateNormal + .Activate + End If + End With + End With + Else + Dim ur As UndoRecord, fontsize As Single + SystemSetup.stopUndo ur, "drrè^仡κ}ȴJܴJIm" + With Selection + fontsize = VBA.IIf(.Font.Size = 9999999, 12, .Font.Size) - 4 + If fontsize < 0 Then fontsize = 10 + If .Type = wdSelectionIP Then + .Move + Else + .Collapse wdCollapseEnd + End If + .TypeText "AmnG" & VBA.Chr(13) + Dim shuoWen As String + shuoWen = VBA.Replace(VBA.Replace(ar(0), "GA", "G" & x & "A"), "q`G", VBA.Chr(13) & "q`G") + .InsertAfter shuoWen & VBA.Chr(13) 'ar(0)=mne .Collapse wdCollapseEnd + If Selection.End = Selection.Document.Range.End - 1 Then + Selection.Document.Range.InsertParagraphAfter + End If .Font.Size = fontsize - .InsertAfter ar(1) + .InsertAfter ar(1) 'J} SystemSetup.contiUndo ur .Collapse wdCollapseStart With .Application diff --git a/WordVBA/SeleniumOP.bas b/WordVBA/SeleniumOP.bas index b6c18d3..0518a64 100644 --- a/WordVBA/SeleniumOP.bas +++ b/WordVBA/SeleniumOP.bas @@ -611,7 +611,7 @@ Function LookupDictionary_of_ChineseCharacterVariants(x As String) As String() If Not code.IsChineseCharacter(x) Then Exit Function End If - ClipBoardObject.SetClipboard x + SystemSetup.SetClipboard x ' If wd Is Nothing Then openChrome "https://dict.variants.moe.edu.tw/" ' Else @@ -648,7 +648,7 @@ Function LookupDictionary_of_ChineseCharacterVariants(x As String) As String() If zhengWen <> "0" Or iwe.text <> 0 Then result(0) = x result(1) = wd.URL - ClipBoardObject.SetClipboard result(1) + SystemSetup.SetClipboard result(1) End If Else 'pGܸӦrADdߵGApG https://dict.variants.moe.edu.tw/dictView.jsp?ID=5565 @@ -657,7 +657,7 @@ Function LookupDictionary_of_ChineseCharacterVariants(x As String) As String() If iwe Is Nothing = False Then result(0) = x result(1) = wd.URL - ClipBoardObject.SetClipboard result(1) + SystemSetup.SetClipboard result(1) End If End If End If @@ -691,7 +691,7 @@ Function LookupDictRevised(x As String) As String() MsgBox "u˯Cˬd˯rAs}lC", vbExclamation Exit Function End If - ClipBoardObject.SetClipboard x + SystemSetup.SetClipboard x openChrome "https://dict.revised.moe.edu.tw/search.jsp?md=1" @@ -722,7 +722,7 @@ Function LookupDictRevised(x As String) As String() If iwe Is Nothing Then result(0) = x result(1) = wd.URL - ClipBoardObject.SetClipboard result(1) + SystemSetup.SetClipboard result(1) End If End If LookupDictRevised = result @@ -753,7 +753,7 @@ Function LookupHYDCD(x As String) As String() MsgBox "u˯Cˬd˯rAs}lC", vbCritical Exit Function End If - ClipBoardObject.SetClipboard x + SystemSetup.SetClipboard x If openChrome("https://ivantsoi.myds.me/web/hydcd/search.html") = False Then openChrome ("https://ivantsoi.myds.me/web/hydcd/search.html") @@ -795,7 +795,7 @@ Function LookupHYDCD(x As String) As String() result(0) = x wd.SwitchTo.Window WindowHandlesItem(WindowHandlesCount - 1) result(1) = wd.URL - ClipBoardObject.SetClipboard result(1) + SystemSetup.SetClipboard result(1) Else MsgBox "ˬd", vbCritical Stop @@ -830,7 +830,7 @@ Function LookupGXDS(x As String) As String() MsgBox "u˯Cˬd˯rAs}lC", vbCritical Exit Function End If - ClipBoardObject.SetClipboard x + SystemSetup.SetClipboard x If openChrome("https://www.guoxuedashi.net/zidian/bujian/") = False Then If openChrome("https://www.guoxuedashi.net/zidian/bujian/") = False Then @@ -865,7 +865,7 @@ Function LookupGXDS(x As String) As String() If iwe Is Nothing Or VBA.InStr(iwe.text, "i̡j覡d") = 0 Then result(0) = x result(1) = wd.URL - ClipBoardObject.SetClipboard result(1) + SystemSetup.SetClipboard result(1) End If End If LookupGXDS = result @@ -895,7 +895,7 @@ Function LookupKangxizidian(x As String) As String() If Not code.IsChineseCharacter(x) Then Exit Function End If - ClipBoardObject.SetClipboard x + SystemSetup.SetClipboard x If Not openChrome("https://www.kangxizidian.com/search/index.php?stype=Word") Then If Not openChrome("https://www.kangxizidian.com/search/index.php?stype=Word") Then @@ -930,7 +930,7 @@ Function LookupKangxizidian(x As String) As String() If iwe Is Nothing Then result(0) = x result(1) = wd.URL - ClipBoardObject.SetClipboard result(1) + SystemSetup.SetClipboard result(1) End If End If @@ -961,7 +961,7 @@ Function LookupHomeinmistsShuowenImageAccess_VineyardHall(x As String) As String If Not code.IsChineseCharacter(x) Then Exit Function End If - ClipBoardObject.SetClipboard x + SystemSetup.SetClipboard x If Not openChrome("https://homeinmists.ilotus.org/shuowen/find.php") Then If Not openChrome("https://homeinmists.ilotus.org/shuowen/find.php") Then @@ -1032,7 +1032,7 @@ Function LookupHomeinmistsShuowenImageAccess_VineyardHall(x As String) As String wd.SwitchTo.Window WindowHandlesItem(WindowHandlesCount - 1) result(1) = wd.URL - ClipBoardObject.SetClipboard result(1) + SystemSetup.SetClipboard result(1) LookupHomeinmistsShuowenImageAccess_VineyardHall = result Exit Function @@ -1068,7 +1068,7 @@ Function LookupHomeinmistsShuowenImageTextSearchWFG_Interpretation(x As String) If Not code.IsChineseString(x) Then Exit Function End If - ClipBoardObject.SetClipboard x '˯ƻsŶKïHƥ + SystemSetup.SetClipboard x '˯ƻsŶKïHƥ If Not openChrome("https://homeinmists.ilotus.org/shuowen/WFG2.php") Then If Not openChrome("https://homeinmists.ilotus.org/shuowen/WFG2.php") Then @@ -1142,7 +1142,7 @@ Function LookupMultiFunctionChineseCharacterDatabase(x As String, Optional backg If Not code.IsChineseCharacter(x) Then Exit Function End If - ClipBoardObject.SetClipboard x + SystemSetup.SetClipboard x If backgroundStartChrome Then Set wd = openChromeBackground("https://humanum.arts.cuhk.edu.hk/Lexis/lexi-mf/") @@ -1228,7 +1228,7 @@ Function LookupShuowenOrg(x As String) As String() If Not code.IsChineseCharacter(x) Then Exit Function End If - ClipBoardObject.SetClipboard x + SystemSetup.SetClipboard x If Not openChrome("https://www.shuowen.org/") Then If Not openChrome("https://www.shuowen.org/") Then @@ -1296,7 +1296,132 @@ Select Case Err.Number End Select End Function +Rem dmrrn^uΡv쪺eGx ndrCǦ^@Ӧr}CA1ӤOuΡverA2ӤOdߵG}CYSAhǦ^Ŧr}C 20240916 +Function LookupDictionary_of_ChineseCharacterVariants_RetrieveShuoWenData(x As String) As String() + On Error GoTo eH + Dim result(1) As String '1=ޭȤW]̤jȡ^ + LookupDictionary_of_ChineseCharacterVariants_RetrieveShuoWenData = result + If Not code.IsChineseCharacter(x) Then + Exit Function + End If + SystemSetup.SetClipboard x + + If Not openChrome("https://dict.variants.moe.edu.tw/") Then + If Not openChrome("https://dict.variants.moe.edu.tw/") Then + Stop + End If + End If + Dim iwe As SeleniumBasic.IWebElement + Dim dt As Date + dt = VBA.Now + 'd߿J + Do While iwe Is Nothing + Set iwe = wd.FindElementByCssSelector("#header > div > flex > div:nth-child(3) > div.quick > form > input[type=text]:nth-child(2)") + If DateDiff("s", dt, VBA.Now) > 5 Then + Exit Function + End If + Loop + + word.Application.WindowState = wdWindowStateMinimize + wd.SwitchTo.Window (wd.CurrentWindowHandle) +' VBA.AppActivate "chrome" + 'd߿Jؤ + Dim keys As New SeleniumBasic.keys + iwe.Clear + iwe.SendKeys keys.Shift + keys.Insert 'KW˯ + iwe.SendKeys keys.Enter + + 'dߵGTءApi[ ] ]A dߵGG 1 rAr 3 r ju1voӤAHӧP_ + Set iwe = wd.FindElementByCssSelector("body > main > div > flex > div:nth-child(1) > red:nth-child(1)") + Rem XӪGGG@OCXBrUrCAGOiHӦrrY + If Not iwe Is Nothing Then + Dim zhengWen As String + zhengWen = iwe.text 'eҪu1v + 'eҪu3v + Set iwe = wd.FindElementByCssSelector("body > main > div > flex > div:nth-child(1) > red:nth-child(2)") + If zhengWen <> "0" Or iwe.text <> "0" Then + 'CXBrUrC + Set iwe = wd.FindElementByCssSelector("#searchL > a") + If Not iwe Is Nothing Then + If VBA.InStr(iwe.GetAttribute("outerHTML"), " data-tp=") = 0 Then + GoTo plural + Else + Do Until VBA.InStr(iwe.GetAttribute("outerHTML"), " data-tp="""" ") + Loop + End If + Else +plural: 'dߵG@ӡurvɡApuh{vr +' Stop + + Dim ai As Byte + ai = 2 '#searchL > a:nth-child(4)'#searchL > a:nth-child(3)'#searchL > a:nth-child(2) + Set iwe = wd.FindElementByCssSelector("#searchL > a:nth-child(" & ai & ")") + Do Until VBA.InStr(iwe.GetAttribute("outerHTML"), " data-tp="""" ") + ai = ai + 1 + Set iwe = wd.FindElementByCssSelector("#searchL > a:nth-child(" & ai & ")") + Loop + End If + iwe.Click + ' + Set iwe = wd.FindElementByCssSelector("#view > tbody > tr:nth-child(2) > td") + GoSub iweNothingExitFunction + result(0) = iwe.GetAttribute("textContent") + result(1) = wd.URL + SystemSetup.SetClipboard result(1) + End If + Else + 'pGܸӦrADdߵGApG https://dict.variants.moe.edu.tw/dictView.jsp?ID=5565 + 'rY + Set iwe = wd.FindElementByCssSelector("#header > section > h2 > span > a") + If iwe Is Nothing = False Then + ' + Set iwe = wd.FindElementByCssSelector("#view > tbody > tr:nth-child(2) > td") + GoSub iweNothingExitFunction + result(0) = iwe.GetAttribute("textContent") + result(1) = wd.URL + SystemSetup.SetClipboard result(1) + End If + End If +'''' '˯G +'''' Set iwe = wd.FindElementByCssSelector("body > div.container.main > div > div.col-md-9.main-content.pull-right > table > tbody > tr > td") +'''' If Not iwe Is Nothing Then +'''' If iwe.text = "SO" Then +'''' Exit Function +'''' End If +'''' End If +'''' +'''' Set iwe = wd.FindElementByCssSelector("body > div.container.main > div > div.col-md-9.main-content.pull-right > div.row.summary > div.col-md-9.pull-left.info-container > div.media.info-body > div.media-body") +'''' GoSub iweNothingExitFunction +'''' +'''' result(0) = iwe.text +'''' result(1) = wd.URL + LookupDictionary_of_ChineseCharacterVariants_RetrieveShuoWenData = result + Exit Function + +iweNothingExitFunction: + If iwe Is Nothing Then + LookupDictionary_of_ChineseCharacterVariants_RetrieveShuoWenData = result + Exit Function + End If + Return +eH: +Select Case Err.Number + Case -2146233088 + If InStr(Err.Description, "disconnected: not connected to DevTools") Then 'disconnected: not connected to DevTools + ' (failed to check if window was closed: disconnected: not connected to DevTools) + ' (Session info: chrome=128.0.6613.85) + 'Set wd = Nothing + SystemSetup.killchromedriverFromHere + Set wd = Nothing + Resume + Else + MsgBox Err.Number & Err.Description, vbExclamation + End If + Case Else + MsgBox "ChromesA@I" & vbCr & vbCr & Err.Number & Err.Description, vbExclamation + End Select +End Function Rem ˯Google @@ -1304,7 +1429,7 @@ Sub GoogleSearch(Optional searchStr As String) On Error GoTo Err1 If searchStr = "" And Selection = "" Then Exit Sub - ClipBoardObject.SetClipboard searchStr + SystemSetup.SetClipboard searchStr 'Dim wd As SeleniumBasic.IWebDriver 'Set wd = openChrome("https://www.baidu.com") @@ -1315,7 +1440,7 @@ Sub GoogleSearch(Optional searchStr As String) Set iwe = wd.FindElementByCssSelector("#APjFqb") If Not iwe Is Nothing Then iwe.Clear - ClipBoardObject.SetClipboard searchStr + SystemSetup.SetClipboard searchStr iwe.SendKeys keys.Shift + keys.Insert iwe.SendKeys keys.Enter End If @@ -1410,7 +1535,7 @@ Function grabGjCoolPunctResult(text As String, resultText As String, Optional Ba ' textBox.SendKeys text 'SystemSetup.GetClipboardText ' ' Else -' ClipBoardObject.SetClipboard text +' systemsetup.SetClipboard text ' textBox.SendKeys key.Control + "v" ' End If @@ -1486,7 +1611,7 @@ Function grabGjCoolPunctResult(text As String, resultText As String, Optional Ba ' ''ŪŶKï@^ǭ 'SystemSetup.Wait 0.3 - 'clipboardobject.SetClipboard textbox.text + 'systemsetup.SetClipboard textbox.text 'grabGjCoolPunctResult = SystemSetup.GetClipboardText grabGjCoolPunctResult = textBox.text resultText = grabGjCoolPunctResult @@ -1510,7 +1635,7 @@ Err1: Resume Case -2146233088 'unknown error: ChromeDriver only supports characters in the BMP (Session info: chrome=109.0.5414.75) Rem L@ - Rem clipboardobject.SetClipboard text + Rem systemsetup.SetClipboard text Rem SystemSetup.Wait 0.3 Rem textBox.SendKeys key.Control + "v" Rem textBox.SendKeys key.LeftShift + key.Insert @@ -1573,7 +1698,7 @@ Rem creedit chatGPT On Error GoTo Err1 Dim retryTimes As Byte DoEvents -'clipboardobject.SetClipboard pastedTxt +'systemsetup.SetClipboard pastedTxt 'SystemSetup.Wait 0.2 If Background Then iwd.Quit retry: