Jump to content

Autoitx3 Code Only Works Not Compiled


da_jokker
 Share

Recommended Posts

I have the following code in a Visual Basic Form.......

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim objAutoIt As AutoItX3Lib.AutoItX3

Set objAutoIt = New AutoItX3Lib.AutoItX3

With objAutoIt

Call .Opt("WinTitleMatchMode", 4)

Call .ControlClick("classname=ThunderRT6FormDC", "", "2", "left", 1)

End With

Set objAutoIt = Nothing

End

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

I have almost the same code in a VB Script File

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim objAutoIt

Set objAutoIt = WScript.CreateObject("AutoItX3.Control")

With objAutoIt

.AutoItSetOption "WinTitleMatchMode", 4

.ControlClick "classname=ThunderRT6FormDC", "", "2", "left", 1

End With

set objAutoIt = nothing

WScript.Quit()

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

This code works perfectly .... UNTIL I compile the program then it doesn't work at all. I tried converting the VBScript over to a .AU3 file so it could be compiled and it didn't work there either.

I would rather not leave this as a VBScript but unless I can figure it out... I don't know what else to do.

What's wrong?

Thkx

Link to comment
Share on other sites

Perhaps the window is not there when ControlClick happens?

You should wait for a window before controlling it.

This is the VBS script with addition.

Dim objAutoIt

Set objAutoIt = WScript.CreateObject("AutoItX3.Control")

With objAutoIt
    .AutoItSetOption "WinTitleMatchMode", 4
    .WinWait "classname=ThunderRT6FormDC"
    .ControlClick "classname=ThunderRT6FormDC", "", "2", "left", 1
End With 

set objAutoIt = nothing
WScript.Quit()

See if that helps.

Link to comment
Share on other sites

Thanks...I can try that but the program I'm trying to click on is always running (it's in the systray)

I never thought automating something to simple click on a systray icon would be so dang hard!

Thanks again for at least trying.

Link to comment
Share on other sites

Remove your reference to AutoIt

Declare it as an object only

Public AutoIt As Object

Then in your Form_Load, or equiv -

Set AutoIt = CreateObject("AutoIt.Control")

Then stuff like

gdoc = AutoIt.IniRead(ini, "SDEXT", "Doc", 0)

should work no problem - having been using it like that for a long time

Link to comment
Share on other sites

- Obviously, Public, Private, whatnot is your use. I declare it in a module, and set it in the main form - and then I can use it any of the 50 or so forms I have in the App with no problem, and not having to mess with it anymore.

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