-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyscript.html
More file actions
1875 lines (1846 loc) · 69.1 KB
/
myscript.html
File metadata and controls
1875 lines (1846 loc) · 69.1 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>my script</title>
</head>
<body>
<main>
<h1>My script</h1>
<p>
This page contain my custom script for personal development environment.
</p>
<hr />
<h1>Table of content</h1>
<figure>
<ol class="toc">
<li>
<a href="#5"></a>
<ol class="sub-toc">
<li><a href="#5.1"></a></li>
<li><a href="#5.2"></a></li>
<li><a href="#5.3"></a></li>
<li><a href="#5.4"></a></li>
</ol>
</li>
<li>
<a href="#1"></a>
<ol class="sub-toc">
<li><a href="#IIFE"></a></li>
<li><a href="#1.1"></a></li>
<li><a href="#1.2"></a></li>
<li><a href="#1.3"></a></li>
<li><a href="#yaodao"></a></li>
</ol>
</li>
<li>
<a href="#autohotkey"></a>
<ol class="sub-toc">
<li><a href="#autohotkey.1"></a></li>
</ol>
</li>
<li>
<a href="#2"></a>
<ol class="sub-toc">
<li><a href="#2.1"></a></li>
<li><a href="#2.2"></a></li>
<li><a href="#2.3"></a></li>
<li><a href="#2.4"></a></li>
<li><a href="#2.5"></a></li>
<li><a href="#2.6"></a></li>
<li><a href="#2.7"></a></li>
<li><a href="#2.8"></a></li>
<li><a href="#2.9"></a></li>
<li><a href="#repo"></a></li>
<li><a href="#php_win"></a></li>
<li><a href="#php_nginx"></a></li>
</ol>
</li>
<li>
<a href="#3"></a>
<ol class="sub-toc">
<li><a href="#3.1"></a></li>
<li><a href="#3.2"></a></li>
<li><a href="#3.3"></a></li>
<li><a href="#3.4"></a></li>
<li><a href="#3.5"></a></li>
<li><a href="#3.6"></a></li>
<li><a href="#3.7"></a></li>
</ol>
</li>
<li>
<a href="#4"></a>
<ol class="sub-toc">
<li><a href="#4.1"></a></li>
<li><a href="#4.2"></a></li>
<li><a href="#4.3"></a></li>
<li><a href="#4.4"></a></li>
</ol>
</li>
</ol>
</figure>
<hr />
<section>
<h2 id="5">Useful keybind</h2>
<div class="datetime">
<time datetime="2025-8-30"></time>
</div>
<div class="content">
<p>Here record useful custom keybinds tailored for my development.</p>
<section>
<h3 id="5.1">VSCode</h3>
<div class="datetime">
<time datetime="2025-8-30"></time>
</div>
<div class="content">
<div class="tablewrapper">
<table>
<thead>
<tr>
<th colspan="4">Navigation</th>
</tr>
<tr>
<th>Key</th>
<th>Command</th>
<th>Command id</th>
<th>When</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>Ctrl+E</kbd></td>
<td>Go to File...</td>
<td>workbench.action.quickOpen</td>
<td>/</td>
</tr>
<tr>
<td><kbd>Ctrl+Shift+E</kbd></td>
<td>Show All Commands</td>
<td>workbench.action.showCommands</td>
<td>!inQuickOpen</td>
</tr>
<tr>
<td><kbd>Ctrl+Tab</kbd></td>
<td>View: Open Next Editor in Group</td>
<td>workbench.action.nextEditorInGroup</td>
<td>!inQuickOpen</td>
</tr>
<tr>
<td><kbd>Ctrl+Shift+Tab</kbd></td>
<td>View: Open Previous Editor in Group</td>
<td>workbench.action.previousEditorInGroup</td>
<td>!inQuickOpen</td>
</tr>
<tr>
<td><kbd>Ctrl+B</kbd></td>
<td>View: Toggle Primary Side Bar Visibility</td>
<td>workbench.action.toggleSidebarVisibility</td>
<td>/</td>
</tr>
<tr>
<td><kbd>Shift+Alt+R</kbd></td>
<td>File: Reveal in File Explorer</td>
<td>revealFileInOS</td>
<td>!editorFocus</td>
</tr>
<tr>
<td><kbd>Ctrl+0</kbd></td>
<td>Explorer: Focus on Folders View</td>
<td>workbench.explorer.fileView.focus</td>
<td>/</td>
</tr>
<tr>
<td><kbd>Ctrl+1</kbd></td>
<td>View: Focus First Editor Group</td>
<td>workbench.action.focusFirstEditorGroup</td>
<td>/</td>
</tr>
<tr>
<td><kbd>Ctrl+2</kbd></td>
<td>/</td>
<td>workbench.action.focusSecondEditorGroup</td>
<td>/</td>
</tr>
<tr>
<td><kbd>Ctrl+W</kbd></td>
<td>View: Close Editor</td>
<td>workbench.action.closeActiveEditor</td>
<td></td>
</tr>
<tr>
<td><kbd>Shift+Alt+RightArrow</kbd></td>
<td>Expand Selection</td>
<td>editor.action.smartSelect.expand</td>
<td>editorTextFocus</td>
</tr>
<tr>
<td><kbd>Ctrl+Shift+I</kbd></td>
<td>Developer: Toggle Developer Tools</td>
<td>workbench.action.toggleDevTools</td>
<td>/</td>
</tr>
</tbody>
</table>
</div>
<div class="tablewrapper">
<table>
<thead>
<tr>
<th colspan="4">Editor</th>
</tr>
<tr>
<th>Key</th>
<th>Command</th>
<th>Command id</th>
<th>When</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>F1</kbd> / <kbd>Ctrl+/</kbd></td>
<td>Toggle Line Comment</td>
<td>editor.action.commentLine</td>
<td>editorTextFocus && !editorReadonly</td>
</tr>
<tr>
<td><kbd>F2</kbd></td>
<td>Rename Symbol</td>
<td>editor.action.rename</td>
<td>
editorHasRenameProvider && editorTextFocus &&
!editorReadonly
</td>
</tr>
<tr>
<td><kbd>Ctrl+F2</kbd></td>
<td>Change All Occurrences</td>
<td>editor.action.changeAll</td>
<td>editorTextFocus && !editorReadonly</td>
</tr>
<tr>
<td><kbd>F3</kbd></td>
<td>Find Next</td>
<td>editor.action.nextMatchFindAction</td>
<td>editorFocus</td>
</tr>
<tr>
<td><kbd>Shift+F3</kbd></td>
<td>Find Previous</td>
<td>editor.action.previousMatchFindAction</td>
<td>editorFocus</td>
</tr>
<tr>
<td><kbd>F5</kbd></td>
<td>Python: Run Python File in Terminal</td>
<td>python.execInTerminal</td>
<td>editorTextFocus && editorLangId == 'python'</td>
</tr>
<tr>
<td><kbd>F6</kbd></td>
<td>/</td>
<td>openInIntegratedTerminal</td>
<td>editorTextFocus</td>
</tr>
<tr>
<td><kbd>F7</kbd></td>
<td>Live Server: Open with Live Server</td>
<td>extension.liveServer.goOnline</td>
<td>editorTextFocus && editorLangId == 'html'</td>
</tr>
<tr>
<td><kbd>F8</kbd></td>
<td>Format Document</td>
<td>editor.action.formatDocument</td>
<td>
editorHasDocumentFormattingProvider && editorTextFocus
&& !editorReadonly && !inCompositeEditor
</td>
</tr>
<tr>
<td><kbd>F12</kbd></td>
<td>Go to Definition</td>
<td>editor.action.revealDefinition</td>
<td>editorHasDefinitionProvider && editorTextFocus</td>
</tr>
<tr>
<td><kbd>Ctrl+Shift+V</kbd></td>
<td>Markdown: Open Preview to the Side</td>
<td>markdown.showPreviewToSide</td>
<td>
!notebookEditorFocused && editorLangId == 'markdown'
</td>
</tr>
<tr>
<td><kbd>Alt+UpArrow</kbd></td>
<td>Move Line Up</td>
<td>editor.action.moveLinesUpAction</td>
<td>editorTextFocus && !editorReadonly</td>
</tr>
<tr>
<td><kbd>Alt+DownArrow</kbd></td>
<td>Move Line Down</td>
<td>editor.action.moveLinesDownAction</td>
<td>editorTextFocus && !editorReadonly</td>
</tr>
</tbody>
</table>
</div>
<div class="tablewrapper">
<table>
<thead>
<tr>
<th colspan="4">Emmet</th>
</tr>
<tr>
<th>Key</th>
<th>Command</th>
<th>Command id</th>
<th>When</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>Tab</kbd></td>
<td>Emmet: Expand Abbreviation</td>
<td>editor.emmet.action.expandAbbreviation</td>
<td>
config.emmet.triggerExpansionOnTab && editorTextFocus &&
!editorReadonly && !editorTabMovesFocus
</td>
</tr>
<tr>
<td><kbd>Ctrl+M</kbd></td>
<td>Emmet: Go to Matching Pair</td>
<td>editor.emmet.action.matchTag</td>
<td>
editorTextFocus && !editorReadonly && editorLangId ==
'html'
</td>
</tr>
<tr>
<td><kbd>Ctrl+Shift+A</kbd></td>
<td>Emmet: Remove Tag</td>
<td>editor.emmet.action.removeTag</td>
<td>
editorTextFocus && !editorReadonly && editorLangId ==
'html'
</td>
</tr>
<tr>
<td><kbd>Ctrl+Shift+W</kbd></td>
<td>Emmet: Wrap with Abbreviation</td>
<td>editor.emmet.action.wrapWithAbbreviation</td>
<td>
editorTextFocus && !editorReadonly && editorLangId ==
'html'
</td>
</tr>
</tbody>
</table>
</div>
<div class="tablewrapper">
<table>
<thead>
<tr>
<th colspan="4">Remote SSH</th>
</tr>
<tr>
<th>Key</th>
<th>Command</th>
<th>Command id</th>
<th>When</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>Ctrl+Shift+S</kbd></td>
<td>Save as Root</td>
<td>save-as-root.saveFile</td>
<td>/</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section>
<h3 id="5.2">PowerToys</h3>
<div class="datetime">
<time datetime="2025-8-30"></time>
</div>
<div class="content">
<div class="tablewrapper">
<table>
<thead>
<tr>
<th colspan="2">Windows</th>
</tr>
<tr>
<th>Key</th>
<th>Tools</th>
<th>Function</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>Win+Shift+T</kbd></td>
<td>Always On Top</td>
<td>Pins windows on top.</td>
</tr>
<tr>
<td><kbd>Win+Shift+Del</kbd></td>
<td>FancyZones</td>
<td>Create window layouts.</td>
</tr>
<tr>
<td><kbd>Win+Space</kbd></td>
<td>PowerToys Run</td>
<td>Quick search.</td>
</tr>
<tr>
<td><kbd>Win+Alt+Space</kbd></td>
<td>PowerToys Command Palette</td>
<td>
Quick search with new command feature. Run commands
using <span class="inline">></span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section>
<h3 id="5.3">Microsoft Office</h3>
<div class="datetime">
<time datetime="2025-9-4"></time>
</div>
<div class="content">
<div class="tablewrapper">
<table>
<thead>
<tr>
<th colspan="2">Excel</th>
</tr>
<tr>
<th>Key</th>
<th>Function</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>Ctrl+Alt+V</kbd></td>
<td>Paste Special</td>
</tr>
<tr>
<td><kbd>Alt+F11</kbd></td>
<td>Open VBA editor</td>
</tr>
<tr>
<td><kbd>Ctrl+Shift+Scroll</kbd></td>
<td>Scroll horizontally</td>
</tr>
<tr>
<td><kbd>Ctrl+1</kbd></td>
<td>Open the Format Cells dialog box.</td>
</tr>
<tr>
<td><kbd>Ctrl+Arrow</kbd></td>
<td>Move to the edge of the current data region.</td>
</tr>
<tr>
<td><kbd>Ctrl+Shift+Arrow</kbd></td>
<td>Highlight to the edge of the current data region.</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section>
<h3 id="5.4">Custom</h3>
<div class="datetime">
<time datetime="2025-10-27"></time>
</div>
<div class="content">
<div class="tablewrapper">
<table>
<thead>
<tr>
<th colspan="2">
PDF-XChange
<a
href="https://www.pdf-xchange.com/knowledgebase/340-How-do-I-view-edit-and-create-keyboard-shortcuts-in-PDF-XChange-Editor"
>*</a
>
</th>
</tr>
<tr>
<th>Key</th>
<th>Function</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>Alt+H</kbd></td>
<td>Highlight Selected Text</td>
</tr>
</tbody>
</table>
</div>
<div class="tablewrapper">
<table>
<thead>
<tr>
<th colspan="2">
AutoHotKey v2 <a href="#autohotkey.1">*</a>
</th>
</tr>
<tr>
<th>Key</th>
<th>Function</th>
</tr>
</thead>
<tbody>
<tr>
<td><kbd>Win+T</kbd></td>
<td>Toggle Between Monitors</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
</div>
</section>
<hr />
<section>
<h2 id="1">Tempermonkey script</h2>
<div class="content">
<p>
Tempermonkey scripts were written in javascript. IIFE (Immediately
Invoked Function Epxression) were primarily used to self-execute the
anonymouse function on webpage load.
</p>
<section>
<h3 id="IIFE">IIFE template</h3>
<div class="datetime">
<time datetime="2025-8-27"></time>
</div>
<div class="content">
<p>
A Javascript Immediately Invoked Function Expression template
</p>
<pre><code class="language-javascript">
(function () {
})();
</code></pre>
</div>
</section>
<section>
<h3 id="1.1">9gag auto open comment section</h3>
<div class="datetime">
<time datetime="2023-9-4"></time>
</div>
<div class="content">
<pre><code class="language-javascript">
// ==UserScript==
// @name Automatically open the comments when opening post on 9gag
// @namespace http://tampermonkey.net/
// @version 0.1
// @description This script automatically opens the comments when opening a post on 9gag.
// @author btypoon
// @match https://9gag.com/gag/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=9gag.com
// @grant none
// ==/UserScript==
(function () {
const button = document.querySelector(".post-tab-bar__tab");
if (button) {
button.click();
}
})();
</code></pre>
</div>
</section>
<section>
<h3 id="1.2">Press "s" To Save Yotube Video</h3>
<div class="datetime">
<time datetime="2023-9-4"></time>
</div>
<div class="content">
<pre><code class="language-javascript">
// ==UserScript==
// @name Press "s" ToSaveVideo
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Press "s" ToSaveVideo
// @author btypoon
// @match https://www.youtube.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
// ==/UserScript==
function AutoCloseAdPopup() {
let elem = document.querySelector(
".ytd-enforcement-message-view-model .yt-spec-touch-feedback-shape__fill"
);
console.log(elem);
if (elem) {
elem.click();
}
}
function CheckActiveID() {
if (typeof document.activeElement.id == "underfined") {
return true;
} else if (document.activeElement.id == "search") {
//searchbar
return false;
} else if (document.activeElement.id == "input") {
//livechat
return false;
} else if (document.activeElement.id == "contenteditable-root") {
//comment
return false;
} else {
return true;
}
}
document.addEventListener("keyup", function (event) {
console.log(event.key);
console.log(document.activeElement.tagName);
console.log(CheckActiveID());
if (
event.key === "s" &&
document.activeElement.tagName != "INPUT" &&
CheckActiveID()
) {
console.log("All True");
document.querySelectorAll("button[aria-label='More actions']")[0].click();
setTimeout(() => {
document
.querySelectorAll(
"yt-formatted-string.style-scope.ytd-menu-service-item-renderer"
)
.forEach((e, i) => {
if (e.innerText.includes("Save")) {
e.click();
}
});
}, 100);
}
});
</code></pre>
</div>
</section>
<section>
<h3 id="1.3">Auto click button periodically</h3>
<div class="datetime">
<time datetime="2023-9-4"></time>
</div>
<div class="content">
<pre><code class="language-javascript">
// ==UserScript==
// @name AutoClickButton
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Auto click button periodically
// @author btypoon
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @match https://hotshow.hkticketing.com/events/SCHOO0823/venues/AWS/performances/EAWH2023836/*
// ==/UserScript==
setInterval(function () {
const button = document.querySelector(
"#ticketSelection+#continueBar>.chooseTicketsOfferDiv>.blueButton"
);
if (button) {
button.click();
}
}, 3000);
</code></pre>
</div>
</section>
<section>
<h3 id="yaodao">Yaodao Dictionary</h3>
<div class="datetime">
<time datetime="2025-10-27"></time>
</div>
<div class="content">
<p>
The script let user press <kbd>;</kbd> key to clear the input
field on Yaodao Dictionary website.
</p>
<pre><code class="language-javascript">
// ==UserScript==
// @name Yaodao ClearInputField
// @namespace http://tampermonkey.net/
// @version 0.1
// @description ClearInputField
// @author btypoon
// @match https://dict.youdao.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youdao.com
// @grant none
// ==/UserScript==
(function removeAd() {
document.querySelectorAll("iframe").forEach(function (e) {
e.remove();
});
})();
function clearInputField() {
const input = document.querySelector("#search_input, #query");
if (input) {
input.click();
setTimeout(function () {
input.focus();
input.value = "";
}, "200");
}
}
document.addEventListener("keydown", function (event) {
if (event.key === ";") {
event.preventDefault();
clearInputField();
}
});
document.addEventListener("keydown", function (event) {
if (event.key === "'") {
event.preventDefault();
document
.querySelector(
"a[title='點擊發音'],a[title='点击发音'],a[title='真人发音'],a[title='真人發音'],a[title='发音'],a[title='發音']"
)
.click();
}
});
</code></pre>
</div>
</section>
</div>
</section>
<hr />
<section>
<h2 id="autohotkey">AutoHotKey v2</h2>
<div class="datetime">
<time datetime="2025-10-27"></time>
</div>
<div class="content">
<section>
<h3 id="autohotkey.1">Toggle cursor between monitors</h3>
<div class="datetime">
<time datetime="2025-10-27"></time>
</div>
<div class="content">
<p>
This script let user press <kbd>Win+T</kbd> to toggle mouse
cursor between monitors. Inspiration was taken from this
<a
href="https://www.reddit.com/r/AutoHotkey/comments/1cf8x85/can_i_create_a_script_which_makes_a_click_on_my/"
>Reddit discussion</a
>
and this
<a
href="https://www.autohotkey.com/boards/viewtopic.php?p=501372#p501372"
>AutoHotkey discussion</a
>.
</p>
<pre><b>Toggle Monitors.ahk</b><code class="language-javascript">
getCursorPos(&X, &Y) {
DllCall("GetCursorPos", "uint64*", &v := 0)
X := v << 32 >> 32
Y := v >> 32
; MsgBox("X: " . X . "`nY: " . Y)
}
#T::
{
MonitorCount := MonitorGetCount()
if (MonitorCount > 1)
{
getCursorPos(&cursorX, &cursorY)
MonitorGetWorkArea(2, &Left2, &Top2, &Right2, &Bottom2)
MonitorGetWorkArea(1, &Left1, &Top1, &Right1, &Bottom1)
mon1hcenter := Left1 + (Right1 - Left1) // 2
mon1vcenter := Top1 + (Bottom1 - Top1) // 2
mon2hcenter := Left2 + (Right2 - Left2) // 2
mon2vcenter := Top2 + (Bottom2 - Top2) // 2
if (cursorX >= Left1 && cursorX <= Right1)
{
DllCall("SetCursorPos", "int", mon2hcenter, "int", mon2vcenter)
}
else if (cursorX >= Left2 && cursorX <= Right2)
{
DllCall("SetCursorPos", "int", mon1hcenter, "int", mon1vcenter)
}
} else {
MsgBox("No second monitor.")
}
}
</code></pre>
</div>
</section>
</div>
</section>
<hr />
<section>
<h2 id="2">Personalized Development Environment</h2>
<div class="datetime">
<time datetime="2025-8-7"></time>
</div>
<div class="content">
<p>
This is the setup for my personalized developement enviornment.
Before 2022, I use Atom as my main coding tool. Since its sunset on
June 2022, I migrated to using Pulsar, a community fork of Atom
aimed to continue and build upon Atom's legacy. In 2024, due to the
lack of support and the abandoment of many packages since Atom
sunset, I migrated once again to and settled on VScode.
</p>
<section>
<h3 id="2.1">Migrate old module into new Python version</h3>
<div class="datetime">
<time datetime="2025-2-7"></time>
</div>
<div class="content">
<p>
When installing newer version of python, modules needed to be
reinstalled. First, we need to generate a list of modules in
older version of Python.
</p>
<p>
To list out installed modules, type
<span class="inline">pip list</span> in cmd. You may attach and
pipe the output into
<span class="inline">| findstr /b /*yourtext*/</span> to filter
individual modules within a large list.
<span class="command">pip list | findstr /b /*yourtext*/</span>
</p>
<p>
To find out where are the modules installed, type in cmd:
<span class="command">python -m site</span> which execute the
<span class="inline">Lib/site.py</span> file.
</p>
<p>You may also run the following custom script in python.</p>
<pre><b>print_pypath.py</b><code class="language-python">
import sys
for e in sys.path:
print(e)
</code></pre>
<p>
Installed modules should be within
<span class="inline">Lib/site-packages</span> directory.
</p>
<p>
To generate an <span class="inline">requirements.txt</span> from
old modules. Type in the cmd:
</p>
<span class="command"
>pip freeze > %userprofile%\downloads\requirement.txt</span
>
<p>
To download and install newer version on python, type in cmd:
<span class="command"
>pip install -r %userprofile%\downloads\requirement.txt</span
>
</p>
<p>
You may use <span class="inline">pip-review</span> modules to
update installed modules. Bewared updating module might break
existing code as the syntax changed.
</p>
</div>
</section>
<section>
<h3 id="2.2">Adding customFun.py to python module search path</h3>
<div class="datetime">
<time datetime="2023-9-4"></time>
</div>
<div class="content">
<p>
Adding the destination to the folder of your custom python
script into the window environmental variable
<span class="inline">PYTHONPATH</span> can let you import the
custom python script as a module. You can then access your
custom function written within your custom Python script
anywhere.
</p>
<p>
I named my custom Python script
<span class="inline">customFun.py</span>, added its folder
destination to window environmental variable
<span class="command">
PYTHONPATH = %OneDrive%\work\Programming
</span>
and attached <span class="inline">import customFun</span> to
each of my python file.
</p>
<p>
To check if it is working, run
<span class="command">print(sys.path)</span> in python and see
if the your path is listed there.
</p>
</div>
</section>
<section>
<h3 id="2.3">Adding pulsar and ppm command to cmd</h3>
<div class="datetime">
<time datetime="2025-8-7"></time>
</div>
<div class="content">
<p>
If <span class="inline">pulsar</span> or
<span class="inline">ppm</span> are unrecognized in terminal
after the instalation of Pulsar-edit, most likely its path did
not get added to windows environmental variables
<span class="inline">Path</span> successfully.
</p>
<p>
To fix that, manually add the absolute path of
<span class="inline">Pulsar\resources</span> and
<span class="inline">Pulsar\resources\app\ppm\bin</span> to the
windows environmental variables <span class="inline">Path</span>
</p>
<p>
Use <span class="inline">open file location</span> to locate the
directory of <i>Pulsar-edit</i>
</p>
</div>
</section>
<section>
<h3 id="2.4">
Change the current directory on pulsar python run terminal
</h3>
<div class="datetime">
<time datetime="2025-8-7"></time>
</div>
<div class="content">
<p>
In Pulsar, I use the package
<a
href="https://web.pulsar-edit.dev/packages/python-run-terminalnx"
>python-run-terminalnx</a
>
to execute the current Python script in terminal by simply
pressing
<span class="inline">f5</span>.
</p>
<p>
Problem was that the current directory of the terminal returned
the directory of Pulsar-edit instead of the folder holding the
current script. So, any relative path within the current script
did not get expanded corrrectly.
</p>
<p>
To fix that, manually modify and prepend the following code into
the package file:
<span class="inline"
>%USERPROFILE%\.pulsar\packages\python-run-terminalnx\bin\run_python_code.bat</span
>
</p>
<pre><b>run_python_code.bat</b><code class="language-bash">
set file_python=%1
cd
cd %~dp1
cd
</code></pre>
</div>
</section>
<section>
<h3 id="2.5">
Environmental configuration for gcc c++ compiler in Pulsar
</h3>
<div class="datetime">
<time datetime="2025-8-7"></time>
</div>
<div class="content">
<p>
In Pulsar, I used the package
<a href="https://web.pulsar-edit.dev/packages/gcc-make-run"
>gcc-make-run</a
>
to compile and execute C++ scripts by simply pressing
<span class="inline">f6</span>.
</p>
<p>
Problem was that when linking external libraries, we need to
manually go into the package setting page, and type the path to
the libraries in
<span class="inline">Link Libraries</span> section. If we want
run another script linking to other libraries, we need to
manually go into the package setting page and modify the path to
the desired libraries again.
</p>
<p>
To dynamically link different libraries when executing different
C++ script, I employed a fixed folder structure when developing
a C++ project.
</p>
<ol>
<li>
Manually add the following path
<span class="command">libraries\*.cpp</span> to the
<span class="inline">Link libraries</span> section in the
package setting page.
</li>