-
Notifications
You must be signed in to change notification settings - Fork 15
/
Qonsole.ahk
1501 lines (1338 loc) · 47.2 KB
/
Qonsole.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
; Supported On AutoHotkey Version: 1.1.13.01+
;ahk2exe compiler directive only support by v1.1.33+
;but non-breaking for older versions, so used here
AppName:="Qonsole"
Version:="1.4.7"
;@Ahk2Exe-SetVersion 1.4.7.0
;@Ahk2Exe-SetProductVersion 1.4.7.0
App_date:="2021/07/18"
;@Ahk2Exe-SetCopyright (C) 2021`, [email protected]
Update_URL:="http://qonsole-ahk.sourceforge.net/update.ini"
Project_URL:="http://qonsole-ahk.sourceforge.net"
;@Ahk2Exe-SetMainIcon logo\Qonsole_sm2.ico
;@Ahk2Exe-SetDescription Qonsole - Quake-like Console Emulator
;@Ahk2Exe-SetOrigFilename Qonsole.exe
;@Ahk2Exe-SetProductName Qonsole
;@Ahk2Exe-SetInternalName Qonsole
;///////////////////////// [ XP Patch ] /////////////////////////
if A_OSVersion in WIN_2003,WIN_XP,WIN_2000,WIN_NT4,WIN_95,WIN_98,WIN_ME ; Note: No spaces around commas.
XPMode:=1
else
{
XPMode:=0
;////// Windows 10+ patch ///////
if A_OSVersion in WIN_7,WIN_8,WIN_8.1,WIN_VISTA
WinTenPlus := 0
else
WinTenPlus := 2
}
;///////////////////////// [ XP Patch ] /////////////////////////
#Include LibCon-minXP.ahk
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn, LocalSameAsGlobal, off
#SingleInstance, Force
SetWinDelay, -1
SetBatchLines, -1
DetectHiddenWindows, On
SetWorkingDir %A_ScriptDir%
OnExit,Quit
;///////////////////////// [ XP Patch ] /////////////////////////
if (XPMode) {
;if (A_Is64bitOS && (A_PtrSize==8)) {
; FileInstall,dll\bin\SizeCon_x64.dll,SizeCon_x64.dll
;}
;else
;{
FileInstall,dll\bin\SizeCon.dll,SizeCon.dll
;}
loadSizeCon()
}
;///////////////////////// [ XP Patch ] /////////////////////////
LibConDebug := 1
autoexecute_thread :=1
configfile:=SubStr(A_ScriptName,1,-4) "_settings.ini"
Default_CMD_Width:=Round((A_ScreenWidth*0.75)/8)
WelcomeFirstTime:=!FileExist(configFile)
self_pid:=DllCall("GetCurrentProcessId")
lastactive:="ahk_ID " WinExist("A","","ahk_pid " self_pid)
CheckUpdate_hide:=0
;<<<<<<<< HEADER END >>>>>>>>>
;###################[ Settings ]#####################
IniRead,Speed,%configfile%,Animation,Speed,1 ;speed:=1
IniRead,Delay,%configfile%,Animation,Delay,20 ;Delay:=20
IniRead,dx,%configfile%,Animation,dx,25 ;dx:=25
quitOnInActive:=0
IniRead,HideOnInActive,%configfile%,Settings,HideOnInActive,0 ;HideOnInActive:=0
IniRead,HorizontallyCentered,%configfile%,Settings,HorizontallyCentered,0 ;HorizontallyCentered:=0
IniRead,BottomPlaced,%configfile%,Settings,BottomPlaced,0 ;BottomPlaced:=0
;IniRead,ShowDebugMenu,%configfile%,Settings,ShowDebugMenu,0 ;ShowDebugMenu:=0
IniRead,AnimationDisabled,%configfile%,Animation,AnimationDisabled,0 ;AnimationDisabled:=0
IniRead,CmdPaste,%configfile%,Settings,CmdPaste,1 ;CmdPaste:=1
IniRead,RunOnStartUp,%configfile%,Settings,RunOnStartUp,0 ;RunOnStartUp:=0
IniRead,AutoWinActivate,%configfile%,Settings,AutoWinActivate,1 ;AutoWinActivate:=1
IniRead,ReduceMemory,%configfile%,Settings,ReduceMemory,1 ;ReduceMemory:=1
chkActiveDelay:=100
IniRead,Console_Mode,%configfile%,Settings,Console_Mode,0 ;Console_2_Mode:=0
;IniRead,Console_2_Mode,%configfile%,Settings,Console_2_Mode,0 ;Console_2_Mode:=0
IniRead,TransparencyPercent,%configfile%,Settings,TransparencyPercent,20 ;TransparencyPercent:=20
IniRead,CMD_Path,%configfile%,Settings,CMD_Path,%A_scriptDir%\cmd_Qonsole.lnk ;CMD_Path:="cmd_tcon.lnk" ;%comspec% ;Quotes!!!
IniRead,Console_2_path,%configfile%,Settings,Console_2_path,%A_scriptDir%\Console.exe ;Console_2_path:="bin\Console.exe"
IniRead,Mintty_path,%configfile%,Settings,Mintty_path,%A_scriptDir%\mintty.exe
IniRead,OpenHotkey,%configfile%,Settings,OpenHotkey,#c
Hotkey,%OpenHotkey%,OpenHotkey,On
IniRead,CMD_Width,%configfile%,Settings,CMD_Width, % (Default_CMD_Width*8)
IniRead,CMD_Height,%configfile%,Settings,CMD_Height,266
IniRead,CMD_StartUpArgs,%configfile%,Settings,CMD_StartUpArgs,%A_space%
IniRead,CMD_offset,%configfile%,Settings,CMD_offset,0
IniRead,GuiBGDarken_Increment,%configfile%,Animation,GuiBGDarken_Increment,6
;///////////////////////// [ XP Patch ] /////////////////////////
if (XPMode)
IniRead,GuiBGDarken_Max,%configfile%,Animation,GuiBGDarken_Max,255
else
IniRead,GuiBGDarken_Max,%configfile%,Animation,GuiBGDarken_Max,128
;///////////////////////// [ XP Patch ] /////////////////////////
IniRead,GuiBGDarken_Color,%configfile%,Animation,GuiBGDarken_Color,0x1A1A1A
;####################################################
MsgBox_AlwaysOnTop:=262144
Console_2_Mode:=InStr(Console_Mode,"Console2")
Console_Mode:=SubStr(Console_Mode,1,8)
; //////////////////////////////////////////////////////////////////////
; Adding in support for High-DPI (e.g. 192) and multiple monitors (?)
; //////////////////////////////////////////////////////////////////////
ScreenScaleFactor:= 1 ;(A_ScreenDPI/96) ;--not fully supported yet (?)
CMD_Width *= ScreenScaleFactor
CMD_Height *= ScreenScaleFactor
Speed *= ScreenScaleFactor
; //////////////////////////////////////////////////////////////////////
if (GuiBGDarken_Max) ;if not equal zero, then create it
gosub Create_GuiBGDarken
if (A_IsCompiled)
Menu,tray,Icon,%A_scriptFullPath%,1
if (!A_IsCompiled || ShowDebugMenu)
menu,tray,Standard
else
menu,tray,NoStandard
Menu,tray,Tip,%AppName% v%Version%
menu,tray,add,Show/Hide Console,OpenHotkey
menu,tray,Default,Show/Hide Console
menu,tray,add,Settings,prog_settings
menu,tray,add ;----------------------
menu,tray,add,Check for update,Check4Update
menu,tray,add,Project Webpage,OpenProjectWebpage
menu,tray,add,About,About_prog
menu,tray,add ;----------------------
menu,tray,add,Reload
menu,tray,add,Quit
Menu, Tray, Click, 1 ;single click instead of double click for default tray icon action
;if (Console_2_Mode)
; con=ahk_class Console_2_Main
;else
; con=ahk_class ConsoleWindowClass
Speed:=(Speed<1)?1:Speed
anim:=0 ;Dont touch, Enables the principle (similar) of jQuery stop()
open:=0
cShown:=0
cmd_w_offset:=0
cPID:=0
Check4Update_hidden_fail:=1
GroupAdd,Console_Classes,ahk_class ConsoleWindowClass
GroupAdd,Console_Classes,ahk_class Console_2_Main
GroupAdd,Console_Classes,ahk_class mintty
if (CmdPaste) {
Hotkey, IfWinActive, ahk_group Console_Classes
Hotkey,^v,PasteHotkey
Hotkey, IfWinActive
}
if (WelcomeFirstTime) {
gosub About_prog
MsgBox, % (64+MsgBox_AlwaysOnTop), %AppName% - Version %Version%, Welcome!`nSee the tray icon/menu in the notifications area.
}
gosub,Check4Update_hidden ;check update on startup
SetTimer,Check4Update_hidden,-300000 ;wait 5 mins till autocheck of update, in case of failure
setAutorun(RunOnStartUp)
;Reduce Memory Usage
SetTimer,cleanself,-1
return ;End of Auto-execute
OpenProjectWebpage:
Run, %Project_URL%
return
Check4Update:
tempupdatefile=%A_temp%\%AppName%_update%A_now%%A_MSec%%A_TickCount%.tmp
URLDownloadToFile,%Update_URL%,%tempupdatefile%
IniRead,NewVersion,%tempupdatefile%,Update,Version,NULL (Error)
IniRead,__URL,%tempupdatefile%,Update,URL
FileDelete,%tempupdatefile%
if (InStr(NewVersion,"NULL") || InStr(NewVersion,"Error"))
{
if (CheckUpdate_hide)
Check4Update_hidden_fail:=1
else
MsgBox, 262192, %AppName% - Update, An error occured.`nPlease check your internet connection and try again.
}
else
{
if (NewVersion > Version)
{
if (CheckUpdate_hide)
{
Check4Update_hidden_fail:=0
menu,tray,Rename,Check for update,Update available...
Menu,Tray,Tip,%AppName% v%Version%`nUpdate available...
}
else
{
MsgBox, 262212, %AppName% - Update, A new version is available.`nCurrent Version: `t%Version%`nLatest Version: `t%NewVersion%`nWould you like to update?
IfMsgBox, Yes
run, %__URL%
}
}
else
{
if (CheckUpdate_hide)
Check4Update_hidden_fail:=0
else
MsgBox, 262208, %AppName% - Update, You have the latest version.
}
}
return
Check4Update_hidden:
if (Check4Update_hidden_fail)
{
CheckUpdate_hide:=1
gosub, Check4Update
CheckUpdate_hide:=0
}
return
OpenHotkey:
if (quitOnInActive)
gosub CloseC
; Settimer allows Multi-threading, gosub does not.
; This allows the program to catch the open/close
; even during the animation.
SetTimer,HideC,Off ; Turn off all ("settimer") Threads
SetTimer,showC,Off
;SetTimer,FadeBG,Off
;if (!autoexecute_thread)
;SetTimer,FadeBG,-1 ; And run sub-routine anew
SetTimer,showC,-1 ;gosub showC
autoexecute_thread:=0
if (HideOnInActive)
SetTimer,chkActive,%chkActiveDelay%
return
PasteHotkey:
if (Console_2_Mode) {
KeyWait, Ctrl, Up
MouseClick, M ;default config
}
IfWinActive, ahk_class ConsoleWindowClass
{
SendInput {Raw}%clipboard% ; ConsolePaste
}
return
/*
~Esc::
if (quitOnInActive)
gosub closeC
else
gosub HideC
return
*/
#IfWinActive, ahk_group Console_Classes
~Enter::
if InStr(WinActive(),"@")
return
if WinActive(con)
Console_ScrollBottom(con)
return
#IfWinActive
showC:
if (!WinExist(con)) {
open:=0
cShown:=0
cPID:=0
xC_height:=CMD_Height
}
if (cShown)
goto HideC
if (!cShown) ;&& (open)
WinShow,%con%
WinActivate,%con%
if ((!open) or (!WinExist(con))) and (!cPID) {
;MsgBox new con - not exist: %con% - o: %open%
if (Console_2_Mode) {
con=ahk_class Console_2_Main
if (!FileExist(Console_2_path))
{
MsgBox, 52, Qonsole Error, Console2 was not found.`nBrowse For Console2? (Console.exe)
IfMsgBox, Yes
{
Console_2_pathS:=BrowseForConsole("Console2")
IniWrite,%Console_2_pathS%,%configFile%,Settings,Console_2_path
MsgBox, 48, Qonsole Error,The program will now restart.
gosub reload
}
IfMsgBox, No
{
MsgBox, 48, Qonsole Error, Cmd Mode will be used.`nThe program will now restart.
IniWrite,0,%configFile%,Settings,Console_Mode
gosub reload
}
}
chk_console_setupfile:
SplitPath,Console_2_Path,,Console_2_Dir
console_setupfile:=Console_2_Dir . "\Qonsole.xml"
if (!FileExist(console_setupfile))
{
write_console_setup(console_setupfile)
MsgBox, 64, Qonsole - Notice, Qonsole has created a configuration file:`n"%console_setupfile%"
goto chk_console_setupfile
}
run,"%Console_2_path%" -c "%console_setupfile%" %CMD_StartUpArgs%,,,cPID
;conP=ahk_pid %cPID%
;WinWait,%con% ;buggy?
DetectHiddenWindows,Off
WinWaitActive,ahk_pid %cPID%
WinWaitActive,%con%
DetectHiddenWindows,On
;Sleep 500
;doesnt work ;WinSet, Transparent, % (abs(100-TransparencyPercent)/100)*255 , %con%
Winset, AlwaysOnTop, On, %con%
cmd_height__:=(-xC_height)
WinMove,ahk_pid %cPID%,,,%cmd_height__%,%cmd_width%,%xC_height%
WinMove,%con%,,,%cmd_height__%,%cmd_width%,%xC_height%
WinGetPos,,,cw_w,ch,%con%
WinGet,hc,ID,%con%
con=ahk_id %hc%
;WindowDesign(hc)
WinSet, Transparent, % (abs(100-TransparencyPercent)/100)*255 , %con%
;Winset, AlwaysOnTop, On, %con%
cmd_w_fix:=cw_w
xC_height-=10
} else if (InStr(Console_Mode,"mintty")) {
con=ahk_class mintty
if (!FileExist(mintty_path))
{
MsgBox, 52, Qonsole Error, mintty was not found.`nBrowse For mintty? (mintty.exe)
IfMsgBox, Yes
{
mintty_pathS:=BrowseForConsole("mintty")
IniWrite,%mintty_pathS%,%configFile%,Settings,mintty_path
MsgBox, 48, Qonsole Error,The program will now restart.
gosub reload
}
IfMsgBox, No
{
MsgBox, 48, Qonsole Error, Cmd Mode will be used.`nThe program will now restart.
IniWrite,0,%configFile%,Settings,Console_Mode
gosub reload
}
}
run,"%mintty_path%" %CMD_StartUpArgs%,,,cPID
WinWait,%con%
DetectHiddenWindows,Off
if (XPMode) ;note(vladimir.kirichenkov): I think this wait is useless as we can't guarantee it at all.
{
WinWaitActive,ahk_pid %cPID%
}
WinWaitActive,%con%
DetectHiddenWindows,On
Winset, AlwaysOnTop, On, %con%
cmd_height__:=(-xC_height)
; hide window border
WinSet, Style, -0x40000, %con%
WinSet, Style, -0x80000, %con%
WinSet, Style, -0x200000, %con%
WinSet, Style, -0xC00000, %con%
WinSet, Style, -0x800000, %con%
WinSet, Style, -0x400000, %con%
WinMove,ahk_pid %cPID%,,,%cmd_height__%,%cmd_width%,% xC_height+0
WinMove,%con%,,,%cmd_height__%,%cmd_width%, % xC_height+0
WinGetPos,,,cw_w,ch,%con%
WinGet,hc,ID,%con%
con=ahk_id %hc%
cmd_w_fix:=cw_w
WinMove,%con%,,,,, % (ch-=14)
xC_height-=14
} else { ;Cmd mode (Quake mode?? >> Quahke)
con=ahk_class ConsoleWindowClass
chk_CMD_Path:
if (!FileExist(CMD_Path))
{
if (WelcomeFirstTime)
MsgBox, 64, Qonsole - Version %Version%, The is no Cmd path currently set.`nQonsole will set it up for you.
else
MsgBox, 64, Qonsole Error, The Cmd path is Invalid.`nQonsole will set it up for you.
/*
if (WelcomeFirstTime)
MsgBox, 52, Qonsole - Version %Version%, The is no Cmd path currently set.`nLet Qonsole set it up for you?
else
MsgBox, 52, Qonsole Error, The Cmd path is Invalid.`nLet Qonsole set it up for you?
IfMsgBox, Yes
{
*/
CMD_Path=%A_scriptDir%\cmd_Qonsole.lnk
FileCreateShortcut,%comspec%,%CMD_Path%
IniWrite,%CMD_Path%,%configFile%,Settings,CMD_Path
MsgBox, 64, Qonsole - Notice, Qonsole has created a configuration file:`n"%CMD_Path%"
goto chk_CMD_Path
/*
}
IfMsgBox, No
{
MsgBox, 52, Qonsole Error, The Cmd path is Invalid.`nBrowse For Cmd?
IfMsgBox, Yes
{
CMD_PathS:=BrowseForConsole("Cmd")
IniWrite,%CMD_PathS%,%configFile%,Settings,CMD_Path
MsgBox, 48, Qonsole Error,The program will now restart.
gosub reload
}
IfMsgBox, No
{
MsgBox, 48, Qonsole Error, `%comspec`% Mode will be used.`nThe program will now restart.
;IniWrite,0,%configFile%,Settings,Console_2_Mode
IniWrite,%comspec%,%configFile%,Settings,CMD_Path
gosub reload
}
}
*/
}
run,"%CMD_Path%" %CMD_StartUpArgs%,,,cPID
conP=ahk_pid %cPID%
WinWait,%conP%,,3
conP:=""
if (ErrorLevel) or (cPID="")
WinGet,cPID,PID,%con%
con=ahk_pid %cPID%
WinGetPos,,,,ch,%con%
offset:=Mod(ch,speed)-ch + speed
WinMove,%con%,,0,%offset%
;conP=ahk_pid %cPID%
WinGet,hc,ID,%con%
con=ahk_id %hc%
ITaskbarList(hc,5) ;delete from taskbar
AttachConsole(cPID)
hs:=getStdoutHandle()
cmd_int_fwidth:=getFontWidth()
winW:=CMD_Width+50
if (WinTenPlus) {
GetConsoleSize(cmd_w_int,t_console_height)
setconsoleSize(cmd_w_int,t_console_height)
cmd_w_fix := winW
} else {
cmd_w_int:=(CMD_Width//cmd_int_fwidth)
t_console_height:=getConsoleHeight()
setconsoleSize(cmd_w_int,t_console_height)
cmd_w_fix:=(cmd_w_int*cmd_int_fwidth)
}
SysGet,tbarH__,4
WinMove,%con%,,,,%winW%,(xC_height+tbarH__)
WindowDesign(hc)
;debugMsgBox(cmd_w_int,t_console_height,tbarH__,xC_height,winW,"_______",cmd_a_w,cmd_a_h)
;///////////////////////// [ XP Patch ] /////////////////////////
if (XPMode) {
wingetpos,,,w_width,w_height, ahk_id %hc%
__www:=(w_width-6)-23 ;(RectX)
__wwh:=(w_height-32)-4 ;(RectY)+fh
__wwzh:=(tbarH__)+4 ;(32+4)
}
;///////////////////////// [ XP Patch ] /////////////////////////
FreeConsole()
WinGetPos,,,cw_w,ch,%con%
ch:=ch+2
}
lastactive:="ahk_ID " WinExist("A")
offset:=Mod(ch,speed)-ch + speed
WinSet,AlwaysOnTop,On,ahk_id %hGuiBGDarken%
WinActivate,ahk_id %hGuiBGDarken%
WinSet,AlwaysOnTop,On,%con%
WinActivate,%con%
_tx:=((HorizontallyCentered) ? ((cmd_w_fix<A_ScreenWidth) ? abs((A_ScreenWidth-cmd_w_fix)/2) : 0) : 0) +((Console_2_Mode) ? 0 : -2)
_ty:=((BottomPlaced) ? ((xC_height<A_ScreenHeight) ? abs(A_ScreenHeight-xC_height+( (WinTenPlus!=0) ? 16 : 0 )) : 0) : ((Console_2_Mode) ? 0 : -2))
if (WinTenPlus && InStr(Console_Mode,"Cmd"))
_tx += 2
WinMove,%con%,,_tx, _ty
;///////////////////////// [ XP Patch ] /////////////////////////
if (XPMode) {
cmd_w_fix:=__www
offset:=offset-(__wwzh) ;;?? this line does nothing???
;winfade("ahk_id " hGuiBGDarken,GuiBGDarken_Max,GuiBGDarken_Increment) ;fade in
__wwwwvar:=(Console_2_Mode) ? 0 : -2
__wwwwvar:=(__wwwwvar)-(__wwzh)
if (BottomPlaced)
WinSlideUpExp(Con,Delay,speed,A_ScreenHeight-((xC_height-CMD_offset)*ScreenScaleFactor),dx)
else
WinSlideDownExp(Con,Delay,speed, (__wwwwvar+CMD_offset)*ScreenScaleFactor,dx)
;WinSlideDown(Con,speed,Delay,(0+(Console_2_Mode) ? 0 : -2) ) }
}
else
{
if (InStr(Console_Mode,"Mintty"))
WinSet, Transparent, % (abs(100-TransparencyPercent)/100)*255 , %con%
winfade("ahk_id " hGuiBGDarken,GuiBGDarken_Max,GuiBGDarken_Increment) ;fade in
if (BottomPlaced) {
wmove_y := (A_ScreenHeight-((xC_height-CMD_offset)*ScreenScaleFactor))+( (WinTenPlus!=0) ? 24 : 0 )
WinSlideUpExp(Con,Delay,speed,wmove_y,dx)
} else
WinSlideDownExp(Con,Delay,speed, (0+(Console_2_Mode) ? 0 : (-2+WinTenPlus) )+((CMD_offset)*ScreenScaleFactor),dx)
;WinSlideDown(Con,speed,Delay,(0+(Console_2_Mode) ? 0 : -2) )
}
;///////////////////////// [ XP Patch ] /////////////////////////
open:=1
}
else
{
;while(anim) {
;do nothing, wait till current animation finishes...
;}
lastactive:="ahk_ID " WinExist("A")
WinSet,AlwaysOnTop,On,ahk_id %hGuiBGDarken%
WinActivate,ahk_id %hGuiBGDarken%
WinSet,AlwaysOnTop,On,%con%
WinActivate,%con%
_tx:=((HorizontallyCentered) ? ((cmd_w_fix<A_ScreenWidth) ? abs((A_ScreenWidth-cmd_w_fix)/2) : 0) : 0) +((Console_2_Mode) ? 0 : -2)
_ty:=((BottomPlaced) ? ((xC_height<A_ScreenHeight) ? abs(A_ScreenHeight-xC_height+( (WinTenPlus!=0) ? 16 : 0 )) : 0) : ((Console_2_Mode) ? 0 : -2))
WinMove,%con%,,_tx, ;_ty
;///////////////////////// [ XP Patch ] /////////////////////////
if (XPMode) {
__wwwwvar:=(Console_2_Mode) ? 0 : -2
__wwwwvar:=(__wwwwvar)-(__wwzh)
;winfade("ahk_id " hGuiBGDarken,GuiBGDarken_Max,GuiBGDarken_Increment) ;fade in
if (BottomPlaced)
WinSlideUpExp(Con,Delay,speed,A_ScreenHeight-((xC_height-CMD_offset)*ScreenScaleFactor),dx)
else
WinSlideDownExp(Con,Delay,speed, (__wwwwvar+CMD_offset)*ScreenScaleFactor,dx)
}
else
{
if (InStr(Console_Mode,"Mintty")) {
WinSet, Transparent, % (abs(100-TransparencyPercent)/100)*255 , %con%
WinSet, Style, -0x40000, %con%
}
winfade("ahk_id " hGuiBGDarken,GuiBGDarken_Max,GuiBGDarken_Increment) ;fade in
;gosub FadeBG
;when qonsole is at the bottom, the action to hide it is the same as to show it when we're at the top, which is to slide it upward
if (BottomPlaced)
{
WinSlideUpExp(Con,Delay,speed,(A_ScreenHeight-((xC_height-CMD_offset)*ScreenScaleFactor))+( (WinTenPlus!=0) ? 16 : 0 ),dx)
}
else
WinSlideDownExp(Con,Delay,speed, (0+(Console_2_Mode) ? 0 : (-2+WinTenPlus) )+((CMD_offset)*ScreenScaleFactor),dx)
}
;///////////////////////// [ XP Patch ] /////////////////////////
}
cShown:=1
SetTimer,cleanself,-1
return
HideC:
if (cShown) {
/* completely disabled for now
if (AutoWinActivate) {
;WinActivate,%lastactive%
WinGet, All_WindowList, List, , , %con%
WinGet, All_WindowList_Count, Count, , , %con%
Loop % All_WindowList_Count
{
index := A_index+1
All_WindowList_id := All_WindowList%index%
WinGet, All_WindowList_state, MinMax, ahk_id %All_WindowList_id%
if (All_WindowList_state!=-1) {
WinActivate, ahk_id %All_WindowList_id%
break
}
}
}
*/
;when qonsole is at the bottom, the action to hide it is the same as to show it when we're at the top, which is to slide it upward
if (BottomPlaced)
WinSlideDownExp(Con,Delay,speed,A_ScreenHeight,dx)
else
WinSlideUpExp(Con,Delay,speed,offset*ScreenScaleFactor,dx)
;WinSlideUp(Con,speed,Delay,offset)
WinHide,%con%
;///////////////////////// [ XP Patch ] /////////////////////////
if (XPMode) {
winfade("ahk_id " hGuiBGDarken,0,GuiBGDarken_Increment) ;fade out
}
else
{
winfade("ahk_id " hGuiBGDarken,0,GuiBGDarken_Increment) ;fade out
;gosub FadeBG
}
;///////////////////////// [ XP Patch ] /////////////////////////
cShown:=0
}
SetTimer,cleanself,-1
return
/*
FadeBG:
if (!cShown)
{
winfade("ahk_id " hGuiBGDarken,GuiBGDarken_Max,GuiBGDarken_Increment)
;MsgBox Fade IN
}
else
{
winfade("ahk_id " hGuiBGDarken,0,GuiBGDarken_Increment)
;MsgBox Fade OUT
}
return
*/
;{ [gui and other]
;######################################################
Create_GuiBGDarken:
;///////////////////////// [ XP Patch ] /////////////////////////
if (!XPMode) {
Gui GuiBGDarken: Color, %GuiBGDarken_Color%
Gui GuiBGDarken: +E0x20 -Caption +LastFound +ToolWindow +AlwaysOnTop +hwndhGuiBGDarken
WinSet, Transparent, 0
SysGet, VirtualLeft, 76
SysGet, VirtualTop, 77
SysGet, VirtualWidth, 78
SysGet, VirtualHeight, 79
_ta:=GetMonitorCoords()
_tMAXx := VirtualLeft ; 0
_tMAXy := VirtualTop ; 0
_tMAXw := VirtualWidth ; A_screenwidth
_tMAXh := VirtualHeight ; A_screenHeight
;MsgBox x:%VirtualLeft% y:%VirtualTop% w:%VirtualWidth% h:%VirtualHeight%
Gui GuiBGDarken:Show, x%_tMAXx% y%_tMAXy% w%_tMAXw% h%_tMAXh%,Qonsole_GuiBGDarken
}
;///////////////////////// [ XP Patch ] /////////////////////////
return
GuiBGDarkenguiescape:
GuiBGDarkenguiclose:
return
winfade(w:="",t:=128,i:=1,d:=10) {
w:=(w="")?("ahk_id " WinActive("A")):w
t:=(t>255)?255:(t<0)?0:t
WinGet,s,Transparent,%w%
s:=(s="")?255:s ;prevent trans unset bug
WinSet,Transparent,%s%,%w%
i:=(s<t)?abs(i):-1*abs(i)
while(k:=(i<0)?(s>t):(s<t)&&WinExist(w)) {
WinGet,s,Transparent,%w%
s+=i
WinSet,Transparent,%s%,%w%
sleep %d%
}
}
/* exit hotstring handling - No Longer needed.
#IfWinActive, ahk_group Console_Classes
::exit::
SendInput, exit{Enter}
if WinExist("ahk_pid " cPID)
{
Process, WaitClose, %cPID%, %chkActiveDelay%
gosub, CloseC
}
return
*/
/*
::ver::
KeyWait,Enter,U
if WinExist("ahk_pid " cPID)
{
AttachConsole(cPID)
SendInput,ver{Enter}
print("`nQonsole [version " . Version . "]")
FreeConsole()
}
return
*/
#IfWinActive
;~LButton::
chkActive:
if (HideOnInActive) {
if !WinActive(con)
{
lastactive:="ahk_ID " WinExist("A")
if (quitOnInActive)
gosub CloseC
else
{
gosub HideC
}
SetTimer,chkActive,Off
}
}
return
CloseC:
WinKill,%con%
WinSet,Transparent,0,ahk_id %hGuiBGDarken%
open:=0
SetTimer,cleanself,-1
return
Reload:
gosub, CloseC
Reload
return
Quit:
gosub CloseC
ExitApp
return
show_settings:
show_settings_btn_clicked:=1
if (Console_2_Mode) {
if (!cShown)
gosub, OpenHotkey
a_keyD:=A_KeyDelay
a_CtrlD:=A_ControlDelay
SetKeyDelay, -1
SetControlDelay, -1
ControlClick,Console_2_View1,%con%,,RIGHT,,
ControlSend,,es,%con%
SetKeyDelay, %a_keyD%
SetControlDelay, %a_CtrlD%
WinWaitActive,Console Settings
WinWaitClose,Console Settings
}
else if (InStr(Console_Mode,"mintty")) {
if (!cShown)
gosub, OpenHotkey
a_keyD:=A_KeyDelay
a_CtrlD:=A_ControlDelay
SetKeyDelay, -1
SetControlDelay, -1
ControlClick, ,%con%,,RIGHT,,
ControlSend,,O,%con%
SetKeyDelay, %a_keyD%
SetControlDelay, %a_CtrlD%
WinWaitActive,ahk_class ConfigBox
WinWaitClose,ahk_class ConfigBox
}
else
show_properties(CMD_Path)
return
prog_settings:
if (!prog_settings) {
show_settings_btn_clicked:=0
GuiSave_btn_clicked:=0
CMD_PathS:=CMD_Path
Console_2_pathS:=Console_2_path
;Gui, +AlwaysOnTop
Gui, Add, Button, x12 y20 w100 h20 gshow_settings, Console Settings
if (InStr(OpenHotkey,"#"))
{
WinKey:=1
Gui, Add, CheckBox, x12 y40 w80 h20 checked vWinKey, Windows... +
}
else
{
WinKey:=0
Gui, Add, CheckBox, x12 y40 w80 h20 vWinKey, Windows... +
}
StringReplace,OpenHotkeyX,OpenHotkey,#,,All
;------------------------ Console Settings --------------------------
Gui, Add, Hotkey, x102 y40 w60 h20 vOpenHotkey, %OpenHotkeyX%
Gui, Add, Edit, xp yp+20 wp hp , ;20
;///////////////////////// [ XP Patch ] /////////////////////////
if (XPMode)
Gui, Add, UpDown, vUTransparencyPercent Disabled, %TransparencyPercent%
else
Gui, Add, UpDown, vUTransparencyPercent, %TransparencyPercent%
;///////////////////////// [ XP Patch ] /////////////////////////
Gui, Add, Text, x16 yp+4 w80 h20 , Transparency `%
Gui, Add, Text, x170 y24 w75 h16 , Console2 Path
Gui, Add, Text, xp+20 y+4 w50 h16 , Cmd Path
Gui, Add, Text, xp-6 y+4 h16 , Mintty Path
Gui, Add, Button, xp+60 y20 w80 h20 gButtonConsole2, Browse...
Gui, Add, Button, xp y+0 wp hp gButtonCMD, Browse...
Gui, Add, Button, xp y+0 wp hp gButtonMintty, Browse...
Gui, Add, Text, x172 y83 w70 h16 , Console Mode
Gui, Add, DropDownList, xp+74 y82 w80 h20 +r3 vDDmode, Cmd|Console2|Mintty
UCMD_Width_max:=(A_ScreenWidth+8)
Gui, Add, Text, x12 yp+3 hp , Width (approx. in px)
Gui, Add, Edit, x+4 yp-3 w55 hp ;, 20
Gui, Add, UpDown, vUCMD_Width Range24-%UCMD_Width_max%, %CMD_Width%
UCMD_Height_max:=(A_screenHeight+8)
Gui, Add, Text, x9 y+5 hp , Height (approx. in px)
Gui, Add, Edit, x+4 yp-3 w55 hp ;, 20
Gui, Add, UpDown, vUCMD_Height Range24-%UCMD_Height_max%, %CMD_Height%
if(HorizontallyCentered)
Gui, Add, CheckBox, x+12 yp hp checked vHorizontallyCentered, Centered
else
Gui, Add, CheckBox, x+12 yp hp vHorizontallyCentered, Centered
if(BottomPlaced)
Gui, Add, CheckBox, x+12 yp hp checked vBottomPlaced, Bottom
else
Gui, Add, CheckBox, x+12 yp hp vBottomPlaced, Bottom
Gui, Add, Text, x16 yp+26, Start Up Arguments
Gui, Add, Edit, x+4 yp-2 h20 w214 vCMD_StartUpArgs hwndhEditCMD_StartUpArgs,%CMD_StartUpArgs%
Gui, Add, Text, x16 yp+26, Vertical offset/margin (px)
Gui, Add, Edit, x+4 yp-3 w55 h20
Gui, Add, UpDown, vUCMD_offset Range-100-100, %CMD_offset%
Gui, Add, GroupBox, x4 y4 w330 h175 , Console Settings
;------------ Animation Settings -------------------
Gui, Add, GroupBox, x4 y+2 w330 h44 , Animation Settings
Gui, Add, Text, xp+12 yp+20 w36 h20 , Speed
Gui, Add, Edit, x+0 yp-3 w60 hp ; , 1
Gui, Add, UpDown, vUspeed Range1-100, %speed%
Gui, Add, Text, xp+76 yp+3 w30 hp, Delay
Gui, Add, Edit, x+4 yp-3 w60 hp ;, 20
Gui, Add, UpDown, vUdelay Range0-1000, %delay%
Gui, Add, Text, xp+74 yp+3 w16 hp , dx
Gui, Add, Edit, x+0 yp-3 w60 hp ;, 25
Gui, Add, UpDown, vUdx Range0-100, %dx%
;------------------- Background ----------------------
;///////////////////////// [ XP Patch ] /////////////////////////
if (!XPMode) {
Gui, Add, GroupBox, x4 y+8 w330 h62 , Background Settings
Gui, Add, Text, x16 yp+20 h20 , BG Color
Gui, Add, Edit, x+4 yp-3 w52 hp vUGuiBGDarken_Color gGUISetting_color +Uppercase, % strupper(RegExReplace(dec2hex(GuiBGDarken_Color),"0x"))
GuiBGDarken_Max_pc:=Round((abs(255-GuiBGDarken_Max)/255)*100)
Gui, Add, Text, x+4 yp+3 hp , Transparency `%
Gui, Add, Edit, x+4 yp-3 w44 hp ;, 25
Gui, Add, UpDown, vUGuiBGDarken_Max Range0-100, %GuiBGDarken_Max_pc%
Gui, Add, Text, x+6 yp+3 hp , Speed
Gui, Add, Edit, x+4 yp-3 w44 hp ;, 25
Gui, Add, UpDown, vUGuiBGDarken_Increment Range1-100, %GuiBGDarken_Increment%
Gui, Font, italic underline c666666
Gui, Add, Text, x4 y+3 w330 +Center +BackgroundTrans, Note: Set the Transparency to '100`%' to Disable the Background
Gui, Font
}
;///////////////////////// [ XP Patch ] /////////////////////////
;----------------------- Misc settings ---------------------------------
Gui, Add, GroupBox, x4 y+8 w330 h70 , Other Settings
if(RunOnStartUp)
Gui, Add, CheckBox, x16 yp+16 checked vRunOnStartUp, Run %AppName% when Windows Starts
else
Gui, Add, CheckBox, x16 yp+16 vRunOnStartUp, Run %AppName% when Windows Starts
/*
if(ShowDebugMenu)
Gui, Add, CheckBox, x+4 yp checked vShowDebugMenu, Show Debug Menu
else
Gui, Add, CheckBox, x+4 yp vShowDebugMenu, Show Debug Menu
*/
if(AnimationDisabled)
Gui, Add, CheckBox, x+8 yp checked vAnimationDisabled, Disable Animation
else
Gui, Add, CheckBox, x+8 yp vAnimationDisabled, Disable Animation
if(CmdPaste)
Gui, Add, CheckBox, x16 y+4 checked vCmdPaste, Enable Console Ctrl+V Pasting
else
Gui, Add, CheckBox, x16 y+4 vCmdPaste, Enable Console Ctrl+V Pasting
if(HideOnInActive)
Gui, Add, CheckBox, x+29 yp hp checked vHideOnInActive, Hide when inactive
else
Gui, Add, CheckBox, x+29 yp hp vHideOnInActive, Hide when inactive
if(ReduceMemory)
Gui, Add, CheckBox, x16 y+4 checked vReduceMemory, Reduce Memory Usage
else
Gui, Add, CheckBox, x16 y+4 vReduceMemory, Reduce Memory Usage
;if(AutoWinActivate)
; Gui, Add, CheckBox, x+64 yp Disabled checked vAutoWinActivate, Auto WinActivate
;else
Gui, Add, CheckBox, x+64 yp Disabled vAutoWinActivate, Auto WinActivate
;----------------- Save and Cancel + Show ------------------------------
Gui, Add, Button, x62 y+14 w100 h30 gGuiSave Default, &Save
Gui, Add, Button, xp+100 yp wp hp gGuiClose, &Cancel
; Partially Generated using SmartGUI Creator for SciTE
;Gui +LastFound
Gui, Show, w338, %appname% Settings
Console_Mode:=(Console_Mode)?Console_Mode:"Cmd"
GuiControl, ChooseString, DDMode, %Console_Mode%
SetEditPlaceholder(hEditCMD_StartUpArgs,"...to be appended when run/launched...")
prog_settings:=1
}
else
{
WinActivate, %appname% Settings
}
return
ButtonMintty:
mintty_pathS:=BrowseForConsole("Mintty")
return
ButtonCMD:
CMD_PathS:=BrowseForConsole("Cmd")
return
ButtonConsole2:
Console_2_pathS:=BrowseForConsole("Console2")
return
GuiSave:
Gui,Submit
GuiSave_btn_clicked:=1
if (WinKey)
OpenHotkey=#%OpenHotkey%
IniWrite,%Uspeed%,%configFile%,Animation,Speed
IniWrite,%Udelay%,%configFile%,Animation,Delay
IniWrite,%Udx%,%configFile%,Animation,dx
IniWrite,%HideOnInActive%,%configFile%,Settings,HideOnInActive
IniWrite,%HorizontallyCentered%,%configFile%,Settings,HorizontallyCentered
IniWrite,%BottomPlaced%,%configfile%,Settings,BottomPlaced
;IniWrite,%ShowDebugMenu%,%configFile%,Settings,ShowDebugMenu
IniWrite,%AnimationDisabled%,%configFile%,Animation,AnimationDisabled
IniWrite,%CmdPaste%,%configFile%,Settings,CmdPaste
IniWrite,%AutoWinActivate%,%configFile%,Settings,AutoWinActivate
IniWrite,%ReduceMemory%,%configFile%,Settings,ReduceMemory
IniWrite,%RunOnStartUp%,%configFile%,Settings,RunOnStartUp
setAutorun(RunOnStartUp)
IniWrite,%DDMode%,%configFile%,Settings,Console_Mode
IniWrite,%UTransparencyPercent%,%configFile%,Settings,TransparencyPercent
if (FileExist(CMD_PathS)) {
SplitPath,CMD_PathS,,,__cmdExt,__cmdName
if __cmdExt = lnk
{
IniWrite,%CMD_PathS%,%configFile%,Settings,CMD_Path
} else {
CMD_Path=%A_scriptDir%\%__cmdName%_Qonsole.lnk
FileCreateShortcut,%CMD_PathS%,%CMD_Path%
IniWrite,%CMD_Path%,%configFile%,Settings,CMD_Path