AC130 Posted June 28, 2011 Share Posted June 28, 2011 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? Link to comment Share on other sites More sharing options...
Richard Robertson Posted June 28, 2011 Share Posted June 28, 2011 You need to separate the parameters. cAutoIt.Opt("MouseCoordMode", 2) Link to comment Share on other sites More sharing options...
AC130 Posted June 28, 2011 Author Share Posted June 28, 2011 (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 June 28, 2011 by AC130 Link to comment Share on other sites More sharing options...
taietel Posted June 28, 2011 Share Posted June 28, 2011 Try this: cAutoIt.Opt "MouseCoordMode", 2 Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
AC130 Posted June 28, 2011 Author Share Posted June 28, 2011 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 ) Link to comment Share on other sites More sharing options...
Richard Robertson Posted June 29, 2011 Share Posted June 29, 2011 Get rid of the parenthesis the same way as with Opt. Visual Basic is one of those inconsistent languages. Link to comment Share on other sites More sharing options...
AC130 Posted June 30, 2011 Author Share Posted June 30, 2011 (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 June 30, 2011 by AC130 Link to comment Share on other sites More sharing options...
taietel Posted June 30, 2011 Share Posted June 30, 2011 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 Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
Brid Posted June 30, 2011 Share Posted June 30, 2011 sorry i can't Link to comment Share on other sites More sharing options...
taietel Posted June 30, 2011 Share Posted June 30, 2011 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. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
AC130 Posted July 1, 2011 Author Share Posted July 1, 2011 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. Link to comment Share on other sites More sharing options...
taietel Posted July 1, 2011 Share Posted July 1, 2011 AC130, what is "Error" in your script? Maybe "vbError"? Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
AC130 Posted July 1, 2011 Author Share Posted July 1, 2011 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. Link to comment Share on other sites More sharing options...
JohnOne Posted July 1, 2011 Share Posted July 1, 2011 Does VB implicitly convert 0x000000 to 0? AutoIt Absolute Beginners  Require a serial  Pause Script  Video Tutorials by Morthawt  ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
taietel Posted July 1, 2011 Share Posted July 1, 2011 Yes. &H000000 = &H0 = 0. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
AC130 Posted July 1, 2011 Author Share Posted July 1, 2011 (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 July 1, 2011 by AC130 Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 2, 2011 Share Posted July 2, 2011 I think you wantPixelSearch = 0 Do While PixelSearch = 0 PixelSearch = cAutoIt.PixelSearch(1000, 1000, 1000, 1000, &H0) Loop MsgBox("Pixel Found") Link to comment Share on other sites More sharing options...
AC130 Posted July 2, 2011 Author Share Posted July 2, 2011 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? Link to comment Share on other sites More sharing options...
AC130 Posted July 2, 2011 Author Share Posted July 2, 2011 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. Link to comment Share on other sites More sharing options...
Richard Robertson Posted July 2, 2011 Share Posted July 2, 2011 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now