Sign in to follow this  
Followers 0
techted89

PixelSearch not working with #RequireAdmin

5 posts in this topic

Okay im trying to get this script to work - it automate's a VNC window on a windows 7 OS.

so the issue im having is with #RequireAdmin & PixelSearch

 

when run without #requireadmin it finds the pixel and it functions correctly.

with #requireadmin on it doesnt write to console even...

 

its strange...   been using autoit for years never had a issue like this >_<

 

$pixel = PixelSearch(347, 346, 347, 346, 0xFFFFFF, 1, 1, $handle)
    If Not @error Then
        ConsoleWrite("Found logout button" & @CR)
    Else
        ;switchit()
        ConsoleWrite("Not Found")
    EndIf

 

i could just use it without #requireadmin but then BlockInput() doesnt work... 

i know it will be hard to reproduce this error on your end cuz you dont have the client im using :/ but hopefully someone still has a bit of knowlegde on whats happening here.

Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client
Opt("PixelCoordMode", 2) ;1=absolute, 0=relative, 2=client

#RequireAdmin

Dim $handle, $pixel

$handle = WinActivate("[CLASS:VNCviewer]")




Func Startup()

    ControlClick("[CLASS:VNCviewer]", "", "[CLASS:ChildClass; INSTANCE:1]", "left", 1, 173, 485)

EndFunc   ;==>Startup()

switchit()

Func switchit()
    ControlClick("[CLASS:VNCviewer]", "", "[CLASS:ChildClass; INSTANCE:1]", "left", 1, 343, 553)
    Sleep(3000)
    ControlClick("[CLASS:VNCviewer]", "", "[CLASS:ChildClass; INSTANCE:1]", "left", 1, 337, 520)
    Sleep(4000)

    BlockInput(1)
    ;WinActivate("[CLASS:VNCviewer]")
    ;Sleep(10000)
    MouseClick("left", 178, 534)
    Sleep(2000)
    MouseClickDrag("left", 178, 534, 185, 206, 500)
    Sleep(1000)
    BlockInput(0)


    $pixel = PixelSearch(347, 346, 347, 346, 0xFFFFFF, 1, 1, $handle)
    If Not @error Then

        ConsoleWrite("Found logout button" & @CR)
    Else

        ;switchit()
        ConsoleWrite("Not Found")

    EndIf

EndFunc   ;==>switchit

Func logoutCheck()

    $pixel2 = PixelSearch(280, 300, 326, 350, 0xFFFFFF, 1, 1, $handle)
    If Not @error Then



        ConsoleWrite("Succesful logout" & @CR)
        ControlClick("[CLASS:VNCviewer]", "", "[CLASS:ChildClass; INSTANCE:1]", "left", 1, 320, 332)
        Sleep(2000)
        ControlClick("[CLASS:VNCviewer]", "", "[CLASS:ChildClass; INSTANCE:1]", "left", 1, 122, 302)
        Sleep(3000)
        MouseMove(184, 489)
        Sleep(500)
        MouseClick("left", 184, 489)
        Sleep(1500)
        MouseClickDrag("left", 184, 489, 175, 157)
        Sleep(500)
        MouseClickDrag("left", 184, 489, 175, 157)
        Sleep(1000)
        ControlClick("[CLASS:VNCviewer]", "", "[CLASS:ChildClass; INSTANCE:1]", "left", 1, 326, 464)
    Else


    EndIf

EndFunc   ;==>logoutCheck

Share this post


Link to post
Share on other sites



You can't use ConsoleWrite and #RequireAdmin, at least not running it from Scite.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

$pixel = PixelSearch(345, 345, 347, 346, 0xFFFFFF, 1, 1, $handle)
    If Not @error Then
        ;ConsoleWrite("Found logout button" & @CR)
        msgBox(1,"found","button found")
    Else
        ;switchit()
        ;ConsoleWrite("Not Found")
        msgBox(1,"not found","not found")
    EndIf
 

:/ consolewrite is not important was just error checking. iv tried with msgbox...   still no good.

same issue #requireadmin is causing pixelsearch to not function.

its not a problem with my script its a problem with #requireadmin. it works perfectly without it.

Edited by techted89

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

sorry double post :/

i tryed compling the program with #requireadmin

it works fine...  seems to be a #requireadmin / pixelsearch in SciTE problem.

WIERD :geek: 

Sorta Solved

Edited by techted89

Share this post


Link to post
Share on other sites

Is this your whole script? 


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
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
Sign in to follow this  
Followers 0