Sign in to follow this  
Followers 0
AC130

Visual Basic 6

22 posts in this topic

Hello, I am trying to use AutoitX with visual basic 6.

I already registered the DLL, and called it in my general section.

What I'm trying to do is MouseMove to a location in calculator.

cAutoit.Opt ("MouseCoordMode,2")

But whenever I try to run this, it says;

"Invalid Outside Procedure"

Could someone help me out here?

Share this post


Link to post
Share on other sites



You need to separate the parameters.

cAutoIt.Opt("MouseCoordMode", 2)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ok I'll try that. Do I put it in general section?

How to make it only work in calculator?

Do I need WinGetHandle?

If so, how do I use that? Thanks for replying also.

Edit: When I use your code it says, "Compile error, Expected: ="

Edited by AC130

Share this post


Link to post
Share on other sites

Hmm I guess that worked..

Can you tell me why this isn't working?

cAutoit.PixelSearch (0,0,500,500, 0x000000, DEFAULT, DEFAULT)

It says Compile Error Expected: list seperator or )

Share this post


Link to post
Share on other sites

Get rid of the parenthesis the same way as with Opt. Visual Basic is one of those inconsistent languages.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hello everyone again. Just a few questions.

Does PixelSearch automatically search for a pixel in the active window, or is it the whole screen?

Also, could someone post an example of using PixelSearch using AutoItX.

In Autoit, I use:

PixelSearch ( 0, 0, 500, 500, 0x000000, DEFAULT, DEFAULT, $hwnd)

However this is not working in Visual Basic. I tried removing the parentheses.

I have definitely tried...

Edited by AC130

Share this post


Link to post
Share on other sites

However this is not working in Visual Basic.

Private Sub Form_Load()
Dim cAutoIt As New AutoItX3
Dim c() As Variant
c = cAutoIt.PixelSearch(0, 0, 500, 500, &HFF0000, -1, -1)
MsgBox c(0) & vbCrLf & c(1)
End Sub

Share this post


Link to post
Share on other sites
:) sorry i can't

Share this post


Link to post
Share on other sites

What exactly you can not? Have you even tried to run in Visual Basic 6 the code posted above?

That was a working example of how to use that PixelSearch function in VB6, not a full-blown one.

Share this post


Link to post
Share on other sites

Well thanks guys. Everything is working good now. Could you help me do one more thing though?

I'm trying to pixelsearch until the pixel is found. so far I have

Do Until Not Error
c = cAutoIt.PixelSearch(0, 0, 500, 500, &HFF0000, -1, -1)
Loop
MsgBox ( "Pixel Found" )

This I guess isn't working though, considering that I now the pixel is there, and it isn't message boxing.

Thanks in advance. :)

Share this post


Link to post
Share on other sites

ok well in AutoIt i use this:

Func Search ()
Do
PixelSearch ( 0, 0, 50, 50, 0x000000, DEFAULT, DEFAULT)
Until Not @Error
MsgBox (0, "Success", "Pixel Found" )
EndFunc

This code keeps pixelsearching in that area until 0x000000 color is found, and then once it's found it Message boxes, Pixel Found.

I'm trying to do that in VB6.

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Ok here is my current code:

Do Until NonError
PixelSearch = cAutoIt.PixelSearch ( 1000, 1000, 1000, 1000, &H0000000)
Loop
MsgBox ( "Pixel Found" )

NonError:
PixelSearch1 = cAutoIt.PixelSearch ( 1000, 1000, 1000, 1000, &H0000000) = True
EndSub

But it's not working, even though I know the pixel is there. Thanks in advance...

Edited by AC130

Share this post


Link to post
Share on other sites

I think you want

PixelSearch = 0
Do While PixelSearch = 0
    PixelSearch = cAutoIt.PixelSearch(1000, 1000, 1000, 1000, &H0)
Loop
MsgBox("Pixel Found")

Share this post


Link to post
Share on other sites

wow that looks exactly right. :) thank you so much. ;) also, &HFCFCFC is the same as 0xFCFCFC right? I don't have to add any more parameters to make it search for that color?

Share this post


Link to post
Share on other sites

Case vbKeyF1
PixelSearch = 0
Do While PixelSearch = 0
    PixelSearch = cAutoit.PixelSearch(1000, 1000, 1000, 1000, &H0)
Loop
MsgBox ("Pixel Found")
End Select

Whenver I run this, it automatically says Pixel Found even if it's not there.

Share this post


Link to post
Share on other sites

Oh ok I looked it up. It doesn't return 0 on failure. It sets error instead.

Do
    PixelSearch = cAutoit.PixelSearch(1000, 1000, 1000, 1000, &H0)
Loop Until cAutoIt.error = 0
MsgBox ("Pixel Found")

This will run until AutoIt's error is zero, meaning no error.

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