nh2ch2cooh. 返回工具库

GLYCINE'S ARCHIVES · TOOL

背

背单词小软件

自己改了下 只留下了背单词部分

费用
开源
类型
学习
系统
Windows
网址
—
说明
自己改了下 只留下了背单词部分
创建时间
2025年8月20日 11:33
日期
—
附件
无

页面内容

一日一技 | 用 AutoHotkey 偷偷背单词,甚至读本书

#Requires AutoHotkey v2.0
; 文档的默认地址为“D:\ahk\”
; 单词本和书本的默认名字分别为“words.txt”和“book.txt”

; 背单词模式
words_list:= []
word_index:= 1
words_path:= "D:\Documents\"
words_flag:= false
dict_flag:= false
favourite_flag:= false
exam_flag:= false
words_last_press:= A_TickCount

^XButton1:: words_mode()
words_mode()
{
global
words_last_press:= A_TickCount
words_flag:= !words_flag
words_list:= []
if words_flag
{
if !FileExist(words_path . "favourites.txt")
FileOpen(words_path . "favourites.txt", "w", "UTF-8").Write(Chr(0xFEFF) "")
Loop Read, words_path . "words.txt", "UTF-8"
words_list.Push(A_LoopReadLine)
SetTimer words_check, 120 * 1000
ToolTip Format("开始")
SetTimer () => ToolTip(), -1200
}
else
{
dict_flag:= false
SetTimer words_check, 0
ToolTip ("结束")
SetTimer () => ToolTip(), -800
}
}

words_check() {
if A_TickCount - words_last_press >= 600 * 1000
words_mode
}

#HotIf words_flag
^MButton::
{
global exam_flag
exam_flag:= !exam_flag
if exam_flag
ToolTip("测试模式")
else
ToolTip("普通模式")
SetTimer () => ToolTip(), -800
}

+XButton1::
{
global favourite_flag, words_list
words_list:= []
favourite_flag:= !favourite_flag
if favourite_flag
{
Loop Read, words_path . "favourites.txt", "UTF-8-RAW"
words_list.Push(A_LoopReadLine)
ToolTip Format("复习模式")
}
else
{
Loop Read, words_path . "words.txt", "UTF-8-RAW"
words_list.Push(A_LoopReadLine)
ToolTip Format("结束复习")
}
SetTimer () => ToolTip(), -800
}

XButton1::
{
global words_list, dict_flag, word_index, words_last_press
words_last_press:= A_TickCount
word_index:= Random(1, words_list.Length)
try
{
word1:= StrSplit(words_list[word_index], " ", , 2)[1]
word2:= StrSplit(words_list[word_index], " ", , 2)[2]
if exam_flag
ToolTip(word2)
else
ToolTip(word1)
KeyWait("LButton", "D")
ToolTip(word1 . "`n" . word2)
dict_flag:= true
}
}
#HotIf

#HotIf dict_flag
LButton::
{
global dict_flag
dict_flag:= false
ToolTip()
}

d::
{
tmp:= ClipboardAll()
A_Clipboard:= StrSplit(words_list[word_index], " ", 2)[1]
Send "^+c"
A_Clipboard:= tmp
}

s::
{
global dict_flag
if !Instr(FileRead(words_path . "favourites.txt"), words_list[word_index])
FileOpen(words_path . "favourites.txt", "a", "utf-8").Write(words_list[word_index] . "`n")
dict_flag:= false
ToolTip Format("加入收藏:{}", StrSplit(words_list[word_index], " ", 2)[1])
SetTimer () => ToolTip(), -1200
}

RButton::
{
global words_list, dict_flag
words_list.RemoveAt(word_index)
new_list:= ""
for i in words_list
new_list.= i "`n"
if favourite_flag
FileOpen(words_path . "favourites.txt", "w", "utf-8").Write(new_list)
else
FileOpen(words_path . "words.txt", "w", "utf-8").Write(new_list)
dict_flag:= false
ToolTip()
}
#HotIf

一日一技 | 用 AutoHotkey 偷偷背单词,甚至读本书