Jump to content

Solved: Class INSTANCE Always Change in Acrobat PDF


Recommended Posts

Hi brothers,

Im trying to make an application to send (down) key when press (f5), but the problem is that 'AcrobatSDIWindow' randomly change its Class INSTANCE Value

So this is my Simple try to deal with that, while i think there must be better to get adobe INSTANCE Value

;#include<Myfuncs.au3>
HotKeySet('{F5}', "Send2")
HotKeySet('{F6}', "Send3")
HotKeySet('{ESC}', "_EXIT")
    For $i =17 to 100
        $test=ControlSend('[CLASS:AcrobatSDIWindow]','','[CLASS:AVL_AVView; INSTANCE:' & $i & ']',"{Down}")
    ;   print($i & ':' & $test)
        If $test=1 Then
            $True_INSTANCE= $i
            ExitLoop
        EndIf
    Next
    MsgBox(0,'$True_INSTANCE',$True_INSTANCE)
Global $True_INSTANCE
While 1
    Sleep(3000)
WEnd
Func Send2()
;   ControlClick('[CLASS:AcrobatSDIWindow]','','ScrollBar2','left',1,10, 581)
;~  Sleep(400)

    $test=ControlSend('[CLASS:AcrobatSDIWindow]','','[CLASS:AVL_AVView; INSTANCE:' & $True_INSTANCE & ']',"{Down}")
        ;Sleep(50)
        ;ControlSend('[CLASS:AcrobatSDIWindow]','','[CLASS:AVL_AVView; INSTANCE:17]',"{Down}")
;~  Next

EndFunc

Func Send3()
    ;ControlSend('[CLASS:AcrobatSDIWindow]','','[CLASS:AVL_AVView; INSTANCE:17]',"{UP}")
    ;ControlClick('[CLASS:AcrobatSDIWindow]','','ScrollBar2','left',1,9, 9)
;~  For $1=0 to 3
            $test=ControlSend('[CLASS:AcrobatSDIWindow]','','[CLASS:AVL_AVView; INSTANCE:' & $True_INSTANCE & ']',"{UP}")
        ;Sleep(50)
    ;   ControlSend('[CLASS:AcrobatSDIWindow]','','[CLASS:AVL_AVView; INSTANCE:17]',"{UP}")

;~  Next
EndFunc

Func _EXIT()

    EXIT
EndFunc
>>>> Window <<<<
Title:  _.pdf - Adobe Acrobat Pro
Class:  AcrobatSDIWindow
Position:   -8, -8
Size:   1382, 744
Style:  0x17CF0000
ExStyle:    0x00000100
Handle: 0x0000000000231F6C

>>>> Control <<<<
Class:  AVL_AVView
Instance:   17
ClassnameNN:    AVL_AVView17
Name:   
Advanced (Class):   [CLASS:AVL_AVView; INSTANCE:17]
ID: 
Text:   AVPageView
Position:   42, 75
Size:   1307, 611

Solved By:
Nine

Edited by abdulrahmanok
Link to comment
Share on other sites

Im not sure how this could help, Im already using control click, but the issue is that I want to get control click for Mid page so it can respond to (down) and (up) keys.. but when restart pdf the true value of Mid page which is: $i 

    $test=ControlSend('[CLASS:AcrobatSDIWindow]','','[CLASS:AVL_AVView; INSTANCE:' & $i & ']',"{Down}")

Keep changing so it sends (down) and (up) keys to wrong control which make no sense...

 

hope everything clear now.

Link to comment
Share on other sites

Please do not use large font like you had, you should know by now it is not very pleasant to get shout at.

My understanding is the you need to find the control handle of a control that changes instance all the time.  Now you are testing every possible instance until you find one.  By using something like this, it would streamline your code :

Local $hWnd = WinGetHandle("[CLASS:AcrobatSDIWindow]")
ConsoleWrite ($hWnd & @CRLF)
WinActivate($hWnd)
WinWaitActive($hWnd)
Local $hCtrl = ControlGetHandle ($hWnd,"","[REGEXPCLASS:AVL_AVView.*]")
ConsoleWrite ($hCtrl & @CRLF)
ControlSend ($hWnd, "", $hCtrl, "{DOWN 4}")

Add some error handling and you are set to go.  (Tested on Win7)

Link to comment
Share on other sites

20 minutes ago, Nine said:

Please do not use large font like you had, you should know by now it is not very pleasant to get shout at.

My understanding is the you need to find the control handle of a control that changes instance all the time.  Now you are testing every possible instance until you find one.  By using something like this, it would streamline your code :

Local $hWnd = WinGetHandle("[CLASS:AcrobatSDIWindow]")
ConsoleWrite ($hWnd & @CRLF)
WinActivate($hWnd)
WinWaitActive($hWnd)
Local $hCtrl = ControlGetHandle ($hWnd,"","[REGEXPCLASS:AVL_AVView.*]")
ConsoleWrite ($hCtrl & @CRLF)
ControlSend ($hWnd, "", $hCtrl, "{DOWN 4}")

Add some error handling and you are set to go.  (Tested on Win7)

Its working only when Pdf window is active, is there is anyway to make it work while inactive window?

 

This is another try to get true control using the size and XY postion:

For $i =17 to 200
        $test=ControlSend('[CLASS:AcrobatSDIWindow]','','[CLASS:AVL_AVView; INSTANCE:' & $i & ']',"{Down}")
        print($i & ':' & $test)
        If $test=1 Then
            $True_INSTANCE= $i
        $aPos=ControlGetPos ( '[CLASS:AcrobatSDIWindow]', "", '[CLASS:AVL_AVView; INSTANCE:' & $i & ']' )
        Global $X= $aPos[0] ,$Y=$aPos[1], $SizeX=$aPos[2], $SizeY=$aPos[3]

            If $X>=63 And $Y>=84 And $SizeX=0 And $SizeY>=584 Then
                ExitLoop
 MsgBox( 0,$True_INSTANCE, "Position: " & $aPos[0] & ", " & $aPos[1] & @CRLF & "Size: " & $aPos[2] & ", " & $aPos[3])
 ;ClipPut($aPos[0] & ", " & $aPos[1] & @CRLF & "Size: " & $aPos[2] & ", " & $aPos[3])
 ;63, 84
;Size: 0, 584
            else
                $test=0
            EndIf

        EndIf
    Next

 

Link to comment
Share on other sites

Ok, I was thinking that RegExp was on CLASSNN, but it is not, it is on Class only.  So my error, but if you use the TEXT, it seems to be working :

Local $hWnd = WinGetHandle("[CLASS:AcrobatSDIWindow]")
ConsoleWrite ($hWnd & @CRLF)
Local $hCtrl = ControlGetHandle ($hWnd,"","[CLASS:AVL_AVView;TEXT:AVPageView]")
ConsoleWrite ($hCtrl & @CRLF)
ControlSend ($hWnd, "", $hCtrl, "{DOWN 4}")

 

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...