LibFunc>user32 - reading data

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Spudwars
Newbie
Posts: 13
Joined: Fri Dec 09, 2005 1:01 pm

LibFunc>user32 - reading data

Post by Spudwars » Fri Dec 16, 2005 2:49 pm

Hi again,

I would like to be able to read more information from a program in use. When it returns an error window, I would like to log the details of the error (error number - listed in the title - and the error description - listed in one of the "Static" fields).

I was very helpfully provided with this piece of code, which works rather well!
LibFunc>user32,FindWindowA,loginWindow_hwnd,FNWNS390,

Here's the details from your Open Windows program:
1771330 - #32770 "AGS Error n° 005"
526282 - Button "OK"
395010 - Static ""
263944 - Static "Connection refused for user USER.

Enter another username or another password."
I get numerous error codes, and would like to note the errors all down. How do I find which fields to access / copy the info from?


Also, this LibFunc seems very handy with User32 - is there anywhere I can go to find out about other functions I can possible use in my script?

Thanks

Chris.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: LibFunc>user32 - reading data

Post by Marcus Tettmar » Fri Dec 16, 2005 3:33 pm

Spudwars wrote:I get numerous error codes, and would like to note the errors all down. How do I find which fields to access / copy the info from?
I'm not sure what you mean. Sounds like you are asking a question about the software you are automating, in which case I don't know the answer. Or have I got this wrong?
Also, this LibFunc seems very handy with User32 - is there anywhere I can go to find out about other functions I can possible use in my script?
The Win32 SDK documentation from Microsoft. Search msdn.microsoft.com

This site is quite useful too. The examples are in Visual Basic but it is easy to translate:

http://www.mentalis.org/apilist/apilist.php
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Spudwars
Newbie
Posts: 13
Joined: Fri Dec 09, 2005 1:01 pm

Post by Spudwars » Fri Dec 16, 2005 3:54 pm

Basically, I'm trying to copy into a variable in the script the error code (005) and the error message (Connection refused for user USER. Enter another username or another password) from the open window. The details of the open window are here below (taken from your Open Windows program):
1771330 - #32770 "AGS Error n° 005"
526282 - Button "OK"
395010 - Static ""
263944 - Static "Connection refused for user USER. Enter another username or another password."
So I'm looking to code something like:
GetWindowHandle>AGS Error*,windowHandle
LibFunc>user32,???blah???,errorNumber,windowHandle?,

GetWindowHandle>AGS Error*,windowHandle
LibFunc>user32,???blah???,errorMessage,windowHandle?,

Message>Error number is: %errorNumber% %CR% Error message is: %errorMessage%
I'll take a look at the microsoft website details another day, after today I don't have any more time until after the hols really.

Thanks for your reply
Chris.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Dec 16, 2005 4:00 pm

"AGS Error n° 005" is the window title. The last part within the quotes in the View System Windows tool is the window title. So you just need to get the window title - you could use GetActiveWindow or GetControlText. Then just parse the result to extract the number.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Spudwars
Newbie
Posts: 13
Joined: Fri Dec 09, 2005 1:01 pm

Post by Spudwars » Fri Dec 16, 2005 4:18 pm

Thanks for the tip, I'm using:
GetControlText>%title%,Static,2,errorMessage

This returns the message fine. The title is easy to obtain too, but how do you parse it easily for just the number? Do you have any proceedures for this?

Cheers

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Dec 16, 2005 4:23 pm

Does the title always begin with "AGS Error n°"? If so the error code alsways starts at the 14th character. So just do:

Length>title,lent
MidStr>title,14,lent,errcode

If it is not as simple as that you could use Regular Expressions or a function to remove all the no-numeric characters.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Spudwars
Newbie
Posts: 13
Joined: Fri Dec 09, 2005 1:01 pm

Post by Spudwars » Fri Dec 16, 2005 4:34 pm

Good point, yes it does always start that so trimming it to length will do nicely. thanks!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts