Alexander (Sasha) Sirotkin wrote:
> Here is the problematic code, in case anybody cares to take a look:
>
> for ( ListWindows( ) ) {
> if ($_->{title} =~ /Firefox/) {
> $hwnd = $_->{hwnd};
> last;
> }
> }
> Win32::GUI::SetForegroundWindow($hwnd);
> my $x = Win32::GUI::ScrollPos($hwnd, 0);
> printf("Scroll pos: " . $x . "\n");
>
> Win32::GUI::Scroll($hwnd, 1, SB_PAGEDOWN);
>
> ScrollPos() returns the same value no matter what is the scroll position
> and scroll() does nothing...
You're calling these functions on the top-level window. The top-level
window usually isn't a scrolled window.
The following code will dump the child controls of the Firefox window.
You can use it as a base to write something to find the scrolled window,
but it looks to me like it will be hard to find the one you want. (Run
it and you'll see what I mean.)
use Win32::GUI;
use Win32::GUI::Constants qw(/^GW_/);
use strict;
my $hwnd = Win32::GUI::GetWindow(Win32::GUI::GetDesktopWindow, GW_CHILD);
while ($hwnd) {
last if (Win32::GUI::Text($hwnd)=~/Firefox/);
$hwnd = Win32::GUI::GetWindow($hwnd, GW_HWNDNEXT);
}
DumpWindows($hwnd);
sub DumpWindows {
my ($ph, $l) = @_;
print "\t" x $l;
my $class = Win32::GUI::GetClassName($ph);
my $text = Win32::GUI::Text($ph);
print qq([$class] "$text"\n);
my $ch = Win32::GUI::GetWindow($ph, GW_CHILD);
while ($ch) {
DumpWindows($ch, $l+1);
$ch = Win32::GUI::GetWindow($ch, GW_HWNDNEXT);
}
}
|