-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProperCtrlShiftRight.ahk
65 lines (54 loc) · 1.7 KB
/
ProperCtrlShiftRight.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
#NoTrayIcon
#NoEnv
#KeyHistory 0
ListLines Off
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
#SingleInstance force
GroupAdd, ExcludedApps, ahk_exe notepad++.exe
GroupAdd, ExcludedApps, ahk_exe devenv.exe
GroupAdd, ExcludedApps, ahk_exe Ssms.exe
GroupAdd, ExcludedApps, ahk_exe soffice.bin
#IfWinNotActive ahk_group ExcludedApps
~^+Right::
if ((A_PriorHotkey = A_ThisHotkey) && (A_TimeSincePriorHotkey < 250)) {
SetTimer, Selection_TrimRight, Off
}
SetTimer, Selection_TrimRight, -250
return
#IfWinNotActive
Selection_TrimRight:
; WinActive("A")
; ControlGetFocus, ctl
; ControlGet, hede, Selected,, %ctl%
; MsgBox %hede%
; Return
; https://stackoverflow.com/a/45722976/1396155
WinActive("A")
ControlGetFocus, ctl
if (RegExMatch(ctl, "Edit\d+")) { ; attempt copying without clipboard
ControlGet, selection, Selected,, %ctl%
}
else { ; fallback solution
Send !{f17} ; disable copyq
Clipboard := ""
Send, ^c ; copy selected text to clipboard
ClipWait, 0, 1 ; There may be no selection yet.
selection := Clipboard
Send !{f16} ; Enable copyq and activate first item
}
if (StrLen(selection) = 0) {
return
}
foundPos := RegExMatch(selection, "s)^(.*?)\s+$", match)
if (foundPos = 0) {
return
}
numOfWhitespaceChars := StrLen(selection) - StrLen(match1)
Send +{Left %numOfWhitespaceChars%}
return