Jump to content

Methods for ObjCreateInterface()


 Share

Recommended Posts

I'm new to AutoIt.  I've read all of the posts that I can find about ObjCreateInterface().  In the examples after the object is created it is used for with various methods ie. $object.xxx().  The help file for ObjCreateInterface() states "ObjCreateInterface() creates objects with methods that are listed in interface-description string."  Where is the referenced "interface-description string" located?

Thanks

Link to comment
Share on other sites

generally you get it from the object documentation, a com viewer, or in some cases from header files, idl files (typelibs)

I'll assume you already saw the example in the helpfile but here it is again

Example()

Func Example()
    ; Declare the CLSID, IID and interface description for ITaskbarList.
    ; It is not necessary to describe the members of IUnknown.
    Local Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}"
    Local Const $sIID_ITaskbarList = "{56FDF342-FD6D-11D0-958A-006097C9A090}"
    Local Const $sTagITaskbarList = "HrInit hresult(); AddTab hresult(hwnd); DeleteTab hresult(hwnd); ActivateTab hresult(hwnd); SetActiveAlt hresult(hwnd);"

    ; Create the object.
    Local $oTaskbarList = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList, $sTagITaskbarList)

    ; Initialize the iTaskbarList object.
    $oTaskbarList.HrInit()

    ; Run Notepad.
    Run("notepad.exe")

    ; Wait for the Notepad window to appear and get a handle to it.
    Local $hNotepad = WinWait("[CLASS:Notepad]")

    ; Tell the user what to look for.
    MsgBox($MB_SYSTEMMODAL, "", "Look in the Taskbar and you should see an entry for Notepad." & @CRLF & @CRLF & "Press OK to continue.")

    ; Delete the Notepad entry from the Taskbar.
    $oTaskbarList.DeleteTab($hNotepad)

    ; Tell the user to look again.
    MsgBox($MB_SYSTEMMODAL, "", "Look in the Taskbar.  There should no longer be a Notepad entry but Notepad is still running." & @CRLF & @CRLF & "Press OK to continue.")

    ; Close Notepad.
    WinClose($hNotepad)
EndFunc   ;==>Example

https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-itaskbarlist

MSDN is kinda junk for anything beyond verifying you have the correct methods and finding the name of the header file

since it doesn't give you the proper order or any of the clsids

shobjidl_core.h -- https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ ;;getting closer but still not what we need

Ahh here we go!

https://github.com/tpn/winsdk-10/blob/9b69fd26ac0c7d0b83d378dba01080e93349c2ed/Include/10.0.16299.0/um/ShObjIdl_core.idl#L4635

Now note we got lucky that MS published the sources

a decent com viewer is invaluable but doesn't always work

Doesn't look like the website is still around but Japheth has a not so bad com viewer

https://www.softpedia.com/get/System/System-Info/COMView.shtml#sgal_0

[edit] wayback machine to the rescue

https://web.archive.org/web/20140830145525/http://japheth.de/ 

https://web.archive.org/web/20140614155346fw_/http://www.japheth.de/COMView.html

maybe others can point you to some of their favorite COM viewers

 

oh and another place to find some info on obscure interfaces are Visual Basic forums (typically vb6) since thats where OLE/COM pretty much originated

 

Edited by Bilgus
Link to comment
Share on other sites

Also even with the proper interface definitions don't be surprised if you crash Autoit [A BUNCH]

its usually a misplaced definition or wrong data type but it can drive you mad because sometimes it perfectly matches and it still crashes

 

Link to comment
Share on other sites

HI Bilgus,

Thank you so much for the extensive information sources.  I've spent hours searching for anything that was even related and pretty much came up with zip.  I've now got a place to start and some serious studying at hand.

Thanks,

rmckay

Link to comment
Share on other sites

Where does one find .idl files? I checked programs files, but I only got windows related ones.

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

I just meant in general, I was hoping to explore what idl files were available and consider what would be possible with them. I don't have something in particular that I'm trying to do right now, I've been interested in ObjCreateInterface since I saw it here.

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

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