-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautocopy-for-saladict.ahk
153 lines (137 loc) · 3.98 KB
/
autocopy-for-saladict.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
;saladict 划译插件[AHK]
;version 0.9
;2016-01-08
;GUI及其他功能完善有待日后空闲
;========使用说明========
;pause键 启用/停用 脚本
;鼠标拖选、双击选词翻译
;~ http://weibo.com/1928931362/Dcdvnphx7?type=comment
;~ https://0paste.com/8133
SetTitleMatchMode, 2
; programs := ["SumatraPDF.exe", "mailmaster.exe"]
programs := ["SumatraPDF.exe", "mailmaster.exe", "Calibrize.exe"]
If WinActive("沙拉查词-独立查词窗口") || CheckProgramActive(programs) {
Pause::Suspend
^+y::
If WinActive("沙拉查词-独立查词窗口") {
WinActivateBottom, A
Sleep, 800
}
oldClipboard := Clipboard
gosub, Copy
return
MButton::
oldClipboard := Clipboard
gosub, Copy
return
~LButton::
; WinClose, "沙拉查词-独立查词窗口"
If !CheckProgramActive(programs) {
return
}
oldClipboard := Clipboard
; WriteLog("oldClipboard: " . oldClipboard)
CoordMode, Mouse, Screen
SetKeyDelay 0, 10
MouseGetPos, x1, y1
output := "previous coordinate: " . x1 . " , " . y1
; WriteLog(output)
; DebugMessage("previous coordinate: ", %x1%, " , ", %y1%)
KeyWait, LButton
MouseGetPos, x2, y2
output := "current coordinate: " . x2 . " , " . y2
; WriteLog(output)
if (x1<>x2 or y1<>y2) {
gosub, Copy
}
else if (A_priorHotKey = "~LButton" and A_TimeSincePriorHotkey < 1000){
; WriteLog("enter double click")
gosub, Copy
}
return
Copy:
Send ^c
Send ^+s
output := "clipboard: " . Clipboard
Clipboard := oldClipboard
; WriteLog(output)
; WriteLog("clipboard: " . %Clipboard%)
return
}
; WriteLog(% "clipboard: ". %Clipboard%)
; If WinActive("ahk_exe notepad++.exe") {
; ^x::
; WinGetActiveTitle, Title
; arr := StrSplit(Title, " ")
; Run, C:/Users/Administrator/GolandProjects/autocopy/main.exe arr[0]
; return
; }
CheckProgramActive(programs) {
flag := False
for index, ele in programs {
If WinActive("ahk_exe " ele) {
flag = True
}
}
return flag
}
WriteLog(text) {
FileAppend, % A_NowUTC ": " text "`n", logfile.txt ; can provide a full path to write to another directory
}
; #IfWinActive, ahk_exe notepad++.exe
; ^x::
; WinGetActiveTitle, Title
; arr := StrSplit(Title, " ")
; Run, C:/Users/Administrator/GolandProjects/autocopy/main.exe arr[0]
; return
~!Tab::
; If CheckProgramActive(programs) {
; Send {Alt+Tab}
; Send {Tab}
; } else {
; Send {Alt+Tab}
; }
; NextWin := WinExist("A", "Next")
; MsgBox, nextwin:%NextWin%
; MsgBox, fdskfdsf
; WriteLog("detect shortcut Alt+Tab")
; WinGetTitle, WinTitle, %WinTitle%
; MsgBox, 窗口标题为:%WinTitle%
; WriteLog("win title: " . WinTitle)
; If WinActive("沙拉查词-独立查词窗口") {
; WriteLog("enter saladcit window")
; Send, !TabTab
; ; Send {Alt+Tab}
; }
Sleep, 800
programs := ["SumatraPDF.exe", "mailmaster.exe"]
If WinActive("沙拉查词-独立查词窗口") {
; WriteLog("enter saladcit window")
; MsgBox, "enter saladcit window"
Send, {Alt Down}{Tab}
Sleep 300
Send, {Tab}{Alt Up}
}
return
; ~^x::
; If WinActive("沙拉查词-独立查词窗口") || CheckProgramActive(programs) {
; oldClipboard := Clipboard
; gosub, Copyon
; Copyon:
; Send ^c
; Send ^+s
; output := "clipboard: " . Clipboard
; Clipboard := oldClipboard
; WriteLog(output)
; ; WriteLog("clipboard: " . %Clipboard%)
; return
; }
; return
SetTimer, CheckWindow, 1000
CheckWindow:
IfWinExist, "沙拉查词-独立查词窗口"
{
WinSet, ExStyle, ^0x80, "沙拉查词-独立查词窗口"
}
return