人間夜行 发布的文章

GoldenDict 在 Linux 上的屏幕取词或许是利用了 X 第二剪贴板的特性,所以当用户选择文本后可以自动在附近弹出一个小按钮,点击后即可查词。而 Windows 上的取词一直不太稳定,唯一稳定的方法是利用剪贴板激活全局热键 Ctrl + C + C,而这对于正在使用剪贴板的情况非常不友好。本次努力是试图利用 AutoHotkey 尽量再现 Linux 上的体验。

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.

; Clip() - Send and Retrieve Text Using the Clipboard
; by berban - updated February 18, 2019
; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=62156
Clip(Text="", Reselect="")
{
    Static BackUpClip, Stored, LastClip
    If (A_ThisLabel = A_ThisFunc) {
        If (Clipboard == LastClip)
            Clipboard := BackUpClip
        BackUpClip := LastClip := Stored := ""
    } Else {
        If !Stored {
            Stored := True
            BackUpClip := ClipboardAll ; ClipboardAll must be on its own line
        } Else
            SetTimer, %A_ThisFunc%, Off
        LongCopy := A_TickCount, Clipboard := "", LongCopy -= A_TickCount ; LongCopy gauges the amount of time it takes to empty the clipboard which can predict how long the subsequent clipwait will need
        If (Text = "") {
            SendInput, ^c
            ClipWait, LongCopy ? 0.6 : 0.2, True
        } Else {
            Clipboard := LastClip := Text
            ClipWait, 10
            SendInput, ^v
        }
        SetTimer, %A_ThisFunc%, -700
        Sleep 20 ; Short sleep in case Clip() is followed by more keystrokes such as {Enter}
        If (Text = "")
            Return LastClip := Clipboard
        Else If ReSelect and ((ReSelect = True) or (StrLen(Text) < 3000))
            SendInput, % "{Shift Down}{Left " StrLen(StrReplace(Text, "`r")) "}{Shift Up}"
    }
    Return
    Clip:
    Return Clip()
}

SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

CoordMode, mouse, Screen
Gui, New, +AlwaysOnTop -Resize -MaximizeBox -MinimizeBox +MinSize -Caption, Dict
Gui, Add, Button, cBlue gSearch X0 Y0, Search
Gui, Margin, 0, 0
Gui, Show, NA AutoSize, movinggui
settimer, WatchCursor, 1000
return

WatchCursor:
MouseGetPos, oX, oY
WinMove, movinggui, , oX +20, oY + 20
return


OnMessage(0x0201, "WM_LBUTTONDOWN")

WM_LBUTTONDOWN()
{
  If (A_Gui)
    PostMessage, 0xA1, 2
}

Search:
Send, !{Tab}
Sleep, 300
text := Clip()
run "C:\Program Files (x86)\GoldenDict\GoldenDict.exe"  %text%
return

不得不承认 AHK 的脚本语言真的非常反人类。我就随便写写了。

不足之处在于,一个按钮会始终跟随光标,怎样根据需要显示我不会。此外,为了让用户能点击到,设置了一秒的运动延迟。GoldenDict 程序路径以及按钮位置等参数可以根据需要在脚本中修改。

GoldenDict 的弹出窗口可以用命令行调用,这个功能真是隐蔽,此前闻所未闻。

脚本参考了:

在此感谢。

舞动的琴弦流入梦影
在白日欢乐的转角
一瞬间醒来
月光阅读阶梯的缝隙

少年失了匕首
他只懂得骑马
只懂得骑马
泪水随着风中的月光飞

那是谁的歌声
假扮帝国万能的纷争

神圣并不必在于所谓的彼岸,神圣的国就是此世,此世的一切都是神圣,以我感受的(ästhetisch)方式显示其神圣。

美即神圣。

神圣:最终无条件的爱与自由。

(无需神圣计划式的历史)

标题:Textus imperfectus, seu compendium vitae omnium mortalium in omnibus historiis possibilibus

哦 那泪水沾染的未竟的组织
在文明残骸的角落隐藏
仍有浮动连绵的光线环游着
照亮它所缺乏的终点无常
我看见叹息的阴云飞散消失
反向的脚步使无情号令四方
那些数字的谜题还能否矛盾
让原初的僭越归于天上

(以上内容彻底失控)

Ein erweiterter Begriff von der Geschichte: Wir müssen alle glänzenden Fragmente menschlichen Geistes in gottverlassenen Räumen und Zeiten außerhalb der Wirklichkeit sammeln, um die beste aller möglichen Welten zu verbessern. Das ist eine menschenwürdige Berufung. Das ist die universale Progression, die Verwirklichung des Trostes.