Jump to content

Scrolling Window Capture


runsnake
 Share

Recommended Posts

who does know Delphi language?

There is a example code about scrolling window capture.

somebody can convert it to au3?

---------------------------------------------------------

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Dialogs, StdCtrls, ComCtrls;

const

TAGCOLOR : TColor = $00FEFEFE;

type

TForm1 = class(TForm)

Memo1: TMemo;

RichEdit1: TRichEdit;

Button1: TButton;

RadioButton1: TRadioButton;

RadioButton2: TRadioButton;

procedure Button1Click(Sender: TObject);

procedure FormCreate(Sender: TObject);

private

function RectHeight(ARect : TRect) : Integer;

function IsScrollEnd(AHandle : THandle) : Boolean;

function NextLineHeight(AHandle : THandle;ARect : TRect) : Integer;

public

end;

var

Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }

function TForm1.RectHeight(ARect: TRect): Integer;

begin

Result := ARect.Bottom - ARect.Top;

end;

procedure TForm1.Button1Click(Sender: TObject);

var

ABuf : TBitmap;

ARect : TRect;

AHandle : THandle;

ACanvas : TCanvas;

ALineHeight : Integer;

begin

if RadioButton1.Checked

then AHandle := Memo1.Handle

else AHandle := RichEdit1.Handle;

Windows.GetClientRect(AHandle,ARect);

SendMessage(AHandle,WM_VSCROLL,SB_TOP,0);

ABuf := TBitmap.Create;

ABuf.Width := ARect.Right - ARect.Left;

ABuf.Height := RectHeight(ARect) div 2;

ACanvas := TCanvas.Create;

ACanvas.Handle := GetDC(AHandle);

ACanvas.Pen.Color := TAGCOLOR;

{ First Copy }

BitBlt(ABuf.Canvas.Handle,0,0,ABuf.Width,RectHeight(ARect) div 2,

ACanvas.Handle,0,0,SRCCOPY);

ACanvas.MoveTo(0,RectHeight(ARect) div 2);

ACanvas.LineTo(3,RectHeight(ARect) div 2);

SendMessage(AHandle,WM_VSCROLL,SB_LINEDOWN,0);

while not IsScrollEnd(AHandle) do

begin

ALineHeight := NextLineHeight(AHandle,ARect) + 1;

ABuf.Height := ABuf.Height + ALineHeight;

BitBlt(ABuf.Canvas.Handle,0,ABuf.Height - ALineHeight,ABuf.Width,ALineHeight,

ACanvas.Handle,0,RectHeight(ARect) div 2- ALineHeight,SRCCOPY);

ACanvas.MoveTo(0,RectHeight(ARect) div 2);

ACanvas.LineTo(3,RectHeight(ARect) div 2);

SendMessage(AHandle,WM_VSCROLL,SB_LINEDOWN,0);

end;

{ Last Copy }

ALineHeight := RectHeight(ARect) - RectHeight(ARect) div 2;

ABuf.Height := ABuf.Height + ALineHeight;

BitBlt(ABuf.Canvas.Handle,0,ABuf.Height - ALineHeight,ABuf.Width,ALineHeight,

ACanvas.Handle,0,RectHeight(ARect) div 2 + 1,SRCCOPY);

ABuf.SaveToFile('C:\ABC.BMP');

ABuf.Free;

ReleaseDC(AHandle,ACanvas.Handle);

ACanvas.Free;

MessageBox(Handle,'Capture File is SaveTo C:\ABC.BMP.','Info',MB_ICONINFORMATION);

end;

function TForm1.IsScrollEnd(AHandle : THandle): Boolean;

var

SI : tagSCROLLINFO;

begin

SI.cbSize := Sizeof(SI);

SI.fMask := SIF_ALL;

GetScrollInfo(AHandle,SB_VERT,SI);

Result := SI.nPos = (SI.nMax - SI.nPage);

end;

function TForm1.NextLineHeight(AHandle: THandle; ARect: TRect): Integer;

var

i : Integer;

ABuf : TBitmap;

begin

ABuf := TBitmap.Create;

ABuf.Width := 3;

ABuf.Height := RectHeight(ARect) div 2;

Result := 0;

BitBlt(ABuf.Canvas.Handle,0,0,3,RectHeight(ARect),GetDC(AHandle),0,0,SRCCOPY);

for i := ABuf.Height -1 downto 0 do

begin

if ABuf.Canvas.Pixels[2,i] = TAGCOLOR then Break;

Result := Result + 1;

end;

ABuf.Free;

end;

procedure TForm1.FormCreate(Sender: TObject);

begin

RichEdit1.Lines.LoadFromFile(ExtractFilePath(ParamStr(0))+'unit1.rtf');

end;

end.

--------------------------------------------------------------

Edited by runsnake
Link to comment
Share on other sites

I am not know Delphi but did you? can you explain the method that it use to get the capture... the most common method used in AutoIt scripts is getting the Window DC and do a BltBit to a HBITMAP and then save it to a file.

My advice: In this forum usually when you don`t show some effort, no one will translate the code for you.

Edited by monoscout999
Link to comment
Share on other sites

Look at this i just made it, i dont copy anything of your delphi code. You should modify a little to clean the bugs, but you will get an idea..

#include <WinAPI.au3>
#Include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <Array.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
 
;~ Global Const $SRCCOPY = 0x00CC0020
 
;Creating Random text.
$Text = "Start of text"& @CRLF
For $i = 0 to 300
    $Text &= random(0,99999999999)
    $Text &= @CRLF
Next
$Text &= "End of text"
 
;Run Notepad and get handle.
Run("Notepad.exe")
$WinHndl = WinWait("[CLASS:Notepad]")
If @error then Exit
 
;Get Edit handle and put some text.
$EditHndl = ControlGetHandle($WinHndl,"","Edit1")
ControlSetText($WinHndl,"",$EditHndl,$Text)
 
;Get Edit1 Vertical Scroll Min/Max range and page size.
$aScrollRange = _GUIScrollBars_GetScrollRange($EditHndl, $SB_VERT)
$iPageSize = _GUIScrollBars_GetScrollInfoPage($EditHndl, $SB_VERT)
$iPages = Round($aScrollRange[1] / $iPageSize)
 
;Getting width and Heigth
$aControlPos = ControlGetPos($WinHndl,"",$EditHndl)
 
;Capturing the screen.
$hDC = _winapi_GetDC($EditHndl)
$hCDC = _WinAPI_CreateCompatibleDC($hDC)
$hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $aControlPos[2], $aControlPos[3]*$iPages)
_WinAPI_SelectObject($hCDC, $hBMP)
For $i = 0 to $iPages
_WinAPI_BitBlt($hCDC, 0, $aControlPos[3]*$i, $aControlPos[2], $aControlPos[3], $hDC,0, 0, $SRCCOPY)
_WinAPI_PostMessage($EditHndl,$WM_VSCROLL,$SB_PAGEDOWN,0)
Next
_WinAPI_ReleaseDC($EditHndl, $hDC)
_WinAPI_DeleteDC($hCDC)
_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
_GDIPlus_ImageSaveToFile($hImage, @Desktopdir & "\TestCapture.bmp")
_GDIPlus_Shutdown()
_WinAPI_DeleteObject($hBMP)

PD: Maybe UEZ can add this feature to his

Edited by monoscout999
Link to comment
Share on other sites

I am not know Delphi but did you? can you explain the method that it use to get the capture... the most common method used in AutoIt scripts is getting the Window DC and do a BltBit to a HBITMAP and then save it to a file.

My advice: In this forum usually when you don`t show some effort, no one will translate the code for you.

Yes, my demo used the same theory, if you readed it, you could find it .

Some time ago, my friend asked me to write a demo about scrolling window capture. But he only knew AU3 language, oppositely, I nerver heard this language. My working computer language was Delphi. So, I tried to learn au3, my work was busy, having a litter time to do it.

Now I only still knew a litter AU3. So I writed this Demo by Delphi and came here for a bridge from Delphi to AU3.

Look at this i just made it, i dont copy anything of your delphi code. You should modify a little to clean the bugs, but you will get an idea..

Thanks for your warm answer.

Your code have some bugs. You don't deal with the height of each line and don't determine condition of scrolling track's position has come to the bottom.

Anyway thank you again, you have give me a lighthouse how to write it by AU3

Edited by runsnake
Link to comment
Share on other sites

I was trying to clean the bugs, but i still can not find a effective way to capture the bottom of the windows. maybe you can explain to us the method that you use in your Delphi code.

This is what i was trying

#include <WinAPI.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
#include <Array.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>

;~ Global Const $SRCCOPY = 0x00CC0020

;Creating Random text.
$Text = "Start of text" & @CRLF
For $i = 0 To 300
    $Text &= Random(0, 99999999999)
    $Text &= @CRLF
Next
$Text &= "End of text"

;Run Notepad and get handle.
Run("Notepad.exe")
$WinHndl = WinWait("[CLASS:Notepad]")
If @error Then Exit

;Get Edit handle and put some text.
$EditHndl = ControlGetHandle($WinHndl, "", "Edit1")
ControlSetText($WinHndl, "", $EditHndl, $Text)

;Get Edit1 Vertical Scroll Min/Max range and page size.
$aScrollRange = _GUIScrollBars_GetScrollRange($EditHndl, $SB_VERT)
$iPageSize = _GUIScrollBars_GetScrollInfoPage($EditHndl, $SB_VERT)
$iPages = Round(($aScrollRange[1] / $iPageSize) + 0.5) ; + 0.5 to round Up

;Getting width and Heigth.
$aControlPos = ControlGetPos($WinHndl, "", $EditHndl)

;Getting ScrollBar Positions and exclude it from the capture.
$tSCROLLBARINFO = _GUIScrollBars_GetScrollBarInfoEx($EditHndl, $OBJID_HSCROLL)
$tpoint = DllStructCreate("int X;int Y")
DllStructSetData($tpoint, "X", DllStructGetData($tSCROLLBARINFO, "Right"))
DllStructSetData($tpoint, "Y", DllStructGetData($tSCROLLBARINFO, "Top"))
_WinAPI_ScreenToClient($EditHndl, $tpoint)
$Width = $aControlPos[2] ; DllStructGetData($tpoint, "X")
$Height = DllStructGetData($tpoint, "Y")

;Preparing for capturing the screen.
$hDC = _WinAPI_GetDC($EditHndl)
$hCDC = _WinAPI_CreateCompatibleDC($hDC)
$hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height * $iPages)
$hPen = _WinAPI_CreatePen($PS_SOLID, 2,0x0000FF)
_WinAPI_SelectObject($hCDC, $hBMP)
_WinAPI_SelectObject($hCDC, $hPen)
$iPos = _GUIScrollBars_GetScrollPos($EditHndl, $SB_VERT)
$iPosAux = _GUIScrollBars_GetScrollPos($EditHndl, $SB_VERT)
$RelativeHeight = $Height

;Capturing the Screen.
For $i = 0 To $iPages
    $iPosAux = _GUIScrollBars_GetScrollPos($EditHndl, $SB_VERT)
    If $iPosAux - $iPos < $iPageSize Then
        $RelativeHeight = ($iPosAux - $iPos) * $Height / $iPageSize
    EndIf
    $iPos = $iPosAux
    _WinAPI_BitBlt($hCDC, 0, $Height * $i, $Width, $Height, $hDC, 0,$RelativeHeight, $SRCCOPY)
    _WinAPI_DrawLine($hCDC,0,($Height * $i)-3,$Width,($Height * $i)-3)
    _WinAPI_PostMessage($EditHndl, $WM_VSCROLL, $SB_PAGEDOWN, 0)
    _WinAPI_PostMessage($EditHndl, $WM_VSCROLL, $SB_LINEDOWN, 0)
    Sleep(150)
Next

;Release resources and save file.
_WinAPI_ReleaseDC($EditHndl, $hDC)
_WinAPI_DeleteDC($hCDC)
_WinAPI_DeleteObject($hPen)
_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP)
_GDIPlus_ImageSaveToFile($hImage, @DesktopDir & "\TestCapture.bmp")
_GDIPlus_Shutdown()
_WinAPI_DeleteObject($hBMP)
Link to comment
Share on other sites

This is good but how to know which window/control has a vertical/horizontal scroll bar, not only notepad?

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Checking the Window Style you can find if a window have a Scroll or not.

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Constants.au3>
 
Run("Notepad.exe")
Run("Calc.exe")
 
WinWait("[CLASS:Notepad]")
WinWait("[CLASS:CalcFrame]")
 
Dim $Handle[5]
$Handle[0] = WinGetHandle("[CLASS:Notepad]")
$Handle[1] = ControlGetHandle($Handle[0], "", "Edit1")
$Handle[2] = WinGetHandle("[CLASS:CalcFrame]")
$Handle[3] = WinGetHandle("[CLASS:SciTEWindow]")
$Handle[4] = ControlGetHandle($Handle[3], "", "Scintilla1")
 
WinActivate("[CLASS:SciTEWindow]")
 
Local $Style
For $i = 0 To UBound($Handle) - 1
    $Style = _WinAPI_GetWindowLong($Handle[$i], $GWL_STYLE)
    If BitAND($Style, $WS_VSCROLL) = $WS_VSCROLL Then ConsoleWrite(_WinAPI_GetClassName($Handle[$i]) & " Have a Vertical Scroll" & @CRLF)
Next
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
;For Test propourses i need that the SciTE Window have a scroll

EDIT: Anyway this must be an user option.

Edited by monoscout999
Link to comment
Share on other sites

Try to check whether the right window side in AutoIt Help has vertical scroll bar.

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Constants.au3>
AutoItSetOption("WinTitleMatchMode", 4)
 
If Not ProcessExists("AutoIt3Help.exe") Then Exit
 
$hWnd = WinGetHandle("[CLASS:HH Parent]")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hWnd = ' & $hWnd & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$hCtrl = ControlGetHandle($hWnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hCtrl = ' & $hCtrl & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
 
If BitAND(_WinAPI_GetWindowLong($hCtrl, $GWL_STYLE), $WS_VSCROLL) = $WS_VSCROLL Then ConsoleWrite(_WinAPI_GetClassName($hCtrl) & " Have a Vertical Scroll" & @CRLF)

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

You have right... it works with the SysTreeView32, but it doesn´t with any internet browser, i try also in mozilla but it doesn`t work either.

But if i send a WM_VSCROLL message it works. :S i will look into this issue to find how to know if a Internet Browser have scrolls.

Edited by monoscout999
Link to comment
Share on other sites

I was

trying to clean the bugs, but i still can not find a effective way to

capture the bottom of the windows. maybe you can explain to us the method

that you use in your Delphi code. This is what i was trying

#include <WinAPI.au3> #include <GuiScrollBars.au3> #include 

<ScrollBarConstants.au3> #include <Array.au3> #include <GDIPlus.au3> 

#include <WindowsConstants.au3> ;~ Global Const $SRCCOPY = 0x00CC0020 

;Creating Random text. $Text = "Start of text" & @CRLF For $i = 0 To 300 

$Text &= Random(0, 99999999999) $Text &= @CRLF Next $Text &= "End of text" 

;Run Notepad and get handle. Run("Notepad.exe") $WinHndl = WinWait

("[CLASS:Notepad]") If @error Then Exit ;Get Edit handle and put some text. 

$EditHndl = ControlGetHandle($WinHndl, "", "Edit1") ControlSetText

($WinHndl, "", $EditHndl, $Text) ;Get Edit1 Vertical Scroll Min/Max range 

and page size. $aScrollRange = _GUIScrollBars_GetScrollRange($EditHndl, 

$SB_VERT) $iPageSize = _GUIScrollBars_GetScrollInfoPage($EditHndl, 

$SB_VERT) $iPages = Round(($aScrollRange[1] / $iPageSize) + 0.5) ; + 0.5 to 

round Up ;Getting width and Heigth. $aControlPos = ControlGetPos($WinHndl, 

"", $EditHndl) ;Getting ScrollBar Positions and exclude it from the 

capture. $tSCROLLBARINFO = _GUIScrollBars_GetScrollBarInfoEx($EditHndl, 

$OBJID_HSCROLL) $tpoint = DllStructCreate("int X;int Y") DllStructSetData

($tpoint, "X", DllStructGetData($tSCROLLBARINFO, "Right")) 

DllStructSetData($tpoint, "Y", DllStructGetData($tSCROLLBARINFO, "Top")) 

_WinAPI_ScreenToClient($EditHndl, $tpoint) $Width = $aControlPos[2] ; 

DllStructGetData($tpoint, "X") $Height = DllStructGetData($tpoint, "Y") 

;Preparing for capturing the screen. $hDC = _WinAPI_GetDC($EditHndl) $hCDC 

= _WinAPI_CreateCompatibleDC($hDC) $hBMP = _WinAPI_CreateCompatibleBitmap

($hDC, $Width, $Height * $iPages) $hPen = _WinAPI_CreatePen($PS_SOLID, 

2,0x0000FF) _WinAPI_SelectObject($hCDC, $hBMP) _WinAPI_SelectObject($hCDC, 

$hPen) $iPos = _GUIScrollBars_GetScrollPos($EditHndl, $SB_VERT) $iPosAux = 

_GUIScrollBars_GetScrollPos($EditHndl, $SB_VERT) $RelativeHeight = $Height 

;Capturing the Screen. For $i = 0 To $iPages $iPosAux = 

_GUIScrollBars_GetScrollPos($EditHndl, $SB_VERT) If $iPosAux - $iPos < 

$iPageSize Then $RelativeHeight = ($iPosAux - $iPos) * $Height / $iPageSize 

EndIf $iPos = $iPosAux _WinAPI_BitBlt($hCDC, 0, $Height * $i, $Width, 

$Height, $hDC, 0,$RelativeHeight, $SRCCOPY) _WinAPI_DrawLine($hCDC,0,

($Height * $i)-3,$Width,($Height * $i)-3) _WinAPI_PostMessage($EditHndl, 

$WM_VSCROLL, $SB_PAGEDOWN, 0) _WinAPI_PostMessage($EditHndl, $WM_VSCROLL, 

$SB_LINEDOWN, 0) Sleep(150) Next ;Release resources and save file. 

_WinAPI_ReleaseDC($EditHndl, $hDC) _WinAPI_DeleteDC($hCDC) 

_WinAPI_DeleteObject($hPen) _GDIPlus_Startup() $hImage = 

_GDIPlus_BitmapCreateFromHBITMAP($hBMP) _GDIPlus_ImageSaveToFile($hImage, 

@DesktopDir & "\TestCapture.bmp") _GDIPlus_Shutdown() _WinAPI_DeleteObject

($hBMP)

I tried to use my only limited knowledge of AU3 to explain it. Here is my

AU3 code about judging scroll track to the bottom.

You had better use 'SB_LINEDOWN' replacing 'SC_PageSize' in the loop. Because using 'SB_LINEDOWN', you can control scroll track accurately. Then you need to get current line height in pixel, for rich Edit control, it's impossible to has the same height for each line.

============================================================

#include <StructureConstants.au3>

#include <GUIScrollBars.au3>

#include <ScrollBarConstants.au3>

#Include <SendMessage.au3>

Run("Notepad")

Sleep(200)

$hWin = WinGetHandle("[CLASS:Notepad]")

For $i = 1 To 100

ControlSend($hWin, "", "Edit1", $i & @LF)

Next

$hCtrl = ControlGetHandle("[CLASS:Notepad]", "", "Edit1")

_SendMessage($hCtrl, $WM_VSCROLL, $SB_TOP, 0)

Do

_SendMessage($hCtrl, $WM_VSCROLL, $SB_LINEDOWN, 0)

Sleep(100)

Until IsScrollEnd($hCtrl)

MsgBox(0, "OK", "Track is on bottom")

Func IsScrollEnd($hCtrl)

Local $nPos, $nMax, $nPage

;I don't know here whether need to set 'fMask' in AU3

$nPos = _GUIScrollBars_GetScrollInfoPos($hCtrl, $SB_VERT)

$nMax = _GUIScrollBars_GetScrollInfoMax($hCtrl, $SB_VERT)

$nPage = _GUIScrollBars_GetScrollInfoPage($hCtrl, $SB_VERT)

If $nPos == ($nMax - $nPage + 1) Then

Return True

Else

Return False

EndIf

EndFunc

======================================================

Link to comment
Share on other sites

that seems a more correct way to do the scroll, i use the page method to set the height of the resulting image. the problem is how to make the capture, how to determine the area to be captured for each scroll.

I am trying to translate following delphi function that gets height of current line to AU3.

It's a litter difficult for me. I lack lots of knowledge of au3.

========================================

function TForm1.NextLineHeight(AHandle: THandle; ARect: TRect): Integer;

var

i : Integer;

ABuf : TBitmap;

begin

ABuf := TBitmap.Create;

ABuf.Width := 3;

ABuf.Height := RectHeight(ARect) div 2;

Result := 0;

BitBlt(ABuf.Canvas.Handle,0,0,3,RectHeight(ARect),GetDC(AHandle),0,0,SRCCOPY);

for i := ABuf.Height -1 downto 0 do

begin

if ABuf.Canvas.Pixels[2,i] = TAGCOLOR then Break;

Result := Result + 1;

end;

ABuf.Free;

end;

=======================================

Link to comment
Share on other sites

Still don´t have any idea... maybe the other users that are looking at this topic can contribute with some ideas.

Like following indication code

I don't know how to express ' if ABuf.Canvas.Pixels[2,i] = TAGCOLOR then Break;' in AU3

===========================================================

$Width = _WinAPI_GetClientWidth($hCtrl)

$Height = _WinAPI_GetClientHeight($hCtrl)

$BufHeight = $Height

Do

$AlineHeight = NextLineHeight($hCtrl) + 1

$BufHeight += $AlineHeight

_WinAPI_BitBlt($hCDC, 0, $BufHeight - $AlineHeight, $Width, $AlineHeight, $hDC, 0, $Height - $AlineHeight, $SRCCOPY)

_WinAPI_MoveTo($hDC, 0, $Height)

_WinAPI_LineTo($hDC, 3, $Height)

_SendMessage($hCtrl, $WM_VSCROLL, $SB_LINEDOWN,0)

Until IsScrollEnd($hCtrl)

Func IsScrollEnd($hCtrl)

Local $nPos, $nMax, $nPage

$nPos = _GUIScrollBars_GetScrollInfoPos($hCtrl, $SB_VERT)

$nMax = _GUIScrollBars_GetScrollInfoMax($hCtrl, $SB_VERT)

$nPage = _GUIScrollBars_GetScrollInfoPage($hCtrl, $SB_VERT)

Return $nPos == ($nMax - $nPage)

EndFunc

Func NextLineHeight($hCtrl)

;........

EndFunc

==========================================================

Link to comment
Share on other sites

It is a little confusing, even what the thread was about.

But I think the poster was indicating that the post above yours was the solution, just without what looks like a while wend loop, with exitloop in place of break.

begin

if ABuf.Canvas.Pixels[2,i] = TAGCOLOR then Break;

Result := Result + 1;

end;

ABuf.Free;

end;

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

You change the title of the topic to [solved] and i don see any solution :graduated: , can you share it?

Sorry for Coming back late.

I found a easy way to count the height of a line(following code) in AU3. Then I sended my delphi code and your au3 code to my friend through email.

He emailed back and said: It's ok! So I changed the thread title to [solved].

In fact, I yet don't know how to change the $hBMP's size for animation:

$hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height)

~~~~~~~~~~~~~~~~?

You're expert in AU3. Maybe you can teach me how to Bitblt(Transfer). It's seem to there isnot Canvas object in AU3

===================================================================================

#include <StructureConstants.au3>

#include <ScrollBarConstants.au3>

#include <GUiScrollBars.au3>

#include <SendMessage.au3>

#Include <WinAPI.au3>

#Include <GDIPlus.au3>

#cs

Run("Notepad")

Sleep(200)

$hWin = WinGetHandle("[CLASS:Notepad]")

#ce

ShellExecute("WordPad")

Sleep(500)

$hWin = WinGetHandle("[CLASS:WordPadClass]")

For $i = 1 To 100

ControlSend($hWin, "", "RICHEDIT50W1", $i & @LF)

;ControlSend($hWin, "", "Edit1", $i & @LF)

Next

$hCtrl = ControlGetHandle("[CLASS:WordPadClass]", "", "RICHEDIT50W1")

;$hCtrl = ControlGetHandle("[CLASS:Notepad]", "", "Edit1")

_SendMessage($hCtrl, $WM_VSCROLL, $SB_TOP, 0)

Local $ThumbTop = _GUIScrollBars_GetScrollBarXYThumbTop($hCtrl, $OBJID_VSCROLL)

Do

$AlineHeight = NextLineHeight($hCtrl)

_SendMessage($hCtrl, $WM_VSCROLL, $SB_LINEDOWN, 0)

Sleep(100)

Until IsScrollEnd($hCtrl)

Func NextLineHeight($hCtrl)

Local $ThumbTopNow, $LineHeight

$ThumbTopNow = _GUIScrollBars_GetScrollBarXYThumbTop($hCtrl, $OBJID_VSCROLL)

$LineHeight = $ThumbTopNow - $ThumbTop

$ThumbTop = $ThumbTopNow

ConsoleWrite($LineHeight & @CRLF)

Return $LineHeight

EndFunc

Func IsScrollEnd($hCtrl)

Local $nPos, $nMax, $nPage

$nPos = _GUIScrollBars_GetScrollInfoPos($hCtrl, $SB_VERT)

$nMax = _GUIScrollBars_GetScrollInfoMax($hCtrl, $SB_VERT)

$nPage = _GUIScrollBars_GetScrollInfoPage($hCtrl, $SB_VERT)

Return $nPos == ($nMax - $nPage)

EndFunc

===================================================================================

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...