Jump to content

How to check if an object supports a member function


zzen11
 Share

Recommended Posts

How to check if an object supports a member function?

For example, I want to call $rtn = $o_object.HWND (), how do I check if $o_object supports the HWND() member function?

- Z

OLEView will often allow you to see COM object methods, and even occasionally provide syntax if you're working with MS objects.

http://www.microsoft.com/downloads/details...;displaylang=en

AutoIt only supports members reachable through the _IDispatch interface, so if the object doesn't support it, you won't be able to use it.

More detailed information about using OLEView for this purpose can be found in the helpfile. Search for COM Reference on the search tab. It walks you through.

-S

(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]
Link to comment
Share on other sites

I guess I am ok without calling the interface if it is not supported. The problem is that <IE.au3> tries to get the handle for all the shell objects, then call this function $o_object.HWND () to get the handle, but some object appraently does not have the HWND () support. So when I use __IEAttach(), it pops up a fatal error autoit dialog.

So In am thinking to fix it

1) by checking if the object supports the HWND () call.

2) wonder if autoit has a "on error goto" or catch exception function, so if it fails, I can move on (thus suppress the error dialog.

Hope someone has some idea of doing either 1) or 2)

- Z

OLEView will often allow you to see COM object methods, and even occasionally provide syntax if you're working with MS objects.

http://www.microsoft.com/downloads/details...;displaylang=en

AutoIt only supports members reachable through the _IDispatch interface, so if the object doesn't support it, you won't be able to use it.

More detailed information about using OLEView for this purpose can be found in the helpfile. Search for COM Reference on the search tab. It walks you through.

-S

Link to comment
Share on other sites

2) wonder if autoit has a "on error goto" or catch exception function, so if it fails, I can move on (thus suppress the error dialog.

Hope someone has some idea of doing either 1) or 2)

Have a good look at the helpfile for ObjEvent().

Calltip from helpfile

ObjEvent ( "AutoIt.Error" [, "function name"] )
oÝ÷ Ø[§qú襥ø¥y«­¢+Ø(ìQ¡¥Ì¥ÌµäÕÍѽ´¥¹Éɽȡ¹±È)Õ¹5åÉÉÕ¹ ¤((ÀÌØí!á9ÕµÈõ¡à ÀÌØí½5åÉɽȹ¹ÕµÈ°à¤ì½È¥ÍÁ±å¥¹ÁÕÉÁ½ÍÌ(5ͽà À°ÅÕ½ÐíÕѽ%Ñ
=4QÍÐÅÕ½Ðì°ÅÕ½Ðí]¥¹ÑÉÁÑ
=4ÉɽÈÌÌìÅÕ½ÐìµÀì
I1µÀì
I1µÀì|(ÅÕ½ÐíÉȹÍÉ¥ÁÑ¥½¸¥ÌèÅÕ½ÐìµÀìQµÀìÀÌØí½5åÉɽȹÍÉ¥ÁÑ¥½¸µÀì
I1µÀì|(ÅÕ½ÐíÉȹ¹ÕµÈ¥ÌèÅÕ½ÐìµÀìQµÀìÀÌØí!á9յȵÀì
I1µÀì|(ÅÕ½ÐíÉȹÍÉ¥Áѱ¥¹¥ÌèÅÕ½ÐìµÀìQµÀìÀÌØí½5åÉɽȹÍÉ¥Áѱ¥¹µÀì
I1|(¤(MÑÉÉ½È Ä¤ìѼ¡¬½ÈÑÈÑ¡¥Ìչѥ½¸ÉÑÕɹÌ)¹Õ¹(
Link to comment
Share on other sites

In your other post on this topic I suggested using _IEErrorHandlerRegister to avoid the fatal error (this does what MHz suggests above). You said you still got a fatal error... however I just test this and it works as expected... you get a COM error message writtn to the console, but the script continues (and you can trap and take action on the error if you choose:

#include <IE.au3>

[quote]_IEErrorHandlerRegister()
$oIE = _IEAttach("Foo")

ConsoleWrite("*** I got past the COM error..." & @CR)

Results in the following when something like the Firefox IE Tab extension is running:

>Running:(3.2.0.1):C:\Program Files\AutoIt3\autoit3.exe "C:\AutoItScripts\tmp-aurrll.au3"

--> COM Error Encountered in tmp-aurrll.au3

----> $IEComErrorScriptline = 2799

----> $IEComErrorNumberHex = 80020009

----> $IEComErrorNumber = -2147352567

----> $IEComErrorWinDescription = Unspecified error

----> $IEComErrorDescription =

----> $IEComErrorSource =

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext = 0

----> $IEComErrorLastDllError = 0

--> IE.au3 Warning from function _IEAttach, $_IEStatus_NoMatch

*** I got past the COM error...

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

I finally got the event handling working.

I also figured out a way to avoid this problem by insert some code into the <IE.au3>, checking browser window URL first before retrieving the the full html. Oddly the app that uses IE control and IE container and causing the problem allows me to retrieve the URL but not the html document. So I check the URL first, if the URL is not the URL I want, I just skip that window.

This set of IE functions does lots of wonder for me in automating things for my users.

Thanks for all the helps from all!

- Z

Have a good look at the helpfile for ObjEvent().

Calltip from helpfile

ObjEvent ( "AutoIt.Error" [, "function name"] )
oÝ÷ Ø[§qú襥ø¥y«­¢+Ø(ìQ¡¥Ì¥ÌµäÕÍѽ´¥¹Éɽȡ¹±È)Õ¹5åÉÉÕ¹ ¤((ÀÌØí!á9ÕµÈõ¡à ÀÌØí½5åÉɽȹ¹ÕµÈ°à¤ì½È¥ÍÁ±å¥¹ÁÕÉÁ½ÍÌ(5ͽà À°ÅÕ½ÐíÕѽ%Ñ
=4QÍÐÅÕ½Ðì°ÅÕ½Ðí]¥¹ÑÉÁÑ
=4ÉɽÈÌÌìÅÕ½ÐìµÀì
I1µÀì
I1µÀì|(ÅÕ½ÐíÉȹÍÉ¥ÁÑ¥½¸¥ÌèÅÕ½ÐìµÀìQµÀìÀÌØí½5åÉɽȹÍÉ¥ÁÑ¥½¸µÀì
I1µÀì|(ÅÕ½ÐíÉȹ¹ÕµÈ¥ÌèÅÕ½ÐìµÀìQµÀìÀÌØí!á9յȵÀì
I1µÀì|(ÅÕ½ÐíÉȹÍÉ¥Áѱ¥¹¥ÌèÅÕ½ÐìµÀìQµÀìÀÌØí½5åÉɽȹÍÉ¥Áѱ¥¹µÀì
I1|(¤(MÑÉÉ½È Ä¤ìѼ¡¬½ÈÑÈÑ¡¥Ìչѥ½¸ÉÑÕɹÌ)¹Õ¹(
Edited by zzen11
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...