Jump to content

PDF Scroll with CLASS


Recommended Posts

Ok I have a PDF im using it's big. I need to hit the go Button then i want it to set zoom at 170 then,

using CLASS call function to move the scroll bars to a certain X,Y Coord

the zoom works perfectly but it wont move the scrollbar it moves part of the PDF. ex; cnote func

CODE
#include <GUIConstants.au3>

Dim $oMyError

Dim $File

Dim $Version

HotKeySet("{f1}","stopit")

$oPDF = ObjCreate("AcroPDF.PDF.1");

$Version=$oPDF.GetVersions

$oPDF.src="C:\my.pdf"

GuiCreate("PDFER",@DesktopWidth,@DesktopHeight, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$jumbo = GUICtrlCreateButton("go",1180,561,20)

$GUI_ActiveX = GUICtrlCreateObj ($oPDF,30,30, 1120 , 800)

GUICtrlSetStyle ( $GUI_ActiveX, $WS_VISIBLE )

GuiSetState(@SW_SHOW)

GuiSetState(@SW_MAXIMIZE)

While 1

$msg = GuiGetMsg()

Select

Case $msg = $jumbo

cnote()

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

EndSelect

WEnd

$oPDF = ""

$GUIActiveX = ""

Exit

func cnote()

WinExists("PDFER", "")

WinActivate("AutoIt v3 GUI", "")

Sleep(1000)

$no = WinGetHandle("AutoIt v3 GUI")

ControlFocus($no,"", "Edit2")

Sleep(1000)

ControlSetText($no,"", "Edit2",'170')

Send('{enter}')

Sleep(1000)

WinActivate("[CLASS:ScrollBar;INSTANCE:1]", "")

Sleep(1000)

$yo = WinGetHandle("[CLASS:ScrollBar;INSTANCE:1]")

Sleep(1000)

ControlFocus("","",$yo)

ControlMove ("", "",$yo,408,13)

EndFunc

Func stopit()

Exit

EndFunc

need help please thanks in advance

Edited by lordicast
[Cheeky]Comment[/Cheeky]
Link to comment
Share on other sites

OK, some funkiness here:

1. You put style properties where the x/y coord belongs in the GuiCreate().

2. You create the GUI to fill the screen but then statically place the button, meaning it may not be visible.

3. You typo'd $GUI_ActiveX in one place.

4. You specify a window title as "AutoIt v3 GUI" which is the window class. To use CLASS to specify a window, first set Opt("WinTitleMatchMode", 4), and then use "[CLASS:AutoIt v3 GUI; INSTANCE 1]" in place of the window title. But this is not required because you can just capture the handle of the GUI, which is returned when you create it: $hGUI = GuiCreate().

5. I can't find ScrollBar1, on the GUI. Only ScrollBars 2, 3, and 4. And moving the scrollbar may not be what you want. There is a control for moving the split between the vertical panes at "[CLASS:AVL_AVView; TEXT:AVSplitterDragView]".

6. Moving the AVSplitterDragView control doesn't do anything, so I tried it with a MouseClickDrag(), which matches how you would use it manually.

7. Nobody but you has "my.pdf", so they can't know if there is anything special going on there. The demo below uses an Adobe readme that most people probably have:

#include <GUIConstants.au3>
#include <array.au3>

Opt("MouseCoordMode", 2) ; 2 = Window client area

Global $oMyError, $oPDF, $File, $Version, $Jumbo_Button, $GUI_ActiveX, $hGUI
Global $iW = @DesktopWidth - 100, $iH = @DesktopHeight - 100, $fJumbo = False

$oPDF = ObjCreate("AcroPDF.PDF.1");
$Version = $oPDF.GetVersions
$oPDF.src = "C:\Program Files\Adobe\Acrobat 7.0\Help\ENU\Reader.pdf"
$hGUI = GUICreate("PDFER", $iW, $iH, 50, 50, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$Jumbo_Button = GUICtrlCreateButton("Jumboize", ($iW / 2) - 50, $iH - 50, 100, 30)
$GUI_ActiveX = GUICtrlCreateObj($oPDF, 20, 20, $iW - 40, $iH - 90)
GUICtrlSetStyle($GUI_ActiveX, $WS_VISIBLE)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $Jumbo_Button
            cnote()
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd
$oPDF = ""
$GUI_ActiveX = ""
Exit

Func cnote()
    ; toggle jumbo mode
    $fJumbo = Not $fJumbo
    Sleep(1000)
    If $fJumbo Then
        ControlSetText($hGUI, "", $Jumbo_Button, "Normalize")
        ControlSetText($hGUI, "", "Edit2", '170')
    Else
        ControlSetText($hGUI, "", $Jumbo_Button, "Jumboize")
        ControlSetText($hGUI, "", "Edit2", '75')
    EndIf
    ControlSend($hGUI, "", "Edit2", '{Enter}')
    Sleep(1000)
    
    ; move scrollbar
    Local $hScrollBar = ControlGetHandle($hGUI, "", "[CLASS:ScrollBar; INSTANCE:2]")
    ControlFocus($hGUI, "", "[CLASS:ScrollBar; INSTANCE:2]")
    Sleep(1000)
    Local $avPos = ControlGetPos($hGUI, "", "[CLASS:AVL_AVView; TEXT:AVSplitterDragView]")
    _ArrayDisplay($avPos, "Debug: $avPos")
    $avPos[0] += $avPos[2] / 2
    $avPos[1] += $avPos[3] / 2
    MouseClickDrag("Left", $avPos[0], $avPos[1], $avPos[0] - 100, $avPos[1], 50)
EndFunc   ;==>cnote

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

awesome idea however i get the

other.au3 (51) : ==> Subscript used with non-Array variable.:

$avPos[0] += $avPos[2] / 2

$avPos^ ERROR

Tested fine for me.

Use Au3Info.exe and check on the "[CLASS:AVL_AVView; TEXT:AVSplitterDragView]" control. If $avPos is not an array, then ControlGetPos() failed, probably because that control specification is different in your version of Adobe.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Using Adobe 8

"[CLASS:AVL_AVView; TEXT:AVSplitterDragView]"

has been changed to

"[CLASS:AVL_AVView; TEXT:AVSplitterView]"

works ok however it doesnt move to a X,Y coord. instead it pops Debug

_ArrayDisplay($avPos, "Debug: $avPos") and hangs

Mouse drag not effective at all...

**** EDIT

In addition im trying to move the scrollbars without having to use Mouse drag

Edited by lordicast
[Cheeky]Comment[/Cheeky]
Link to comment
Share on other sites

Using Adobe 8

"[CLASS:AVL_AVView; TEXT:AVSplitterDragView]"

has been changed to

"[CLASS:AVL_AVView; TEXT:AVSplitterView]"

works ok however it doesnt move to a X,Y coord. instead it pops Debug

_ArrayDisplay($avPos, "Debug: $avPos") and hangs

Mouse drag not effective at all...

**** EDIT

In addition im trying to move the scrollbars without having to use Mouse drag

The #include <array.au3>, and the _ArrayDisplay() are only there for debug purposes and can be completely deleted.

The Click-n-Drag was the only way I saw to move the divider between the panes. Moving a scrollbar will not change the size of the window pane it's attached to.

Good luck with it... Maybe the smart people will chime in and tell us how it's done.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...