-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTSolidBackground.ahk
2764 lines (2487 loc) · 97 KB
/
TSolidBackground.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
#SingleInstance Force
#NoEnv
SendMode Input
SetBatchLines, 10000
SetWinDelay, 0
SetControlDelay, 0 ;Mostly useless.
FileEncoding, UTF-16 ;Use UCS-2 Little Endian BOM for the ini, but not for the .bat file.
Version := "v2.9.18"
IniVersion := "v1.0"
;#Warn, All, StdOut
/*
TSolidBackground
An AIO Autohotkey script that can make any window pseudo-fullscreen using padding over window borders and background. It can also move/resize windows and make them always on top.
https://github.com/Onurtag/TSolidBackground
To anyone reading the code;
This script has an old history and contains many globals which is not how a nice, clean and optimal script should look like.
If you have any good suggestions, feel free to contact me or open an issue.
TODO:
-Fix GUI tab orderings or FULLY REMAKE the gui (Maybe with a tool or a template) https://www.autohotkey.com/boards/viewtopic.php?f=6&t=3851 https://github.com/G33kDude/Neutron.ahk/
^^^^^neutron examples https://github.com/samfisherirl/Geo3D_Manager https://github.com/samfisherirl/Artum-VR_Screen_Cap-Gui
^^^^^related: group parts of the ui to make them more clear, or use something like tabs tabs
-Rename advanced options to settings
-Add named presets for the move/resize menu. Maybe for custom tsb sizes as well. Can save window title as well and show it as a tooltip maybe.
-hotkeys should be manually added to start labels instead.
-maybe use an ini handler library (example in "ini handler library.zip")
-fix ini long variable names with or without spaces. Long variables might be fine but no spaces?
-default autosave everything possible to ini option, disable "saved" popups except for the first time
-better tooltips for permanent/temporary positions
-ini autosave+autobackup(s)
-seperate ini categories for hooker etc
-loop while loading ini and check for errors maybe
-add scale + button that enlarges/shrinks the window
-add toggle clickthrough button to move/resize menu
-dont use hotkeys as a label, enable them manually. (like the MoveKey s)
-switch to CoordMode "Client" and remove border/caption calculations https://www.autohotkey.com/docs/v1/lib/CoordMode.htm
-update to AHK 2.0 (if ever needed)
-rchk mouse mover
TEMP HACKS:
[CHECK1]
[CHECK2]
*/
OnExit("Exiting")
bgcolor := 250000
TSolidBackgroundKey := "!T"
OnTopKey := "!Y"
CenterKey := "!G"
TaskbarKey := "!F"
OptionsKey := "!U"
SuspendKey := "!F8"
Iniexists := "No"
MoveKey1 := ""
MoveKey2 := ""
MoveKey3 := ""
CustomWidthLeft := 0
CustomWidthRight := 0
CustomHeightTop := 0
CustomHeightBottom := 0
startupWindow := 1
protectVNR := 1
hookPartialTitle := 1
excludeSystemWindows := 1
Hooking := 0
TitleOne := "Main Window Title"
TitleTwo := "Hooked Window Title"
Vmove := 5
Vresize := 5
MoveBy := 2
preventSend := 1
Debug := 0
Checking := 0
CheckForUpdates := 0
useKeyboardHook := 0
Arrs := Object()
;These titles are excluded from move/resize menu
;You don't have to edit these manually.
;Use the edit menu under advanced options to add more titles or remove these.
excludedTitles := Object("TSolidBackground Advanced Features", ""
,"TSolidBackground Splash Text", ""
,"Stacked Pleasant Notification", ""
,"TSolidBackground Move/Resize Window", ""
,"Windows Shell Experience Host", ""
,"Program Manager", "")
;--------------------------------------------------------------------
;----------- Advanced settings for Window Hooker (Alpha) ------------
;--------------------------------------------------------------------
;Window containing this string in its title does not minimize the hooked window (similar to the main window or the alt+tab menu)
hookerExcludeWindow := "Clipboard Inserter"
;Window with a title that matches this regex string gets activated when the hooked window is restored (when you activate the main window). This one is a Regular Expression.
hookerTopOfWindowTwoRegex := "Clipboard Inserter.*(Overlay Mode)"
;The hooker KILLS window two instead of minimizing it.
hookerKillWindowTwoInstead := 0
;--------------------------------------------------------------------
;--------------------------------------------------------------------
;--------------------------------------------------------------------
Menu, Tray, Icon,,, 0
Menu, Tray, NoStandard
Menu, Tray, Add, About TSolidBackground, Abouted
Menu, Tray, Add, Advanced Features, Advanced
Menu, Tray, Add, Edit TSolidBackground.ini, Editini
Menu, Tray, Add, Stop Window Hooker, StopHook
Menu, Tray, Disable, Stop Window Hooker
Menu, Tray, Add, Restart, Restarted
Menu, Tray, Add, Exit, Exited
Menu, Tray, Default, Advanced Features
Menu, Tray, Tip, TSolidBackground
IfExist, %A_ScriptDir%\TSolidBackground.ini
{
Iniexists := "Yes"
Readini(WrittenIniVersion, "Settings", "Ini Version")
if ((WrittenIniVersion == "ERROR") || (WrittenIniVersion != IniVersion)) {
if (WrittenIniVersion == "ERROR") {
new StackingPleasantNotify("TSolidBackground", "Your TSolidBackground.ini is likely corrupt.`nIt was automatically renamed and recreated.", "", 400, "auto", 15000, "0x292929", "0x836DFF", "0xF34242 wBold", "0xDCDCCC wBold")
} else if (WrittenIniVersion != IniVersion) {
new StackingPleasantNotify("TSolidBackground", "Your TSolidBackground.ini needs to be updated.`nIt was automatically renamed and recreated.", "", 400, "auto", 15000, "0x292929", "0x836DFF", "0xF34242 wBold", "0xDCDCCC wBold")
}
FileMove, %A_ScriptDir%\TSolidBackground.ini, TSolidBackground_OLD_%A_DD%-%A_MM%-%A_YYYY%.ini
CreateSaveini(0)
new StackingPleasantNotify("TSolidBackground", "Restarting TSolidBackground in 10 seconds...", "", 400, "auto", 15000, "0x292929", "0x836DFF", "0xb8b8ac wBold", "0xDCDCCC wBold")
Sleep, 15000
Reload
}
Readini(TSolidBackgroundKey, "Hotkeys", "TSolidBackground Key")
Readini(OnTopKey, "Hotkeys", "On Top Key")
Readini(CenterKey, "Hotkeys", "Center Window Key")
Readini(TaskbarKey, "Hotkeys", "Show Hide Taskbar Key")
Readini(OptionsKey, "Hotkeys", "Advanced Features Key")
Readini(SuspendKey, "Hotkeys", "Suspend Hotkeys Key")
Readini(MoveKey1, "Hotkeys", "Move Key 1")
Readini(MoveKey2, "Hotkeys", "Move Key 2")
Readini(MoveKey3, "Hotkeys", "Move Key 3")
Readini(bgcolor, "Settings", "Background Color")
Readini(CustomWidthLeft, "Settings", "Custom Width Left")
Readini(CustomWidthRight, "Settings", "Custom Width Right")
Readini(CustomHeightTop, "Settings", "Custom Height Top")
Readini(CustomHeightBottom, "Settings", "Custom Height Bottom")
Readini(startupWindow, "Settings", "Enable Startup Window")
Readini(excludeSystemWindows, "Settings", "Exclude system windows from dropdown")
Readini(CheckForUpdates, "Settings", "Check for Updates on Startup")
Readini(useKeyboardHook, "Settings", "Use Keyboard Hook")
Readini(TitleOne, "Settings", "Hooker Main Window")
Readini(TitleTwo, "Settings", "Hooker Hooked Window")
Readini(hookPartialTitle, "Settings", "Hook Partial Main Window Title")
Readini(MoveBy, "Settings", "Mouse Mover Move By")
Readini(Debug, "Settings", "Debug")
ReadTitlesFromIni()
if (TSolidBackgroundKey != "!T") {
if (TSolidBackgroundKey != "") {
Hotkey, %TSolidBackgroundKey%, !T
}
Hotkey, !T, Off
}
if (OnTopKey != "!Y") {
if (OnTopKey != "") {
Hotkey, %OnTopKey%, !Y
}
Hotkey, !Y, Off
}
if (CenterKey != "!G") {
if (CenterKey != "") {
Hotkey, %CenterKey%, !G
}
Hotkey, !G, Off
}
if (TaskbarKey != "!F") {
if (TaskbarKey != "") {
Hotkey, %TaskbarKey%, !F
}
Hotkey, !F, Off
}
if (OptionsKey != "!U") {
if (OptionsKey != "") {
Hotkey, %OptionsKey%, !U
}
Hotkey, !U, Off
}
if (SuspendKey != "!F8") {
if (SuspendKey != "") {
Hotkey, %SuspendKey%, ~!F8
}
Hotkey, !F8, Off
}
if (MoveKey1 == "ERROR") {
MoveKey1 := ""
}
if (MoveKey2 == "ERROR") {
MoveKey2 := ""
}
if (MoveKey3 == "ERROR") {
MoveKey3 := ""
}
if (MoveKey1 != "") {
Hotkey, %MoveKey1%, LoadHotkey1
}
if (MoveKey2 != "") {
Hotkey, %MoveKey2%, LoadHotkey2
}
if (MoveKey3 != "") {
Hotkey, %MoveKey3%, LoadHotkey3
}
If (useKeyboardHook == 1) {
if (TSolidBackgroundKey != "")
Hotkey, $%TSolidBackgroundKey%
if (OnTopKey != "!Y")
Hotkey, $%OnTopKey%
if (CenterKey != "")
Hotkey, $%CenterKey%
if (TaskbarKey != "")
Hotkey, $%TaskbarKey%
if (OptionsKey != "")
Hotkey, $%OptionsKey%
if (SuspendKey != "")
Hotkey, $%SuspendKey%
}
;Re-save the ini to write the new ini options? Might break things in the future.
CreateSaveini(0)
}
if (startupWindow == 1) {
Gui, start: Color, 292929
Gui, start: Font, s14 c836DFF Bold, Segoe UI
Gui, start: Add, Text,, TSolidBackground %Version%
Gui, start: Font, s8 c836DFF Bold
Gui, start: Font, s10 cDCDCCC norm
Gui, start: Add, Text, x18 y42, Current Hotkeys and Options: `n------------------------`nTSolidBackground: %TSolidBackgroundKey% `nAlways On Top: %OnTopKey% `nShow Hide Taskbar: %TaskbarKey% `nCenter Window: %CenterKey% `nAdvanced Features: %OptionsKey% `nSuspend other hotkeys: %SuspendKey%`nTSolidBackground.ini file exists: %Iniexists%`n------------------------ `nOn AutoHotkey [!] means [Alt]. `nIf no hotkeys work on selected window, run TSolidBackground as admin.`n`nIf you have any problems, want to change the hotkeys, want to check for updates `nor just can't understand anything above visit the project page:
Gui, start: Font, s10 c3257BF underline
Gui, start: Add, Text, x18 y303 gGotoSite, https://github.com/Onurtag/TSolidBackground
Gui, start: Font, s10 cBlack norm Bold
Gui, start: Add, Button, x243 y338 w64 h36, Ok
Gui, start: Show, w550 h393, TSolidBackground Startup
}
if (CheckForUpdates == 1) {
CheckUpdate(0)
}
Return
!Y::
ToggleAlwaysOnTop()
Return
ToggleAlwaysOnTop(windowtoAOT := "") {
Global
if (windowtoAOT == "") {
WinGet, currentWindow, ID, A
} else {
currentWindow := windowtoAOT
}
WinGetTitle, currentTitle, ahk_id %currentWindow%
if (currentTitle == "Kagami") {
if (protectVNR) {
new StackingPleasantNotify("TSolidBackground", "Window [" . currentTitle . "] is protected.", "Check advanced options to disable it.", 400, "auto", 5000, "0x292929", "0x836DFF", "0xb8b8ac", "0xDCDCCC wBold")
Return
}
}
WinStack(currentWindow)
WinGet, WindowExStyle, ExStyle, ahk_id %currentWindow%
if (WindowExStyle & 0x8) {
WinSet, AlwaysOnTop, off, ahk_id %currentWindow%
new StackingPleasantNotify("TSolidBackground", "Window [" . currentTitle . "]", "Always on top status: OFF", 400, "auto", 5000, "0x292929", "0x836DFF", "0xb8b8ac", "0xDCDCCC wBold")
} else {
WinSet, AlwaysOnTop, on, ahk_id %currentWindow%
new StackingPleasantNotify("TSolidBackground", "Window [" . currentTitle . "]", "Always on top status: ON", 400, "auto", 5000, "0x292929", "0x836DFF", "0xb8b8ac", "0xDCDCCC wBold")
}
}
!T::
RunTSB()
Return
!G::
WinGetPos,,, WWWidth, HHHeight, A
GetMonitorIndexFromWindow(WinExist("A"))
mHeight := monitorBottom-monitorTop
mWidth := monitorRight-monitorLeft
WinMove, A,, (mWidth-WWWidth)/2+monitorLeft, (mHeight-HHHeight)/2+monitorTop
Return
!F::
if (TBtoggle == "") {
VarSetCapacity( APPBARDATA, 36, 0 )
NumPut( 36, APPBARDATA, 0, "UInt" )
NumPut( WinExist( "ahk_class Shell_TrayWnd" ), APPBARDATA, 4, "UInt" )
TBtoggle := 0
}
if (TBtoggle == 0) {
NumPut( ( ABS_ALWAYSONTOP := 0x2 )|( ABS_AUTOHIDE := 0x1 ), APPBARDATA, 32, "UInt" )
DllCall( "Shell32.dll\SHAppBarMessage", "UInt", ( ABM_SETSTATE := 0xA ), "UInt", &APPBARDATA )
Sleep, 100
WinHide, ahk_class Shell_TrayWnd
WinHide, Start ahk_class Button
Sleep, 500
WinHide, ahk_class Shell_TrayWnd ;Do these again as they bug a lot.
WinHide, Start ahk_class Button
TBtoggle := 1
} else {
WinShow, ahk_class Shell_TrayWnd
WinShow, Start ahk_class Button
NumPut( ( ABS_ALWAYSONTOP := 0x2 ), APPBARDATA, 32, "UInt" )
DllCall( "Shell32.dll\SHAppBarMessage", "UInt", ( ABM_SETSTATE := 0xA ), "UInt", &APPBARDATA )
Sleep, 100
WinShow, ahk_class Shell_TrayWnd ;Do these again as they bug a lot.
WinShow, Start ahk_class Button
DllCall( "Shell32.dll\SHAppBarMessage", "UInt", ( ABM_SETSTATE := 0xA ), "UInt", &APPBARDATA )
TBtoggle := 0
}
Return
!U::
if (WinExist("A") != TBResized) {
TBResized := WinExist("A")
WinGetTitle, titleTBResized, ahk_id %TBResized%
if ((protectVNR) && (titleTBResized == "Kagami")) {
TBResized := ""
} else {
;DrawHUD("Got a new window to move/resize.", "y160", "c836DFF", "s11", "1350")
WinGetPos, Xorig, Yorig, Worig, Horig, ahk_id %TBResized%
}
}
if (WinExist("TSolidBackground Move/Resize Window")) {
ShowResizer()
} else {
ShowNewMenu("","")
}
Return
ShowNewMenu(nmX, nmY) {
Global
Gui, newmenu: Destroy
Gui, newmenu: +AlwaysOnTop
Gui, newmenu: Color, 292929
Gui, newmenu: Font, s14 c836DFF Bold, Segoe UI
Gui, newmenu: Add, Text, x236 y15, Advanced Features
Gui, newmenu: Font, s10 c836DFF norm Underline
Gui, newmenu: Add, Text, x219 y435, Create .ini for permanent options
Gui, newmenu: Font, s10 cDCDCCC norm
Gui, newmenu: Add, Button, x254 y460 w130 h28 gRunCreateSaveini, Create/Save .ini
Gui, newmenu: Font, s12 c836DFF Bold
Gui, newmenu: Add, Button, x198 y70 w242 h38 gStartResizeGui, &Move/Resize Window
Gui, newmenu: Add, Button, x198 y125 w242 h38 gStartOptionsGui, &Advanced Options
Gui, newmenu: Add, Button, x198 y180 w242 h38 gStartHookGui, &Window Hooker (Alpha)
Gui, newmenu: Add, Button, x198 y235 w242 h38 gStartMouseMoveGui, Mouse Mo&ver
Gui, newmenu: Font, s10 c836DFF Bold
Gui, newmenu: Add, Button, x198 y320 w242 h26 gStartDummyWindow, Ma&ke a Dummy Window
Gui, newmenu: Add, Button, x198 y355 w242 h26 gRunCheckUpdate, &Check For Updates
Gui, newmenu: Add, Button, x174 y515 w290 h24, Close
if ((nmX == "") || (nmX == -32000)) {
Gui, newmenu: Show, w640 h560, TSolidBackground Advanced Features
} else {
Gui, newmenu: Show, w640 h560 x%nmX% y%nmY%, TSolidBackground Advanced Features
}
SetTimer, Killcht, 30
}
~!F8::
Suspend
if (A_IsSuspended) {
new StackingPleasantNotify("TSolidBackground", "Suspended all other hotkeys.", "To enable hotkeys press " . SuspendKey . ".", 400, "auto", 5000, "0x292929", "0x836DFF", "0xb8b8ac", "0xDCDCCC wBold")
Menu, Tray, Tip, TSolidBackground Suspended
} else {
new StackingPleasantNotify("TSolidBackground", "Enabled all hotkeys.", "", 400, "auto", 5000, "0x292929", "0x836DFF", "0xb8b8ac", "0xDCDCCC wBold")
Menu, Tray, Tip, TSolidBackground
}
Return
Advanced:
ShowNewMenu("","")
Return
;Debug Vars with F10 if debug is enabled
#If Debug
~F10::
ListVars
Return
#If
Abouted:
Gui, about: +AlwaysOnTop
Gui, about: Destroy
Gui, about: Color, 292929
Gui, about: Font, s14 c836DFF, Segoe UI
Gui, about: Add, Text,, TSolidBackground %Version%
Gui, about: Font, s10 cDCDCCC
Gui, about: Add, Text,, For readme, updates and more `ncheck out the project page:
Gui, about: Font, s10 c3257BF underline
Gui, about: Add, Text, x18 y100 gGotoSite, https://github.com/Onurtag/TSolidBackground/
Gui, about: Font, s10 cBlack norm Bold
Gui, about: Add, Button, x118 y136 w64 h36, Ok
Gui, about: Show, w300 h192, About TSolidBackground
Return
RunTSB(windowtoTSB := "") {
Global
if (Activewin == "") {
Activewin := WinExist("A")
}
Toggle := !Toggle
if (Toggle == "1") {
old_Activewin := Activewin
if (windowtoTSB == "") {
Activewin := WinExist("A")
WinGetTitle, Activewintitle, ahk_id %Activewin%
if (Hooking) {
if (hookPartialTitle) {
checkTitleOne := InStr(Activewintitle, TitleOne)
} else {
checkTitleOne := (Activewintitle == TitleOne)
}
if (checkTitleOne > 0) {
Activewin := WinExist(TitleTwo)
}
}
} else {
Activewin := windowtoTSB
}
/*
if (old_Activewin != Activewin) {
DrawHUD("Got a new window for TSolidBackground.", "", "c836DFF", "s11", "1350")
}
*/
TSolidBackground()
} else {
DestroyTSolidBackground()
}
}
TSolidBackground() {
Global
WinGetPos, wX, wY, WWidth, HHeight, ahk_id %Activewin%
GetMonitorIndexFromWindow(Activewin)
mHeight := monitorBottom-monitorTop
mWidth := monitorRight-monitorLeft
WI := 0
WI := Object()
WI := API_GetWindowInfo(Activewin)
Border_SizeW := WI.Client.Left - WI.Window.Left
Border_SizeH := WI.Window.Bottom - WI.Client.Bottom
Caption_Size := WI.Client.Top - WI.Window.Top - Border_SizeH
if (Caption_Size < -7) { ;[CHECK1] Some bug with the top of the window (1pixel border stays visible on top)
Caption_Size++
}
bg1FY := wY
bg2FX := wX
bg3SY := wY+HHeight
bg4SX := wX+WWidth
bg1FY += Border_SizeH+Caption_Size
bg2FX += Border_SizeW
bg3SY -= Border_SizeH
bg4SX -= Border_SizeW
WinGet, WinExStyle, ExStyle, ahk_id %Activewin%
WinGet, WinStyle, Style, ahk_id %Activewin%
if (WinExStyle & 0x8) {
WinGetTitle, currTitle, ahk_id %Activewin%
if (currTitle != "Kagami") { ;VNR fix
WinSet, AlwaysOnTop, off, ahk_id %Activewin%
new StackingPleasantNotify("TSolidBackground", "Window [" . currTitle . "]", "Always on top status: OFF", 400, "auto", 5000, "0x292929", "0x836DFF", "0xb8b8ac", "0xDCDCCC wBold")
}
}
bg1FY -= %CustomHeightTop%
bg2FX -= %CustomWidthLeft%
bg3SY += %CustomHeightBottom%
bg4SX += %CustomWidthRight%
bg2FX -= monitorLeft
bg1FY -= monitorTop
bg3H := monitorBottom-bg3SY
bg4W := monitorRight-bg4SX
Gui, bg1: +AlwaysOnTop -Caption +ToolWindow -DPIScale
Gui, bg1: Color, %bgcolor%
Gui, bg2: +AlwaysOnTop -Caption +ToolWindow -DPIScale
Gui, bg2: Color, %bgcolor%
Gui, bg3: +AlwaysOnTop -Caption +ToolWindow -DPIScale
Gui, bg3: Color, %bgcolor%
Gui, bg4: +AlwaysOnTop -Caption +ToolWindow -DPIScale
Gui, bg4: Color, %bgcolor%
WinSet, Top,, ahk_id %Activewin%
if (wX < 0) {
bg4W := Abs(bg4SX)+monitorRight
Gui, bg2: Show, NoActivate x%monitorLeft% y%monitorTop% h%mHeight% w%bg2FX%, TSolidBackground BG2 (RIGHT)
Gui, bg4: Show, NoActivate x%bg4SX% y%monitorTop% h%mHeight% w%bg4W%, TSolidBackground BG4 (LEFT)
} else {
Gui, bg2: Show, NoActivate x%monitorLeft% y%monitorTop% h%mHeight% w%bg2FX%, TSolidBackground BG2 (LEFT)
Gui, bg4: Show, NoActivate x%bg4SX% y%monitorTop% h%mHeight% w%bg4W%, TSolidBackground BG4 (RIGHT)
}
if (wY < 0) {
bg3H := Abs(bg3SY)+monitorBottom
Gui, bg3: Show, NoActivate x%monitorLeft% y%bg3SY% h%bg3H% w%mWidth%, TSolidBackground BG3 (TOP)
Gui, bg1: Show, NoActivate x%monitorLeft% y%monitorTop% h%bg1FY% w%mWidth%, TSolidBackground BG1 (BOTTOM)
} else {
Gui, bg3: Show, NoActivate x%monitorLeft% y%bg3SY% h%bg3H% w%mWidth%, TSolidBackground BG3 (BOTTOM)
Gui, bg1: Show, NoActivate x%monitorLeft% y%monitorTop% h%bg1FY% w%mWidth%, TSolidBackground BG1 (TOP)
}
Return
}
DestroyTSolidBackground() {
Gui, bg1: Destroy
Gui, bg2: Destroy
Gui, bg3: Destroy
Gui, bg4: Destroy
Return
}
;Draws splash text (currently using StackingPleasantNotify instead)
/*
DrawHUD(hudtext, xyvalue, hudtextcolor := "c836DFF", hudtextsize := "s11", hudtimer := 1350) {
Gui, hud: Destroy
Gui, hud: +AlwaysOnTop -Caption +ToolWindow +Border
Gui, hud: Color, 292929
Gui, hud: Font, %hudtextsize% %hudtextcolor% Bold, Segoe UI
Gui, hud: Add, Text,, %hudtext%
Gui, hud: Show, NoActivate %xyvalue%, TSolidBackground Splash Text
SetTimer, Deletehud, %hudtimer%
Return
}
*/
Deletehud:
SetTimer, Deletehud, off
Gui, hud: Destroy
Return
GotoSite:
Run, %A_GuiControl%
Return
startButtonOk:
startGuiEscape:
Gui, start: Destroy
Return
aboutButtonOk:
aboutGuiEscape:
Gui, about: Destroy
Return
newmenuGuiEscape:
newmenuButtonClose:
Gui, newmenu: Destroy
Return
updateButtonOk:
updateButtonClose:
updateGuiEscape:
Gui, update: Destroy
Return
DummyGuiEscape:
Gui, Dummy: Destroy
Return
BackGui: ;Not planning to make the gui tabbed yet.
WinGetPos, aX, aY, aW, aH, A
Gui, cht: Color, 292929
Gui, cht: Show, w640 h560 x%aX% y%aY%, TSolidBackground Advanced Features
Gui, Destroy
ShowNewMenu(aX,aY)
;SetTimer, Killcht, 30
Return
Killcht:
Gui, cht: Destroy
SetTimer, Killcht, Off
Return
;Advanced Options Start
StartOptionsGui:
ShowOptions()
Return
ShowOptions() {
Global
Gui, options: Destroy
Gui, options: +AlwaysOnTop
Gui, options: Font, s14 c836DFF Bold, Segoe UI
Gui, options: Add, Text, x238 y15, Advanced Options
Gui, options: Color, 292929
Gui, options: Font, s10 cDCDCCC norm
Gui, options: Add, Text, x152 y75, Custom Width Left:
Gui, options: Add, Text, x152 y97, Custom Width Right:
Gui, options: Add, Text, x152 y119, Custom Height Top:
Gui, options: Add, Text, x152 y141, Custom Height Bottom:
Gui, options: Add, Text, x152 y205, TSolidBackground Color:
Gui, options: Add, Text, x436 y80, Permanent `nSave/Load
Gui, options: Font, s10 c836DFF Bold
Gui, options: Add, Button, x174 y515 w290 h24, Close
Gui, options: Add, Button, x10 y10 w44 h24 gBackGui, Back
Gui, options: Add, Edit, x310 y73 w70 h20 vCustomWidthLeft, %CustomWidthLeft%
Gui, options: Add, UpDown, 0x80 Range-90000-90000, %CustomWidthLeft%
Gui, options: Add, Edit, x310 y95 w70 h20 vCustomWidthRight, %CustomWidthRight%
Gui, options: Add, UpDown, 0x80 Range-90000-90000, %CustomWidthRight%
Gui, options: Add, Edit, x310 y117 w70 h20 vCustomHeightTop, %CustomHeightTop%
Gui, options: Add, UpDown, 0x80 Range-90000-90000, %CustomHeightTop%
Gui, options: Add, Edit, x310 y139 w70 h20 vCustomHeightBottom, %CustomHeightBottom%
Gui, options: Add, UpDown, 0x80 Range-90000-90000, %CustomHeightBottom%
Gui, options: Add, Edit, x310 y203 w70 h20 vbgcolor, %bgcolor%
Gui, options: Add, Progress, x310 y225 w70 h20 c%bgcolor% Background%bgcolor% vbarcolored, 100
Gui, options: Font, norm Underline
Gui, options: Add, Text, x219 y435, Create .ini for permanent options
Gui, options: Font, s9 cDCDCCC norm
Gui, options: Add, Button, x384 y75 w15 h15 hwndhResetcwh gResetcwh, R
Gui, options: Add, Button, x540 y302 w50 h20 gShowExcluded, Edit
AddTooltip(hResetcwh, "Reset Custom Width and Height")
Gui, options: Add, Button, x430 y120 w21 h17 gSaveCustom1, S1
Gui, options: Add, Button, x457 y120 w21 h17 gSaveCustom2, S2
Gui, options: Add, Button, x484 y120 w21 h17 gSaveCustom3, S3
Gui, options: Add, Button, x430 y142 w21 h17 gLoadCustom1, L1
Gui, options: Add, Button, x457 y142 w21 h17 gLoadCustom2, L2
Gui, options: Add, Button, x484 y142 w21 h17 gLoadCustom3, L3
Gui, options: Add, Button, x384 y205 w15 h15 hwndhResetcolor gResetcolor, R
AddTooltip(hResetcolor, "Switch between Red and Blue")
Gui, options: Add, Button, x311 y164 w68 h18 hwndhSetCWH gSetnow, Set CWH
AddTooltip(hSetcwh, "Set Custom Width and Height")
Gui, options: Add, Button, x311 y249 w68 h18 gSetcolor, Set Color
Gui, options: Font, s10 cDCDCCC norm
Gui, options: Add, Button, x254 y460 w130 h28 gRunCreateSaveini, Create/Save .ini
Gui, options: Add, Checkbox, x152 y280 Checked%protectVNR% vprotectVNR gSetnow, Protect VNR ("Kagami" titled window)
Gui, options: Add, Checkbox, x152 y302 Checked%excludeSystemWindows% vexcludeSystemWindows gSetnow, Exclude specified windows from the Move/Resize dropdown.
Gui, options: Add, Checkbox, x152 y324 Checked%startupWindow% vstartupWindow gSetnow, Show info window on startup
Gui, options: Add, Checkbox, x152 y346 Checked%CheckForUpdates% vCheckForUpdates gSetSaveini, Check for updates on startup (Save to ini required)
Gui, options: Add, Checkbox, x152 y368 Checked%useKeyboardHook% vuseKeyboardHook gSetKBhook, Use Keyboard Hook to force hotkeys to work (Save to ini required)
WinGetPos, optX, optY, optW, optH, TSolidBackground Advanced Features
if ((optX == "") || (optX == -32000)) {
Gui, options: Show, w640 h560, TSolidBackground Advanced Options
} else {
Gui, options: Show, w640 h560 x%optX% y%optY%, TSolidBackground Advanced Options
}
Gui, newmenu: Destroy
Return
}
OptionsButtonClose:
Gui, options: Destroy
Return
OptionsGuiEscape:
Gosub, BackGui
Return
ShowExcluded:
ShowExcludedTitles()
Return
ShowExcludedTitles() {
Gui, titles: Destroy
Gui, titles: Default
Gui, titles: +AlwaysOnTop
Gui, titles: Color, 292929
Gui, titles: Font, s12 cDCDCCC norm
Gui, titles: Add, ListView, x35 y15 r11 w435 NoSort NoSortHdr -ReadOnly Background292929 cDCDCCC, Window Title (Untitled windows will be blocked too.)
Gui, titles: Font, s10 c836DFF
Gui, titles: Add, Button, x485 y98 w90 h24 gRemoveLV, Remove
Gui, titles: Add, Button, x485 y65 w90 h24 gAddLV, Add
Gui, titles: Font, Bold
Gui, titles: Add, Button, x175 y385 w250 h24, Close
Gui, titles: Font, s12
Gui, titles: Add, Button, x175 y325 w250 h44 gSaveTitles, Save to .ini
Gui, titles: Show, w600 h430, TSolidBackground Edit Excluded Titles
PopulateTitles()
}
PopulateTitles() {
Global
For titleKey, value in excludedTitles {
LV_Add("", titleKey)
}
}
SaveTitles:
SaveTitlesToIni()
ReadTitlesFromIni()
Return
SaveTitlesToIni() {
Global
rowsText := ""
rowCounter := LV_GetCount()
Loop {
If (rowCounter == 0) {
Break
}
LV_GetText(thisRow, rowCounter)
rowsArray := StrSplit(rowsText, "<|TSB|>")
alreadyExists := 0
Loop % rowsArray.MaxIndex()
{
thisOne := rowsArray[A_Index]
If (thisRow == thisOne) {
alreadyExists := 1
}
}
If (!alreadyExists) {
rowsText .= thisRow . "<|TSB|>"
}
rowCounter--
}
IfNotExist, %A_ScriptDir%\TSolidBackground.ini
{
CreateSaveini(1)
}
Writeini(rowsText, "Settings", "Excluded Titles")
}
ReadTitlesFromIni() {
Global
Readini(iniTitles, "Settings", "Excluded Titles")
If (iniTitles != "ERROR") {
excludedTitles := 0
excludedTitles := Object()
iniTitlesArray := StrSplit(iniTitles, "<|TSB|>")
Loop % iniTitlesArray.MaxIndex()
{
thisTitle := iniTitlesArray[A_Index]
If (thisTitle != "") {
excludedTitles[thisTitle] := ""
}
}
}
}
RemoveLV:
RowNumber := 0
Loop
{
RowNumber := LV_GetNext(RowNumber-1)
if not RowNumber
break
LV_Delete(RowNumber)
}
Return
AddLV:
LV_Add("", "Window Title")
Return
TitlesGuiEscape:
TitlesButtonClose:
Gui, titles: Destroy
Return
Setnow:
Gui, Submit, NoHide
Return
SetKBhook:
Gui, Submit, NoHide
CreateSaveini(1)
If (useKeyboardHook == 1) {
if (TSolidBackgroundKey != "")
Hotkey, $%TSolidBackgroundKey%
if (OnTopKey != "!Y")
Hotkey, $%OnTopKey%
if (CenterKey != "")
Hotkey, $%CenterKey%
if (TaskbarKey != "")
Hotkey, $%TaskbarKey%
if (OptionsKey != "")
Hotkey, $%OptionsKey%
if (SuspendKey != "")
Hotkey, $%SuspendKey%
} else {
MsgBox, 4097, TSolidBackground, Restarting TSolidBackground to disable the hooks.
IfMsgBox, OK
{
Reload
}
}
Return
SetSaveini:
Gui, Submit, NoHide
CreateSaveini(1)
Return
Resetcwh:
GuiControl, options:, CustomHeightBottom, 0
GuiControl, options:, CustomHeightTop, 0
GuiControl, options:, CustomWidthRight, 0
GuiControl, options:, CustomWidthLeft, 0
Gui, Submit, NoHide
Return
Setcolor:
Gui, Submit, NoHide
RefresherOptions()
Return
Resetcolor:
if (bgcolor == 051523) {
GuiControl, options:, bgcolor, 250000
} else {
GuiControl, options:, bgcolor, 051523
}
Gui, Submit, NoHide
RefresherOptions()
Return
RefresherOptions() {
Global
GuiControl,+c%bgcolor% +Background%bgcolor%, barcolored
Return
}
SaveCustom1:
SaveCustom(1)
Return
LoadCustom1:
LoadCustom(1)
Return
SaveCustom2:
SaveCustom(2)
Return
LoadCustom2:
LoadCustom(2)
Return
SaveCustom3:
SaveCustom(3)
Return
LoadCustom3:
LoadCustom(3)
Return
SaveCustom(thenr) {
Global
IfNotExist, %A_ScriptDir%\TSolidBackground.ini
{
CreateSaveini(1)
}
Writeini(CustomWidthLeft, "Custom TSB Sizes " . thenr, "Custom Width Left")
Writeini(CustomWidthRight, "Custom TSB Sizes " . thenr, "Custom Width Right")
Writeini(CustomHeightTop, "Custom TSB Sizes " . thenr, "Custom Height Top")
Writeini(CustomHeightBottom, "Custom TSB Sizes " . thenr, "Custom Height Bottom")
Return
}
LoadCustom(thenr) {
Global
Readini(PermWL, "Custom TSB Sizes " . thenr, "Custom Width Left")
Readini(PermWR, "Custom TSB Sizes " . thenr, "Custom Width Right")
Readini(PermHT, "Custom TSB Sizes " . thenr, "Custom Height Top")
Readini(PermHB, "Custom TSB Sizes " . thenr, "Custom Height Bottom")
if (PermWL == "ERROR") {
new StackingPleasantNotify("TSolidBackground", "Requested save or the .ini file does not exist.", "", 400, "auto", 7000, "0x292929", "0x836DFF", "0xF34242 wBold", "0xDCDCCC wBold")
} else {
CustomWidthLeft := PermWL
CustomWidthRight := PermWR
CustomHeightTop := PermHT
CustomHeightBottom := PermHB
}
GuiControl, options:, CustomHeightBottom, %CustomHeightBottom%
GuiControl, options:, CustomHeightTop, %CustomHeightTop%
GuiControl, options:, CustomWidthRight, %CustomWidthRight%
GuiControl, options:, CustomWidthLeft, %CustomWidthLeft%
Gui, Submit, NoHide
Return
}
Editini:
IfExist, %A_ScriptDir%\TSolidBackground.ini
{
Run, %A_ScriptDir%\TSolidBackground.ini,,UseErrorLevel
if ErrorLevel == ERROR
{
Run, notepad %A_ScriptDir%\TSolidBackground.ini,,UseErrorLevel
}
} else {
new StackingPleasantNotify("TSolidBackground", "You must first create an ini in the Advanced Features menu before being able to edit it.", "", 400, "auto", 8000, "0x292929", "0x836DFF", "0xF34242 wBold", "0xDCDCCC wBold")
}
Return
RunCheckUpdate:
if (Checking == 0) {
CheckUpdate(1)
}
Return
CheckUpdate(notify) {
Global
;----- [CHECK2] TEMP HACK. Checking for updates while the hooker is on crashes the application and deletes the exe!? Probably an av false-positive.
if (Hooking) {
Hooking := 0
SetTimer, Hooker, Off
Menu, Tray, Disable, Stop Window Hooker
new StackingPleasantNotify("TSolidBackground", "Window hooker was disabled.", "", 400, "auto", 5000, "0x292929", "0x836DFF", "0xb8b8ac wBold", "0xDCDCCC wBold")
}
;-----
Checking := 1
updater := ComObjCreate("WinHttp.WinHttpRequest.5.1")
updater.Open("GET", "https://github.com/Onurtag/TSolidBackground/releases/latest", true)
updater.Send()
updater.WaitForResponse()
NewVersion := StrSplit(updater.Option(1),"/releases/tag/")[2]
if (NewVersion != Version) {
Gui, update: Destroy
Gui, update: +AlwaysOnTop
Gui, update: Color, 292929
Gui, update: Font, s14 cBB002D
Gui, update: Add, Text,, A TSolidBackground update is available.
Gui, update: Font, s14 c836DFF, Segoe UI
Gui, update: Add, Text,, Latest version: %NewVersion% (Current version: %Version%)
Gui, update: Font, s9 cDCDCCC
Gui, update: Add, Text, x15 y90, Note: If your TSolidBackground.exe is currently in a system protected folder`n(eg. C:\Program Files\TSolidBackground)`nyou need to run TSolidBackground as admin if you want to update.
Gui, update: Add, Text, x15 y150, Check out the changelog to see what has changed:
Gui, update: Font, s10 c3257BF underline
Gui, update: Add, Text, x15 y165 gGotoSite, https://github.com/Onurtag/TSolidBackground#changelog
Gui, update: Font, s12 cBlack norm Bold
Gui, update: Add, Button, x110 y200 w230 h48 gRunAutoUpdateNow, Update and Restart Now
Gui, update: Font, s10 cBlack norm Bold
Gui, update: Add, Button, x193 y270 w64 h30, Close
Gui, update: Show, w450 h320, TSolidBackground Update Available!
} else if (notify) {
Gui, update: Destroy
Gui, update: +AlwaysOnTop
Gui, update: Color, 292929
Gui, update: Font, s14 c2EA319
Gui, update: Add, Text,, `nYour TSolidBackground is up to date.
Gui, update: Font, s14 c836DFF, Segoe UI
Gui, update: Add, Text,, Latest version: %NewVersion% (Current version: %Version%)
Gui, update: Font, s10 cDCDCCC
Gui, update: Add, Text,, Visit the link below if you want to download it again.
Gui, update: Font, s11 c3257BF underline
Gui, update: Add, Text, gGotoSite, https://github.com/Onurtag/TSolidBackground/releases/latest
Gui, update: Font, s10 cBlack norm Bold
Gui, update: Add, Button, x193 y190 w64 h36, Ok
Gui, update: Show, w450 h240, TSolidBackground is Up to Date!
}
Checking := 0
}
RunAutoUpdateNow:
if (A_IsCompiled) {
AutoUpdateNow(NewVersion)
} else {
Run, "https://github.com/Onurtag/TSolidBackground/releases/latest"
}
Return
AutoUpdateNow(NewVersion) {
new StackingPleasantNotify("TSolidBackground", "TSolidBackground will now update and restart.`nJust hold on a second...", "", 400, "auto", 120000, "0x292929", "0x836DFF", "0x27A100", "0xDCDCCC wBold")
UrlDownloadToFile, https://github.com/Onurtag/TSolidBackground/releases/download/%NewVersion%/TSolidBackground.exe, TSolidBackground_NEWVER.exe
FileEncoding, ;Batch files don't work on UTF-16
FileDelete, TSolidBackgroundUpdater.bat
FileAppend, del TSolidBackground.exe`n, TSolidBackgroundUpdater.bat
FileAppend, ren TSolidBackground_NEWVER.exe TSolidBackground.exe`n, TSolidBackgroundUpdater.bat
FileAppend, start TSolidBackground.exe`n, TSolidBackgroundUpdater.bat
FileAppend, del TSolidBackgroundUpdater.bat`n, TSolidBackgroundUpdater.bat
FileEncoding, UTF-16
Run, TSolidBackgroundUpdater.bat,, Hide
ExitApp
}
;Advanced Options End
;Move/Resize Start
StartResizeGui:
ShowResizer()
Return
;Might need a re-design soon.
ShowResizer() {
Global
GetAllWindows()
BlockResizer := 0