-
Notifications
You must be signed in to change notification settings - Fork 0
/
PyDubManager8modsv.py
1662 lines (1530 loc) · 56.7 KB
/
PyDubManager8modsv.py
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
import wx
import os
import time
import win32gui
#https://github.com/wuxc/pywin32doc/blob/master/md/win32gui.md
import win32con
import win32process
import psutil
#from ObjectListView import ObjectListView, ColumnDefn
import pdb
from datetime import datetime
import wx.stc
import pygame
import win32api
import win32ui
import pickle
import base64
import clr
clr.AddReference('NAudio') #ildasm used on NAudio.dll showed this was the namespace
clr.AddReference('Jacobi.Vst.Core')
clr.AddReference('Jacobi.Vst.Framework')
#clr.AddReference('Jacobi.Vst3.Interop')
import NAudio as NAudio
#print("import clr succeeded, NAudio imported")
ID_BUTTON=100
ID_EXIT=200
ID_SPLITTER=300
pathL = ""
pathR = ""
filetgt = ""
#set by message box
counter1 = 0
#passt2 = ""
#looks like this was based on the code here http://zetcode.com/wxpython/skeletons/
#geany Build - Set Build Commands - Execute:
#"C:\Python27\python.exe" -i "%f"
def fixString(streng):
#remove trailing \\
tempstr = streng.split('\\')
#if tempstr[len(tempstr)-1] == '':
#tempstr.pop()
if len(tempstr) > 1:
return "\\".join(tempstr)
else:
return str(tempstr) + "\\"
def addSlash(streng):
#if necessary
if streng.endswith("\\"):
pass
else:
streng = streng + "\\"
return streng
def justfile(streng):
tempstr = streng.split('\\')
return tempstr[len(tempstr)-1]
#pydubmanager5 for use in def File
#def justdir(streng):
#example inputs C:\program files
#example input2 c:\program files\
def upDir(streng):
tempstr = streng.split('\\')
tempstr2 = "\\".join(tempstr[0:len(tempstr)-1])
if len(tempstr2) == 2:
tempstr2 = tempstr2 + '\\'
return tempstr2
def get_hwnds_for_pid(pid):
def callback(hwnd, hwnds):
if win32gui.IsWindowVisible(hwnd) \
and win32gui.IsWindowEnabled(hwnd):
(_, found_pid) = win32process.GetWindowThreadProcessId(hwnd)
if found_pid == pid:
hwnds.append(hwnd)
return True
hwnds = []
win32gui.EnumWindows(callback, hwnds)
return hwnds
def checkTgt(hwnd):
file1 = open(filetgt,"a+")
#file1.write(str(win32gui.GetWindowText(int(hwnd))) + "\r\n")
file1.write(str(win32gui.GetWindowText(int(hwnd))) + "\n")
file1.close()
file1a = open(filetgt,"r+")
filelines = file1a.readlines()
if len(filelines)>2:
if filelines[len(filelines)-1] == filelines[len(filelines)-2]:
filelines.pop()
file1a.close()
file2 = open(filetgt,"w")
file2.writelines(filelines)
file2.close()
'''
filelines = file1.readlines()
if filelines[len(filelines)-1] == filelines[len(filelines)-2]:
filelines.pop()
file1.close()
'''
'''
file2 = open(filetgt,"w")
file2.writelines(filelines)
file2.close()
'''
#pdb.set_trace()
#print(file1.read())
#print(win32gui.GetWindowText(int(hwnd)))
def hideConsole():
#pids = psutil.pids()
try:
os.system('"' + "winhide.exe PyDubManager1.exe" + '"')
except:
pass
def unhideConsole():
try:
os.system('"' + "winshow.exe cmd.exe" + '"')
except:
pass
class MyListCtrl(wx.ListCtrl):
def __init__(self, parent, id):
wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT)
files = os.listdir('.')
images = ['empty.png','folder.png','sourcepy.png','image.png','pdf.png','up16.png']
self.InsertColumn(0, 'Name')
self.InsertColumn(1, 'Ext')
self.InsertColumn(2, 'Size', wx.LIST_FORMAT_RIGHT)
self.InsertColumn(3, 'Modified')
self.SetColumnWidth(0, 220)
self.SetColumnWidth(1, 70)
self.SetColumnWidth(2, 100)
self.SetColumnWidth(3, 420)
self.il = wx.ImageList(16,16)
for i in images:
self.il.Add(wx.Bitmap(i))
self.SetImageList(self.il,wx.IMAGE_LIST_SMALL)
j = 1
self.InsertItem(0,'..')
self.SetItemImage(0,5)
#new label logic to try to handle different directories
global pathL
global pathR
pathL = os.getcwd()
pathR = os.getcwd()
##print('init path')
##print('repr(pathL)>' + repr(pathL))
##print('repr(pathR)>' + repr(pathR))
#print(self.mypath)
#images =
j=1
self.Bind(wx.EVT_KEY_UP,self.prockey)
for i in files:
(name, ext) = os.path.splitext(i)
ex = ext[1:]
size = os.path.getsize(i)
sec = os.path.getmtime(i)
self.InsertItem(j, i)
self.SetItem(j, 1, ex)
self.SetItem(j, 2, str(size) + ' B')
self.SetItem(j, 3, time.strftime('%Y-%m-%d %H:%M',
time.localtime(sec)))
if os.path.isdir(i):
self.SetItemImage(j, 1)
elif ex == 'py':
self.SetItemImage(j, 2)
elif ex == 'jpg':
self.SetItemImage(j, 3)
elif ex == 'pdf':
self.SetItemImage(j, 4)
else:
self.SetItemImage(j, 0)
if (j % 2) == 0:
self.SetItemBackgroundColour(j, '#e6f1f5')
j = j + 1
def update(self):
global pathL
global pathR
filesDef = os.listdir('.')
filesL = os.listdir(str(pathL))
#(filesL)
#print("filesL^")
filesR = os.listdir(str(pathR))
files = filesDef
##print("FILES =")
##print(dir(files))
##print(files)
if self.Id == 6969:
#print('right updateZ')
os.chdir(pathR)
files = filesR
if self.Id == 4646:
#print('left updateZ')
os.chdir(pathL)
files = filesL
#files = os.listdir('.')
j=1
#self.InsertStringItem(0,'..')
self.InsertItem(0,'..')
#print('hey update')
#print(self)
#print(dir(self))
#print(os.getcwd())
#self.SetLabel(os.getcwd())
#print(self.GetLabel())
for i in files:
(name, ext) = os.path.splitext(i)
ex = ext[1:]
size = os.path.getsize(i)
sec = os.path.getmtime(i)
#self.InsertStringItem(j, i)
self.InsertItem(j,i)
#self.SetStringItem(j,1,ex)
self.SetItem(j,1,ex)
#self.SetStringItem(j,2,str(size) + ' B')
self.SetItem(j,2,str(size) + ' B')
#self.SetStringItem(j,3,time.strftime('%Y-%m-%d %H:%M', time.localtime(sec)))
self.SetItem(j,3,time.strftime('%Y-%m-%d %H:%M', time.localtime(sec)))
if os.path.isdir(i):
self.SetItemImage(j, 1)
elif ex == 'py':
self.SetItemImage(j, 2)
elif ex == 'jpg':
self.SetItemImage(j, 3)
elif ex == 'pdf':
self.SetItemImage(j, 4)
else:
self.SetItemImage(j, 0)
if (j % 2) == 0:
self.SetItemBackgroundColour(j, '#e6f1f5')
j = j + 1
#filething.sb.SetStatusText(os.getcwd())
filething.sb.SetStatusText(pathL + " - - - - " + pathR)
def update2(self):
print("oops")
def prockey(self,event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_BACK:
#print("oh shit")
#copying the entire OnClick code here and modifying it lol
#pathq = os.getcwd() + '\\' + event.GetText()
#pathb = event.GetText()
pathb = ".."
#print('event ingested into OnClick')
#print(event)
#print(dir(event))
#print(event.Text)
#print(event.Id) #4646 left 6969 right
#print(event.Item)
#print(dir(event.Item))
#print(event.Item.Text)
##event text is the text that we clicked on which was the literal filename
#print event.GetItem()
#print event.GetColumn()
##-1
global pathL
global pathR
if event.Id == 4646:
#print('left verified: pathL = ' + pathL)
pathLprev = pathL
fixedLprev = fixString(pathLprev)
if pathb == '..':
pathL = upDir(fixedLprev)
#print('go up dir')
#print(pathLprev.split('\\'))
else:
#pathL = pathLprev + '\\' + event.GetText()
pathL = fixedLprev + '\\' + event.GetText()
pathL = pathL.replace('\\\\','\\').replace("'[","").replace("]'","")
#print('left new: pathL = ' + pathL)
if os.path.isdir(pathL):
pass
else:
pathL = pathLprev
os.chdir(pathL)
os.system('"' + pathb + '"')
if event.Id == 6969:
#print('right verified: pathR = ' + pathR)
pathRprev = pathR
fixedRprev = fixString(pathRprev)
if pathb == '..':
pathR = upDir(fixedRprev)
else:
pathR = fixedRprev + '\\' + event.GetText()
pathR = pathR.replace('\\\\','\\').replace("'[","").replace("]'","")
#print('right new: pathR = ' + pathR)
if os.path.isdir(pathR):
pass
else:
pathR = pathRprev
os.chdir(pathR)
os.system('"' + pathb + '"')
pp = event.GetEventObject()
pp.DeleteAllItems()
pp.update()
class FileMgr1(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self,parent,569,title,(50,50),(900,900))
#button1 = wx.Button(self, ID_BUTTON + 1, "F3 View")
#button2 = wx.Button(self, ID_BUTTON + 2, "F4 Edit")
#button3 = wx.Button(self, ID_BUTTON + 3, "F5 Copy")
#button4 = wx.Button(self, ID_BUTTON + 4, "F6 Move")
#button5 = wx.Button(self, ID_BUTTON + 5, "F7 Mkdir")
#button6 = wx.Button(self, ID_BUTTON + 6, "F8 Delete")
#button7 = wx.Button(self, ID_BUTTON + 7, "F9 Rename")
#button8 = wx.Button(self, ID_EXIT, "F10 Quit")
#self.sizer2.Add(button1, 1, wx.EXPAND)
#self.sizer2.Add(button2, 1, wx.EXPAND)
#self.sizer2.Add(button3, 1, wx.EXPAND)
#self.sizer2.Add(button4, 1, wx.EXPAND)
#self.sizer2.Add(button5, 1, wx.EXPAND)
#self.sizer2.Add(button6, 1, wx.EXPAND)
#self.sizer2.Add(button7, 1, wx.EXPAND)
#self.sizer2.Add(button8, 1, wx.EXPAND)
#self.Bind(wx.EVT_BUTTON,self.OnExit,id=ID_EXIT)
#self.sizer=wx.BoxSizer(wx.VERTICAL)
#self.sizer.Add(self.splitter,1,wx.EXPAND)
#self.sizer.Add(self.sizer2,0,wx.EXPAND)
#self.SetSizer(self.sizer)
#size = wx.DisplaySize()
#self.SetSize(size)
self.sb = self.CreateStatusBar()
#self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnClick, self.list
def OnExit(self,e):
self.Close(True)
def OnSize(self,event):
size = self.GetSize()
self.splitter.SetSashPosition(size.x/2)
self.sb.SetStatusText(os.getcwd())
event.Skip()
def onFuncL(self,event):
print("Left Pane Path is :")
global pathL
print(pathL)
def onFuncR(self,event):
print("Right Pane Path is :")
global pathR
print(pathR)
def DirL(self,event):
#print("dirL")
dlg = wx.TextEntryDialog(self,'Goto Path:','?')
global pathL
dlg.SetValue(pathL)
if dlg.ShowModal() == wx.ID_OK:
itext = dlg.GetValue()
itext2 = addSlash(itext)
dlg.Destroy()
pathL = itext2
p1.update()
def DirR(self,event):
#print("dirR")
dlg = wx.TextEntryDialog(self,'Goto Path:','?')
global pathR
dlg.SetValue(pathR)
if dlg.ShowModal() == wx.ID_OK:
itext = dlg.GetValue()
itext2 = addSlash(itext)
dlg.Destroy()
pathR = itext2
p2.update()
def OnDoubleClick(self,event):
size = self.GetSize()
self.splitter.SetSashPosition(size.x/2)
def OnClick(self, event):
#print event.GetText()
#print event.GetText()
#os.chdir(os.getcwd() + '\\\\' + event.GetText())
pathq = os.getcwd() + '\\' + event.GetText()
pathb = event.GetText()
#print('event ingested into OnClick')
#print(event)
#print(dir(event))
#print(event.Text)
#print(event.Id) #4646 left 6969 right
#print(event.Item)
#print(dir(event.Item))
#print(event.Item.Text)
##event text is the text that we clicked on which was the literal filename
#print event.GetItem()
#print event.GetColumn()
##-1
global pathL
global pathR
if event.Id == 4646:
#print('left verified: pathL = ' + pathL)
pathLprev = pathL
fixedLprev = fixString(pathLprev)
if event.GetText() == '..':
pathL = upDir(fixedLprev)
#print('go up dir')
#print(pathLprev.split('\\'))
else:
#pathL = pathLprev + '\\' + event.GetText()
pathL = fixedLprev + '\\' + event.GetText()
pathL = pathL.replace('\\\\','\\').replace("'[","").replace("]'","")
#print('left new: pathL = ' + pathL)
if os.path.isdir(pathL):
pass
else:
pathL = pathLprev
os.chdir(pathL)
os.system('"' + pathb + '"')
if event.Id == 6969:
#print('right verified: pathR = ' + pathR)
pathRprev = pathR
fixedRprev = fixString(pathRprev)
if event.GetText() == '..':
pathR = upDir(fixedRprev)
else:
pathR = fixedRprev + '\\' + event.GetText()
pathR = pathR.replace('\\\\','\\').replace("'[","").replace("]'","")
#print('right new: pathR = ' + pathR)
if os.path.isdir(pathR):
pass
else:
pathR = pathRprev
os.chdir(pathR)
os.system('"' + pathb + '"')
'''
if os.path.isdir(pathq):
os.chdir(os.getcwd() + '\\' + event.GetText())
else:
#print(pathq)
os.system('"' + pathb + '"')
'''
#print(os.getcwd())
#print(os.listdir('.'))
##print(event.GetEventObject())
pp = event.GetEventObject()
pp.DeleteAllItems()
pp.update()
def startTask(self, event):
taskFrame = TaskFrame(self)
taskFrame.Show()
def startText(self,event):
textFrame = TextFrame(self)
textFrame.Show()
#brb
def startG(self,event):
gFrame = GFrame(self)
gFrame.Show()
class TaskListCtrl(wx.ListCtrl):
def __init__(self, parent, id):
wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT)
self.InsertColumn(0, 'PID')
self.InsertColumn(1, 'Exe')
self.InsertColumn(2, 'HWND')
self.InsertColumn(3, 'Misc')
self.InsertColumn(4,'PATH')
#self.InsertItem(1,"yo","c:\\","135","lol")
##self.InsertItem(1,"yo")
##self.SetItem(0,2,"c:\\")
self.InsertItem(1,"..")
self.getpids()
self.addpids()
print(self.pids)
def getpids(self):
self.pids = psutil.pids()
def addpids(self):
print('length')
print(len(self.pids))
print(self.pids[1])
for i in range(len(self.pids)):
self.InsertItem(1,str(self.pids[i]))
try:
p = psutil.Process(self.pids[i])
str1 = p.exe()
str2 = str1.split('\\')
strexe = str2[len(str2)-1]
#print(str2[len(str2)-1])
#self.SetItem(1,1,str(p.exe()))
self.SetItem(1,1,strexe)
hwnds = []
hwnds = get_hwnds_for_pid(int(self.pids[i]))
if len(hwnds) > 1:
self.SetItem(1,3,"multi")
#for ix in range(len(hwnds)):
#print("wow")
#print(dir(parent))
#global passt2
#passt2.InsertItem(1,str(hwnds[ix]))
#passt2.SetItem(1,2,str(self.pids[i]))
#parent.t2.InsertItem(1,str(hwnds[ix]))
#parent.t2.SetItem(1,2,str(self.pids[i]))
self.SetItem(1,2,str(hwnds[0]))
self.SetItem(1,4,str(str1))
except:
pass
class RightListCtrl(wx.ListCtrl):
def __init__(self,parent,id):
wx.ListCtrl.__init__(self,parent,id,style=wx.LC_REPORT)
self.InsertColumn(0,'HWND')
self.InsertColumn(1,"PID")
self.InsertColumn(2,"Title")
self.SetColumnWidth(2,250)
class TaskFrame(wx.Frame):
def __init__(self, parent):
#wx.Frame.__init__(self, parent, -1, size = (800, 700), style = wx.CAPTION | wx.SYSTEM_MENU | wx.CLOSE_BOX)
wx.Frame.__init__(self, parent, -1, size = (800, 700))
self.SetIcon(wx.Icon("icon.png"))
self.SetTitle("Process Manager")
self.splitter = wx.SplitterWindow(self, ID_SPLITTER,style=wx.SP_BORDER)
self.splitter.SetMinimumPaneSize(50)
self.tbtask = self.CreateToolBar(wx.TB_HORIZONTAL | wx.TB_FLAT)
self.btn1 = self.tbtask.AddTool(721,"L",wx.Bitmap("folder.png"))
self.btn2 = self.tbtask.AddTool(722,"T",wx.Bitmap("timer.png"))
self.tbtask.Realize()
self.timer = wx.Timer(self)
self.timertgt = "" #will contain the HWND to check
self.Bind(wx.EVT_TIMER,self.Tick,self.timer)
self.t1 = TaskListCtrl(self.splitter,11)
self.t2 = RightListCtrl(self.splitter,12)
#global passt2
#passt2 = self.t2
self.splitter.SplitVertically(self.t1,self.t2)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.splitter,135,wx.EXPAND)
self.SetSizer(self.sizer)
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED,self.OnClick,self.t1)
self.Bind(wx.EVT_LIST_ITEM_ACTIVATED,self.RightSideClick,self.t2)
self.Bind(wx.EVT_TOOL,self.dobtn,self.btn1)
self.Bind(wx.EVT_TOOL,self.dobtn2,self.btn2)
def OnClick(self,event):
#print event.Id
#print event.GetText()
hwnds = []
hwnds = get_hwnds_for_pid(int(event.GetText()))
print(hwnds)
if len(hwnds)>=0:
for i in range(len(hwnds)):
self.t2.InsertItem(0,str(hwnds[i]))
self.t2.SetItem(0,1,event.GetText())
#add window title
self.t2.SetItem(0,2,win32gui.GetWindowText(hwnds[i]))
#print(dir(self.splitter))
def RightSideClick(self,event):
print(event.GetText())
time.sleep(0.2)
#win32gui.SetForegroundWindow(int(event.GetText()))
win32gui.ShowWindow(int(event.GetText()),1)
def dobtn(self,event):
#print(dir(self.t1))
#print(help(self.t1.GetItem))
#print(self.t1.GetItemCount())
itemct = int(self.t1.GetItemCount())
#print('self.t1.GetItem(1).GetData() >>')
#print(self.t1.GetItem(1).GetData())
#pdb.set_trace()
txt = self.t1.GetItem(1).Text
#txt = pid
for ict in range(itemct):
txt = self.t1.GetItem(ict).Text
txtHwnd = self.t1.GetItem(ict,2).Text
hwnds = []
if txtHwnd != "":
hwnds = get_hwnds_for_pid(int(txt))
#pdb.set_trace()
for ixy in range(len(hwnds)):
self.t2.InsertItem(0,str(hwnds[ixy]))
self.t2.SetItem(0,1,txt)
self.t2.SetItem(0,2,win32gui.GetWindowText(hwnds[ixy]))
pass
def dobtn2(self,event):
dlg = wx.TextEntryDialog(self,'Monitor title of which HWND?:','?')
#dlg.SetValue(pathL)
if dlg.ShowModal() == wx.ID_OK:
itext = dlg.GetValue()
#itext2 = addSlash(itext)
dlg.Destroy()
self.timertgt = itext
print(itext)
dlg2 = wx.TextEntryDialog(self,'ms interval?:','?')
if dlg2.ShowModal() == wx.ID_OK:
interval = dlg2.GetValue()
dlg2.Destroy()
dlg3 = wx.TextEntryDialog(self,'filename eg history.txt?:','?')
if dlg3.ShowModal() == wx.ID_OK:
global filetgt
filetgt = dlg3.GetValue()
dlg3.Destroy()
self.timer.Start(int(interval)) #timer gets started with the given interval
def Tick(self,event):
print(self.timertgt)
checkTgt(self.timertgt)
'''
class GFrame(PygameDisplay):
def __init__(self,parent,id):
PygameDisplay.__init__(self,parent,id)
#wx.Window.__init__(self, parent, 9996, size = (900,660))
'''
class FileMgr(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self,parent,569,title,(50,50),(800,300))
self.sb = self.CreateStatusBar()
tb = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT)
bt1 = tb.AddTool(701,"Rec",wx.Bitmap("icon.png"))
bt2 = tb.AddTool(702,"PDB",wx.Bitmap("icon.png"))
bt3 = tb.AddTool(703,"DBG",wx.Bitmap("icon.png"))
self.Bind(wx.EVT_TOOL,gorecordA,bt1)
self.Bind(wx.EVT_TOOL,gorecordA,bt2)
self.Bind(wx.EVT_TOOL,mytest2,bt3)
tb.Realize()
self.topsplitter = wx.SplitterWindow(self,808,pos=wx.Point(0,0),size=wx.Size(400,400),style=wx.SP_BORDER,name="TopSplitter")
self.AudioChecker = AudioCheckList(self.topsplitter, 777)
self.recdevct = self.AudioChecker.Count
#self.MonitorChoice = MonitorChoice(self.topsplitter, 888)
self.rightside = MonitorPanel(self.topsplitter,999,self.recdevct)
#self.splitter = wx.SplitterWindow(self.topsplitter, ID_SPLITTER,pos=wx.Point(0,0),size=wx.Size(400,400),style=wx.SP_BORDER,name="Splitter")
self.topsplitter.SplitVertically(self.AudioChecker,self.rightside)
def OnExit(self,e):
self.Close(True)
class AudioCheckList(wx.CheckListBox):
def __init__(self, parent, id):
devicecount = NAudio.Wave.WaveIn.DeviceCount
devicelist = []
for n in range(devicecount):
devicelist.append(NAudio.Wave.WaveIn.GetCapabilities(n).ProductName)
wx.CheckListBox.__init__(self, parent, id,(0,0),(50,50),devicelist)
#https://docs.wxpython.org/gallery.html shows most widgets
#class ASIOChoice(wx.Choice):
#lol
class ASIOChoice(wx.CheckListBox):
def __init__(self, parent, id, pos, size):
global availables
availables = NAudio.Wave.AsioOut.GetDriverNames()
#global asiolist
global asiolist
asiolist = []
for n in range(10):
try:
asiolist.append(availables.Get(n))
except:
pass
print('asiolist?')
print(asiolist)
wx.CheckListBox.__init__(self, parent, id, pos,size, asiolist)
class MonitorChoice(wx.Choice):
#def __init__(self,parent,id):
def __init__(self,parent,id,pos,size):
devicecount = NAudio.Wave.WaveOut.DeviceCount
devicelist = []
for n in range(devicecount):
devicelist.append(NAudio.Wave.WaveOut.GetCapabilities(n).ProductName)
#wx.Choice.__init__(self, parent, id, (0,0), (50,50), devicelist)
wx.Choice.__init__(self, parent, id, pos, size, devicelist)
class MonitorPanel(wx.Panel):
def __init__(self,parent,id, countt):
wx.Panel.__init__(self,parent,id, (0,0), (50,50), 0, "Monitor-Panel")
for xx in range(countt):
globals()["mon" + str(xx)] = MonitorChoice(self, 1200 + xx, (0+(xx*5),0+(xx*23)), (120,23))
for xx in range(countt):
globals()["monbt" + str(xx)] = wx.CheckBox(self,1400 + xx, "mon"+str(xx), (127+(xx*5),0+(xx*23)), (70,23))
global asiochoice
asiochoice = ASIOChoice(self, 5678,(220,0),(200,200))
########
def gorecordA(anevent):
devicecount = NAudio.Wave.WaveIn.DeviceCount
devicelist = []
for n in range(devicecount):
devicelist.append(NAudio.Wave.WaveIn.GetCapabilities(n).ProductName)
print(devicelist)
traceyesno = 0
if traceyesno == 0:
pass
elif traceyesno == 1:
pdb.set_trace()
#checkedlist = recordbox.AudioChecker.GetChecked()
checkedlist = recordbox.AudioChecker.GetChecked()
print(checkedlist)
#pdb.set_trace()
#filething.rightside.
#for xx in range(devicecount):
#global globals()["waveIn" + str(xx)]
## replacing range devicecount with for xx in checkedlist:
for xx in checkedlist:
globals()["waveIn" + str(xx)] = NAudio.Wave.WaveIn()
for xx in checkedlist:
globals()["waveIn" + str(xx)].DeviceNumber = xx
for xx in checkedlist:
globals()["waveIn" + str(xx) + "capz"] = NAudio.Wave.WaveIn.GetCapabilities(xx)
#globals()["waveIn" + str(xx) + "capz_a"] = globals()["waveIn" + str(xx) + "capz"].SupportsWaveFormat(NAudio.Wave.SupportedWaveFormat.WAVE_FORMAT_44S16)
globals()["waveIn" + str(xx) + "capz_a"] = globals()["waveIn" + str(xx) + "capz"].SupportsWaveFormat(NAudio.Wave.SupportedWaveFormat.WAVE_FORMAT_96S16)
print(globals()["waveIn" + str(xx) + "capz_a"])
#globals()["waveIn" + str(xx) + "capz"] = globals()["waveIn" + str(xx)].GetCapabilities()
#__1__#pdb.set_trace()
##global waveIn
##global waveIn2
##global waveIn3
###waveIn = NAudio.Wave.WaveIn()
###waveIn2 = NAudio.Wave.WaveIn()
###waveIn3 = NAudio.Wave.WaveIn()
####waveIn.DeviceNumber = 0
####waveIn2.DeviceNumber = 1
####waveIn3.DeviceNumber = 2
fourfour = 44100
foureight = 48000
channels = 2
for xx in checkedlist:
globals()["waveIn" + str(xx)].WaveFormat = NAudio.Wave.WaveFormat(fourfour,channels)
print("waveIn" + str(xx) + ": " + str(globals()["waveIn" + str(xx)].WaveFormat.bitsPerSample))
#24-bit recording can't be done haha
#globals()["waveIn" + str(xx)].WaveFormat.bitsPerSample = 24
#print("waveIn" + str(xx) + ": " + str(globals()["waveIn" + str(xx)].WaveFormat.bitsPerSample))
#####waveIn.WaveFormat = NAudio.Wave.WaveFormat(fourfour,channels)
#####waveIn2.WaveFormat = NAudio.Wave.WaveFormat(fourfour,channels)
#####waveIn3.WaveFormat = NAudio.Wave.WaveFormat(fourfour,channels)
import datetime
timestampz = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
for xx in checkedlist:
globals()["writer" + str(xx)] = NAudio.Wave.WaveFileWriter(timestampz + "." + str(xx) + '.wav', globals()["waveIn" + str(xx)].WaveFormat)
##writer1 = NAudio.Wave.WaveFileWriter(timestampz + ".1.wav", waveIn.WaveFormat)
##writer2 = NAudio.Wave.WaveFileWriter(timestampz + ".2.wav", waveIn2.WaveFormat)
##writer3 = NAudio.Wave.WaveFileWriter(timestampz + ".3.wav", waveIn3.WaveFormat)
def wave0write(sender, e):
if 1 == 1:
writer0.WriteData(e.Buffer,0,e.BytesRecorded)
writer0.Flush()
def wave1write(sender, e):
if 1 == 1:
writer1.WriteData(e.Buffer,0,e.BytesRecorded)
writer1.Flush()
def wave2write(sender, e):
if 1 == 1:
writer2.WriteData(e.Buffer,0,e.BytesRecorded)
writer2.Flush()
def wave3write(sender, e):
if 1 == 1:
writer3.WriteData(e.Buffer,0,e.BytesRecorded)
writer3.Flush()
def wave4write(sender, e):
if 1 == 1:
writer4.WriteData(e.Buffer,0,e.BytesRecorded)
writer4.Flush()
def wave5write(sender, e):
if 1 == 1:
writer5.WriteData(e.Buffer,0,e.BytesRecorded)
writer5.Flush()
def wave6write(sender, e):
if 1 == 1:
writer6.WriteData(e.Buffer,0,e.BytesRecorded)
writer6.Flush()
def wave7write(sender, e):
if 1 == 1:
writer7.WriteData(e.Buffer,0,e.BytesRecorded)
writer7.Flush()
def wave8write(sender, e):
if 1 == 1:
writer8.WriteData(e.Buffer,0,e.BytesRecorded)
writer8.Flush()
def wave9write(sender, e):
if 1 == 1:
writer9.WriteData(e.Buffer,0,e.BytesRecorded)
writer9.Flush()
def wave10write(sender, e):
if 1 == 1:
writer10.WriteData(e.Buffer,0,e.BytesRecorded)
writer10.Flush()
#for xx in range(devicecount):
#globals()["waveIn" + str(xx)].DataAvailable += locals()["wave"+str(xx)+"write"]
##for xx in range(devicecount):
'''
if 'waveIn0' in globals():
waveIn0.DataAvailable += wave0write
waveIn0.StartRecording()
'''
if 0 in checkedlist:
waveIn0.DataAvailable += wave0write
waveIn0.StartRecording()
if 1 in checkedlist:
waveIn1.DataAvailable += wave1write
waveIn1.StartRecording()
if 2 in checkedlist:
waveIn2.DataAvailable += wave2write
waveIn2.StartRecording()
if 3 in checkedlist:
waveIn3.DataAvailable += wave3write
waveIn3.StartRecording()
if 4 in checkedlist:
waveIn4.DataAvailable += wave4write
waveIn4.StartRecording()
if 5 in checkedlist:
waveIn5.DataAvailable += wave5write
waveIn5.StartRecording()
if 6 in checkedlist:
waveIn6.DataAvailable += wave6write
waveIn6.StartRecording()
if 7 in checkedlist:
waveIn7.DataAvailable += wave7write
waveIn7.StartRecording()
if 8 in checkedlist:
waveIn8.DataAvailable += wave8write
waveIn8.StartRecording()
if 9 in checkedlist:
waveIn9.DataAvailable += wave9write
waveIn9.StartRecording()
if 10 in checkedlist:
waveIn10.DataAvailable += wave10write
waveIn10.StartRecording()
#waveIn.DataAvailable += wave1write
#waveIn2.DataAvailable += wave2write
#waveIn3.DataAvailable += wave3write
#waveIn.StartRecording()
#waveIn2.StartRecording()
#waveIn3.StartRecording()
recordbox.sb.SetStatusText("recording started")
'''
def gorecord(shelf): #unused. for reference.
devicecount = NAudio.Wave.WaveIn.DeviceCount
devicelist = []
for n in range(devicecount):
devicelist.append(NAudio.Wave.WaveIn.GetCapabilities(n).ProductName)
print(devicelist)
waveIn = NAudio.Wave.WaveIn()
waveIn2 = NAudio.Wave.WaveIn()
waveIn3 = NAudio.Wave.WaveIn()
waveIn.DeviceNumber = 0
waveIn2.DeviceNumber = 1
waveIn3.DeviceNumber = 2
fourfour = 44100
foureight = 48000
channels = 2
waveIn.WaveFormat = NAudio.Wave.WaveFormat(fourfour,channels)
waveIn2.WaveFormat = NAudio.Wave.WaveFormat(fourfour,channels)
waveIn3.WaveFormat = NAudio.Wave.WaveFormat(fourfour,channels)
import datetime
timestampz = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
writer1 = NAudio.Wave.WaveFileWriter(timestampz + ".1.wav", waveIn.WaveFormat)
writer2 = NAudio.Wave.WaveFileWriter(timestampz + ".2.wav", waveIn2.WaveFormat)
writer3 = NAudio.Wave.WaveFileWriter(timestampz + ".3.wav", waveIn3.WaveFormat)
def wave1write(sender, e):
if 1 == 1:
#print('ifone')
##print(e.Buffer)
##print(e.BytesRecorded)
writer1.WriteData(e.Buffer,0,e.BytesRecorded)
writer1.Flush()
def wave2write(sender, e):
#print('okay2')
if 1 == 1:
writer2.WriteData(e.Buffer,0,e.BytesRecorded)
writer2.Flush()
def wave3write(sender, e):
#print('okay3')
if 1 == 1:
writer3.WriteData(e.Buffer,0,e.BytesRecorded)
writer3.Flush()
waveIn.DataAvailable += wave1write
waveIn2.DataAvailable += wave2write
waveIn3.DataAvailable += wave3write
waveIn.StartRecording()
waveIn2.StartRecording()
waveIn3.StartRecording()
'''
def debog(shelf):
pdb.set_trace()
#https://markheath.net/category/naudio
def mytest(shelf):
filething.sb.SetStatusText(str(filething.AudioChecker.GetCheckedItems()))
def asio1write(sender, e):
samples = e.GetAsInterleavedSamples()
asio1writer.WriteSamples(samples,0,samples.Length)
asio1writer.Flush()
def mytest2(shelf):
filething.sb.SetStatusText(str(asiochoice.GetCheckedStrings() ) )
global asiodev
asiodev = NAudio.Wave.AsioOut(asiochoice.GetCheckedStrings()[0])
#stathreadattribute needed > https://github.com/pythonnet/pythonnet/issues/108
asiodev_channelcount = asiodev.DriverInputChannelCount #6 for Zoom H6
#https://github.com/naudio/NAudio/blob/master/Docs/AsioRecording.md
asiodev.InitRecordAndPlayback(None, asiodev_channelcount, 44100)
import datetime
timestampz = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
#asiowaveformat = NAudio.Wave.WaveFormat(44100,24,asiodev_channelcount)
asiowaveformat = NAudio.Wave.WaveFormat(44100,16,asiodev_channelcount)
global asio1writer
asio1writer = NAudio.Wave.WaveFileWriter(timestampz + "." + 'poly' + '.wav', asiowaveformat)
asiodev.AudioAvailable += asio1write
asiodev.Play()
#pdb.set_trace()
class GFrame(wx.Frame):
def __init__(self,parent):
wx.Frame.__init__(self,parent,9996,size=(900,600))
#GFrame contains a PygameDisplay called .display. this GFrame is called gFrame. created by startG in the filething .tb
self.display = PygameDisplay(self,9999)
self.tbg = self.CreateToolBar(wx.TB_HORIZONTAL | wx.TB_FLAT)
self.btn1 = self.tbg.AddTool(9901,"L",wx.Bitmap("folder.png"))
self.btn2 = self.tbg.AddTool(9902,"S",wx.Bitmap("floopy16x16.png"))
self.btn3 = self.tbg.AddTool(9903,"S",wx.Bitmap("dead.png"))
self.btn4 = self.tbg.AddTool(9904,"S",wx.Bitmap("dnarr.png"))
self.btn5 = self.tbg.AddTool(9905,"S",wx.Bitmap("uparr.png"))
self.btn6 = self.tbg.AddTool(9906,"R",wx.Bitmap("icon.png"))
self.btn7 = self.tbg.AddTool(9907,"R",wx.Bitmap("icon.png"))
self.btn8 = self.tbg.AddTool(9908,"R",wx.Bitmap("icon-pause.gif"))
self.btn9 = self.tbg.AddTool(9909,"R",wx.Bitmap("icon-play.gif"))
self.tbg.Realize()
self.Bind(wx.EVT_TOOL,self.b1proc,self.btn1)
self.Bind(wx.EVT_TOOL,self.b2proc,self.btn2)
self.Bind(wx.EVT_TOOL,self.b3proc,self.btn3)
self.Bind(wx.EVT_TOOL,self.b4proc,self.btn4)
self.Bind(wx.EVT_TOOL,self.b5proc,self.btn5)
self.Bind(wx.EVT_TOOL,self.PLAYBUTTON,self.btn6)
self.Bind(wx.EVT_TOOL,self.SPAWNRECORDER,self.btn7)
self.Bind(wx.EVT_TOOL,self.PANBUTTON,self.btn8)
self.Bind(wx.EVT_TOOL,self.PANBUTTON2,self.btn9)
self.Bind(wx.EVT_CLOSE, self.OnClose)
#try:
#import clr
#clr.AddReference('NAudio') #ildasm used on NAudio.dll showed this was the namespace
#import NAudio as NAudio
#print("import clr succeeded, NAudio imported")
#except:
#print("import clr failed")
def Kill(self,event):
self.display.Kill(event)
self.Destroy()
def b1proc(self, event):
dlg = wx.TextEntryDialog(self,'Filepath:','?')
if dlg.ShowModal() == wx.ID_OK:
filename_0 = dlg.GetValue()
dlg.Destroy()
#self.display.File(filename_0)
self.display.File2(filename_0)
#self.scite1.SaveFile(filename_0)
def b2proc(self, event):
dlg = wx.TextEntryDialog(self,'Save image:','?')