Jump to content

General Autoit3X question


JohnOne
 Share

Recommended Posts

Have you ever had one of those moments where you have a thought, a moment of clarity. then as quick as it happend its gone again?

Well I did earlier today and I spent a while trying to invoke the thought again, unsucsessfuly.

All I remember was I wondered if you could call functions from Autoit3X.dll from within a regular AU3 script, and I think the thought was how such a thing could be useful.

So my question is can you think of a scenario where it might be useful?

I hope I'm making sense.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

@JohnOne, Something like this?

Global $sAutoItX = RegRead("HKLM\Software\Wow6432Node\AutoIt v3\Autoit", "InstallDir") & "\AutoItX\AutoItX3_x64.dll"
ConsoleWrite("-> File is: " & $sAutoItX & @CRLF)


Global $oAutoIt = ObjCreate("AutoItX3.Control")
If Not IsObj($oAutoIt) Then
    _SomeCoolRegisterFunc($sAutoItX)
    $oAutoIt = ObjCreate("AutoItX3.Control")
EndIf

If Not IsObj($oAutoIt) Then
    MsgBox(48 + 262144, "Ahh!", "Something is wrong. God knows what.")
    Exit -1
EndIf

; THIS...
$oAutoIt.ToolTip("This is some tip from AutoItX version " & $oAutoIt.Version & @LF & "Visible enough?")
$oAutoIt.Sleep(2000)
$oAutoIt.ToolTip("")
$oAutoIt.ToolTip("Bye bye now...")
$oAutoIt.Sleep(800)



; Functions:
Func _SomeCoolRegisterFunc($sModule)
    If IsAdmin() Then Return _RegisterServer($sModule)
    Local $sShellExecuteString = ' /AutoIt3ExecuteLine ' & _
            '"Exit (' & _
            'DllCall(''ole32.dll'', ''long'', ''OleInitialize'', ''ptr'', 0) & ' & _
            'DllCall(''' & $sModule & ''', ''long'', ''DllRegisterServer'')' & _
            ')"'
    ShellExecuteWait('"' & @AutoItExe & '"', $sShellExecuteString, "", "runas", @SW_HIDE)
EndFunc   ;==>_SomeRegisterFunc

Func _RegisterServer($sDll)
    Local $fInit, $fError
    Local $aCall = DllCall("ole32.dll", "long", "OleInitialize", "ptr", 0)
    If Not @error Then $fInit = $aCall[0] <> 1 ; The COM library is already initialized
    $aCall = DllCall($sDll, "long", "DllRegisterServer")
    If @error Then $fError = True
    If $fInit Then DllCall("ole32.dll", "none", "OleUninitialize")
    If $fError Then Return SetError(2, 0, False)
    Return SetError($aCall[0] <> 0, $aCall[0], $aCall[0] = 0)
EndFunc   ;==>_RegisterServer

Btw, that's dumb. You know why?

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

is it because its using the interpreter to make the call, and so its just plain slower that doing it normally?

My thought probably disappeard because it was stupid really, so its probably for the best I dont recall it.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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