-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathC++_QTCreator_Macro_Public.ahk
793 lines (628 loc) · 19.6 KB
/
C++_QTCreator_Macro_Public.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
;Credits to David Wu for making this script©
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
VERSION=1.1.5
timeDate=(7:43 PM Sunday, March 6, 2016)
;==================================================================
MsgBox, ,Version %VERSION% ,Type \help (Backslash above enter key.) anywhere to get started
;==================================================================
;==================================================================
;Variables
doubleClickToggle:=false
;==================================================================
;==================================================================
;Misc
SetKeyDelay, 10
;==================================================================
;==================================================================
;opens help menu
:O:\help::
Gui, Font, underline
Gui, Add, Text, x320 y0 cBlue gUpdateLink, Version %VERSION% (Click here for source code and updates!)
Gui, Font, norm
Gui, Add, Edit, ReadOnly x0 y25 w910 h480, C++_QTCreator_Macro_Public.ahk`nPurpose: More efficient programming!`n`n@author David Wu`n@version %VERSION% %timeDate%`n`n`n`n`nHOTKEYS`n`nMiddle Mouse Button`nPressing the middle mouse button, aka the scrolling wheel, double clicks and selects words faster.`n`nAlt+D`nToggles double click when you press the middle mouse button`n`nAlt+B`nDeletes semicolon and adds brackets to function definitions.`n`nAlt+A`nAuto indents entire file.`n`nAlt+F`nActivate while cursor is just after function prototype to add function definition.`n`nAlt+T`nAdds template`n`n`nCtrl+Shift+1`nCopies selection onto it's own clipboard. (Note: There are 0 - 9 clipboards)`n`nCtrl+1`nPastes clipboard 1. (Note: There are 0 - 9 clipboards)`n`nCtrl+~`nConverts current clipboard into a macro, then types it.`n`n`n`n`nCOMMANDS`n(Notice: uses the backslash above your enter key. Start typing anywhere.)`n`n\help`nOpens up a list of commands and descriptions, duh.`n`n\exit`n\quit`n\close`nCloses the script.`n`n\while`n\w`nPastes in a while loop statement.`n`n\try`nPastes in a try/catch`n`n\ternary`n\tern`n\turn`n\t`nPastes in a ternary.`n`n\endl`n\e`nPastes in a end line statement.`n`n\if`nPastes in a if statement.`n`n\do while`n\dowhile`n\dw`n\do`nPastes in a do while statement`n`n\ifelse`n\ife`nPastes in a if else statement.`n`n\switchcase`n\switch`n\s`nPastes in a switch case statement.`n`n\header`n\head`n\h`nPastes in a standardized header documentation template.`n`n\function`n\func`n\f`nPastes in a standardized function documentation template`n`n\again`nPastes in a small do again program.`n`n\debug`n\d`nPastes in a debug statement with a variable.`n`n\class`n\c`nPastes in a label format to help initialize a new class.`n`n\debug2`n\d2`nPastes in a comment only debug statement`n`n\for`nPastes in a for loop statement.`n`n\for2`nPastes in a slightly different for loop statement.`n`n\paste`nConverts current clipboard into a macro, then types it.`n`n`n`n`nAUTO CORRECT`n(::typo::correction)`n`n::enld::endl`n::ednl::endl`n::null::NULL`n::reutnr::return`n::reutrn::return`n::int he::in the`n::t he::the`n::toekn::token`n::fucntion::function`n::ednk::endl`n::endk::endl`n::stauts::status`n::sutats::status`n::stats::status`n::remtoe::remote`n::freidn::friend`n::git s::git status`n::git l::git log`n::git r::git remote`n::@include::#include`n::reutn::return`n::ruent::return`n::rutne::return`n::retunr::return`n::virtural::virtual`n::treu::true`n::ture::true`n::funciton::function`n::fucntion::function`n::\:: (removes stray backslashes)`n
; Generated using SmartGUI Creator for SciTE
Gui, Show, w916 h508, Help
Send, Edit, {PGUP}
return
UpdateLink:
Run https://github.com/Secret-Asian-Man/CPlusPlus_Macros
GuiClose:
gui, destroy
;~ HOTKEYS`nPressing the middle mouse button, aka the scrolling wheel, double clicks.`n`nAlt+B`nDeletes semicolon and adds brackets to function definitions.`n`nAlt+A`nAuto indents entire file.`n`nAlt+F`nActivate while cursor is just after function prototype to add function definition.`n`nCtrl+Shift+1`nCopies selection onto it's own clipboard. (Note: There are 1 - 5 clipboards)`n`nCtrl+1`nPastes clipboard 1. (Note: There are 1 - 5 clipboards)`n`nCtrl+~`nConverts current clipboard into a macro, then types it.`n`n`n`n`nCOMMANDS`n(Notice: uses the backslash above your enter key. Start typing anywhere)`n`n\help`nOpens up a list of commands and descriptions, duh.`n`n\exit`n\quit`n\close`nCloses the script.`n`n\while`n\w`nPastes in a while loop statement.`n`n\endl`n\e`nPastes in a end line statement.`n`n\if`nPastes in a if statement.`n`n\ifelse`n\ife`nPastes in a if else statement.`n`n\switchcase`n\switch`n\s`nPastes in a switch case statement.`n`n\header`n\head`n\h`nPastes in a standardized header documentation template.`n`n\function`n\func`n\f`nPastes in a standardized function documentation template`n`n\again`nPastes in a small do again program.`n`n\debug`n\d`nPastes in a debug statement.`n`n\for`nPastes in a for loop statement.`n`n\for2`nPastes in a slightly different for loop statement.`n`n`n`n`nAUTO CORRECT`n::typo::correction`n`n::enld::endl`n::ednl::endl`n::null::NULL`n::reutnr::return`n::reutrn::return`n::int he::in the`n::t he::the`n::toekn::token`n::fucntion::function`n::ednk::endl`n::endk::endl`n::stauts::status`n::sutats::status`n::stats::status`n::remtoe::remote`n::freidn::friend`n::git s::git status`n::git l::git log`n::git r::git remote`n::@include::#include`n::reutn::return`n::ruent::return`n::rutne::return`n::retunr::return`n::virtural::virtual`n::treu::true`n::ture::true`n::funciton::function`n::fucntion::function`n::\:: (removes stray backslashes)`n
return
;==================================================================
;==================================================================
;Closes the script
:O:\exit::
:O:\quit::
:O:\close::
ExitApp
;==================================================================
;==================================================================
;When ALT+d is pressed
;toggles double click for middle mouse button
!d::
doubleClickToggle:=!doubleClickToggle
return
;==================================================================
;==================================================================
;When middle mouse button is pressed
;double clicks
MButton::
if (doubleClickToggle)
{
MouseClick,left
MouseClick,left
}
else
{
send, {MButton}
sleep, 150
}
return
;==================================================================
;==================================================================
;When ALT+b is pressed
;deletes semicolon and adds brackets to functions at the bottom of the program.
!b::
Send {Backspace}{Enter}{{}{Enter}
return
;==================================================================
;==================================================================
;When ALT+a is pressed
;does ctrl+a then ctrl+i
!a::
Send ^a^i
return
;==================================================================
;==================================================================
;When ALT+F is pressed
;adds function to .cpp too
!f::
Send !{Enter}{Enter}!{Left}
return
;==================================================================
;==================================================================
;When ALT+T is pressed
;Put in a Template
!t::
ClipSaved := ClipboardAll
Clipboard =
(
template<typename T>
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;================================================================== (Learn how it works below)
;adds a while statement
:O:\while:: ;when user types out \while
:O:\w:: ;or when user types out \w
ClipSaved := ClipboardAll ;saves what is currently on the clipboard to a temporary clipboard
Clipboard = ;sets the clipboard to whatever is between the parenthesis( )
(
while(true)
{
}
)
Send ^v ;Pastes the clipboard
sleep 150
Clipboard := ClipSaved ;returns the clipboard to the original
ClipSaved = ;empties the temporary clipboard
return
;==================================================================
;==================================================================
;adds an end line to console
:O:\do while::
:O:\dowhile::
:O:\dw::
:O:\do::
ClipSaved := ClipboardAll
Clipboard =
(
do
{
} while(true);
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
;adds an end line to console
:O:\try::
ClipSaved := ClipboardAll
Clipboard =
(
try
{
}
catch(insertVariableType error)
{
switch (error)
{
case insertConditionHere:
std::cout<<"ERROR insertErrorMessageHere "<<std::endl;
break;
default:
std::cout<<"Unknown Error... "<<std::endl;
break;
}
}
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
;adds an end line to console
:O:\endl::
:O:\e::
ClipSaved := ClipboardAll
Clipboard =
(
std::cout<<std::endl;
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
;adds an if statement
:O:\if::
ClipSaved := ClipboardAll
Clipboard =
(
if (true)
{
}
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
;adds an if else statement
:O:\ife::
:O:\ifelse::
ClipSaved := ClipboardAll
Clipboard =
(
if (true)
{
}
else
{
}
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
;adds a switch case statement
:O:\switchcase::
:O:\switch::
:O:\case::
:O:\s::
ClipSaved := ClipboardAll
Clipboard =
(
switch (insertVariableHere)
{
case insertConditionHere:
break;
default:
std::cout<<"Invalid key..."<<std::endl;
break;
}
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
;adds a standardized header documentation template
;NOTE: make it smarter. Hilight the function, save it into clipboard and covert to a string variable, tokenize the variable to find the name, parameters, and return type. returnType name(parameterType name, parameterType* name, parameterType &name)
:O:\head::
:O:\h::
FormatTime, dateVar,Mdyyyyhmtt
ClipSaved := ClipboardAll
Clipboard =
(
/**
enterCourseYouAreTakingHere
fileName.extensionName
Purpose: enterPurposeOfProgramHere
@author enterNameHere
@version enterVersionNumberHere (%dateVar%)
*/
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
;adds a standardized function documentation template
:O:\function::
:O:\func::
:O:\f::
ClipSaved := ClipboardAll
Clipboard =
(
/**
enterPurposeOfFunctionHere
@param enterDesriptionOfAllParametersHere
@return enterDesriptionOfReturnHere
*/
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
:O:\class::
:O:\c::
ClipSaved := ClipboardAll
Clipboard =
(
//Constructors
//Destructor
//Accessors
//Mutators
//Operators
//Functions
private:
//Private Member Variables
//Private Functions
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
:O:\again::
ClipSaved := ClipboardAll
Clipboard =
(
char again='y';
while (again=='y' || again=='Y')
{
cout<<"Run program again? y/n: ";
cin>>again;
}
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
:O:\debug::
:O:\d::
ClipSaved := ClipboardAll
Clipboard =
(
std::cout<<"DEBUG : "<<insertVariable<<std::endl;
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
:O:\debug2::
:O:\d2::
ClipSaved := ClipboardAll
Clipboard =
(
std::cout<<"DEBUG @@@@@@@@@@@@@@@@@@@@@@@@@@@@: "<<std::endl;
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
:O:\for::
ClipSaved := ClipboardAll
Clipboard =
(
for (unsigned int i=0;i<something;++i)
{
}
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
:O:\for2::
ClipSaved := ClipboardAll
Clipboard =
(
for (unsigned int j=0;j<something;++j)
{
}
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
:O:\t::
:O:\turn::
:O:\tern::
:O:\ternary::
ClipSaved := ClipboardAll
Clipboard =
(
condition ? value_if_true : value_if_false;
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
:O:\tt::
ClipSaved := ClipboardAll
Clipboard =
(
if DEBUG_MODE:
pubDebug.publish(String(data = "$$$DEBUG class::main => function::stateTransform() => message:: Fired : "))
)
Send {Enter}
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;==================================================================
:O:\tt2::
ClipSaved := ClipboardAll
Clipboard =
(
pubDebug.publish("$$$DEBUG Message : ")
)
Send ^v
sleep 150
Clipboard := ClipSaved
ClipSaved =
return
;==================================================================
;####################################################################### Multiple Clipboards #########################################################################
; Hotkeys
^+1::Copy(1) ;Control+Shift+1
^1::Paste(1) ;Control+1
^+2::Copy(2)
^2::Paste(2)
^+3::Copy(3)
^3::Paste(3)
^+4::Copy(4)
^4::Paste(4)
^+5::Copy(5)
^5::Paste(5)
^+6::Copy(6)
^6::Paste(6)
^+7::Copy(7)
^7::Paste(7)
^+8::Copy(8)
^8::Paste(8)
^+9::Copy(9)
^9::Paste(9)
^+0::Copy(0)
^0::Paste(0)
:O:\paste::
sleep, 150
PasteSend()
return
^`::PasteSend()
Copy(clipboardID)
{
global ; All variables are global by default
local oldClipboard := ClipboardAll ; Save the (real) clipboard
Clipboard = ; Erase the clipboard first, or else ClipWait does nothing
Send ^c
ClipWait, 2, 1 ; Wait 1s until the clipboard contains any kind of data
if ErrorLevel
{
Clipboard := oldClipboard ; Restore old (real) clipboard
return
}
ClipboardData%clipboardID% := ClipboardAll
Clipboard := oldClipboard ; Restore old (real) clipboard
}
Cut(clipboardID)
{
global ; All variables are global by default
local oldClipboard := ClipboardAll ; Save the (real) clipboard
Clipboard = ; Erase the clipboard first, or else ClipWait does nothing
Send ^x
ClipWait, 2, 1 ; Wait 1s until the clipboard contains any kind of data
if ErrorLevel
{
Clipboard := oldClipboard ; Restore old (real) clipboard
return
}
ClipboardData%clipboardID% := ClipboardAll
Clipboard := oldClipboard ; Restore old (real) clipboard
}
Paste(clipboardID)
{
global
local oldClipboard := ClipboardAll ; Save the (real) clipboard
Clipboard := ClipboardData%clipboardID%
Send ^v
sleep, 200
Clipboard := oldClipboard ; Restore old (real) clipboard
oldClipboard =
}
PasteSend() ;pastes with keystrokes instead (for apps that don't allow pasting)
{
global
temp := clipboard
SendEvent {Raw}%temp%
temp =
}
;#########################################################################################################################################################################
;==================================================================
;AutoCorrect (Keep adding common typos in here.)
; ::typo::correction
::enld::endl
::ednl::endl
::null::NULL
::reutnr::return
::reutrn::return
::int he::in the
::t he::the
::toekn::token
::fucntion::function
::ednk::endl
::endk::endl
::stauts::status
::sutats::status
::stats::status
::remtoe::remote
::freidn::friend
::git s::git status
::git l::git log
::git r::git remote
::@include::#include
::reutn::return
::ruent::return
::rutne::return
::retunr::return
::virtural::virtual
::treu::true
::ture::true
::funciton::function
::fucntion::function
::usnigned::unsigned
::unsinged::unsigned
::unsgined::unsigned
::\::
return
;==================================================================
;==================================================================
; HELP MENU
;~ HOTKEYS
;~ Pressing the middle mouse button, aka the scrolling wheel, double clicks.
;~ Alt+B
;~ Deletes semicolon and adds brackets to function definitions.
;~ Alt+A
;~ Auto indents entire file.
;~ Alt+F
;~ Activate while cursor is just after function prototype to add function definition.
;~ Ctrl+Shift+1
;~ Copies selection onto it's own clipboard. (Note: There are 1 - 5 clipboards)
;~ Ctrl+1
;~ Pastes clipboard 1. (Note: There are 1 - 5 clipboards)
;~ Ctrl+~
;~ Converts current clipboard into a macro, then types it.
;~ COMMANDS
;~ (Notice: uses the backslash above your enter key)
;~ \help
;~ Opens up a list of commands and descriptions, duh.
;~ \exit
;~ \quit
;~ \close
;~ Closes the script.
;~ \while
;~ \w
;~ Pastes in a while loop statement.
;~ \endl
;~ \e
;~ Pastes in a end line statement.
;~ \if
;~ Pastes in a if statement.
;~ \ifelse
;~ \ife
;~ Pastes in a if else statement.
;~ \switchcase
;~ \switch
;~ \s
;~ Pastes in a switch case statement.
;~ \header
;~ \head
;~ \h
;~ Pastes in a standardized header documentation template.
;~ \function
;~ \func
;~ \f
;~ Pastes in a standardized function documentation template
;~ \again
;~ Pastes in a small do again program.
;~ \debug
;~ \d
;~ Pastes in a debug statement.
;~ \for
;~ Pastes in a for loop statement.
;~ \for2
;~ Pastes in a slightly different for loop statement.
;~ AUTO CORRECT
;~ ::typo::correction
;~ ::enld::endl
;~ ::ednl::endl
;~ ::null::NULL
;~ ::reutnr::return
;~ ::reutrn::return
;~ ::int he::in the
;~ ::t he::the
;~ ::toekn::token
;~ ::fucntion::function
;~ ::ednk::endl
;~ ::endk::endl
;~ ::stauts::status
;~ ::sutats::status
;~ ::stats::status
;~ ::remtoe::remote
;~ ::freidn::friend
;~ ::git s::git status
;~ ::git l::git log
;~ ::git r::git remote
;~ ::@include::#include
;~ ::reutn::return
;~ ::ruent::return
;~ ::rutne::return
;~ ::retunr::return
;~ ::virtural::virtual
;~ ::treu::true
;~ ::ture::true
;~ ::funciton::function
;~ ::fucntion::function
;~ ::\:: (removes stray backslashes)
;==================================================================