diff --git a/README.md b/README.md index 2002123..83b0863 100644 --- a/README.md +++ b/README.md @@ -308,6 +308,7 @@ Ctrl + F12 :檢索《國語辭典》 - Alt + v : **單字**檢索《異體字字典》並讀入其《說文》及網址資料以便引文。 - Alt + n : **單字**檢索《漢語多功能字庫》並取回其說文解釋欄位之值插入至插入點位置。 (n= 能 neng) - Alt + o : **單字**檢索[《說文解字》網站](https://www.shuowen.org/)並取回其解釋欄位及網址值插入至插入點位置。 (o= 說文解字 ShuoWen.ORG 的 O) +- Ctrl + Alt + Shift + 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 diff --git a/TextForCtextPortable.zip b/TextForCtextPortable.zip index 4a5bc20..de97489 100644 Binary files a/TextForCtextPortable.zip and b/TextForCtextPortable.zip differ diff --git a/WordVBA/Keywords.bas b/WordVBA/Keywords.bas index 6c432af..e4ff8c0 100644 --- a/WordVBA/Keywords.bas +++ b/WordVBA/Keywords.bas @@ -9,7 +9,7 @@ Property Get "ѳ", "Ѷ", "ֳ", "ֶ", "") End Property Rem ΥHѩr -Property Get KeywordsToMark() As Variant 'string() +Property Get KeywordsToMark() As Variant 'string()] Array Returns a Variant containing an array,ҥHg as string() KeywordsToMark = Array("", "P", "g", "j", "g", "g", "Cg", "QTg", "", _ "", "`", "", _ "", _ diff --git a/WordVBA/Network.bas b/WordVBA/Network.bas index eb9d0bf..b316207 100644 --- a/WordVBA/Network.bas +++ b/WordVBA/Network.bas @@ -167,7 +167,7 @@ Sub End If End With End With - Else + Else 'ar(0)Ů Dim ur As UndoRecord, fontsize As Single SystemSetup.stopUndo ur, "d~yh\rwè^仡줧ȴJܴJIm" With Selection @@ -179,8 +179,8 @@ Sub .Collapse wdCollapseEnd End If 'J^mne - .TypeText "AmnG" - .InsertAfter ar(0) & VBA.Chr(13) 'ar(0)=mne + .TypeText "AmnGu" + .InsertAfter ar(0) & "v" & VBA.Chr(13) 'ar(0)=mne .Collapse wdCollapseEnd If Selection.End = Selection.Document.Range.End - 1 Then Selection.Document.Range.InsertParagraphAfter @@ -221,7 +221,60 @@ Sub End If End With End With - Else + Else 'ar(0)Ů + Dim ur As UndoRecord, fontsize As Single + SystemSetup.stopUndo ur, "dѦrè^κ}ȴ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 "AmnGu" + .InsertAfter ar(0) & "v" & 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 dѦrè^q`κ}ȴJܴJIm() + Rem Ctrl+ Shift + Alt + o ]o= Ѧr ShuoWen.ORG O^ + If Selection.Characters.Count > 1 Then + MsgBox "d1r", vbExclamation ', vbError + Exit Sub + End If + Dim ar 'As Variant + ar = SeleniumOP.LookupShuowenOrg(Selection.text, True) + 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 'ar(0)Ů Dim ur As UndoRecord, fontsize As Single SystemSetup.stopUndo ur, "dѦrè^κ}ȴJܴJIm" With Selection @@ -235,9 +288,37 @@ Sub .TypeText "AmnG" .InsertAfter ar(0) & VBA.Chr(13) 'ar(0)=mne .Collapse wdCollapseEnd + 'Jq`e + .InsertAfter "q`G" & VBA.IIf(VBA.Asc(VBA.Left(ar(2), 1)) = 13, vbNullString, VBA.Chr(13)) & ar(2) & VBA.Chr(13) If Selection.End = Selection.Document.Range.End - 1 Then Selection.Document.Range.InsertParagraphAfter End If + Dim p As Paragraph, s As Byte, sDuan As Byte + s = VBA.Len(" ") 'q` + sDuan = VBA.Len(" ") 'q`q` +reCheck: + For Each p In .Paragraphs + If VBA.InStr(p.Range.text, "MN qɵmѦr`n") Then + p.Range.Delete + GoTo reCheck: + ElseIf VBA.Replace(p.Range.text, " ", "") = Chr(13) Then + p.Range.Delete + GoTo reCheck: + ElseIf VBA.Left(p.Range.text, s) = VBA.space(s) Then 'q` + p.Range.text = Mid(p.Range.text, s + 1) + ElseIf VBA.Left(p.Range.text, sDuan) = VBA.space(sDuan) Then 'q`q` + With p.Range + .text = Mid(p.Range.text, sDuan + 1) + With .Font + .Size = fontsize + 2 + .ColorIndex = 11 '.Font.Color= 34816 + End With + End With + End If + Next p + .Collapse wdCollapseEnd + + '}榡]w .Font.Size = fontsize .InsertAfter ar(1) 'J} SystemSetup.contiUndo ur @@ -262,7 +343,9 @@ 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 @@ -275,7 +358,7 @@ Sub End If End With End With - Else + Else 'pGar(0)DŦr]ŭȡ^ Dim ur As UndoRecord, fontsize As Single SystemSetup.stopUndo ur, "drrè^仡κ}ȴJܴJIm" With Selection @@ -286,11 +369,26 @@ Sub Else .Collapse wdCollapseEnd End If - .TypeText "AmnG" & VBA.Chr(13) + Dim s As Byte + s = VBA.InStr(ar(0), "mnC") + If s = 0 Then + If ar(0) = "ΨSơI" Then + .TypeText VBA.Chr(13) + Else + .TypeText "AmnG" & VBA.Chr(13) + End If + Else + .TypeText "A" & VBA.Mid(ar(0), s) & VBA.Chr(13) + End If 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 VBA.Left(shuoWen, 1) = "A" Then + shuoWen = x & shuoWen + End If + If s = 0 And ar(0) <> "ΨSơI" Then + .InsertAfter shuoWen & VBA.Chr(13) 'ar(0)=mne + .Collapse wdCollapseEnd + End If If Selection.End = Selection.Document.Range.End - 1 Then Selection.Document.Range.InsertParagraphAfter End If diff --git a/WordVBA/SeleniumOP.bas b/WordVBA/SeleniumOP.bas index 0518a64..120bc6f 100644 --- a/WordVBA/SeleniumOP.bas +++ b/WordVBA/SeleniumOP.bas @@ -1220,11 +1220,11 @@ Select Case Err.Number End Select End Function -Rem dmѦrn^mnuv쪺eGx ndrCǦ^@Ӧr}CA1ӤOmnuverA2ӤOdߵG}CYSAhǦ^Ŧr}C -Function LookupShuowenOrg(x As String) As String() +Rem dmѦrn^mnuv쪺eGx ndr,includingDuan O_]Ǧ^q`eCǦ^@Ӧr}CA1ӤOmn]j}^uverA2ӤOdߵG}A3ӫhOq`eCYSAhǦ^Ŧr}C +Function LookupShuowenOrg(x As String, Optional includingDuan As Boolean) As String() On Error GoTo eH - Dim result(1) As String '1=ޭȤW]̤jȡ^ - LookupShuowenOrg = result + Dim result(2) As String '2=ޭȤW]̤j = UBound Ǧ^ȡ^ + LookupShuowenOrg = result ']wnnǦ^r}CASᤩȮɴNOǦ^Ŧrꪺ}C If Not code.IsChineseCharacter(x) Then Exit Function End If @@ -1263,12 +1263,30 @@ Function LookupShuowenOrg(x As String) As String() Exit Function End If End If - + '檺e 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 + 'oq`e + If includingDuan Then + Dim i As Byte + i = 1 + 'Dim duanCommentary As String + 'oq`eت + Set iwe = wd.FindElementByCssSelector("body > div.container.main > div > div.col-md-9.main-content.pull-right > div:nth-child(" & i & ") > div") + Do + If i > 30 Then Exit Do + If Not iwe Is Nothing Then + If VBA.InStr(iwe.GetAttribute("textContent"), "MN qɵmѦr`n") Then Exit Do + End If + Set iwe = wd.FindElementByCssSelector("body > div.container.main > div > div.col-md-9.main-content.pull-right > div:nth-child(" & i & ") > div") + i = i + 1 + Loop + GoSub iweNothingExitFunction + result(2) = iwe.GetAttribute("textContent") '=duanCommentary + End If + LookupShuowenOrg = result Exit Function @@ -1363,7 +1381,16 @@ plural: ' Loop End If iwe.Click - ' + 'ˬd xs rO_OuΡv + Set iwe = wd.FindElementByCssSelector("#view > tbody > tr:nth-child(2) > th") + GoSub iweNothingExitFunction + If iwe.GetAttribute("textContent") <> "" Then + Set iwe = Nothing + result(0) = "ΨSơI" + result(1) = wd.URL + GoSub iweNothingExitFunction + End If + ' xs椸k䪺xs Set iwe = wd.FindElementByCssSelector("#view > tbody > tr:nth-child(2) > td") GoSub iweNothingExitFunction result(0) = iwe.GetAttribute("textContent") @@ -1375,7 +1402,17 @@ plural: ' 'rY Set iwe = wd.FindElementByCssSelector("#header > section > h2 > span > a") If iwe Is Nothing = False Then - ' + + 'ˬd xs rO_OuΡv + Set iwe = wd.FindElementByCssSelector("#view > tbody > tr:nth-child(2) > th") + GoSub iweNothingExitFunction + If iwe.GetAttribute("textContent") <> "" Then + Set iwe = Nothing + result(0) = "ΨSơI" + result(1) = wd.URL + GoSub iweNothingExitFunction + End If + ' xs椸k䪺xs Set iwe = wd.FindElementByCssSelector("#view > tbody > tr:nth-child(2) > td") GoSub iweNothingExitFunction result(0) = iwe.GetAttribute("textContent")