Jump to content

Recommended Posts

Posted

hello all,

my overall goal is to be able to be able to run a script, then it go threw all the panes that it needs to then take screenshots of the pages, that are of value

my targeted program is towards vnc viewer, (this is work related, i work flowback in the oil industry)

my issue is when im 2-3 pages deep into the vnc i want it to back out to the main screen then go into the next category but my code will keep clicking, causing it to go past the main screen and open up another options pane that will throw the rest of the code off.

my code:

#include <MsgBoxConstants.au3>

HotKeySet("e", "EndProgram")
func EndProgram()
    Exit
EndFunc

WinWait ( '192.168.1.2 (PanelView VNC Server) - VNC Viewer', '' )
WinActivate ( '192.168.1.2 (PanelView VNC Server) - VNC Viewer', '' )
Sleep(1000)
WinMove ( '192.168.1.2 (PanelView VNC Server) - VNC Viewer', '', '', '', 710, 710 )
$_WinPos = WinGetPos ( '192.168.1.2 (PanelView VNC Server) - VNC Viewer', '' )
$gold = PixelGetColor($_WinPos[0]+$_WinPos[2]/2.13, $_WinPos[1]+$_WinPos[3]/5.30) ;returns 15446573
;MsgBox("","gold",$gold) 
$gold2 = 15446573



;button locations
;middle- MouseClick ( 'Left', $_WinPos[0]+$_WinPos[2]/2, $_WinPos[1]+$_WinPos[3]/2, 1 )
;goldpixel- MouseClick ( 'Left', $_WinPos[0]+$_WinPos[2]/2.13, $_WinPos[1]+$_WinPos[3]/5.30, 1 )
;saltwater button- MouseClick ( 'Left', $_WinPos[0]+$_WinPos[2]/2.5, $_WinPos[1]+$_WinPos[3]/1.07, 1 )
;main button- MouseClick ( 'Left', $_WinPos[0]+$_WinPos[2]/1.1, $_WinPos[1]+$_WinPos[3]/1.07, 1 )
;rolf7 button- ;MouseClick ( 'Left', $_WinPos[0]+$_WinPos[2]/4, $_WinPos[1]+$_WinPos[3]/2, 1 )




;rolf 7
backout()
;;Sleep(1000)
;MouseClick ( 'Left', $_WinPos[0]+$_WinPos[2]/4, $_WinPos[1]+$_WinPos[3]/2, 1 )
;print()
;MouseClick ( 'Left', $_WinPos[0]+$_WinPos[2]/6.8, $_WinPos[1]+$_WinPos[3]/5, 1 )
;sleep(1000)
;send("{PRINTSCREEN}")
;sleep(1000)
;Backout()
;Sleep(1000)









;--------------------------------------------------------functions---------------------------------------------------------

Func print()
    Sleep(1000)
    send("{PRINTSCREEN}")
    sleep(1000)
    MouseClick ( 'Left', $_WinPos[0]+$_WinPos[2]/2.5, $_WinPos[1]+$_WinPos[3]/1.07, 1 )
    sleep(1000)
EndFunc


;back out to main screen
Func Backout()
    IF $gold <> $gold2 then MouseClick ( 'Left', $_WinPos[0]+$_WinPos[2]/1.1, $_WinPos[1]+$_WinPos[3]/1.07, 1 )
    sleep(1000)
    IF $gold <> $gold2 then MouseClick ( 'Left', $_WinPos[0]+$_WinPos[2]/1.1, $_WinPos[1]+$_WinPos[3]/1.07, 1 )
    ;sleep(1000)
    ;IF $gold <> $gold2 then MouseClick ( 'Left', $_WinPos[0]+$_WinPos[2]/1.1, $_WinPos[1]+$_WinPos[3]/1.07, 1 )
EndFunc

This line of code, that pulls a pixel is a static pixel, no where else in the vnc, that pixel is static and never changes. all ways returns the same variable.

$gold = PixelGetColor($_WinPos[0]+$_WinPos[2]/2.13, $_WinPos[1]+$_WinPos[3]/5.30) ;returns 15446573

thank you for your time, if you decided to help, if you cant, thanks for reading.

I hope i gave you all enough info and dont confuse anyone.

Posted

MouseClick and PixelGetColor are the worst way to automate an application.  You should truly consider using a control-based approach.

Since we do not have your specific application, it is hard for us to help you efficiently.  But at first glance, the issue could be that you do not update the $gold variable after each click.

If you are interested to use a better approach, you should try using au3info.exe tool to see if controls are readable this way.  Also post a printscreen of the application so we can see what it looks like.

Posted

 

 

i do not have a main screen picture, as i said, i am accessing this program threw a vnc viewer, i will check when i get back to work if there is any info in the au3info has anything in it.

 

000186.png.5c02085ba0c14ac38ebba02093f1cb5f.png000185.png.e6c8dc10ab6359bde4b4b4043d450177.png

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
  • Recently Browsing   0 members

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