forked from aviaryan/Clipjump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Clipjump.ahk
1664 lines (1464 loc) · 48.4 KB
/
Clipjump.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Clipjump
Copyright 2013-15 Avi Aryan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
;@Ahk2Exe-SetName Clipjump
;@Ahk2Exe-SetDescription Clipjump
;@Ahk2Exe-SetVersion 12.5
;@Ahk2Exe-SetCopyright Avi Aryan
;@Ahk2Exe-SetOrigFilename Clipjump.exe
SetWorkingDir, %A_ScriptDir%
SetBatchLines,-1
#NoEnv
#SingleInstance, force
#ClipboardTimeout 0 ;keeping this value low as I already check for OpenClipboard in OnClipboardChange label
CoordMode, Mouse
CoordMode, Tooltip
FileEncoding, UTF-8
ListLines, Off
#KeyHistory 0
#HotkeyInterval 1000
#MaxHotkeysPerInterval 1000
global ini_LANG := "" , H_Compiled := RegexMatch(Substr(A_AhkPath, Instr(A_AhkPath, "\", 0, 0)+1), "iU)^(Clipjump).*(\.exe)$") && (!A_IsCompiled) ? 1 : 0
global mainIconPath := H_Compiled || A_IsCompiled ? A_AhkPath : "icons/icon.ico"
/*
**********************
PROGRAM VARIABLES
**********************
*/
global PROGNAME := "Clipjump"
global VERSION := "12.5"
global CONFIGURATION_FILE := "settings.ini"
ini_LANG := ini_read("System", "lang")
if !ini_LANG
ini_LANG := "english"
global TXT := Translations_load("languages/" ini_LANG ".txt") ;Load translations
global UPDATE_FILE := "http://sourceforge.net/projects/clipjump/files/version.txt/download"
global PRODUCT_PAGE := "http://clipjump.sourceforge.net"
global HELP_PAGE := "http://clipjump.sourceforge.net/docs"
global AUTHOR_PAGE := "http://aviaryan.in"
global MSG_TRANSFER_COMPLETE
, MSG_CLIPJUMP_EMPTY
, MSG_ERROR
, MSG_MORE_PREVIEW
, MSG_PASTING
, MSG_DELETED
, MSG_ALL_DELETED
, MSG_CANCELLED
, MSG_FIXED
, MSG_HISTORY_PREVIEW_IMAGE
, MSG_FILE_PATH_COPIED
, MSG_FOLDER_PATH_COPIED
Translations_fixglobalVars() ; copymessage will be globalized and fixed in validateSettings()
;History Tool
global hidden_date_no := 4 , history_w , history_partial := 1 ;start off with partial=1 <> much better
global PREV_FILE := "cache\prev.html" , GHICON_PATH := A_ScriptDir "\icons\octicons-local.ttf"
global DBPATH := "cache\data.db"
/*
****************
BASIC STRUCTURE
****************
*/
;Creating Storage Directories
FileCreateDir, cache
FileCreateDir, cache/clips
FileCreateDir, cache/thumbs
FileCreateDir, cache/history
FileSetAttrib, -H, %A_WorkingDir%\cache
;Init Non-Ini Configurations
FileDelete, % A_temp "/clipjumpcom.txt"
try Clipboard := ""
/*
*********
VARIABLES
*********
*/
Sysget, temp, MonitorWorkArea
global WORKINGHT := tempbottom-temptop, restoreCaller := 0, startUpComplete := 0
;Global Inits
global CN := {}, CUSTOMS := {}, CDS := {}, CPS := {}, SEARCHOBJ := {}, HISTORYOBJ := {}, TOTALCLIPS, ACTIONMODE := {}, PLUGINS := {}, STORE := {}
global cut_is_delete_windows := "XLMAIN QWidget" ;excel, kingsoft office
global CURSAVE, TEMPSAVE, LASTCLIP, LASTFORMAT, Islastformat_Changed := 1, IScurCBACTIVE := 0, curPformat, curPfunction, curPisPreviewable
global NOINCOGNITO := 1, SPM := {}, protected_DoBeep := 1
global pastemodekey := {} , spmkey := {}
global windows_copy_k, windows_cut_k, ini_OpenAllChbyDef := 0, pstIdentifier := "^", pstKeyName := (pstIdentifier == "^") ? "Ctrl" : "LWin"
;Initailizing Common Global Variables
global CALLER_STATUS, CLIPJUMP_STATUS := 1 ; global vars are not declared like the below , without initialising
global CALLER := CALLER_STATUS := 1, IN_BACK := 0, MULTIPASTE, PASTEMODE_ACT
global CLIP_ACTION := "", ONCLIPBOARD := 1 , ISACTIVEEXCEL := 0 , HASCOPYFAILED := 0 , ctrlRef ;specific purpose global vars
global wasManualClipboard := false
;Global Ini declarations
global ini_IsImageStored , ini_Quality , ini_MaxClips , ini_Threshold , ini_isMessage, CopyMessage, ini_DaysToStore
, Copyfolderpath_K, Copyfilepath_K, Copyfilepath_K, onetime_K, paste_k, actionmode_k, ini_is_duplicate_copied, ini_formatting
, ini_CopyBeep , beepFrequency , ignoreWindows, ini_defEditor, ini_defImgEditor, ini_def_Pformat, pluginManager_k, holdClip_K, ini_PreserveClipPos
, chOrg_K, ini_startSearch, ini_revFormat2def, ini_pstMode_X, ini_pstMode_Y, ini_HisCloseOnInstaPaste, history_K, ini_ram_flush, ini_winClipjump := 1
, ini_monitorClipboard := 0
;Init General vars
is_pstMode_active := 0
/*
***********************
GET THE PROGRAM WORKING
***********************
*/
;Setting up Icons
FileCreateDir, icons
FileInstall, icons\no_history.Ico, icons\no_history.Ico, 0 ;Allow users to have their icons
FileInstall, icons\no_monitoring.ico, icons\no_monitoring.ico, 0
;MANAGE PROGRAM UPDATE
Iniread, ini_Version, %CONFIGURATION_FILE%, System, Version
;FileCreateDir, plugins/pformat
;FileCreateDir, plugins/external
;migratePlugins()
If !FileExist(CONFIGURATION_FILE)
{
save_default(1)
if !Instr(VERSION, "b") ; betas have b
{
MsgBox, 52, Recommended, % TXT.ABT_seehelp
IfMsgBox, Yes
gosub, hlp
}
if !A_IsAdmin
MsgBox, 16, WARNING, % TXT.ABT_runadmin
try TrayTip, Clipjump, % TXT.ABT_cjready , 10, 1
}
else if (ini_Version != VERSION)
{
save_default(0) ;0 corresponds to selective save
gosub Reload ; Update plugin includes with what the user has incase he updates his Clipjump
sleep 10000 ; to counter race condition
}
; start history
; migrate if needed
global DB := new SQLiteDB()
if (!FileExist(DBPATH))
isnewdb := 1
else
isnewdb := 0
if (!DB.OpenDB(DBPATH))
msgbox some error occured
/*
***********************
DEFAULT SETTINGS LOADING
************************
*/
temp_keys := "Enter|Up|Down|Home"
loop, parse, temp_keys,|
spmkey[A_LoopField] := A_LoopField
init_actionmode() ;Initialising Clipjump Channels
initChannels()
/*
********************
LOAD USER SETTINGS
********************
*/
trayMenu() ; before customization and settings as customization can affect tray
;loading Settings
load_Settings(1)
validate_Settings()
loadPlugins()
loop
{
IfNotExist, cache/Clips/%A_Index%.avc
{
CURSAVE := A_Index - 1 , TEMPSAVE := CURSAVE
break
}
}
global CLIPS_dir := "cache/clips"
, THUMBS_dir := "cache/thumbs"
, FIXATE_txt := "fixed"
, NUMBER_ADVANCED := 34 + CN.Total ;the number stores the line number of ADVANCED section
/*
******************************
MORE SETTINGS A/C USER SETTINGS
******************************
*/
temp_keys := "a|c|s|z|space|x|e|up|down|f|h|Enter|t|F1|q"
loop, parse, temp_keys,|
pastemodekey[A_LoopField] := A_LoopField
;Setting Up shortcuts
hkZ( ( paste_k ? "$" pstIdentifier paste_k : emptyvar ) , "Paste")
copyCutShortcuts()
hkZ(Copyfilepath_K, "CopyFile") , hkZ(Copyfolderpath_K, "CopyFolder")
hkZ(history_K, "History")
hkZ(Copyfiledata_K, "CopyFileData") , hkZ(channel_K, "channelGUI")
hkZ(onetime_K, "oneTime") , hkZ(pitswap_K, "pitswap")
hkZ(actionmode_K, "actionmode") , hkZ(pluginManager_k, "pluginManagerGUI")
hkZ(holdClip_K, "holdClip") , hkZ(chOrg_K, "channelOrganizer")
;more shortcuts
hkZ(windows_copy_k, "windows_copy") , hkZ(windows_cut_k, "windows_cut")
;create Ignore windows group from | separated values
loop, parse, ignoreWindows,|
GroupAdd, ignoreGroup, ahk_class %A_LoopField%
;group created
/*
*********************
LOAD END-USER CUSTOMIZATIONS
*********************
*/
loadClipboardDataS()
loadCustomizations()
/*
***************
ERROR HANDLINGS AND
COMPATIBILITY
***************
*/
if FileExist(GHICON_PATH)
DllCall("GDI32.DLL\AddFontResourceEx", Str, GHICON_PATH ,UInt,(FR_PRIVATE:=0x10), Int,0)
else
MsgBox, 16, % PROGNAME, % valueof(TXT.ABT_errorFontIcon)
if (isnewdb == 1){
migrateHistory()
}
/*
**********
LAST WORDS
**********
*/
fillHISTORYOBJ()
historyCleanup() ;Clean History
OnMessage(0x4a, "Receive_WM_COPYDATA") ; 0x4a is WM_COPYDATA
; Portable Startup
IfExist, %A_Startup%/Clipjump.lnk
{
FileDelete, %A_Startup%/Clipjump.lnk
FileCreateShortcut, % H_Compiled ? A_AhkPath : A_ScriptFullPath, %A_Startup%/Clipjump.lnk
Menu, Options_Tray, Check, % TXT.TRY_startup
}
EmptyMem()
lastClipboardTime := 0
startUpComplete := 1
OnExit, exit
return
;Tooltip No 1 is used for Paste Mode tips, 2 is used for notifications , 3 is used for updates , 4 is used in WM_MOUSEMOVE , 5 is used in Action Mode
;6 used in Class Tool, 7 in API (Plugin) , 8 used in Customizer, 9 used in history tool, 10 in edit clips, 11 in Channel Organizer
;End Of Auto-Execute================================================================================================================
loadClipboardDataS(){
API.showTip(TXT.TIP_initMsg)
API.blockMonitoring(1)
loop % CN.Total
{
fp := "cache\clips" ( A_index-1 ? A_index-1 : "" )
CDS[R:=A_index-1] := {}
CPS[R] := ini2Obj(fp "\prefs.ini")
loop, % fp "\*.avc"
{
ONCLIPBOARD:="" , Z := ""
if try_ClipboardfromFile(A_LoopFileFullPath, 300)
Z := trygetVar("Clipboard", 500) ; 300 tries minimize chances of Clipboard recorders like Exekutor to interrupt
else ONCLIPBOARD := 1 , Z := ""
while !ONCLIPBOARD
sleep 5
CDS[R][Substr(A_LoopFileName,1,-4)] := Z
}
}
API.removeTip()
API.blockMonitoring(0)
}
paste:
Critical, On
IfWinActive, ahk_group ignoreGroup
{
Send ^{vk56}
return
}
Gui, imgprv:Destroy
CALLER := 0
if !ctrlRef
firstPasteMode := 1
if ini_startSearch && firstPasteMode
SPM.ACTIVE := 1
ctrlRef := "pastemode"
if IN_BACK
IN_BACK_correction()
if (TEMPSAVE>CURSAVE) or !TEMPSAVE
TEMPSAVE := CURSAVE
If !FileExist(CLIPS_dir "/" TEMPSAVE ".avc")
{
if !oldclip_exist
{
oldclip_exist := 1
try oldclip_data := ClipboardAll
}
try Clipboard := ""
hkZ(pstIdentifier pastemodekey.up, "channel_up") , hkZ(pstIdentifier pastemodekey.down, "channel_down") ;activate the 2 keys to jump channels
PasteModeTooltip("{" CN.Name "} " MSG_CLIPJUMP_EMPTY, 1) ;No Clip Exists
setTimer, ctrlCheck, 50
}
else
{
if !oldclip_exist ;will be false when V is pressed for 1st time
{
oldclip_exist := 1
try oldclip_data := ClipboardAll
catch {
makeClipboardAvailable(0) ; make clipbboard available in case it is blocked
}
}
else
IScurCBACTIVE := 0 ;false it when V is pressed for the 2nd time
if !is_pstMode_active
hkZ_pasteMode(1) , is_pstMode_active := 1
if !IScurCBACTIVE ;if the current clipboard is not asked for , then only load from file
try_ClipboardfromFile(A_WorkingDir "/" CLIPS_dir "/" TEMPSAVE ".avc") ; gets file onto clipboard trying 100 times
temp_clipboard := trygetVar("Clipboard") ;gets variable with multiple tries
fixStatus := fixCheck()
realclipno := CURSAVE - TEMPSAVE + 1
if temp_clipboard =
showPreview()
else
{
If strlen(temp_clipboard) > 200
halfClip := Substr(temp_clipboard, 1, 200) "`n`n" MSG_MORE_PREVIEW
else halfClip := temp_clipboard
if curPisPreviewable
halfClip := %curPfunction%(halfClip)
}
realActive := TEMPSAVE
PasteModeTooltip(temp_clipboard)
SetTimer, ctrlCheck, 50
TEMPSAVE -= 1
If (TEMPSAVE == 0)
TEMPSAVE := CURSAVE
}
if ini_startSearch && firstPasteMode
setTimer, run_searchpm, -10 ; dont open in this thrd. critical
firstPasteMode := 0
return
onClipboardChange:
Critical, On
if !ONCLIPBOARD
{
ONCLIPBOARD:=1 ; if let blank, the label ends quickly
return
}
ONCLIPBOARD := 1 ;used by paste/or another to identify if OnCLipboard has been breached
if !startUpComplete ;if not started, not allow - after onclipboard=1 as the purpose of onc is served
return
; check for machine-done clipboard manipulations
timeDiff := TickCount64() - lastClipboardTime
lastClipboardTime := TickCount64()
if (timeDiff < 200){
return
}
; check monitor clipboard setting
if (ini_monitorClipboard == 0) {
if (wasManualClipboard == false){
return
} else {
wasManualClipboard := false
setTimer, manualClipboardTimer, Off
}
}
; ignore windows
ifwinactive, ahk_group IgnoreGroup
return
;debugTip("1") ;<<<<<<<
If CALLER
{
STORE.CBCaptured := 0
if !WinActive("ahk_class XLMAIN")
try clipboard_copy := makeClipboardAvailable() , ISACTIVEEXCEL := 0
else try clipboard_copy := LASTCLIP , ISACTIVEEXCEL := 1 ;so that Cj doesnt open excel clipboard (for a longer time) and cause problems
;clipboard_copy = lastclip as to remove duplicate copies in excel , ^x or ^c makes lastclip empty
;debugTip("2") ;<<<<<<<<<
try eventinfo := A_eventinfo
if ISACTIVEEXCEL
isLastFormat_changed := 1 ;same reason as above
else
try isLastFormat_changed := ( LASTFORMAT != (temp_lastformat := GetClipboardFormat(0)) ) ? 1 : 0
if isLastFormat_changed or ( LASTCLIP != clipboard_copy) or ( clipboard_copy == "" )
returnV := clipChange(eventinfo, clipboard_copy)
LASTFORMAT := temp_lastformat , CLIP_ACTION := returnV ? "" : CLIP_ACTION ;make CLIP_ACTION empty if copy/cut succeeded else let it be so that if window uses
;2 transfers like Excel , the demand can be fulfilled
IScurCBACTIVE := returnV ;current clipboard is active after new data copied to clipboard SUCCESSFULLY
if CPS[CN.NG][CURSAVE][FIXATE_txt] ; not active if the first clip is FIXED
IScurCBACTIVE := 0
if !ISACTIVEEXCEL ;excel has known bugs with AHK and manipulating clipboard *infront* of it will cause errors
makeClipboardAvailable(0) ;close clipboard in case it is still opened by clipjump
;debugTip("") ;<<<<<<<<<<<<
STORE.CBCaptured := 1
}
else
{
;debugTip("pst mode 2") ;<<<<<<<<<<<<
LASTFORMAT := WinActive("ahk_class XLMAIN") ? "" : GetClipboardFormat(0)
if restoreCaller
restoreCaller := "" , CALLER := CALLER_STATUS
if onetimeOn
{
onetimeOn := 0 ;--- To avoid OnClipboardChange label to open this routine [IMPORTANT]
sleep 500 ;--- Allows the restore Clipboard Transfer in apps
CALLER := CALLER_STATUS
autoTooltip("One Time Stop " TXT.TIP_deactivated, 600, 2)
changeIcon()
}
;debugTip("") ;<<<<<<<<<<
}
return
clipChange(CErrorlevel, clipboard_copy) {
If CErrorlevel = 1
{
if ( clipboard_copy != LASTCLIP ) or ( clipboard_copy == "" ) ;dont let go if lastclip = clipboard_copy = <empty>
{
CURSAVE += 1
if ISACTIVEEXCEL
LASTCLIP := clipsaver()
else
LASTCLIP := clipboard_copy , temp := clipSaver()
If HASCOPYFAILED
{
CURSAVE -= 1 , TEMPSAVE := CURSAVE
return
}
if NOINCOGNITO and ( CN.Name != "pit" ){
addHistoryText(LASTCLIP, A_now)
}
BeepAt(ini_CopyBeep, beepFrequency)
ToolTip, %copyMessage%
if CLIP_ACTION = CUT
{
WinGetClass, activeclass, A
if Instr(cut_is_delete_windows, activeclass)
Send {vk2e} ;del
}
TEMPSAVE := CURSAVE
while ( CURSAVE >= TOTALCLIPS )
compacter()
returnV := 1
}
}
else If CErrorlevel = 2
{
CURSAVE += 1 , TEMPSAVE := CURSAVE , LASTCLIP := ""
clipSaver()
if HASCOPYFAILED
{
CURSAVE -= 1 , TEMPSAVE := CURSAVE
return
}
BeepAt(ini_CopyBeep, beepFrequency)
ToolTip, %copyMessage%
thumbGenerator()
if NOINCOGNITO and ini_IsImageStored and ( CN.Name != "pit" ){
addHistoryImage(THUMBS_dir "\" CURSAVE ".jpg", A_Now)
}
while ( CURSAVE >= TOTALCLIPS )
compacter()
returnV := 2
}
SetTimer, TooltipOff, 500
emptyMem()
return returnV
}
moveBack:
Critical ;, On
IfWinActive, ahk_group IgnoreGroup
return
Gui, imgprv:Destroy
IN_BACK := true
TEMPSAVE := realActive + 1
if realActive = %CURSAVE%
TEMPSAVE := 1
realActive := TEMPSAVE
IScurCBACTIVE := 0 ;the key will be always pressed after V
try_ClipboardfromFile(CLIPS_dir "/" TEMPSAVE ".avc")
temp_clipboard := trygetVar("Clipboard")
fixStatus := fixCheck()
realClipNo := CURSAVE - TEMPSAVE + 1
if temp_clipboard =
showPreview()
else
{
if strlen(temp_clipboard) > 200
{
StringLeft, halfClip, temp_clipboard, 200
halfClip := halfClip "`n`n" MSG_MORE_PREVIEW
}
else halfClip := temp_clipboard
IF curPisPreviewable
halfClip := %curPfunction%(halfClip)
}
PasteModeTooltip(temp_clipboard)
SetTimer, ctrlCheck, 50
return
IN_BACK_correction(){ ; corrects TEMPSAVE value when C (backwards) is used in paste mode
global
IN_BACK := false
If (TEMPSAVE == 1)
TEMPSAVE := CURSAVE
else
TEMPSAVE -= 1
}
;-------------- paste mode tips ------------------------
multiPaste:
if SPM.ACTIVE {
WinHide, Clipjump_SPM ahk_class AutoHotkeyGUI
WinWaitNotActive, Clipjump_SPM ahk_class AutoHotkeyGUI
temp_spmWasActive := 1
}
MULTIPASTE := PASTEMODE_ACT := 1
while PASTEMODE_ACT
sleep 50 ; wait till ctrlCheck: runs
if MULTIPASTE ; if multipaste is still ON, becomes OFF due to release of ctrl (which doesnt disturb when spm is active)
gosub paste
if temp_spmWasActive {
WinShow, Clipjump_SPM ahk_class AutoHotkeyGUI
temp_spmWasActive := 0
}
return
cancel:
Gui, Hide
PasteModeTooltip(TXT.TIP_cancelm "`t(1)`n" TXT.TIP_modem, 1)
ctrlref := "cancel"
if SPM.ACTIVE
gosub SPM_dispose ; dispose it if There - Note that this step ends the label as ctrlCheck dies so ctrlRef is kept upwards to be updated
hkZ_pasteMode(0, 0) , hkZ_pi(pastemodekey.x, "Delete", 1)
return
delete:
PasteModeTooltip(TXT.TIP_delm "`t`t(2)`n" TXT.TIP_modem, 1)
ctrlref := "delete"
hkZ_pi(pastemodekey.x, "Delete", 0) , hkZ_pi(pastemodekey.x, "cutclip", 1)
return
cutclip:
PasteModeTooltip(TXT.TIP_move "`t`t(3)`n" TXT.TIP_modem, 1)
ctrlref := "cut"
hkZ_pi(pastemodekey.x, "cutclip", 0) , hkZ_pi(pastemodekey.x, "copyclip", 1)
return
copyclip:
PasteModeTooltip(TXT.TIP_copy "`t`t(4)`n" TXT.TIP_modem, 1)
ctrlref := "copy"
hkZ_pi(pastemodekey.x, "copyclip", 0) , hkZ_pi(pastemodekey.x, "DeleteAll", 1)
return
deleteall:
PasteModeTooltip(TXT.TIP_delallm "`t`t(5)`n" TXT.TIP_modem, 1)
ctrlref := "deleteAll"
hkZ_pi(pastemodekey.x, "DeleteAll", 0) , hkZ_pi(pastemodekey.x, "Cancel", 1)
return
nativeCopy:
Critical
if WinActive("ahk_class XLMAIN")
{
copyCutShortcuts(0)
hkZ("$^c", "keyblocker")
LASTCLIP := ""
setTimer, ctrlforCopy, 50
}
if ini_is_duplicate_copied
LASTCLIP := ""
CLIP_ACTION := "COPY"
wasManualClipboard := true
setTimer, manualClipboardTimer, -1000
Send, ^{vk43}
return
nativeCut:
Critical
if WinActive("ahk_class XLMAIN")
{
copyCutShortcuts(0)
hkZ("$^x", "keyblocker")
LASTCLIP := ""
setTimer, ctrlforCopy, 50
}
if ini_is_duplicate_copied
LASTCLIP := ""
CLIP_ACTION := "CUT"
wasManualClipboard := true
setTimer, manualClipboardTimer, -1000
Send, ^{vk58}
return
ctrlForCopy:
if GetKeyState("Ctrl", "P") = 0 ; if key is up
{
Critical ;To make sure the hotkeys are changed
copyCutShortcuts() ; keyblocker is removed bcoz ^x and ^c overwrites it
SetTimer, ctrlforCopy, Off
}
return
manualClipboardTimer:
wasManualClipboard := false
return
Formatting:
matched_pformat := 0 , curPformat := Trim(curPformat)
if curPformat=
matched_pformat := 1
for key,value in PLUGINS["pformat"]
{
if matched_pformat {
curPformat := value.name , curPfunction := value["*"] , matched_pformat := 0
break
}
if ( value["name"] == curPformat )
matched_pformat := 1
}
;rebuild show text
if temp_clipboard != ""
{
If strlen(temp_clipboard) > 200
{
StringLeft,halfclip,temp_clipboard, 200
halfClip := halfClip . "`n`n" MSG_MORE_PREVIEW
}
else halfClip := temp_clipboard
}
if matched_pformat
curPformat := "" , curPisPreviewable := 0 ; case of switching to default
else halfClip := (curPisPreviewable := value["Previewable"]) ? %curPfunction%(halfClip) : halfClip
if ctrlRef = pastemode
PasteModeTooltip(temp_clipboard) ; rebuild prvw
return
fixate:
If CPS[CN.NG][realActive][FIXATE_txt]
fixStatus := "" , CPS[CN.NG][realActive].remove(FIXATE_txt)
else
fixStatus := MSG_FIXED , AddClipPref(CN.NG, realActive, FIXATE_txt, 1)
prefs_changed := 1
PasteModeTooltip(temp_clipboard)
return
TogglejumpClip:
jumpClip_sign := !jumpClip_sign
return
AddjumpClip:
if IN_BACK
IN_BACK_correction()
TEMPSAVE += (!jumpClip_sign ? -Substr(A_ThisHotkey, 2)+1 : Substr(A_ThisHotkey, 2)+1)
loop ; as somthing like +9 could make tempsave = 17 when tempsave was 8 and the cursave is also 8
if (TEMPSAVE>CURSAVE)
TEMPSAVE := TEMPSAVE-CURSAVE
else if TEMPSAVE<1
TEMPSAVE := CURSAVE+TEMPSAVE
else break
gosub paste
return
move_to_first:
API.manageClip(CN.NG, CN.NG, realClipNo, 0)
gosub navigate_to_first
return
navigate_to_first:
if IN_BACK
IN_BACK_correction()
TEMPSAVE := CURSAVE ; make tempsave 29 if total clips (cursave) is 29 . so load the first (latest) clip
gosub paste
return
setClipTag:
gosub endPastemode
InputBox, ov, % TXT._tags, % TXT.TIP_tagprompt ,,,,,,,, % CPS[CN.NG][realActive]["Tags"]
if !ErrorLevel
AddClipPref(CN.NG, realActive, "Tags", ov), Prefs2Ini() , autoTooltip(TXT.TIP_done, 800, 2)
else autoTooltip(TXT.TIP_cancelled, 800, 2)
EmptyMem()
return
clipSaver() {
FileDelete, %CLIPS_dir%/%CURSAVE%.avc
HASCOPYFAILED := 0
Tooltip, % TXT["_processing"],,, 7
while !copied
{
if ( A_index=100 ) or HASCOPYFAILED {
HASCOPYFAILED := 1
Tooltip,,,, 7
return
}
try {
if ISACTIVEEXCEL
{
foolGUI(1) ;foolGUI() is a blank gui to get focus over excel [crazy bug- crazy fix]
tempC := ClipboardAll
tempCB := Clipboard
foolGUI(0)
}
else
tempC := ClipboardAll
if Substr(CN.Name, 1, 1) = "_" ; protected channels
{
Critical, Off
BeepAt(protected_DoBeep, 2000, 200)
temp21 := TT_Console("{" CN.Name "}`n " TXT.TIP_confirmcopy, "Y N Insert")
Critical, On
}
if (temp21 = "Y") or (temp21 = "")
{
FileAppend, %tempC%, %CLIPS_dir%/%CURSAVE%.avc
CDS[CN.NG][CURSAVE] := ISACTIVEEXCEL ? tempCB : Clipboard
copied := 1
}
else {
LASTCLIP := "" , LASTFORMAT := "" , HASCOPYFAILED := 1 ; lastclip was not captured by cj
if (temp21 = "Insert") {
Tooltip, % TXT["_processing"]
SetTimer, addClipLater, -50
}
}
} catch {
if ISACTIVEEXCEL
foolGUI(0)
}
}
Tooltip,,,, 7
; check for empty file
FileRead, test, %CLIPS_dir%/%CURSAVE%.avc
if test=
return (HASCOPYFAILED := 1) * ablankvar ;actually the return doesnt matter here
manageFIXATE(CURSAVE, CN.NG, CN.N)
return tempCB
}
manageFIXATE(clipAdded, channel, Dir_constant){
; manages how Fixed clip are re-positioned when a new clip is added disturing the order.
; It is necessary for the new clip to be added at Clip 1 position
path_CLIPS := "cache\clips" Dir_constant
path_THUMBS := "cache\thumbs" Dir_constant
Loop, %clipAdded%
{
tempNo := clipAdded - A_Index + 1
If CPS[channel][tempNo][FIXATE_txt]
{
t_TempNo := tempNo + 1
FileMove, %path_CLIPS%\%t_TempNo%.avc, %path_CLIPS%\%t_TempNo%_a.avc
FileMove, %path_CLIPS%\%tempNo%.avc, %path_CLIPS%\%t_TempNo%.avc
FileMove, %path_CLIPS%\%t_TempNo%_a.avc, %path_CLIPS%\%tempNo%.avc
z := CDS[channel][t_TempNo] , CDS[channel][t_TempNo] := CDS[channel][tempNo] , CDS[channel][tempNo] := z
IfExist, %path_THUMBS%\%tempNo%.jpg
{
FileMove, %path_THUMBS%\%t_TempNo%.jpg, %path_THUMBS%\%t_TempNo%_a.jpg
FileMove, %path_THUMBS%\%tempNo%.jpg, %path_THUMBS%\%t_TempNo%.jpg
FileMove, %path_THUMBS%\%t_TempNo%_a.jpg, %path_THUMBS%\%tempNo%.jpg
}
rmv := CPS[channel][t_tempNo] , CPS[channel][t_tempNo] := CPS[channel][tempNo] , CPS[channel][tempno] := rmv
prefs_changed := 1
}
}
if prefs_changed
Prefs2Ini()
}
fixCheck() {
If CPS[CN.NG][TEMPSAVE][FIXATE_txt]
Return TXT.TIP_fixed
}
;Shows tooltips in Clipjump Paste Modes
PasteModeTooltip(cText, notpaste=0) {
global
local tx, ty
if STORE["pstTipRebuild"] {
Tooltip
TooltipEx()
STORE["pstTipRebuild"] := 0
}
; SPM.X and y contain place to show a/c searchbox
tx := ini_pstMode_X ? ini_pstMode_X : SPM.X , ty := ini_pstMode_Y ? ini_pstMode_Y : SPM.Y
if (notpaste == 1){
Tooltip, % cText, % tx, % ty
} else {
tagText := (t := CPS[CN.NG][realActive]["Tags"]) != "" ? "(" t ")" : ""
if (cText == "")
ToolTip % "{" CN.Name "} Clip " realclipno " of " CURSAVE fillWithSpaces("",7) tagText " " fixStatus
. (WinExist("Display_Cj") ? "" : "`n`n" MSG_ERROR "`n`n"), % tx, % ty
else
ToolTip % "{" CN.Name "} Clip " realclipno " of " CURSAVE fillWithSpaces("",7) GetClipboardFormat() fillWithSpaces("",5) (curPformat ? "[" curPformat "]" : "")
. fillWithSpaces("",5) tagText " " fixstatus "`n`n" halfclip, % tx, % ty
}
}
ctrlCheck:
if ((!GetKeyState(pstKeyName)) && (!SPM.ACTIVE)) || PASTEMODE_ACT
{
Critical
SetTimer, ctrlCheck, Off
CALLER := false , sleeptime := 300 , TEMPSAVE := realActive ; keep the current clip pos saved
Gui, imgprv:Destroy
; Change vars a/c MULTIPASTE
if MULTIPASTE && !GetKeyState(pstKeyName) && !temp_spmWasActive ;if spmIsActive user is not expected to cancel by releasing Ctrl
if ctrlRef = pastemode
ctrlRef := "cancel"
; ---
if ctrlRef = cancel
{
PasteModeTooltip(MSG_CANCELLED, 1)
sleeptime := 200
}
else if ctrlRef = deleteAll
{
Critical, Off ;End Critical so that the below function can overlap this thread
IScurCBACTIVE := 0 ; now not active in clipjump
temp21 := TT_Console_PasteMode(TXT.TIP_delallprompt, "Y N")
if temp21 = Y
{
PasteModeTooltip(MSG_ALL_DELETED,1)
clearData()
}
else
PasteModeTooltip(MSG_CANCELLED,1)
Critical, On ;Just in case this may be required.
}
else if ctrlRef = delete
{
IScurCBACTIVE := 0
PasteModeToolTip(MSG_DELETED,1)
clearClip(realActive)
}
else if ctrlRef in cut,copy
{
Tooltip
Critical, Off
temp21 := choosechannelgui()
if Instr(temp21, "-") != 1
{
API.manageClip( temp21 , empty, empty, ( ctrlref == "cut" ) ? 0 : 1 )
PasteModeTooltip(TXT.TIP_done,1)
}
else PasteModeTooltip(TXT.TIP_copycutfailed,1)
Critical, On
}
else if ctrlRef = pastemode
{
PasteModeToolTip(MSG_PASTING,1)
if (GetKeyState("Shift")) ; POP
dopop := 1
if curPformat ;use curpf to get the func
{
Critical, Off
API.blockMonitoring(1) ; this is done to have the boomerang effect ONCLIPBOARD work.
STORE.ClipboardChanged := 0
zCb := trygetVar("Clipboard")
if IsFunc(curPfunction)
Coutput := %curPfunction%(zCb) ; don't try here, the exception in fileread-filemissing-commonformats will nt allow it.
if STORE.ClipboardChanged
try Clipboard := Coutput , IScurCBACTIVE := 0
else ONCLIPBOARD := 1
API.blockMonitoring(0, 5)
Critical, On
Send, ^{vk56}
sleeptime := 1
}
else
{
Send, ^{vk56}
sleeptime := 100
}
}
IN_BACK := is_pstMode_active := oldclip_exist := jumpClip_sign := 0
hkZ_pasteMode(0)
restoreCaller := 1 ; Restore CALLER in the ONC label . This a second line of defence wrt to the last line of this label.
Critical, Off
; The below thread will be interrupted when the Clipboard command is executed. The ONC label will exit as CALLER := 0 in the situtaion
if ((ctrlRef == "pastemode") && dopop) ; pop clip
{
clearClip(TEMPSAVE)
IScurCBACTIVE := 0
}
if !ini_PreserveClipPos
TEMPSAVE := cursave ; not preserve active clip
if ctrlref in cancel, delete, DeleteAll
if !IScurCBACTIVE ;dont disturb current clipboard if it is already active
try Clipboard := oldclip_data ;The command opens, writes and closes clipboard . The ONCC Label is launched when writing takes place.
sleep % sleeptime
Tooltip
restoreCaller := PASTEMODE_ACT := 0 ; restoreCaller - make it 0 in case Clipboard was not touched (Pasting was done)
if !GetKeyState(pstKeyName) && !SPM.ACTIVE
MULTIPASTE := 0 ; deactivated when Ctrl released
ctrlRef := ""
CALLER := CALLER_STATUS
if ini_revFormat2def
set_pformat(ini_def_Pformat)
if prefs_changed
Prefs2Ini() ; save preferences in memory
EmptyMem()
dopop := 0
} else {
; record previous shift presses too
; is more user convenient
if (GetKeyState("Shift"))
dopop := 1
else
dopop := 0
}