-
Notifications
You must be signed in to change notification settings - Fork 11
/
Unit1.pas
1520 lines (1330 loc) · 50 KB
/
Unit1.pas
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
{History:
- 2008:
Weiterentwicklung, Wechsel von Delphi -> Lazarus
Umbenennung von APIV (API Verwalter??) in API Manager
(wegen Namenskonflikt einem anderen APIV von 2000)
- Ende 2002:
Fertigstellung der Version 2
- 2001:
Erste Veröffentlichung von APIV (entweder Version 1 oder 2)
}
unit Unit1;
interface
{$mode delphi}{$h+}
uses
LResources, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, ComCtrls,registry,
windowfuncs, Spin,sysutils,Menus,FileUtil,
CheckLst,TreeListView,windowcontrolfuncs;
type
{ TmainForm }
TmainForm = class(TForm)
alphatrans_cb: TCheckBox;
Button1: TButton;
callAPI: TButton;
callAPIDLL: TEdit;
callAPIProc: TEdit;
callAPIParameter: TEdit;
Label14: TLabel;
Label16: TLabel;
callAPIResult_lbl: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
systemProperties: TListView;
windowsListFilterThread: TEdit;
Label12: TLabel;
windowProcessIDedt: TEdit;
windowThreadIdEdt: TEdit;
showHandle: TButton;
Label38: TLabel;
posRBEdt: TEdit;
sizeEdt: TEdit;
Label37: TLabel;
ownerWnd_edt: TEdit;
hideAPIVwhenSearching: TCheckBox;
Label35: TLabel;
Label36: TLabel;
windowStyles_lb: TLabel;
windowExStyles_lb: TLabel;
windowStyles: TCheckListBox;
windowListFilterParentUp: TButton;
windowsListfilterDirectChilds: TCheckBox;
colorkey_cb: TCheckBox;
userdata_edt: TEdit;
windowExStyles: TCheckListBox;
wndproc_edt: TEdit;
Label33: TLabel;
Label34: TLabel;
windowListFilterParent_edt: TEdit;
windowListFilterProgram_edt: TEdit;
Label30: TLabel;
Label31: TLabel;
Label32: TLabel;
optwinconst_Edt: TEdit;
Label29: TLabel;
messagemes_cb: TComboBox;
Label22: TLabel;
Label25: TLabel;
lablparam: TLabel;
labwparam: TLabel;
messagelparam_edt: TEdit;
messagewparam_edt: TEdit;
Panel2: TPanel;
windowPropChange: TMenuItem;
windowPropRemoveItem: TMenuItem;
windowAddProperty: TMenuItem;
windowPropertyListPopup: TPopupMenu;
windowPropertyList: TListView;
mouseRefreshAllLive: TCheckBox;
linksoben: TPanel;
miniScreen: TPanel;
mouseToolImage: TImage;
Label1: TLabel;
Label27: TLabel;
Label28: TLabel;
mouseHandleEdt: TEdit;
Label26: TLabel;
mouseWindowTextEdt: TEdit;
mouseWindowClassEdt: TEdit;
mouseWindowProgramEdt: TEdit;
mouseWindowFamily: TListView;
PageControl2: TPageControl;
PaintBox1: TPaintBox;
parentWndCmb: TComboBox;
posLTEdt: TEdit;
Label2: TLabel;
Label24: TLabel;
rechtsunten: TPanel;
alphatrans_sp: TSpinEdit;
colorKeyShape: TShape;
stayOnTopCb: TCheckBox;
classNameEdt: TEdit;
handleEdt: TEdit;
Label23: TLabel;
TabSheet6: TTabSheet;
windowListTabSheet: TTabSheet;
findTimer: TTimer;
Label7: TLabel;
Panel1: TPanel;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
processTabSheet: TTabSheet;
Panel5: TPanel;
displayProcesses: TButton;
TabSheet2: TTabSheet;
Button26: TButton;
TabSheet5: TTabSheet;
CheckBox3: TCheckBox;
Edit14: TEdit;
Label21: TLabel;
ImageList1: TImageList;
windowPropertySheet: TScrollBox;
Label8: TLabel;
enabledCb: TCheckBox;
visibleCb: TCheckBox;
unicodeCb: TCheckBox;
showStateCmb: TComboBox;
messageSend_btn: TButton;
windowtextEdt: TEdit;
Splitter2: TSplitter;
Label9: TLabel;
Label10: TLabel;
ComboBox2: TComboBox;
Label11: TLabel;
processidedit: TEdit;
checkhex: TCheckBox;
Label13: TLabel;
labclassname: TLabel;
Label15: TLabel;
Button5: TButton;
ColorDialog1: TColorDialog;
// ss1: Tss;
procedure Button1Click(Sender: TObject);
procedure callAPIClick(Sender: TObject);
procedure enabledCbChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure messagemes_cbKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ownerWnd_edtDblClick(Sender: TObject);
procedure parentWndCmbDblClick(Sender: TObject);
procedure posLTEdtKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
);
procedure processTabSheetResize(Sender: TObject);
procedure showHandleClick(Sender: TObject);
procedure processTabSheetShow(Sender: TObject);
procedure systemPropertiesAdvancedCustomDrawSubItem(
Sender: TCustomListView; Item: TListItem; SubItem: Integer;
State: TCustomDrawState; Stage: TCustomDrawStage; var DefaultDraw: Boolean
);
procedure TabSheet2Show(Sender: TObject);
procedure windowListDblClick(Sender: TObject);
procedure windowListFilterParentUpClick(Sender: TObject);
procedure windowListFilterParent_edtChange(Sender: TObject);
procedure windowProcessIDedtDblClick(Sender: TObject);
procedure windowPropChangeClick(Sender: TObject);
procedure windowPropertySheetClick(Sender: TObject);
procedure windowsListfilterDirectChildsChange(Sender: TObject);
procedure colorKeyShapeMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure windowListFilterProgram_edtKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure windowConstOpenEvent(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure linksobenMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure ComboBox2Change(Sender: TObject);
procedure processideditChange(Sender: TObject);
procedure checkhexClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Label14Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure ComboBox3Change(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure updatePropertyKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Button19Click(Sender: TObject);
procedure Button26Click(Sender: TObject);
procedure CheckBox3Click(Sender: TObject);
procedure displayProcessesClick(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure findTimerTimer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure messageSend_btnClick(Sender: TObject); //
procedure mouseToolImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure mouseToolImageMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PageControl1Change(Sender: TObject);
procedure PaintBox1Click(Sender: TObject);
procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure PaintBox1Paint(Sender: TObject);
procedure parentwndEdtDblClick(Sender: TObject);
procedure windowListTabSheetShow(Sender: TObject);
procedure windowAddPropertyClick(Sender: TObject);
procedure windowListKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState
);
procedure windowListSelectItem(Sender: TObject; Item: TTreeListItem);
procedure windowPropertyChanged1(Sender: TObject);
procedure windowPropertyListChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
procedure windowPropertyListDeletion(Sender: TObject; Item: TListItem);
procedure windowPropRemoveItemClick(Sender: TObject);
procedure windowStylesClickCheck(Sender: TObject);
procedure windowStylesItemClick(Sender: TObject; Index: integer);
procedure windowtextEdtChange(Sender: TObject);
procedure windowTreeListExpandItem(sender: TObject; item: TTreeListItem);
private
{ Private-Deklarationen}
procedure WM_HELP(var message:TMessage);message WM_HELP;
procedure WM_SYSCOMMAND(var message:TMessage);message WM_SYSCOMMAND;
//mouseToolActive: boolean;
currentMouseWindow:HWND;
currentWindow:HWND;
displayCalls: longint;
niceVisible: boolean;
procedure niceSetVisible(vis: boolean; needMouseEvents: boolean);
procedure displayProperty(prop:TObject);
procedure changeProperty(prop:TObject);
//Fensterliste
windowTreeList: TTreeListView;
procedure displayWindows(itemExtend:TTreeListItem=nil);
procedure openWindowsConst;
//Processliste
processTreeList: TTreeListView;
//System/Sonstiges
procedure displaySysProperties();
public
{ Public-Deklarationen}
// procedure MessageHandler;
end;
var
edi:TEdit;
mainForm: TmainForm;
status:integer=0;
helpon:boolean=false;
implementation
uses TLHelp32,proc9, wstyles, help, bbutils, win32proc, applicationConfig,winConstWindow;
const
crScanner:integer=101;
{$R cursor.res}
function getWindowClassNameToDisplay(wnd:hwnd):string;
begin
Result:=GetWindowClassNameS(wnd)+' ('+Cardinal2Str(GetClassLong(wnd,GCW_ATOM))+')';
end;
function GetFileNameFromHandleToDisplay(wnd:hwnd):string;
var pid:dword;
begin
GetWindowThreadProcessId(wnd,@pid);
Result:=GetFileNameFromHandle(wnd)+' ('+Cardinal2Str(pid)+')';
end;
procedure TmainForm.WM_HELP(var message:TMessage);
var helpinfo:tHELPINFO;
comp,ocomp,tcomp:TWinControl;
i:integer;
begin
helpon:=false;
helpinfo:=tHELPINFO(pointer(message.LParam)^);
comp:=mainForm;ocomp:=nil;
while (comp<>ocomp) do begin
if ocomp<>nil then
helpinfo.MousePos:=comp.ScreenToClient(ocomp.ClientToScreen( helpinfo.MousePos))
else
helpinfo.MousePos:=comp.ScreenToClient(helpinfo.MousePos);
ocomp:=comp;
for i:=comp.ControlCount-1 downto 0 do begin
if not (comp.Controls[i] is TWinControl) then continue;
tcomp:=comp.Controls[i] as TWinControl;
if (tcomp.left<helpinfo.MousePos.x) and
(tcomp.Top<helpinfo.MousePos.y) and
(tcomp.left+tcomp.Width>helpinfo.MousePos.x) and
(tcomp.Top+tcomp.Height>helpinfo.MousePos.y) then begin
comp:=tcomp;
break;
end;
end;
// comp:=comp.ControlAtPos(helpinfo.MousePos,true) as TWinControl;
end;
if (comp<>nil) and (comp.hint<>'') then
ShowMessage(comp.hint)
else
ShowMessage('Keine Hilfe verfügbar');
inherited;
end;
procedure TmainForm.WM_SYSCOMMAND(var message:TMessage);
begin
if message.WParam=SC_CONTEXTHELP then begin
if helpon then begin
helpform.ShowModal;
helpon:=false;
exit;
end;
helpon:=true;
end;
inherited;
end;
procedure TmainForm.niceSetVisible(vis: boolean; needMouseEvents: boolean);
var i:longint;
begin
if niceVisible=vis then exit;
niceVisible:=vis;
if runonNT then begin;
if vis then begin
for i:=7 to 25 do begin
windowfuncs.SetLayeredWindowAttributes(handle,0,10*i+5,LWA_ALPHA);
Application.ProcessMessages;
end;
windowfuncs.SetLayeredWindowAttributes(handle,0,0,0);
if (PageControl2.ActivePage=windowListTabSheet) or
(PageControl1.ActivePage=processTabSheet) then //TreeList doesn't like layered windows
SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, GWL_EXSTYLE) and not WS_EX_LAYERED);
end else begin
SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, GWL_EXSTYLE) or WS_EX_LAYERED);
Application.ProcessMessages;
for i:=25 downto 7 do begin
windowfuncs.SetLayeredWindowAttributes(handle,0,10*i,LWA_ALPHA);
Application.ProcessMessages;
if niceVisible then exit;
end;
end;
end else begin
if needMouseEvents then exit;
visible:=vis;
end;
end;
function WindowPropertyEnumProc(wnd:HWND; name:LPTSTR; hData:HANDLE; listView: TListView):boolean;stdcall;
var nameStr: array[0..255] of char;
begin
with listView.Items.add do begin
if dword(name) and $FFFF0000 =0 then
if GlobalGetAtomName(Atom(name),@nameStr[0],255) <> 0 then
name:=@nameStr[0];
caption:=string(name);
subitems.add(Cardinal2Str(hdata));
subitems.add(caption); //need old name when renaming
end;
result:=true;
end;
procedure TmainForm.displayProperty(prop: TObject);
var propEdt:TEdit;
rect:TRect;
tempHandle: THandle;
parent: hwnd;
s:string;
color:COLORREF;
i,flags:longint;
alpha:byte;
begin
displayCalls+=1;
try
if prop=handleEdt then handleEdt.Text:=Cardinal2Str(currentWindow)
else if prop=parentWndCmb then begin
parent:=GetParent(currentWindow);
parentWndCmb.Clear;
parentWndCmb.Text:=Cardinal2Str(parent);
while parent<>0 do begin
s:=GetWindowTextS(parent);
if s<>'' then parentWndCmb.Items.Add(Cardinal2Str(parent) + ' - '+s)
else parentWndCmb.Items.Add(Cardinal2Str(parent));
parent:=GetParent(parent);
end;
end else if prop=windowtextEdt then windowtextEdt.Text:=GetWindowTextS(currentWindow)
else if prop=ownerWnd_edt then ownerWnd_edt.Text:=Cardinal2Str(GetWindow(currentWindow,GW_OWNER))
else if prop=classNameEdt then classNameEdt.text:=getWindowClassNameToDisplay(currentWindow)
else if prop=enabledCb then enabledCb.Checked:=IsWindowEnabled(currentWindow)
else if prop=visibleCb then visibleCb.Checked:=IsWindowVisible(currentWindow)
else if prop=unicodeCb then unicodeCb.Checked:=IsWindowUnicode(currentWindow)
else if prop=stayOnTopCb then stayOnTopCb.Checked:=GetWindowLong(currentWindow,GWL_EXSTYLE) and WS_EX_TOPMOST = WS_EX_TOPMOST
else if prop=showStateCmb then begin
case getshowwindow(currentWindow) of
SW_MAXIMIZE:showStateCmb.ItemIndex:=2;
SW_MINIMIZE:showStateCmb.ItemIndex:=1;
else showStateCmb.ItemIndex:=0;
end;
end else if (prop=posLTEdt) or (prop=posRBEdt) or (prop=sizeEdt) then begin
FillChar(rect,sizeof(rect),0);
GetWindowRect(currentWindow, rect);
windows.ScreenToClient(getParent(currentWindow),rect.TopLeft);
windows.ScreenToClient(getParent(currentWindow),rect.BottomRight);
posLTEdt.Text:='('+IntToStr(rect.left) + ', '+IntToStr(rect.top)+')';
posRBEdt.Text:='('+IntToStr(rect.Right) + ', '+IntToStr(rect.Bottom)+')';
sizeEdt.Text:=IntToStr(rect.Right-rect.Left) + 'x'+IntToStr(rect.Bottom-rect.Top);
end else if (prop=alphatrans_cb) or (prop=alphatrans_sp) or
(prop=colorkey_cb) or (prop=colorKeyShape) then begin
if runonNT and GetWindowAlphaColorKey(currentWindow,color,alpha,flags) then begin
alphatrans_cb.Caption:='Transparent:';
colorkey_cb.Caption:='ColorKey:';
alphatrans_cb.Checked:=flags and lwa_alpha = lwa_alpha;
colorkey_cb.Checked:=flags and lwa_colorkey= lwa_colorkey;
if alphatrans_cb.Checked then
alphatrans_sp.Value:=alpha;//trunc(100-(alpha * 100) / 255);
if colorkey_cb.Checked then
colorKeyShape.Brush.Color:=color;
end else begin
alphatrans_cb.Caption:='Transparent??';
colorkey_cb.Caption:='ColorKey??';
end;
end else if prop=windowPropertyList then begin
windowPropertyList.Clear;
EnumPropsEx(currentWindow,@WindowPropertyEnumProc,lparam(windowPropertyList));
end else if prop=messagemes_cb then begin
// messagemes_cb.items.Text:='WM_DESTROY ($0002)'#13#10'WM_CLOSE ($0010)'#13#10'WM_QUIT ($0012)'#13#10+
// 'WM_ENDSESSION ($0016)'#13#10'WM_SHOWWINDOW ($0018)'#13#10'WM_SETCURSOR ($0020)'#13#10+
// 'WM_NEXTDLGCTL ($0028;
messagemes_cb.items.Clear;
for i:=1 to $00A9 do
if not strbeginswith(WM_To_String(i),'Unknown') then
messagemes_cb.items.Add(WM_To_String(i)+' = '+Cardinal2Str(i)+';');
for i:=$100 to $03E8 do
if not strbeginswith(WM_To_String(i),'Unknown') then
messagemes_cb.items.Add(WM_To_String(i)+' = '+Cardinal2Str(i)+';');
end else if prop=userdata_edt then userdata_edt.Text:=Cardinal2Str(cardinal(GetWindowLong(currentWindow,GWL_USERDATA)))
else if prop=wndproc_edt then wndproc_edt.Text:=Cardinal2Str(cardinal(GetWindowLong(currentWindow,GWL_WNDPROC)))
else if prop=windowStyles then windowStylesToCheckListBox(currentWindow,windowStyles,windowStyles_lb)
else if prop=windowExStyles then windowExStylesToCheckListBox(currentWindow,windowExStyles,windowExStyles_lb)
else if (prop=windowProcessIDedt) or (prop=windowThreadIdEdt) then begin
tempHandle:=0;
windowThreadIdEdt.Text:=Cardinal2Str(GetWindowThreadProcessId(currentWindow,@tempHandle));
windowProcessIDedt.Text:=Cardinal2Str(tempHandle);
end;
;
finally
displayCalls-=1;
end;
end;
procedure TmainForm.changeProperty(prop: TObject);
var i,flags:longint;
s,sf:string;
rec: trect;
begin
if displayCalls>0 then exit;
if prop=handleEdt then begin
//Alle Werte aktualisieren
currentWindow:=Str2Cardinal(handleEdt.Text);
for i:=0 to windowPropertySheet.ControlCount-1 do
if windowPropertySheet.Controls[i].Tag=1 then
// if Controls[i].Parent=windowPropertySheet then
displayProperty(windowPropertySheet.Controls[i]);
{ displayProperty(parentwndEdt);
displayProperty(windowtextEdt);
displayProperty(classNameEdt);
displayProperty(enabledCb);
displayProperty(visibleCb);
displayProperty(unicodeCb);
displayProperty(stayOnTopCb);
displayProperty(showStateCmb);}
end else if prop=parentWndCmb then begin
s:=parentWndCmb.Text;
if pos(' - ',s)>0 then s:=splitGet(' - ',s);
windows.SetParent(currentWindow,Str2Cardinal(s));
end else if prop=windowtextEdt then SetWindowText(currentWindow,pchar(windowtextEdt.Text))
else if prop=enabledCb then EnableWindow(currentWindow,enabledCb.Checked)
else if prop=visibleCb then begin
if visibleCb.Checked then showWindow(currentWindow,sw_show)
else ShowWindow(currentWindow,SW_HIDE);
end else if prop=unicodeCb then enabledCb.Checked:=IsWindowUnicode(currentWindow)
else if prop=stayOnTopCb then begin
if stayOnTopCb.Checked then SetWindowPos(currentWindow,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE)
else SetWindowPos(currentWindow,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);
end else if prop=showStateCmb then begin
case showStateCmb.ItemIndex of
0: ShowWindow(currentWindow,SW_NORMAL);
1: ShowWindow(currentWindow,SW_MINIMIZE);
2: ShowWindow(currentWindow,SW_MAXIMIZE);
end;
end else if prop=posLTEdt then begin
s:=StringReplace(posLTEdt.text,' ','',[rfReplaceAll]);
delete(s,1,pos('(',s));
rec.Left:=StrToInt(splitGet(',',s));
rec.top:=StrToInt(splitGet(')',s));
SetWindowPos(currentWindow,0,rec.Left,rec.top,0,0,SWP_NOACTIVATE or SWP_NOZORDER or SWP_NOSIZE);
RedrawWindow(currentWindow,nil,0,RDW_ERASE or RDW_INVALIDATE);
end else if prop=posRBEdt then begin
s:=StringReplace(posLTEdt.text,' ','',[rfReplaceAll]);
delete(s,1,pos('(',s));
rec.Left:=StrToInt(splitGet(',',s));
rec.top:=StrToInt(splitGet(')',s));
s:=StringReplace(posRBEdt.text,' ','',[rfReplaceAll]);
delete(s,1,pos('(',s));
rec.Right:=StrToInt(splitGet(',',s));
rec.Bottom:=StrToInt(splitGet(')',s));
SetWindowPos(currentWindow,0,0,0,rec.Right-Rec.Left,rec.Bottom-Rec.Top,SWP_NOACTIVATE or SWP_NOZORDER or SWP_NOMOVE)
end else if prop=sizeEdt then begin
s:=StringReplace(sizeEdt.text,' ','',[rfReplaceAll]);
rec.Right:=StrToInt(splitGet('x',s));
rec.Bottom:=StrToInt(s);
SetWindowPos(currentWindow,0,0,0,rec.Right,rec.Bottom,SWP_NOACTIVATE or SWP_NOZORDER or SWP_NOMOVE)
end else if (prop=alphatrans_sp) or (prop=alphatrans_cb) or
(prop=colorkey_cb) or (prop=colorKeyShape) then begin
{ flags:=GetWindowLong(currentWindow,GWL_EXSTYLE);
if colorkey_cb.checked or alphatrans_cb.checked then begin
if flags and WS_EX_LAYERED <> WS_EX_LAYERED then
SetWindowLong(currentWindow,GWL_EXSTYLE,flags or WS_EX_LAYERED); }
flags:=0;
if colorkey_cb.checked then flags+=LWA_COLORKEY;
if alphatrans_cb.checked then flags+=LWA_ALPHA;
if flags <> 0 then windowfuncs.SetLayeredWindowAttributes(currentWindow,colorKeyShape.Brush.Color,alphatrans_sp.Value,flags)
else SetWindowLong(currentWindow,GWL_EXSTYLE,GetWindowLong(currentWindow,GWL_EXSTYLE) and not WS_EX_LAYERED);
{end else if flags and WS_EX_LAYERED = WS_EX_LAYERED then
SetWindowLong(currentWindow,GWL_EXSTYLE,flags and not WS_EX_LAYERED);}
end else if prop=userdata_edt then SetWindowLong(currentWindow,GWL_USERDATA,Str2Cardinal(userdata_edt.Text));
;
displayProperty(prop);
end;
procedure TmainForm.displayWindows(itemExtend:TTreeListItem);
var i,j:longint;
wnd,parentWnd:hwnd;
parentItem: TTreeListItem;
list:TIntArray;
s,programS:string;
filterParentWnd: thandle;
filterProgram: string;
begin
filterProgram:=lowercase(windowListFilterProgram_edt.Text);
if itemExtend <> nil then filterParentWnd:=Str2Cardinal(itemExtend.Text)
else if windowListFilterParent_edt.text<>'' then filterParentWnd:=Str2Cardinal(windowListFilterParent_edt.text)
else filterParentWnd:=0;
list:=EnumWindowsToIntList(filterParentWnd,not windowsListfilterDirectChilds.Checked);
windowTreeList.BeginUpdate;
if itemExtend=nil then windowTreeList.Items.Clear
else itemExtend.SubItems.Clear;
for i:=0 to high(list) do begin
wnd:=list[i];
programS:=GetFileNameFromHandleToDisplay(wnd);
if (filterProgram<>'') and (pos(filterProgram,LowerCase(programS))<=0) then continue;
parentWnd:=GetParent(wnd);
parentItem:=nil;
if (parentWnd<>0) and (filterParentWnd <> 0) then
parentItem:=windowTreeList.Items.FindItemWithText(Cardinal2Str(parentWnd));
with windowTreeList.Items.Add(parentItem) do begin
if (filterParentWnd = 0) then
if GetWindow(wnd,GW_CHILD)<>0 then begin
SubItems.Add('Dummy'); //will be expanded later
Expanded:=false;
end;
Text:=Cardinal2Str(wnd);
{ if filterParentWnd <> 0 then begin
nextParent:=getparent(wnd);
while nextParent<>filterParentWnd do begin
nextParent:=getparent(nextParent);
Caption:=' '+Caption;
end;
end;}
RecordItems.Add(getwindowtexts(wnd));
RecordItems.Add(getWindowClassNameToDisplay(wnd));
s:='';
if IsWindowVisible(wnd) then s:=s+'visible';//'Visible: true | ' else s:=s+'Visible: false | ';
if IsWindowEnabled(wnd) then begin
if s<>'' then s:=s+', ';//Enable: true' else s:=s+'Enable: false';
s+='enabled';
end;
RecordItems.Add(s);
RecordItems.Add(GetWindowPosStr(wnd));
RecordItems.Add(programS);
end;
end;
windowTreeList.EndUpdate;
end;
procedure TmainForm.openWindowsConst;
var p:tpoint;
current: twincontrol;
begin
current:=FindControl(GetFocus);
if current=nil then current:=FindOwnerControl(GetFocus);
if current=nil then exit;
if not ((current is tedit) or (current is TComboBox)) then exit;
p.x:=0;
p.y:=0;//current.Height;
p:=current.ClientToScreen(p);
windowConstForm.Left:=p.x;
windowConstForm.top:=p.y;
if current is tedit then windowConstForm.currentConst:=TEdit(current).Text
else if current is TComboBox then windowConstForm.currentConst:=TComboBox(current).Text;
windowConstForm.currentConst:=trim(windowConstForm.currentConst);
windowConstForm.ShowModal;
if windowConstForm.currentConst<>'' then
if current is tedit then begin
TEdit(current).Text:=windowConstForm.currentConst;
TEdit(current).SelStart:=length(TEdit(current).Text);
end else if current is TComboBox then begin
TComboBox(current).Text:=windowConstForm.currentConst;
TComboBox(current).SelStart:=length(TComboBox(current).Text);
end;
end;
procedure AddProcF1(text:string);
begin
//mainForm.ListBox1.items.add(text);
end;
procedure TmainForm.displaySysProperties();
var i:longint;
begin
systemProperties.BeginUpdate;
systemProperties.items.Clear;
for i:=0 to high(systemPropertiesArray) do
with systemProperties.Items.add,
systemPropertiesArray[i] do begin
Caption:=name;
subitems.Add(value);
end;
systemProperties.EndUpdate;
end;
procedure TmainForm.messagemes_cbKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=VK_RETURN then messageSend_btn.Click;
end;
procedure TmainForm.ownerWnd_edtDblClick(Sender: TObject);
begin
handleEdt.Text:=ownerWnd_edt.Text;
changeProperty(handleEdt);
end;
procedure TmainForm.parentWndCmbDblClick(Sender: TObject);
var s:string;
begin
s:=parentWndCmb.text;
if pos(' - ',s)>0 then s:=splitGet(' - ',s);
handleEdt.Text:=s;
changeProperty(handleEdt);
end;
procedure TmainForm.posLTEdtKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
end;
procedure TmainForm.processTabSheetResize(Sender: TObject);
begin
end;
procedure TmainForm.showHandleClick(Sender: TObject);
begin
if GetWindowThreadProcessId(currentWindow,0)<>MainThreadID then
niceSetVisible(false,false);
toggleWindowMarkStatus(currentWindow);
sleep(125);
toggleWindowMarkStatus(currentWindow);
sleep(125);
toggleWindowMarkStatus(currentWindow);
sleep(125);
toggleWindowMarkStatus(currentWindow);
if GetWindowThreadProcessId(currentWindow,0)<>MainThreadID then
niceSetVisible(true,false);
end;
procedure TmainForm.processTabSheetShow(Sender: TObject);
begin
SetWindowLong(Handle,GWL_EXSTYLE,GetWindowLong(handle,GWL_EXSTYLE) and not WS_EX_LAYERED);
displayProcesses.Click;
end;
procedure TmainForm.systemPropertiesAdvancedCustomDrawSubItem(
Sender: TCustomListView; Item: TListItem; SubItem: Integer;
State: TCustomDrawState; Stage: TCustomDrawStage; var DefaultDraw: Boolean);
begin
end;
procedure TmainForm.TabSheet2Show(Sender: TObject);
begin
threadedCall(calculateSysProperties,displaySysProperties);
end;
procedure TmainForm.windowListDblClick(Sender: TObject);
var temp:word;
begin
//TODO: windowslist
{ if windowList.Selected=nil then exit;
windowListFilterParent_edt.Text:=trim(windowList.Selected.Caption);
temp:=vk_return;
windowListFilterProgram_edtKeyUp(nil,temp,[]);}
end;
procedure TmainForm.windowListFilterParentUpClick(Sender: TObject);
var temp:word;
begin
windowListFilterParent_edt.text:=Cardinal2Str(GetParent(Str2Cardinal(windowListFilterParent_edt.text)));
temp:=vk_return;
windowListFilterProgram_edtKeyUp(nil,temp,[]);
end;
procedure TmainForm.windowListFilterParent_edtChange(Sender: TObject);
begin
windowsListfilterDirectChilds.Enabled:=StrToIntDef(windowListFilterParent_edt.Text,0)<>0;
end;
procedure TmainForm.windowProcessIDedtDblClick(Sender: TObject);
begin
processidedit.Text:=windowProcessIDedt.text;
processTabSheet.Show;
end;
procedure TmainForm.windowPropChangeClick(Sender: TObject);
begin
end;
procedure TmainForm.windowPropertySheetClick(Sender: TObject);
begin
end;
procedure TmainForm.windowsListfilterDirectChildsChange(Sender: TObject);
begin
displayWindows;
end;
procedure TmainForm.colorKeyShapeMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ColorDialog1.Color:=colorKeyShape.brush.color;
if not ColorDialog1.Execute then exit;
colorKeyShape.Brush.Color:=ColorDialog1.Color;
changeProperty(colorKeyShape);
end;
procedure TmainForm.windowListFilterProgram_edtKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=VK_RETURN then displayWindows;
end;
procedure TmainForm.windowConstOpenEvent(Sender: TObject; var Key: Word; Shift: TShiftState
);
begin
if (shift = [ssCtrl]) and (key=VK_SPACE) then begin
openWindowsConst;
key:=0;
end;
end;
procedure TmainForm.FormShow(Sender: TObject);
var reg:TRegistry;
begin
reg:=TRegistry.create;
try
reg.RootKey:=HKEY_CURRENT_USER;
reg.OpenKey('\Software\BeniBela\APIV\1.5\',true);
if reg.ValueExists('WindowLeft') then self.left:=reg.ReadInteger('WindowLeft')
else reg.WriteInteger('WindowLeft',self.left);
if reg.ValueExists('WindowTop') then self.top:=reg.ReadInteger('WindowTop')
else reg.WriteInteger('WindowTop',self.Top);
if reg.ValueExists('WindowWidth') then self.Width:=reg.ReadInteger('WindowWidth')
else reg.WriteInteger('WindowWidth',self.Width);
if reg.ValueExists('WindowHeight') then self.Height:=reg.ReadInteger('WindowHeight')
else reg.WriteInteger('WindowHeight',self.Height);
if reg.ValueExists('ScreenWindowLeft') then miniScreen.left:=reg.ReadInteger('ScreenWindowLeft')
else reg.WriteInteger('ScreenWindowLeft',miniScreen.left);
if reg.ValueExists('ScreenWindowTop') then miniScreen.top:=reg.ReadInteger('ScreenWindowTop')
else reg.WriteInteger('ScreenWindowTop',miniScreen.Top);
if reg.ValueExists('ScreenWindowWidth') then PaintBox1.Width:=reg.ReadInteger('ScreenWindowWidth')
else reg.WriteInteger('ScreenWindowWidth',PaintBox1.Width);
if reg.ValueExists('ScreenWindowHeight') then PaintBox1.Height:=reg.ReadInteger('ScreenWindowHeight')
else reg.WriteInteger('ScreenWindowHeight',PaintBox1.Height);
linksoben.left:=miniScreen.left;
linksoben.Top:=miniScreen.Top;
rechtsunten.left:=miniScreen.left+PaintBox1.width;
rechtsunten.Top:=miniScreen.Top+PaintBox1.Height;
finally
reg.free;
end;
end;
procedure TmainForm.enabledCbChange(Sender: TObject);
begin
end;
procedure TmainForm.Button1Click(Sender: TObject);
begin
windowListFilterParent_edt.Text:=Cardinal2Str(currentWindow);
windowListFilterProgram_edt.Text:='';
if PageControl2.ActivePage<>windowListTabSheet then windowListTabSheet.Show
else displayWindows;
end;
procedure TmainForm.callAPIClick(Sender: TObject);
begin
callAPIResult_lbl.Caption:=Cardinal2Str(genericCall(callAPIDLL.Text,callAPIProc.Text,createMemoryBlocks(callAPIParameter.Text)));
end;
procedure TmainForm.windowPropertyListChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
//TODO:??
{if change<>ctText then exit;
if item=nil then exit;
if displayCalls>0 then exit; //change is called when internally changing *grr*
ShowMessage(item.Caption);
systemProperties.EditingDone;
RemoveProp(currentWindow, pchar(item.SubItems[2]));
SetProp(currentWindow, pchar(item.Caption), Str2Cardinal(item.SubItems[0]));
displayProperty(windowPropertyList);}
end;
procedure TmainForm.windowPropertyListDeletion(Sender: TObject; Item: TListItem
);
begin
if item=nil then exit;
if displayCalls>0 then exit; //save is save
RemoveProp(currentWindow, pchar(item.Caption));
displayProperty(windowPropertyList);
end;
procedure TmainForm.windowPropRemoveItemClick(Sender: TObject);
begin
if windowPropertyList.Selected<>nil then begin
RemoveProp(currentWindow, pchar(windowPropertyList.Selected.Caption));
displayProperty(windowPropertyList);
end else ShowMessage('Keine Eigenschaft ausgewählt');
end;
procedure TmainForm.windowStylesClickCheck(Sender: TObject);
begin
end;
procedure TmainForm.windowStylesItemClick(Sender: TObject; Index: integer);
var currentSelected: string;
begin
if index<0 then exit;
currentSelected:=TCheckListBox(sender).items[index];
if Sender=windowStyles then changeWindowStyle(currentWindow, currentSelected,windowStyles.checked[index])
else if Sender=windowExStyles then changeWindowExStyle(currentWindow, currentSelected,windowExStyles.checked[index]);
//displayProperty(sender);
changeProperty(handleEdt); //update all, window styles can have strange effects
Application.ProcessMessages;
PostMessage(TCheckListBox(sender).Handle,LB_SETCURSEL,TCheckListBox(sender).items.IndexOf(currentSelected),0);
//TCheckListBox(sender).ItemIndex:=TCheckListBox(sender).items.IndexOf(currentSelected);
// caption:=caption+TCheckListBox(sender).items[TCheckListBox(sender).itemindex];
end;
procedure TmainForm.windowtextEdtChange(Sender: TObject);
begin
end;
procedure TmainForm.windowTreeListExpandItem(sender: TObject;
item: TTreeListItem);
begin
if item.SubItems.count=0 then exit;
if item.SubItems[0].Text='Dummy' then begin
displayWindows(item);
end;
end;
procedure TmainForm.windowAddPropertyClick(Sender: TObject);
var name,value:string;
begin
if sender=windowAddProperty then begin
if not InputQuery('','Name der neuen Eigenschaft: ',name) then exit;
value:=Cardinal2Str(0);
end else if windowPropertyList.Selected<>nil then begin
name:=windowPropertyList.selected.Caption;
value:=windowPropertyList.Selected.SubItems[0];
end;
if not InputQuery('','Neuer Wert der Eigenschaft: ',value) then exit;
SetPropA(currentWindow,pchar(name),Str2Cardinal(value));
displayProperty(windowPropertyList);
end;
procedure TmainForm.mouseToolImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i:longint;
begin
if button=mbLeft then begin
screen.Cursor:=crScanner;
currentMouseWindow:=0;
if hideAPIVwhenSearching.Checked then
niceSetVisible(false, true);
end;
end;
procedure TmainForm.mouseToolImageMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i:longint;
begin
if button=mbLeft then begin
screen.Cursor:=crDefault;
toggleWindowMarkStatus(currentMouseWindow);
if hideAPIVwhenSearching.Checked then
niceSetVisible(true,true);
handleEdt.Text:=Cardinal2Str(currentMouseWindow);
changeProperty(handleEdt);
end;
end;
procedure TmainForm.PaintBox1Click(Sender: TObject);
begin
handleEdt.Text:=mouseHandleEdt.Text;
changeProperty(handleEdt);
end;
procedure TmainForm.parentwndEdtDblClick(Sender: TObject);
var s:string;
begin
s:=parentWndCmb.text;
if pos(' - ',s)>0 then
s:=splitGet(' - ',s);
handleEdt.Text:=s;
changeProperty(handleEdt);
end;
procedure TmainForm.windowListTabSheetShow(Sender: TObject);
begin
//Workaround treelistview works not correct when enabled
if GetWindowLong(handle, GWL_EXSTYLE) or WS_EX_LAYERED <>0then
SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, GWL_EXSTYLE) and not WS_EX_LAYERED);
displayWindows;
end;
procedure TmainForm.windowListKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=VK_F5 then displayWindows;
end;
procedure TmainForm.windowListSelectItem(Sender: TObject; Item: TTreeListItem);