Jump to content

Recommended Posts

Posted

@mLipok  

  Quote

ptrex is the one who can answer on my question ?

Expand  

This is the way trancexx created the feature in AutoIT.

You can use either way to use the IID GUID

In case there is only 1 interface in the COM Module you can refer to the IID Flag = DEFAULT

Some ActiveX modules have multiple IID's so you need to refer to the by the relevant IID GUID.

 

 

Posted
  On 1/4/2021 at 2:14 PM, ptrex said:

This is the way trancexx created the feature in AutoIT.

Expand  

Could you point me to the post I want to focus on this discussion.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

@mLipok 

Sorry I don't have a post to refer to, this info is from old discussions with trancexx many years ago.

I don't have access to the source code either.  But If you use some debugging tools like the very old but still usefull MS OLEView.

You can see the COM object details to see the IID GUID's.

 

Posted

@Professor_Bernd  

This is the registration free AutoIT example that shows a TOOLTIP on your screen.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=beta
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=Y

Global $hActiveX

; Load the ActiveX Module
If @AutoItX64 Then
    $hActiveX  = DllOpen(@ScriptDir & "\AutoItX3_x64.dll")
Else
    $hActiveX  = DllOpen(@ScriptDir &  "\AutoItX3.dll")
EndIf
;MsgBox(0,"x64",@AutoItX64)

; Object identifiers
Global Const $sCLSID = "{1A671297-FA74-4422-80FA-6C5D8CE4DE04}"
Global Const $sIID = Default ; Or use keyword Default if you want to use the Default interface ID

; Error Monitoring
Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc()
    ConsoleWrite("! COM Error ! Number: 0x" & Hex($oError.number, 8) & " ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF)
    Return
EndFunc    ;==>_ErrFunc

; Create the hActiveX
Local $oAutoIt = ObjCreate($sCLSID, $sIID, $hActiveX)

If $oAutoIt = 0 Then MsgBox(16,"Error", "Could not create the object, Common problem ActiveX not registered.")

; This will create a tooltip in the upper left of the screen
$oAutoIt.ToolTip ("This is a tooltip", 450, 200)
$oAutoIt.Sleep (3000)    ; Sleep to give tooltip time to display

$oAutoIt = ""
DllClose($hActiveX)

Enjoy !

Posted
  On 1/4/2021 at 3:34 PM, ptrex said:

This is the registration free AutoIT example that shows a TOOLTIP on your screen.

Expand  

@ptrex

I've read your "Hex Editor COM Control" thread and your posts up here carefully. Thanks for the code of the registration free AutoIT example! 👍

How can you use this in VBScript? So how to register AutoItX.dll in ROT and call AutoItX functions in VBScript?

 

I created the following code in a VBScript which should use the AutoItX registered with regsvr32.

Dim oAutoIt
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ToolTip "This is a tooltip"
oAutoIt.Sleep 3000  ' Sleep to give tooltip time to display
oAutoIt.ToolTip ""  ' Remove the tooltip

When I run the VBScript directly in Windows Explorer, an error comes up saying "Object cannot be created." In PSPad's VBScript exactly the same code worked. I suspect it will be the same when creating an AutoItX object registered in ROT. More likely that will work in PSPad's VBScript as well.

So if you need a test environment, I can create a PSPad test version for you.

 

Please excuse me for not being full force on this topic. COM, ROT, the "evil" AutoIt functions and the constant switching between VBScript and AutoIt are all that can fit in my head at the moment. :lmao: Next month I should be able to properly address how to register an ActiveX DLL (AutoItX.dll) in ROT and use it in VBScript. I hope I can ask you for help then. :)

Posted

@Professor_Bernd  

You have 2 problems, one that can be fixed the other is not possible 

1. To get rid of the COM error.

You run x86 COM object on a x64 OS.  This will not work. You need to tell the vbscript host  to execute it as x86 like this  

run %windir%\SysWoW64\cmd.exe

and next your vbscript : wscript Test.vbs

2. The vbscript running AutoITX will run but not show anything. Because vbs does not have access to the Windows API's out of the box.

extend your script by adding this line msgbox "This was a tooltip"

And run again.

WORK AROUNDS :

1. Let vbscript run a AutoIT compiled script to show the ToolTip

2. Use DYNACALL to extend vbscript to access Windows API's

https://www.itprotoday.com/devops-and-software-development/rem-calling-win32-api-vbscript-code

Example calling a msgbox using WinAPI:

  Quote

Option Explicit
Dim UserWrap 
Set UserWrap = CreateObject("DynamicWrapper")

' Call MessageBoxA(), first register the API function
UserWrap.Register "USER32.DLL", "MessageBoxA", "I=HsSu", _
                 "f=s", "R=l"
' now call the function
UserWrap.MessageBoxA Null, "MessageBox (ANSI)", _
        "From DynaWrap Object", 3

Expand  

 

Posted
  On 1/5/2021 at 8:49 AM, ptrex said:

2. Use DYNACALL to extend vbscript to access Windows API's

Expand  

Thanks for your information, I may use that later.

  On 1/5/2021 at 8:49 AM, ptrex said:

You run x86 COM object on a x64 OS.

Expand  

This is strange to me, since AutoItX also has an AutoItX3_x64.dll, but what you say works. (Maybe only the AutoItX3.dll is registered!?) But that is not important, it should only serve the demo, which can thus be created much easier.

  On 1/5/2021 at 8:49 AM, ptrex said:

2. The vbscript running AutoITX will run but not show anything. Because vbs does not have access to the Windows API's out of the box.

Expand  

I don't understand that either, because in this case no access to the Windows API is needed. Only an access to the COM object of AutoItX. Here is an example without ToolTip:

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
PID = oAutoIt.Run("Notepad.exe", "", oAutoIt.SW_SHOWNORMAL)
MsgBox "Notepad is closed"
oAutoIt.ProcessClose PID

Save the code as Test.vbs and (as you said) start the Test.vbs with "C:\Windows\SysWOW64\wscript.exe". (Or you can just drop the Test.vbs on the wscript.exe).

Can you show me how to register the AutoItX3.dll in the ROT and use it in this example (Test.vbs)? Or is that too much work?

Posted

@Professor_Bernd  

I am not sure what your are trying to achieve the ROT ?  

Please read this first 

https://docs.microsoft.com/en-us/windows/win32/com/registering-objects-in-the-rot

The ROT updates are handled automatically when a COM server starts windows will add this to he ROT as a COM server.

So I am not sure where you are heading now with your last question ... 

Bottom line is that whatever your are trying to achieve with AutoItx3.dll it will NEVER give you access to all windows API's. 

Because this is by design.

 

So you will have to chose between the 2 workarounds that I mentioned in my prior post.

Posted (edited)
  On 1/6/2021 at 12:11 PM, ptrex said:

I am not sure what your are trying to achieve the ROT ? 

Expand  

Please excuse, some things have become quite convoluted. :'(

My intention is to use AutoItX in PSPad's VBScript without registering it in the system with regsvr32. PSPad4AutoIt3 should become fully portable, so independent of a registration in the system by the user.

My idea was to create an Au3 script, use your "HEX Editor COM Control" and LarsJ's "IRunningObjectTable Interface" to register the "AutoItX3.dll" in the ROT and use the AutoItX COM objects in PSPad's VBScript. In this post LarsJ gave a hint how creating an AutoItX COM object in an Au3 script could work.

Since this has become a bigger topic than I thought and does not belong in this thread, I have created a separate thread "Use AutoItX as COM ROT object, without regsvr32 registration". Please read more there. :)

Edited by Professor_Bernd

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...