Jump to content

DllCall Newbie question


Recommended Posts

Hello i am trying to detect pixel change during movie playback on windows mediaplayer. I know autoit has a build-in GetPixelColor function but it doesnt work on a movie playback.

I stumbled onto a small chunk of VB6 code on google that uses GetPixel in gdi32.dll, but I am a newb programmer without visual basic background.

>>I tried to translate these:

Dim hdc As Long

Dim color As Long

hdc = GetDC(0)

color = GetPixel(hdc, x, y)

>>Into AutoIt3

$hdc = DllCall("user32", "hwnd", "GetDC", "hwnd", 0)

$color = DllCall("gdi32", "long", "GetPixel", "hwnd", $hdc, "int", $x, "int", $y)

But it seems that $color is always -1 regardless of any $x / $y values i put in

Can somebody help ?

:lmao:

Link to comment
Share on other sites

Obviously you haven't fully read the documentation for DllCall() yet. If you had, you wouldn't of asked that question, and you would also see the error in your code as to why it doesn't work.

Edit: Typo (Fixed).

Edited by Valik
Link to comment
Share on other sites

Obviously you haven't fully read the documentation for DllCall() yet.  If you had, you wouldn't of asked that question, and you would also see the error in your code as to why it doesn't work.

It's rather easy to miss in the docs after the big Valid Types table. I made the same mistake the first time.

Return value is an array; try

$result = DllCall(...)

MsgBox(4096,"Info", $result[0])

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

thx for the replies

i did know the return value is in arrary

i made the mistake of saying " $color is always -1 "

when i meant $color[0] is always -1

i'll keep trying

<{POST_SNAPBACK}>

If you are aware of the fact that DllCall returns an array, then you should know that your dc value should be $hdc[0] and the type should be "ptr". Have a look at Jon's DllCall thread in the developers forum for a list of valid types.

$hdc = DllCall("user32", "ptr", "GetDC", "hwnd", 0)
$color = DllCall("gdi32", "long", "GetPixel", "ptr", $hdc[0], "int", $x, "int", $y)
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...