Jump to content

WinActivate


AC130
 Share

Recommended Posts

  • Replies 54
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

If the others work fine then calling convention isn't it.

You need to pass it a character array and not a string for the szRetText parameter and the nBufSize would be the length of the array. I don't believe you are ready for P/Invoke.

So, (ByVal szText As Char)... I'll give it a try. What should I put as the szText and buffer if I just want to use Calculator as the 3rd party program?

Link to comment
Share on other sites

Show me your declaration and usage.

Public Declare Function AU3_WinGetHandle Lib "AutoItX3" (ByVal Title As String, Optional ByVal Text As String = "", Optional ByVal szText As String = "", Optional ByVal Buffer As Integer = 256) As Char

Link to comment
Share on other sites

More facepalms. I can't tell if you're a poor programmer or poor English reader at this point.

Public Declare Sub AU3_WinGetHandle Lib "AutoItX3" (ByVal szTitle As String, ByVal szText As String, ByRef szRetText() As Char, ByVal nBufSize As Integer)

Dim buffer(32) As Char
AU3_WinGetHandle("Notepad", Nothing, buffer, 32)
Dim result As String = New String(buffer)

You now have a string containing the window handle as I believe it is returned as a string.

I must repeat though, you aren't ready for this kind of interop.

Link to comment
Share on other sites

I expect that the problem is my unfamiliarity with VB.Net. Also, try sending "" instead of Nothing when calling it. See if that helps.

Edit: It's a different error now... Actually, two.

The runtime has encountered a fatal error. The address of the error was at 0x5e41a520, on thread 0x1518. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

After I press continue...

Exception of type 'System.ExecutionEngineException' was thrown.

Edited by AC130
Link to comment
Share on other sites

Ok, that means that the function call is still incorrect and I'm blaming it on my lack of experience in VB.Net. There's a thread somewhere in here that has most of the functions mapped out already in VB.Net. See if you can find that.

The thread is in C# and doesn't have the WinGetHandle declaration. I think that's the thread you're referring to, anyway...

Owell, just one last problem then. What's up with pixelsearch? I know this declaration is correct, but results in the same error as what we were experiencing with WinGetHandle:

Public Declare Sub AU3_PixelSearch Lib "AutoItX3" (ByVal nLeft As Integer, ByVal nTop As Integer, ByVal nRight As Integer, ByVal nBottom As Integer, ByVal nCol As Integer, Optional ByVal Shade As Integer = 0, Optional ByVal nStep As Integer = 1, Optional ByVal hWnd As String = "")

I tried "hWnd" with IntPtr instead of string, but still the same error. It's probably because I may be calling it wrong.

AU3_PixelSearch(1,1,1,1,&HFFFFFF)

I also tried setting the PixelCoordMode, but no success. My only guess is the color is wrong. AI uses Hex, but VB.NET uses RGB. This should really be the last problem I'm having.

Link to comment
Share on other sites

There was a thread that had VB.Net bindings but I'm not sure what happened to it.

I'm not sure what your problem is though because I haven't got the AutoIt docs or recent VB.Net experience.

I only have three functions left that I need to import from AutoItX:

AU3_API void WINAPI AU3_PixelSearch(long nLeft, long nTop, long nRight, long nBottom, long nCol, /*default 0*/long nVar, /*default 1*/long nStep, LPPOINT pPointResult);

AU3_API void WINAPI AU3_Send(const char *szSendText, /*[in,defaultvalue(0)]*/long nMode);

AU3_API long AU3_error(void);

I've tried PixelSearch as stated above, and it's not working.

I thought I had tried error, but it turns out the reason it wasn't working was because PixelSearch wasn't working, thus the error I was receiving was from PixelSearch, not error. It will probably work once I get PixelSearch working.

I haven't tried send yet, because I like to go in order, but I'm fairly sure it will work.

I'm starting to think that the problem is in AutoItX itself, and not API/VB.NET.

Do you mind posting your declarations in C#, since that what's your familiar with? I'll probably have a better chance that way.

Thank you for taking the time to help.

Link to comment
Share on other sites

To get around Send, you should try VB's SendKeys thing.

As I already said though, I don't have AutoIt installed at all so I haven't got the files since I reformatted.

Yes, I know the VB.NET equivalent's for AutoIt; SendWait for Send, GetPixel for PixelSearch, and I don't really need an error return.

Just let me know when you get everything setup, please. It just really irritates me that only one function won't work! :(

Link to comment
Share on other sites

Thus far, I only can't get PixelSearch working. I have yet to try error, and Send works great. I used to have a problem with MouseClick; it also wouldn't work, but I tried using an older DLL, and it worked. (I was using the latest version). I tried swapping DLL's numerous amounts of times to try PixelSearch, but none worked. I posted the declarations above.

Edit: Oh yeah, I gave up on WinGetHandle. So, that too.

Edited by AC130
Link to comment
Share on other sites

That's all big nothing. I don't believe a word you are saying, as far as I can see you tried nothing.

I won't say there aren't bugs on our side, I'll just say you are terrible with all this. Hell, you don't even know how to this simple forum interface (hint: code tags). You either have visual disturbances and use screen reader of some sort that can't read in-between code tags or you are just little short.

Learn some language basics and then come back and ask questions.

Good luck learning.

Edited by trancexx

♡♡♡

.

eMyvnE

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...