Leser: 2
|< 1 2 >| | 12 Einträge, 2 Seiten |
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
#!/usr/bin/perl
use strict;
use warnings;
use Win32;
use Win32::API;
use Win32::API::Callback;
my $org_title = "Unbenannt - Editor";
my $new_title = "Hacked by esskar! :-)";
my $EnumWindows = Win32::API->new( "user32", "EnumWindows", "PN", "N" );
my $EnumChildWnds = Win32::API->new( "user32", "EnumChildWindows", "NKN", "N" );
my $FindWindowEx = Win32::API->new( "user32", "FindWindowEx", "NNPP", "N" );
my $GetClassName = Win32::API->new( "user32", "GetClassName", "NPN", "N" );
my $SetWindowText = Win32::API->new( "user32", "SetWindowText", "NP", "N" );
my $PostMessage = Win32::API->new( "user32", "PostMessage", "NNNN", "N" );
my $hwnd = $FindWindowEx->Call( 0, 0, "Notepad", 0 );
die "Window not found." unless $hwnd;
my $editHwnd = 0;
my $EnumWindowsProc = Win32::API::Callback->new(
sub {
my ( $hwnd, $param ) = @_;
my $className = " " x 256;
my $len =
$GetClassName->Call( $hwnd, $className, length($className) - 1 );
$className = substr( $className, 0, $len );
if ( lc $className eq 'edit' ) {
$editHwnd = $hwnd;
return 0;
}
return 1;
},
"NN",
"N"
);
$EnumChildWnds->Call( $hwnd, $EnumWindowsProc, 0 );
die "Edit Window not found." unless $editHwnd;
$SetWindowText->Call( $hwnd, $new_title );
&write_to_window( $editHwnd, "Just a test!\n" );
use constant WM_CHAR => 258;
sub write_to_window {
my ( $hwnd, $text ) = @_;
my @chars = split //, $text;
foreach my $c (@chars) {
$PostMessage->Call($hwnd, WM_CHAR, ord $c, 0);
}
}
|< 1 2 >| | 12 Einträge, 2 Seiten |