-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMacroGamer.au3
2371 lines (2365 loc) · 108 KB
/
MacroGamer.au3
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
;=============================================
; Author: Toady (Josh Bolton)
; Email: itoady@gmail.com
; Website: http://www.itoady.com
; Language: Autoit3
; Version: 2.7.5
; Date Created: Jan. 25, 2007
; Last Updated: Jun. 22, 2007
; Requirements:
; OS: Win2000 / WinXP / Vista
; CPU: 800Mhz Processor
; Standard Keyboard US/UK (QWERTY)
; Purpose and Use:
; This application is a keystroke simulator.
; It is geared torward the gaming industry.
; Some games block this application from sending
; key strokes to them.
; Terms of Use:
; Source code is open to use.
; Please give credit where its due.
; Code is provided "As is", any alteration
; will void ANY warranty.
;==============================================
#include <GuiConstants.au3>
#include <GuiList.au3>
#include <GuiListView.au3>
#include <Array.au3>
#Include <GuiStatusBar.au3>
#Include <GuiCombo.au3>
#include <File.au3>
#Include <Constants.au3>
#include <INet.au3>
#Include <A3LString.au3> ;Library provided by Paul Campbell (PaulIA)
#include <A3LListbox.au3> ;Library provided by Paul Campbell (PaulIA)
$g_szVersion = "MacroGamer"
If _Singleton($g_szVersion, 1) = 0 Then
MsgBox(64, "MacroGamer", "MacroGamer Already running.", 2)
Exit
EndIf
;====================================================
; MacroGamer only works on OS's of win 2000 or newer.
;====================================================
If StringRegExp(@OSVersion,"(98)|(95)|(ME)") = 1 Then
MsgBox(0,"Unable to run","MacroGamer is only compatible with Windows 2000, XP, and Vista")
Exit
EndIf
Opt("TrayMenuMode",1)
TraySetState()
FileInstall ( "scancodes.dat", @ScriptDir & "\", 1) ;Installs if these dont exist
FileInstall("profile.mgp",@ScriptDir & "\", 0) ; ^^
FileInstall ( "mgconfig.dat", @ScriptDir & "\", 0) ; ^^
;===================================
; Application Config
;===================================
Global $timerit = 0
$exe_name = "MacroGamer2007.au3"
Global $version = "2.7.5"
Global $updateLocation = "http://home.insightbb.com/~theojdude/itoady/check_update.txt"
Global $tempUpdateSaveName = "check_update.txt"
Global $App_Name = "MacroGamer"
Global $MainWidth, $MainHeight
Global $CeWidth, $CeHeight
Global $editflag = 0
Global $time_init = 0
Global $time_between = 0
Global $OptionsW, $OptionsH
Global $ini_file = "profile.mgp"
Global $config = @ScriptDir & "\mgconfig.dat"
Global $scancodes = @ScriptDir & "\scancodes.dat"
Global $AboutStr = "Author: Toady" & @CRLF & @CRLF & "Version " & $version & @CRLF & @CRLF & "http://www.itoady.com"
Global $keydowndelay = 10
Global $DisplayNotify = 1
Global $DisplayNotifyRecord = 1
Global $runstop_hotkey = "{F3}"
Global $currentOpenMacroIndex = 0
Global $MacroList
Global $Paused = 1
Global $time_init = TimerInit()
Global $downlist = _ArrayCreate(-1)
Global $PlayingMacro = 0
Global $b_runstop_used = 0
Global $first_time_ran = 1
Global $macroOBJ = _ArrayCreate(-1)
Global $MacroIndex = _ArrayCreate(-1) ;Macro Index
$MainWidth = 235
$MainHeight = 250
$CeWidth = 450
$CeHeight = 330
$OptionsW = 340
$OptionsH = 220
$KeybindsW = 250
$KeybindsH = 220
;===================================
; GUI: Main
;===================================
$MainWin = GUICreate($App_Name, $MainWidth, $MainHeight, (@DesktopWidth-$MainWidth)/2, (@DesktopHeight-$MainHeight)/2)
$filemenu = GuiCtrlCreateMenu ("File")
$newitem = GuiCtrlCreateMenuitem ("New Profile",$filemenu)
$fileitem = GuiCtrlCreateMenuitem ("Load Profile...",$filemenu)
$separator1 = GuiCtrlCreateMenuitem ("",$filemenu)
$exititem = GuiCtrlCreateMenuitem ("Exit",$filemenu)
$viewmenu = GuiCtrlCreateMenu ("View")
$optionsitem = GuiCtrlCreateMenuitem ("Settings...",$viewmenu)
$optionsbindedkeys = GuiCtrlCreateMenuitem ("Binded keys",$viewmenu)
$helpmenu = GuiCtrlCreateMenu ("Help")
$helpitem = GuiCtrlCreateMenuitem ("Help",$helpmenu)
$aboutitem = GuiCtrlCreateMenuitem ("About",$helpmenu)
GuiCtrlCreateMenuitem ("",$helpmenu)
$updateitem = GuiCtrlCreateMenuitem ("Check for update",$helpmenu)
$macrolist=GUICtrlCreateList ("", 10,10,120,200)
$b_run = GUICtrlCreateButton ("Run", 140, 150,38,38)
$b_stop = GUICtrlCreateButton ("Stop", 185,150,38,38)
GUICtrlSetState($b_stop,$GUI_DISABLE)
$b_New = GUICtrlCreateButton("Create New",140,20,80,30)
$b_Edit = GUICtrlCreateButton("Edit",140,58,80,30)
$b_Delete = GUICtrlCreateButton("Delete",140,96,80,30)
GUICtrlSetState($b_Edit,$GUI_DISABLE)
GUICtrlSetState($b_Delete,$GUI_DISABLE)
GUICtrlSetState($b_run,$GUI_DISABLE)
Global $a_PartsRightEdge[2] = [160,-1]
Global $a_PartsText[2] = ["Stopped"," Version " & $version ]
$statusbar = _GUICtrlStatusBarCreate($MainWin,$a_PartsRightEdge,$a_PartsText)
GUISetState(@SW_SHOW,$MainWin)
;===================================
; GUI: Create / Edit
;===================================
$CeWin = GUICreate("Macro Editor", $CeWidth, $CeHeight, (@DesktopWidth-$CeWidth)/2, (@DesktopHeight-$CeHeight)/2,$WS_CAPTION,Default,$MainWin)
$l_name = GUICtrlCreateLabel("Name: ",10,15,40,20)
$l_timed = GUICtrlCreateLabel("Events",10,35,40,20)
$in_name = GUICtrlCreateInput("",50,10,120,20)
$Seqlist=GUICtrlCreateList ("", 10,50,180,250,BitOR($WS_BORDER, $WS_VSCROLL, $WS_TABSTOP, $LBS_NOTIFY,$LBS_DISABLENOSCROLL))
$b_startRec = GUICtrlCreateButton("Start Recording",210,10,100,30)
$b_stopRec = GUICtrlCreateButton("Stop Recording",210,45,100,30)
GUICtrlSetState($b_stopRec,$GUI_DISABLE)
$b_Insert = GUICtrlCreateButton("Insert >>",210,85,100,30)
$b_DeleteItem = GUICtrlCreateButton("Delete",210,120,100,30)
$b_MoveUp = GUICtrlCreateButton("Move Up",210,155,100,30)
$b_MoveDown= GUICtrlCreateButton("Move Down",210,190,100,30)
$b_OK = GUICtrlCreateButton("OK",210,270,100,30)
$b_Cancel = GUICtrlCreateButton("Cancel",330,270,100,30)
$in_hidden = GUICtrlCreateInput("",0,0) ;Send all keypresses to this hidden control
GUICtrlSetState($in_hidden,$GUI_HIDE) ;keeps Windows from making funny noises
GUICtrlSetState($b_DeleteItem,$GUI_DISABLE)
$InsertDummy = GUICtrlCreateDummy()
$InsertContext= GUICtrlCreateContextMenu($InsertDummy)
$m_InsertDelay = GUICtrlCreateMenuItem("Delay", $InsertContext)
GUICtrlCreateMenuItem("", $InsertContext)
$m_InsertKeyUpDown = GUICtrlCreateMenuItem("Key Event", $InsertContext)
$m_InsertMouseEvent = GUICtrlCreateMenuItem("Mouse Event", $InsertContext)
GUICtrlCreateMenuItem("", $InsertContext)
$m_InsertPixelCheck = GUICtrlCreateMenuItem("Pixel Event", $InsertContext)
$l_delay = GUICtrlCreateLabel("Delay: ",215,242,30,20)
$in_delay = GUICtrlCreateInput("0.05",250,240,45,20,BitOR($ES_CENTER,$ES_NUMBER,$ES_READONLY))
$b_up = GUICtrlCreateButton("/\",295,240,15,10)
$b_down = GUICtrlCreateButton("\/",295,250,15,10)
$c_delayrecord = GUICtrlCreateCheckbox("Record delays",330,15)
$c_mousepathrecord = GUICtrlCreateCheckbox("Mouse moves",330,35)
$c_mouseclickrecord = GUICtrlCreateCheckbox("Mouse clicks",330,55)
$c_mouseclickposrecord = GUICtrlCreateCheckbox("Click position",345,75)
GUICtrlSetState($c_mouseclickposrecord,$GUI_DISABLE)
$l_bindkey = GUICtrlCreateLabel("Binded to:",330,110,100,20)
$in_bindkey = GUICtrlCreateInput("No Key",330,130,100,20,BitOR($ES_CENTER,$ES_READONLY))
$b_bindkey = GUICtrlCreateButton("Bind to key",330,155,100,30)
GUICtrlSetTip($b_bindkey,"Press ESC to debind","",0,1)
$r_mtype1 = GuiCtrlCreateRadio("Play only once", 330, 195, 120)
GuiCtrlSetState($r_mtype1, $GUI_CHECKED)
$r_mtype2 = GuiCtrlCreateRadio("Repeat", 330, 217, 55)
$repeat_input = GUICtrlCreateInput("1",390,217,50,20,BitOR($ES_CENTER,$ES_NUMBER))
$r_mtype3 = GuiCtrlCreateRadio("Repeat until stopped", 330, 238, 120)
Global $a_editorEdges[1] = [-1]
Global $a_PartsText[1] = ["Stopped"]
$statusbar2 = _GUICtrlStatusBarCreate($CeWin,$a_editorEdges,$a_PartsText)
GUICtrlSetState($repeat_input,$GUI_DISABLE)
GUICtrlCreateUpdown($repeat_input)
GUICtrlSetLimit($repeat_input,2,1)
GuiCtrlSetState($c_delayrecord, $GUI_CHECKED)
GUICtrlSetState($b_DeleteItem,$GUI_DISABLE)
GUICtrlSetState($b_MoveUp,$GUI_DISABLE)
GUICtrlSetState($b_MoveDown,$GUI_DISABLE)
;===================================
; GUI: Options
;===================================
$OptionWin = GUICreate("Settings", $OptionsW, $OptionsH, (@DesktopWidth-$OptionsW)/2, (@DesktopHeight-$OptionsH)/2, $WS_CAPTION,Default,$MainWin)
$Option_b_defaultpro = GUICtrlCreateButton("Default Profile",10,25,80,30)
$Option_in_default = GUICtrlCreateInput(@ScriptDir & "\profile.mgp",100,30,220,20,BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY,$ES_OEMCONVERT))
$Option_b_ONOFF = GUICtrlCreateButton("Run/Stop Hotkey",10,70,100,30)
$Option_in_ONOFF = GUICtrlCreateInput("{F3}",120,75,100,20,BitOR($ES_CENTER,$ES_READONLY))
$Option_ck_Notify = GUICtrlCreateCheckbox("Notify with sound",230,75)
$Option_b_Record = GUICtrlCreateButton("Start/Stop Record",10,110,100,30)
$Option_in_Record = GUICtrlCreateInput("{F2}",120,115,100,20,BitOR($ES_CENTER,$ES_READONLY))
$Option_ck_Record_Notify = GUICtrlCreateCheckbox("Notify with sound",230,115)
$Option_b_OK = GUICtrlCreateButton("OK",60,170,100,30)
$Option_b_cancel = GUICtrlCreateButton("Cancel",170,170,100,30)
;===================================
; GUI: Insert Keypress (up/down)
;===================================
$KeyUpDownWin = GUICreate("Insert Key Event", 230, 170, (@DesktopWidth-230)/2, (@DesktopHeight-170)/2, $WS_CAPTION,Default,$CeWin)
GuiCtrlCreateGroup("Type of press", 10, 60, 100, 90)
$r_keypress = GuiCtrlCreateRadio("Normal", 20, 80, 80)
GuiCtrlSetState($r_keypress, $GUI_CHECKED)
$r_keydown = GuiCtrlCreateRadio("Hold down", 20, 100, 80)
$r_keyup = GuiCtrlCreateRadio("Release", 20, 120, 80)
GUICtrlCreateGroup ("",-99,-99,1,1)
$b_InsertOK = GUICtrlCreateButton("OK",120,80,100,30)
$b_InsertCancel = GUICtrlCreateButton("Close",120,120,100,30)
$b_InsertRecord = GUICtrlCreateButton("Record",10,20,100,30)
$in_insert = GUICtrlCreateInput("",120,20,100,20,BitOR($ES_CENTER,$ES_READONLY))
GUICtrlSetState($b_InsertOK,$GUI_DISABLE)
;===================================
; GUI: Insert Mouse button press (up/down)
;===================================
$MouseWin = GUICreate("Insert Mouse Event", 230, 170, (@DesktopWidth-230)/2, (@DesktopHeight-170)/2, $WS_CAPTION,Default,$CeWin)
GuiCtrlCreateGroup("Select Mouse Button", 45, 10, 140, 100)
$r_l_mouse = GuiCtrlCreateRadio("Left", 85, 30, 80)
GuiCtrlSetState($r_l_mouse, $GUI_CHECKED)
$r_m_mouse = GuiCtrlCreateRadio("Middle", 85, 55, 80)
$r_r_mouse = GuiCtrlCreateRadio("Right", 85, 80, 80)
GUICtrlCreateGroup ("",-99,-99,1,1)
$b_InsertMouseOK = GUICtrlCreateButton("OK",10,120,100,30)
$b_InsertMouseCancel = GUICtrlCreateButton("Close",120,120,100,30)
;===================================
; GUI: Insert Delay
;===================================
$DelayWin = GUICreate("Insert Delay", 230, 190, (@DesktopWidth-230)/2, (@DesktopHeight-190)/2, $WS_CAPTION,Default,$CeWin)
GuiCtrlCreateGroup("In Seconds", 50, 10, 120, 70)
$delay_digit_input = GUICtrlCreateInput("0",65,40,40,20,BitOR($ES_CENTER,$ES_NUMBER))
$delay_decimal_input = GUICtrlCreateInput("05",115,40,40,20,BitOR($ES_CENTER,$ES_NUMBER))
GUICtrlSetLimit($delay_decimal_input,2,1)
GUICtrlCreateGroup (".",-99,-99,1,1)
$b_InsertDelayOK = GUICtrlCreateButton("OK",60,100,100,30)
$b_InsertDelayCancel = GUICtrlCreateButton("Close",60,140,100,30)
;===================================
; GUI: View Keybinds
;===================================
$KeyBindWin = GUICreate("View Binded Keys", $KeybindsW, $KeybindsH, (@DesktopWidth-$KeybindsW)/2, (@DesktopHeight-$KeybindsH)/2, $WS_CAPTION,Default,$MainWin)
GUICtrlCreateLabel("Profile:",10,5)
$profile_keybind_label = GUICtrlCreateLabel("",45,5,100,20)
$listview = GUICtrlCreateListView ("Macro|Key",10,25,$KeybindsW-20,$KeybindsH-65,BitOr($GUI_SS_DEFAULT_LISTVIEW,$LVS_NOSORTHEADER,$LVS_EDITLABELS ))
GUICtrlSetState($listview,$GUI_DROPACCEPTED)
$keybinds_b_close = GUICtrlCreateButton("Close",($KeybindsW-100)/2,$KeybindsH-35,100,30)
;===================================
; GUI: Insert Pixel check
;===================================
$PixelCheckWin = GUICreate("Insert Pixel Event", 260, 260, (@DesktopWidth-260)/2, (@DesktopHeight-260)/2, $WS_CAPTION,Default,$CeWin)
GuiCtrlCreateGroup("Location", 20, 10, 220, 80)
GUICtrlCreateLabel("X",30,35)
$in_PixelX = GUICtrlCreateInput("0",50,30,60,20)
GUICtrlCreateLabel("Y",30,65)
$in_PixelY = GUICtrlCreateInput("0",50,60,60,20)
$b_GetPixelLocation = GUICtrlCreateButton("Pick Location",130,40,100,30)
GuiCtrlCreateGroup("Event", 20, 100, 220, 110)
$PixelCheck_Wait_ck = GUICtrlCreateCheckbox("Wait for color",35,120)
$PixelCheck_hex = GUICtrlCreateLabel("Hex",35,150)
$in_PixelColor = GUICtrlCreateInput("000000",60,145,60,20)
$b_GetPixelColor = GUICtrlCreateButton("Update",80,175,60)
GUICtrlSetState($b_GetPixelColor,$GUI_DISABLE)
GUICtrlSetState($PixelCheck_hex,$GUI_DISABLE)
GUICtrlSetState($in_PixelColor,$GUI_DISABLE)
$PixelCheck_Move_ck = GUICtrlCreateCheckbox("Mouse move",150,120)
$PixelCheck_Click_ck = GUICtrlCreateCheckbox("Mouse click",150,140)
$r_l_mouse_pixel = GuiCtrlCreateRadio("Left", 165, 160,65)
$r_r_mouse_pixel = GuiCtrlCreateRadio("Right", 165, 180,65)
GuiCtrlSetState($r_l_mouse_pixel, $GUI_CHECKED)
GUICtrlSetState($PixelCheck_Click_ck,$GUI_DISABLE)
GUICtrlSetState($r_l_mouse_pixel,$GUI_DISABLE)
GUICtrlSetState($r_r_mouse_pixel,$GUI_DISABLE)
$preview_color = GUICtrlCreateGraphic(30,175,40,25,$SS_BLACKFRAME)
$b_InsertPixelOK = GUICtrlCreateButton("Insert",20,220,100,30)
$b_InsertPixelCancel = GUICtrlCreateButton("Cancel",140,220,100,30)
;===================================
; HotKey config
;===================================
Opt("SendKeyDelay",0)
Opt("SendKeyDownDelay",0)
Opt("MouseClickDelay",0)
Opt("MouseClickDownDelay",0)
Opt("MouseClickDragDelay",0)
Opt("GUICloseOnESC",0)
Opt("GUIOnEventMode",0)
Opt("OnExitFunc", "_ClearKeyboardCache")
;===================================
; Initialize configuration
;===================================
LoadSettings($config) ;Init all user settings
$first_time_ran = 0
LoadMacroList($ini_file) ;Init current macro profile in listbox
LoadKeyBoardLayout($scancodes) ;Init array of keyboard scancodes
;===================================
; Main Loop
;===================================
While 1
$msg = GUIGetMsg(1)
Select
Case $msg[0] = $GUI_EVENT_CLOSE
If $msg[1] = $MainWin Then
Exit
ElseIf $msg[1] = $KeyUpDownWin Then
GUISetState(@SW_HIDE,$KeyUpDownWin)
GUISetState(@SW_ENABLE,$CeWin)
GUISetState(@SW_RESTORE,$CeWin)
EndIf
Case $msg[0] = $keybinds_b_close
GUISetState(@SW_HIDE,$KeyBindWin)
Case $msg[0] = $helpitem
If FileExists(@scriptdir & "\help.chm") Then
ShellExecute("help.chm", "", @ScriptDir, "open")
Else
MsgBox(0,"No help file found","Please re-install MacroGamer")
EndIf
Case $msg[0] = $optionsbindedkeys
GUISetState(@SW_SHOW,$KeyBindWin)
OnClick_ViewKeyBinds()
Case $msg[0] = $updateitem
_CheckForUpdate($version,$updateLocation,$tempUpdateSaveName)
Case $msg[0] = $fileitem ;load profile
OnClick_LoadProfile()
Case $msg[0] = $newitem ;make new profile
OnClick_NewProfile()
Case $msg[0] = $Option_b_defaultpro
SetDefaultProfile()
Case $msg[0] = $Option_b_ONOFF
DisableCurrentONOFF()
RecordONOFF_HotKey()
EnabledCurrentONOFF()
Case $msg[0] = $Option_b_Record
RecordStartStop_HotKey()
Case $msg[0] = $Option_b_OK
Onclick_SaveSettings()
GUISetState(@SW_HIDE,$OptionWin)
GUISetState(@SW_ENABLE,$MainWin)
GUISetState(@SW_RESTORE,$MainWin)
Case $msg[0] = $Option_b_cancel
EnabledCurrentONOFF()
GUISetState(@SW_HIDE,$OptionWin)
GUISetState(@SW_ENABLE,$MainWin)
GUISetState(@SW_RESTORE,$MainWin)
Case $msg[0] = $aboutitem
MsgBox(0,"About",$AboutStr)
Case $msg[0] = $b_New
GUISetState(@SW_SHOW,$CeWin)
GUISetState(@SW_DISABLE,$MainWin)
DisableCurrentONOFF()
HotKeySet($runstop_hotkey)
HotKeySet(_ConvertToHotKeyNotation(GUICtrlRead($Option_in_Record)),"Toggle_Record_Start_Stop")
$editflag = 0
ClearEditorWindow()
Case $msg[0] = $b_Cancel
EnabledCurrentONOFF()
HotKeySet($runstop_hotkey,"Toggle_Run_Stop")
GUISetState(@SW_HIDE,$CeWin)
GUISetState(@SW_HIDE,$DelayWin)
GUISetState(@SW_ENABLE,$MainWin)
GUISetState(@SW_RESTORE,$MainWin)
HotKeySet(GUICtrlRead($Option_in_Record))
Case $msg[0] = $optionsitem
DisableCurrentONOFF()
Global $curr_defualt_profile = GUICtrlRead($Option_in_default)
LoadSettings($config)
GUISetState(@SW_DISABLE,$MainWin)
GUISetState(@SW_SHOW,$OptionWin)
Case $msg[0] = $b_Edit
Interface_EditMacro_Load()
$editflag = 1
HotKeySet($runstop_hotkey)
HotKeySet(_ConvertToHotKeyNotation(GUICtrlRead($Option_in_Record)),"Toggle_Record_Start_Stop")
DisableCurrentONOFF()
LoadEditorWindow()
Interface_EditMacro_Load_Finish()
Case $msg[0] = $b_Delete
DeleteMacro($ini_file,_GUICtrlListGetText($macrolist,_GUICtrlListSelectedIndex($macrolist)))
If _GUICtrlListCount($macrolist) = 0 Then
GUICtrlSetState($b_run,$GUI_DISABLE)
Else
_GUICtrlListSelectIndex($macrolist,0)
EndIf
Case $msg[0] = $b_OK
;~ Local $check = CheckMacroForErrors()
;~ If $check = "OK" Or $check = 6 Then
GUISetState(@SW_HIDE,$DelayWin)
_GUICtrlStatusBarSetText($statusbar2,"Saving macro...")
_DisableEditorControls()
CreateMacro()
LoadMacroList($ini_file)
HotKeySet($runstop_hotkey,"Toggle_Run_Stop")
If _GUICtrlListCount($macrolist) > 0 Then
_GUICtrlListSelectIndex($macrolist,$currentOpenMacroIndex)
Else
GUICtrlSetState($b_run,$GUI_DISABLE)
EndIf
HotKeySet(_ConvertToHotKeyNotation(GUICtrlRead($Option_in_Record)))
_GUICtrlStatusBarSetText($statusbar2,"Recordng stopped")
_EnableEditorControls()
;~ EndIf
Case $msg[0] = $exititem
Exit
Case $msg[0] = $b_startRec
$downlist = _ArrayCreate(-1)
_HookKeyBoardMouseRecord($CeWin)
StartRecording()
_GUICtrlStatusBarSetText($statusbar2,"Recordng...")
Case $msg[0] = $b_stopRec
StopRecording()
_UnHookKeyBoardMouseRecord()
_GUICtrlStatusBarSetText($statusbar2,"Recordng stopped")
Case $msg[0] = $b_DeleteItem
DeleteEventItem()
Case $msg[0] = $b_bindkey
BindToKey()
Case $msg[0] = $b_InsertOK
InsertRecordedKey(_GUICtrlListSelectedIndex($Seqlist))
Case $msg[0] = $b_InsertMouseOK
InsertMouseEvent(_GUICtrlListSelectedIndex($Seqlist))
Case $msg[0] = $b_InsertPixelOK
InsertPixelEvent()
Case $msg[0] = $b_GetPixelLocation
GUICtrlSetState($b_GetPixelLocation,$GUI_DISABLE)
GUISetState(@SW_MINIMIZE,$MainWin)
GUISetState(@SW_HIDE,$PixelCheckWin)
Sleep(10)
While Not _IsPressed("01")
ToolTip("Click a screen location")
Sleep(50)
WEnd
While _IsPressed("01")
ToolTip("Click a screen location")
Sleep(50)
WEnd
Local $pos = MouseGetPos()
GUICtrlSetState($b_GetPixelLocation,$GUI_ENABLE)
GUICtrlSetData($in_PixelX,$pos[0])
GUICtrlSetData($in_PixelY,$pos[1])
GUICtrlSetData($in_PixelColor,Hex(PixelGetColor($pos[0],$pos[1]),6))
GUICtrlSetBkColor($preview_color,"0x" & Hex(PixelGetColor($pos[0],$pos[1]),6))
GUISetState(@SW_RESTORE,$MainWin)
GUISetState(@SW_SHOW,$PixelCheckWin)
ToolTip("")
Case $msg[0] = $b_GetPixelColor
Local $hex = Guictrlread($in_PixelColor)
If StringIsXDigit(GUICtrlRead($in_PixelColor)) <> 1 Or StringLen(GUICtrlRead($in_PixelColor)) <> 6 Then
MsgBox(0,"Invalid color entered","Please enter a 6 digit hex number for color" & @CRLF & "or use 'Pick Location' button to get the color")
Else
GUICtrlSetBkColor($preview_color,"0x" & $hex)
EndIf
Case $msg[0] = $PixelCheck_Move_ck
If BitAND(GUICtrlRead($PixelCheck_Move_ck),$GUI_CHECKED) Then
GUICtrlSetState($PixelCheck_Click_ck,$GUI_ENABLE)
If BitAND(GUICtrlRead($PixelCheck_Click_ck),$GUI_CHECKED) Then
GUICtrlSetState($r_l_mouse_pixel,$GUI_ENABLE)
GUICtrlSetState($r_r_mouse_pixel,$GUI_ENABLE)
Else
GUICtrlSetState($r_l_mouse_pixel,$GUI_DISABLE)
GUICtrlSetState($r_r_mouse_pixel,$GUI_DISABLE)
EndIf
Else
GUICtrlSetState($PixelCheck_Click_ck,$GUI_DISABLE)
GUICtrlSetState($r_l_mouse_pixel,$GUI_DISABLE)
GUICtrlSetState($r_r_mouse_pixel,$GUI_DISABLE)
EndIf
Case $msg[0] = $PixelCheck_Click_ck
If BitAND(GUICtrlRead($PixelCheck_Click_ck),$GUI_CHECKED) Then
GUICtrlSetState($r_l_mouse_pixel,$GUI_ENABLE)
GUICtrlSetState($r_r_mouse_pixel,$GUI_ENABLE)
Else
GUICtrlSetState($r_l_mouse_pixel,$GUI_DISABLE)
GUICtrlSetState($r_r_mouse_pixel,$GUI_DISABLE)
EndIf
Case $msg[0] = $PixelCheck_Wait_ck
If BitAND(GUICtrlRead($PixelCheck_Wait_ck),$GUI_CHECKED) Then
GUICtrlSetState($PixelCheck_hex,$GUI_ENABLE)
GUICtrlSetState($in_PixelColor,$GUI_ENABLE)
GUICtrlSetState($b_GetPixelColor,$GUI_ENABLE)
Else
GUICtrlSetState($PixelCheck_hex,$GUI_DISABLE)
GUICtrlSetState($in_PixelColor,$GUI_DISABLE)
GUICtrlSetState($b_GetPixelColor,$GUI_DISABLE)
EndIf
Case $msg[0] = $m_InsertPixelCheck
GUISetState(@SW_SHOW,$PixelCheckWin)
GUISetState(@SW_DISABLE,$CeWin)
Case $msg[0] = $b_InsertPixelCancel
GUISetState(@SW_HIDE,$PixelCheckWin)
GUISetState(@SW_ENABLE,$CeWin)
GUISetState(@SW_RESTORE,$CeWin)
Case $msg[0] = $m_InsertMouseEvent
GUISetState(@SW_SHOW,$MouseWin)
GUISetState(@SW_DISABLE,$CeWin)
GuiCtrlSetState($r_l_mouse, $GUI_CHECKED)
Case $msg[0] = $b_InsertCancel
GUISetState(@SW_HIDE,$KeyUpDownWin)
GUISetState(@SW_ENABLE,$CeWin)
GUISetState(@SW_RESTORE,$CeWin)
Case $msg[0] = $b_InsertMouseCancel
GUISetState(@SW_HIDE,$MouseWin)
GUISetState(@SW_ENABLE,$CeWin)
GUISetState(@SW_RESTORE,$CeWin)
Case $msg[0] = $b_InsertRecord
RecordInsert()
Case $msg[0] = $b_MoveUp
MoveListItem("up",_GUICtrlListSelectedIndex($Seqlist))
Case $msg[0] = $b_MoveDown
MoveListItem("down",_GUICtrlListSelectedIndex($Seqlist))
Case $msg[0] = $b_Insert
ShowMenu($CeWin, $msg, $InsertContext)
Case $msg[0] = $m_InsertKeyUpDown
GUISetState(@SW_SHOW,$KeyUpDownWin)
GUISetState(@SW_DISABLE,$CeWin)
GuiCtrlSetState($r_keypress, $GUI_CHECKED)
Case $msg[0] = $m_InsertDelay
GUISetState(@SW_SHOW,$DelayWin)
GUICtrlSetData($delay_decimal_input,"05")
GUICtrlSetData($delay_digit_input,"0")
Case $msg[0] = $b_InsertDelayOK
InsertDelay(_GUICtrlListSelectedIndex($Seqlist))
Case $msg[0] = $b_InsertDelayCancel
GUISetState(@SW_HIDE,$DelayWin)
Case $msg[0] = $b_up
ModifyDelay("up")
Case $msg[0] = $b_down
ModifyDelay("down")
Case $msg[0] = $b_run
AppRun()
Case $msg[0] = $b_stop
AppStop()
Case $msg[0] = $c_mouseclickrecord
If BitAND(GUICtrlRead($c_mouseclickrecord),$GUI_CHECKED) Then
GUICtrlSetState($c_mouseclickposrecord,$GUI_ENABLE)
GUICtrlSetState($c_mouseclickposrecord,$GUI_CHECKED)
Else
GUICtrlSetState($c_mouseclickposrecord,$GUI_DISABLE)
GUICtrlSetState($c_mouseclickposrecord,$GUI_UNCHECKED)
EndIf
Case $msg[0] = $r_mtype1
GUICtrlSetState($repeat_input,$GUI_DISABLE)
GUICtrlSetData($repeat_input,"")
Case $msg[0] = $r_mtype2
GUICtrlSetState($repeat_input,$GUI_ENABLE)
GUICtrlSetData($repeat_input,"2")
Case $msg[0] = $r_mtype3
GUICtrlSetState($repeat_input,$GUI_DISABLE)
GUICtrlSetData($repeat_input,"")
Case $msg[0] = $Seqlist
If StringRight(_GUICtrlListGetText($Seqlist,_GUICtrlListSelectedIndex($Seqlist)),5) = "Delay" Then
GUICtrlSetState($in_delay,$GUI_ENABLE)
GUICtrlSetState($b_up,$GUI_ENABLE)
GUICtrlSetState($b_down,$GUI_ENABLE)
GUICtrlSetData($in_delay,StringTrimRight(_GUICtrlListGetText($Seqlist,_GUICtrlListSelectedIndex($Seqlist)),6))
Else
GUICtrlSetState($b_up,$GUI_DISABLE)
GUICtrlSetState($b_down,$GUI_DISABLE)
GUICtrlSetState($in_delay,$GUI_DISABLE)
GUICtrlSetData($in_delay,"") ;If its not a number then display nothing
EndIf
Case $msg[0] = $repeat_input
If Guictrlread($repeat_input) < 2 Then ;Lowest value of repeat updown is 1
GUICtrlSetData($repeat_input,"2")
EndIf
Case $msg[0] = $in_delay
ModifyDelay()
EndSelect
WEnd
;===================================
;===================================
;=========== Functions =============
;===================================
;===================================
;=============================================================================
; Waits for pixel to change to a certain color.
;=============================================================================
Func WaitOnPixel($x,$y,$color)
Local $intversion = Int($color)
While PixelGetColor($x,$y) <> $intversion
$msg = GUIGetMsg(1)
If $msg[0] = $b_stop Then AppStop()
If $paused = 1 Then ExitLoop
WEnd
EndFunc
;=============================================================================
; Inserts a pixel event into the event list
; The user can make the macro pause until a certain pixel on the screen
; changes to a specified color.
; The user can also allow the mouse cursor to click on that pixel after it
; changes.
;=============================================================================
Func InsertPixelEvent()
Local $move = BitAND(GUICtrlRead($PixelCheck_Move_ck),$GUI_CHECKED)
Local $wait = BitAND(GUICtrlRead($PixelCheck_Wait_ck),$GUI_CHECKED)
Local $click = BitAND(GUICtrlRead($PixelCheck_Click_ck),$GUI_CHECKED)
Local $left = BitAND(Guictrlread($r_l_mouse_pixel),$GUI_CHECKED)
If $move + $wait = 0 Then ;neither are checked
MsgBox(0,"No event selected","Please choose an event")
ElseIf StringIsXDigit(GUICtrlRead($in_PixelColor)) <> 1 Or StringLen(GUICtrlRead($in_PixelColor)) <> 6 Then
MsgBox(0,"Invalid color entered","Please enter a 6 digit hex number for color" & @CRLF & "or use 'Pick Location' button to get the color")
Else
Local $insertValue = "<Wait ("& GUICtrlRead($in_PixelX) &","& GUICtrlRead($in_PixelY) &") " & GUICtrlRead($in_PixelColor) & ">"
If $move = 1 Then
If $click = 1 Then
If $left = 1 Then
If $wait Then
InsertEntry($insertValue,_GUICtrlListSelectedIndex($Seqlist))
EndIf
InsertEntry("{LMouse} Hold ("& GUICtrlRead($in_PixelX) &","& GUICtrlRead($in_PixelY) &")",_GUICtrlListSelectedIndex($Seqlist))
InsertEntry("0.05 Delay",_GUICtrlListSelectedIndex($Seqlist))
InsertEntry("{LMouse} Release ("& GUICtrlRead($in_PixelX) &","& GUICtrlRead($in_PixelY) &")",_GUICtrlListSelectedIndex($Seqlist))
Else
If $wait Then
InsertEntry($insertValue,_GUICtrlListSelectedIndex($Seqlist))
EndIf
InsertEntry("{RMouse} Hold ("& GUICtrlRead($in_PixelX) &","& GUICtrlRead($in_PixelY) &")",_GUICtrlListSelectedIndex($Seqlist))
InsertEntry("0.05 Delay",_GUICtrlListSelectedIndex($Seqlist))
InsertEntry("{RMouse} Release ("& GUICtrlRead($in_PixelX) &","& GUICtrlRead($in_PixelY) &")",_GUICtrlListSelectedIndex($Seqlist))
EndIf
Else
If $wait Then
InsertEntry($insertValue,_GUICtrlListSelectedIndex($Seqlist))
EndIf
InsertEntry("Move ("& GUICtrlRead($in_PixelX) &","& GUICtrlRead($in_PixelY) &")",_GUICtrlListSelectedIndex($Seqlist))
Endif
Else
InsertEntry($insertValue,_GUICtrlListSelectedIndex($Seqlist))
EndIf
GUISetState(@SW_HIDE,$PixelCheckWin)
GUISetState(@SW_ENABLE,$CeWin)
GUISetState(@SW_RESTORE,$CeWin)
EndIf
EndFunc
;=============================================================================
; Notifys the user that a "key down" event does not have a matching "key up" event
; A warning message is displayed with the key events that dont have matching events
;=============================================================================
Func CheckMacroForErrors()
Local $KeyDownList = _ArrayCreate(-1)
Local $EventList = EventListToArray()
For $i = 1 To UBound($EventList) - 1 ;For each event in the macro
If StringRight($EventList[$i],4) = "Hold" Then ;Store all Hold events in array list
If _ArraySearch($KeyDownList,$EventList[$i],1) > -1 Then
ExitLoop ;If key down is already in array then exit
Else
_ArrayAdd($KeyDownList,$EventList[$i])
EndIf
ElseIf StringRight($EventList[$i],7) = "Release" Then ;If a release event then compare with Hold array list
Local $index_found = _ArraySearch($KeyDownList,StringReplace($EventList[$i],"Release","Hold"))
If $index_found > - 1 Then ;If found the romove from stack
_ArrayDelete($KeyDownList,$index_found)
EndIf
EndIf
Next
If UBound($KeyDownList) > 1 Then ;If any Hold events remain then there is an unbalance of key presses
Local $keysdownSTR = "List of unbalanced Hold keys" & @CRLF & "----------------" & @CRLF
Local $reason = "Do you want to continue saving?"
For $i = 1 To UBound($KeyDownList) - 1
$keysdownSTR &= $KeyDownList[$i] & @CRLF
Next
Local $yes_or_no = MsgBox(4,"Warning","One or more of the key Hold events do " & @CRLF & "not have a matching key Release event." & @CRLF & @CRLF & $keysdownSTR & "----------------" & @CRLF & @CRLF & $reason)
Return $yes_or_no ;If = 6 then YES button is clicked, else NO was clicked
EndIf
Return "OK" ;No errors found
EndFunc ;CheckMacroForErrors()==>
;=============================================================================
; If a key is in a pressed down state, then clear it before recording
; This is a rare case.
;=============================================================================
Func _ClearKeyboardCache()
for $i = 8 to 222
If _IsPressed(hex($i,2)) Then
Local $key = $keyboardLayout[$i]
If StringInStr($keyboardLayout[$i],"{") = 1 Then
Send(StringReplace($keyboardLayout[$i],"}"," up}"))
Else
Send($keyboardLayout[$i])
EndIf
EndIf
Next
If _IsPressed(1) Then
MouseDown("left")
MouseUp("left")
EndIf
If _IsPressed(2) Then
MouseDown("right")
MouseUp("right")
EndIf
If IsDeclared("$hhKey") Then
DLLCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hhKey[0])
DLLCall("kernel32.dll","int","FreeLibrary","hwnd",$DLLinst[0])
EndIf
EndFunc ;_ClearKeyboardCache()==>
;=============================================================================
; Displays a message box displaying a message to user that a newer version
; of the application is available
;=============================================================================
Func _CheckForUpdate($version,$location,$tempsave)
Local $updateCheck = _INetGetSource($location)
If @error <> 1 Then
If StringReplace($version,".","") < StringReplace($updateCheck,".","") Then
MsgBox(4096, "Update Found", "Version " & $updateCheck & " " & @CRLF & "Download it at www.itoady.com", 10)
Else
MsgBox(4096, "No Newer Versions", "Current version is already installed", 10)
EndIf
Else
MsgBox(0,"Update","Visit http://www.itoady.com for updates")
EndIf
EndFunc ;_CheckForUpdate()==>
;=============================================================================
; Displays a message box containing all the macros and their keybinds
;=============================================================================
Func OnClick_ViewKeyBinds()
_GUICtrlListViewSetColumnWidth($listview,0,$KeybindsW-100)
_GUICtrlListViewSetColumnWidth($listview,1,75)
_GUICtrlListViewDeleteAllItems($listview)
GUICtrlSetData($profile_keybind_label,_Str_ExtractFileName($ini_file))
GUICtrlCreateListViewItem("Run/Stop" & "|" & GUICtrlRead($Option_in_ONOFF),$listview)
GUICtrlCreateListViewItem("Start/Stop Recording" & "|" & GUICtrlRead($Option_in_Record),$listview)
Local $ini = ""
For $i = 0 To _GUICtrlListCount($macrolist) - 1 ;Add each macro name and its key bind to listview
$ini = IniReadSection($ini_file,_GUICtrlListGetText($macrolist,$i))
If IsArray($ini) Then
If $ini[1][1] <> "No Key" Then ;Different listview add display if macro has no bind
GUICtrlCreateListViewItem(_GUICtrlListGetText($macrolist,$i) & "|" & StringReplace($ini[1][1]," Key",""),$listview)
Else
GUICtrlCreateListViewItem(_GUICtrlListGetText($macrolist,$i) & "|" & $ini[1][1],$listview)
EndIf
EndIf
Next
If _GUICtrlListViewGetItemCount($listview) > 9 Then ;adjust headers for scrollbars
_GUICtrlListViewSetColumnWidth($listview,0,$KeybindsW-116)
EndIf
EndFunc ;OnClick_ViewKeyBinds()==>
;=============================================================================
; Displays an open dialog box allowing user to open a existing profile
;=============================================================================
Func OnClick_LoadProfile()
Local $default_profile_path = FileOpenDialog("Find MacroGamer Profile...",@ScriptDir,"MacroGamer Profile (*.mgp)")
If $default_profile_path <> "" And StringRight($default_profile_path,4) =".mgp" Then
If FileExists($default_profile_path) Then
LoadMacroList($default_profile_path)
$ini_file = $default_profile_path
EndIf
EndIf
EndFunc ;OnClick_LoadProfile()==>
;=============================================================================
; Displays a save dialog box allowing user to create a new profile
;=============================================================================
Func OnClick_NewProfile()
Local $new_profile_path = FileSaveDialog( "Choose a name.", @ScriptDir, "MacroGamer Profile (*.mgp)", 2,"new_profile.mgp")
If $new_profile_path <> "" Then
If FileExists($new_profile_path) Then
MsgBox(1,"Error","File already exists!" & @LF & "Choose a different name")
OnClick_NewProfile()
Else
FileClose(FileOpen($new_profile_path, 2))
LoadMacroList($new_profile_path)
$ini_file = $new_profile_path
EndIf
EndIf
EndFunc ;OnClick_NewProfile()==>
;=============================================================================
; Toggles the application recording start and stop
;=============================================================================
Func Toggle_Record_Start_Stop()
Opt("WinSearchChildren",1)
If BitAND(WinGetState("Macro Editor", ""),4) Then
HotKeySet(_ConvertToHotKeyNotation(GUICtrlRead($Option_in_Record)))
If GUICtrlGetState($b_stopRec) = 80 Then ;enabled
StopRecording()
_UnHookKeyBoardMouseRecord()
If $DisplayNotifyRecord = 1 Then ;Play a sound
SoundPlay(@ScriptDir & "\RecordingStopped.wav")
EndIf
SLeep(100) ;give some time for macros to load
ElseIf GUICtrlGetState($b_startRec) = 80 Then
$downlist = _ArrayCreate(-1)
_HookKeyBoardMouseRecord($CeWin)
StartRecording()
If $DisplayNotifyRecord = 1 Then
SoundPlay(@ScriptDir & "\RecordingStarted.wav")
EndIf
SLeep(100) ;give some time for macros to load
Endif
HotKeySet(_ConvertToHotKeyNotation(GUICtrlRead($Option_in_Record)),"Toggle_Record_Start_Stop")
EndIf
Opt("WinSearchChildren",0)
EndFunc ;Toggle_Run_Stop()==>
;=============================================================================
; Toggles the application macros on and off
;=============================================================================
Func Toggle_Run_Stop()
If BitAND(WinGetState($App_Name, ""),4) Then ;Only toggle if Main Window is active, not other child gui's are active
HotKeySet($runstop_hotkey)
If _GUICtrlListCount($macrolist) > 0 Then ;Only toggle if macros exist
$Paused = Not $Paused
If $Paused = 1 Then
AppStop() ;Disable all keybinds
If $DisplayNotify = 1 Then ;Play a sound
SoundPlay(@ScriptDir & "\MacrosDisabled.wav")
EndIf
SLeep(200) ;give some time for macros to load
for $i = 8 to 222 ;addstop must be called before this loop
If _IsPressed(hex($i,2)) Then
Send($keyboardLayout[$i])
EndIf
Next
HotKeySet($runstop_hotkey,"Toggle_Run_Stop")
ElseIf $Paused = 0 Then
AppRun() ;Parce through macros and set keybinds
HotKeySet($runstop_hotkey)
If $DisplayNotify = 1 Then
SoundPlay(@ScriptDir & "\MacrosEnabled.wav")
EndIf
SLeep(200) ;give some time for macros to load
Endif
EndIf
HotKeySet($runstop_hotkey,"Toggle_Run_Stop") ;Keep macros toggle from being spammed
EndIf
EndFunc ;Toggle_Run_Stop()==>
;=============================================================================
; Saves the settings in the config file
;=============================================================================
Func Onclick_SaveSettings()
Local $delay_val
HotKeySet($runstop_hotkey)
IniWrite($config, "settings", "default", GUICtrlRead($Option_in_default))
IniWrite($config, "settings", "togglekey", GUICtrlRead($Option_in_ONOFF))
IniWrite($config, "settings", "notifytoggle", BitAND(GUICtrlRead($Option_ck_Notify),$GUI_CHECKED))
IniWrite($config, "settings", "togglekeyrecord", GUICtrlRead($Option_in_Record))
IniWrite($config, "settings", "notifytogglerecord", BitAND(GUICtrlRead($Option_ck_Record_Notify),$GUI_CHECKED))
HotKeySet(_ConvertToHotKeyNotation(GUICtrlRead($Option_in_ONOFF)),"Toggle_Run_Stop")
If $curr_defualt_profile <> GUICtrlRead($Option_in_default) Then
$ini_file = GUICtrlRead($Option_in_default)
EndIf
$DisplayNotifyRecord = BitAND(GUICtrlRead($Option_ck_Record_Notify),$GUI_CHECKED)
$DisplayNotify = BitAND(GUICtrlRead($Option_ck_Notify),$GUI_CHECKED)
LoadMacroList($ini_file)
$runstop_hotkey = _ConvertToHotKeyNotation(GUICtrlRead($Option_in_ONOFF))
$DisplayNotify = BitAND(GUICtrlRead($Option_ck_Notify),$GUI_CHECKED)
EndFunc ;Onclick_SaveSettings()==>
;=============================================================================
; Enable ON/OFF Hotkey
;=============================================================================
Func EnabledCurrentONOFF()
HotKeySet($runstop_hotkey,"Toggle_Run_Stop")
EndFunc ; EnabledCurrentONOFF()==>
;=============================================================================
; Disable ON/OFF Hotkey
;=============================================================================
Func DisableCurrentONOFF()
HotKeySet($runstop_hotkey)
EndFunc ;DisableCurrentONOFF()==>
;=============================================================================
; Opens dialog box letting user find and select the defaul profile to use
;=============================================================================
Func SetDefaultProfile()
Local $default_profile_path = FileOpenDialog("Find MacroGamer Profile...",@ScriptDir,"All (*.mgp)")
If $default_profile_path <> "" Then
If FileExists($default_profile_path) Then
GUICtrlSetData($Option_in_default,$default_profile_path)
EndIf
EndIf
EndFunc ;SetDefaultProfile()==>
;=============================================================================
; Sets all the settings back to original values
; NOTE: Not used, maybe in later versions
;=============================================================================
Func ResetToDefaults()
GUICtrlSetData($Option_in_ONOFF,"{F3}")
GUICtrlSetState($Option_ck_Notify,$GUI_CHECKED)
HotKeySet(GUICtrlRead($Option_in_ONOFF),"Toggle_Run_Stop")
EndFunc ;ResetToDefaults()==>
;=============================================================================
; Loads in settings from config file and sets appropriate variables
;=============================================================================
Func LoadSettings($config)
Local $ini = IniReadSection($config,"settings")
If $first_time_ran = 1 Then
If $ini[1][1] <> "" Then
$ini_file = $ini[1][1] ;type string
GUICtrlSetData($Option_in_default,$ini_file)
Else ;Below line only ran on first installation
$ini_file = @ScriptDir & "\profile.mgp" ;type string
EndIf
EndIf
$runstop_hotkey = $ini[2][1] ;type string
$DisplayNotify = $ini[3][1] ;type boolean
$DisplayNotifyRecord = $ini[5][1]
GUICtrlSetData($Option_in_ONOFF,$runstop_hotkey)
GUICtrlSetState($Option_ck_Notify,$DisplayNotify)
GUICtrlSetData($Option_in_Record,$ini[4][1])
GUICtrlSetState($Option_ck_Record_Notify,$DisplayNotifyRecord)
HotKeySet(_ConvertToHotKeyNotation(GUICtrlRead($Option_in_ONOFF)),"Toggle_Run_Stop")
EndFunc ;LoadSettings($config)==>
;=============================================================================
; Reads the keyboard layout file OMFG! WTF! HAX! 102 standard keyboard
; Using an external INI file in case scancodes not compatible with keyboard
; This allows updates to scancodes to be simple, even user can modify it.
;=============================================================================
Func LoadKeyBoardLayout($file)
Local $ini = IniReadSection($file,"keyboard")
Global $keyboardLayout = _ArrayCreate($ini[1][1])
For $i = 2 To $ini[0][0]
_ArrayAdd($keyboardLayout,$ini[$i][1])
Next
EndFunc ;LoadKeyBoardLayout($file)==>
;=============================================================================
; If a macro is long it will take a short period of time to load macro into
; editor window.
;=============================================================================
Func Interface_EditMacro_Load()
_GUICtrlStatusBarSetText($statusbar,"Loading macro...")
GUICtrlSetState($b_run,$GUI_DISABLE) ;Disable all controls while loading
GUICtrlSetState($macrolist,$GUI_DISABLE)
GUICtrlSetState($b_stop,$GUI_ENABLE)
GUICtrlSetState($b_new,$GUI_DISABLE)
GUICtrlSetState($b_edit,$GUI_DISABLE)
GUICtrlSetState($b_delete,$GUI_DISABLE)
GUICtrlSetState($optionsitem,$GUI_DISABLE)
GUICtrlSetState($newitem,$GUI_DISABLE)
GUICtrlSetState($fileitem,$GUI_DISABLE)
GUICtrlSetState($b_run,$GUI_DISABLE)
GUICtrlSetState($b_stop,$GUI_DISABLE) ;^^
EndFunc ;Interface_EditMacro_Load()==>
;=============================================================================
; If a macro is long it will take a short period of time to load macro into
; editor window. This gets called after macro is loaded into editor window.
;=============================================================================
Func Interface_EditMacro_Load_Finish()
_GUICtrlStatusBarSetText($statusbar,"Stopped")
GUICtrlSetState($b_run,$GUI_ENABLE) ;Disable all controls while loading
GUICtrlSetState($macrolist,$GUI_ENABLE)
GUICtrlSetState($b_new,$GUI_ENABLE)
GUICtrlSetState($b_edit,$GUI_ENABLE)
GUICtrlSetState($b_delete,$GUI_ENABLE)
GUICtrlSetState($optionsitem,$GUI_ENABLE)
GUICtrlSetState($newitem,$GUI_ENABLE)
GUICtrlSetState($fileitem,$GUI_ENABLE)
GUICtrlSetState($b_run,$GUI_ENABLE)
EndFunc ;Interface_EditMacro_Load_Finish()==>
;=============================================================================
; Takes each macro out of the profile file and stores each into memory.
; Each macro in memory is inserted into an index lookup table.
; The index table is used to quickly return the location of the stored macro.
; Three tables are used to make this work.
; Table 1: Index table (keybind1,keybind2,keybind3...,keybind64)
; Table 2: Macro object (event1,event2,..,eventN)
; Table 3: Macros table (macro object1,...,macro objectN)
;=============================================================================
Func AppRun()
If @Compiled Then
ProcessSetPriority(@ScriptName, 4)
Else
ProcessSetPriority("AutoIt3.exe", 4) ;testing purposes
EndIf
HotKeySet($runstop_hotkey) ;Keep macros toggle from being spammed
$paused = 0
_GUICtrlStatusBarSetText($statusbar,"Loading macros...") ;used if macro objects are large
GUICtrlSetState($b_run,$GUI_DISABLE) ;Disable all controls while loading
GUICtrlSetState($macrolist,$GUI_DISABLE)
GUICtrlSetState($b_stop,$GUI_ENABLE)
GUICtrlSetState($b_new,$GUI_DISABLE)
GUICtrlSetState($b_edit,$GUI_DISABLE)
GUICtrlSetState($b_delete,$GUI_DISABLE)
GUICtrlSetState($optionsitem,$GUI_DISABLE)
GUICtrlSetState($newitem,$GUI_DISABLE)
GUICtrlSetState($fileitem,$GUI_DISABLE)
GUICtrlSetState($b_stop,$GUI_DISABLE) ;^^
Global $MacrosArr = _ArrayCreate(-1) ;OMFGHAX!!
$MacroIndex = _ArrayCreate(-1) ;Macro Index
For $j = 0 To _GUICtrlListCount($macrolist) - 1 ;For each of the macros
Local $IniSection = IniReadSection($ini_file,_GUICtrlListGetText($macrolist,$j))
If IsArray($IniSection) Then ;If its an actual macro
Local $keybind = StringLower($IniSection[1][1]) ;Get the keybinds and all each to index array
If $keybind <> "No Key" Then ;if its not supposed to be binded then dont bind it!!!
_ArrayAdd($MacroIndex,_ConvertToHotKeyNotation($keybind)) ;Add keybind to macro indexing list
Local $aMacroOBJ = _ArrayCreate($IniSection[2][1]) ;Create a Macro Object
Local $mytime = TimerInit()
For $i = 3 To $IniSection[0][0] ;For all the events in current macro read
_ArrayAdd($aMacroOBJ,$IniSection[$i][1]) ;Add macro events to MacroOBJ
Next
_ArrayAdd($MacrosArr,$aMacroOBJ) ;Add Macro object to MacroArrayList
EndIf
EndIf
Next
_GUICtrlStatusBarSetText($statusbar,"Running",0)
GUICtrlSetState($b_stop,$GUI_ENABLE)
HotKeyMacroIndexes()
HotKeySet($runstop_hotkey,"Toggle_Run_Stop") ;Keep macros toggle from being spammed
EndFunc ;AppRun()==>
;=============================================================================
; Parces through each of the macro objects and disables the corresponding
; hotkey.
;=============================================================================
Func AppStop()
If @Compiled Then
ProcessSetPriority(@ScriptName, 2)
Else
ProcessSetPriority("AutoIt3.exe", 2) ;testing purposes
EndIf
If IsArray($MacroIndex) Then ;Only if there are keybinds
For $i = 1 To UBound($MacroIndex) - 1