Jump to content

Can't run scenario by clicking au3 but script run successfully in SciTE-Lite


Recommended Posts

Hi I'm new here. I've been around with AutoIT for my new testing project. I encountered this issue. When I run my script from  SciTE-Lite, it works. However, when I run by double-clicking .au3 file, it always throw me the error: 

Subscript used on non-accessible variable

 

I've been searching around, and people always asks to place ImageSearch.au3, ImageSearchDLL.dll and my script file in same location. I did, but the script doesn't work. Can some one show me how to fix this. Much appreciate!!

 

Scenario: launch Outlook application, Click on New Email icon.

Here is my script:

#include<ImageSearch.au3>
#include <AutoItConstants.au3>

Local $x=0, $y=0

Run("C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE")
AutoItSetOption('MouseCoordMode', 0)

WinWait('Inbox - P.Minh@aswhiteglobal.com - Outlook')
Sleep(3000)

$search=_ImageSearch('D:\Greenshot Output\OL_NewMailBtn.bmp', 1, $x, $y, 0)
if $search = 1 then MouseMove($x,$y)
MouseClick($MOUSE_CLICK_LEFT)

 

I also attach screenshot of my script folders along with other referenced files.

autoIT folder.png

ImageSearch.au3 ImageSearchDLL.dll

Link to comment
Share on other sites

Try copying ImageSearch.au3 and ImageSearchDLL.dll into the Autoit library of Includes. By default: C:\Program Files (x86)\AutoIt3\Include

Are you running it as a script or compiling it before running?

If the above works it is good practice to make your own Include directory for UDFs to prevent them from being removed when upgrading. You can follow the link below to set that up.
https://www.autoitscript.com/wiki/Adding_UDFs_to_AutoIt_and_SciTE

Edited by kjpolker
Link to comment
Share on other sites

19 minutes ago, Danp2 said:

Have you considered using the Outlook UDF instead of searching for an image of the button? Also, I would recommend installing the full version of Scite.

I've been internet and found some Outlook UDF, which one you refers me. Could you please attach one for me to download. I also read from the wiki of this site, couldn't find download link.

 

Besides, I researched AUTOIT to do autoamtion testing for my project. the project is about a plug-in to Outlook, after installing it will display an icon in the ribbons. I don't think the Outlook UDF is able to find a plug-in icon. So I'm thinking the most possibility is to use ImageSearch to look for icon to iteract with it. I'm new to AutoIT, please fix me if my thinking is wrong 

 

Link to comment
Share on other sites

I have tested your code on my end and it works. The only thing I can think of is that there is a hidden character somewhere in your script? Try copying and pasting the code below and running it.

Right click the .au3 file and select "Run Script", any changes?

#include <ImageSearch.au3>
#include <AutoItConstants.au3>

Local $x=0, $y=0

Run("C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE")
AutoItSetOption('MouseCoordMode', 0)

WinWait('Inbox - P.Minh@aswhiteglobal.com - Outlook')
Sleep(3000)

$search = _ImageSearch('D:\Greenshot Output\OL_NewMailBtn.bmp', 1, $x, $y, 0)
if $search = 1 then MouseMove($x,$y)
MouseClick($MOUSE_CLICK_LEFT)

 

Link to comment
Share on other sites

9 hours ago, phuocvo88 said:

the project is about a plug-in to Outlook, after installing it will display an icon in the ribbons.

Could you clarify this part, what do you mean by "plug-in"? I'm guessing you either mean your script will function as a plug-in or that you'll be installing a Add-In. These have very different potential solutions. If you mean an Add-In, what's the name of it? Some will have an exposed public API

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

8 hours ago, kjpolker said:

I have tested your code on my end and it works. The only thing I can think of is that there is a hidden character somewhere in your script? Try copying and pasting the code below and running it.

Right click the .au3 file and select "Run Script", any changes?

#include <ImageSearch.au3>
#include <AutoItConstants.au3>

Local $x=0, $y=0

Run("C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE")
AutoItSetOption('MouseCoordMode', 0)

WinWait('Inbox - P.Minh@aswhiteglobal.com - Outlook')
Sleep(3000)

$search = _ImageSearch('D:\Greenshot Output\OL_NewMailBtn.bmp', 1, $x, $y, 0)
if $search = 1 then MouseMove($x,$y)
MouseClick($MOUSE_CLICK_LEFT)

 

IT still show me this error. It just open Outlook and mouse doesn't move to New Mail button

image.png.e27e15c69bb9ba61784d79028c5c7082.png

Link to comment
Share on other sites

5 hours ago, seadoggie01 said:

Could you clarify this part, what do you mean by "plug-in"? I'm guessing you either mean your script will function as a plug-in or that you'll be installing a Add-In. These have very different potential solutions. If you mean an Add-In, what's the name of it? Some will have an exposed public API

I have project to make a plug in for outlook. The other developer takes care of implementing that plug in. My responsibility is to make an automation test to test that plug-in. Simple test scenario that:

1. launch OUtlook

2.move to New Email button

3. hit button

4. type in recipients

5. input title, body message

6. the plug-in will scan body and message. if input text matches defined pattern, the icon of this plug-in will turn red to warn user. For example, TAA567xxxxx, TCA334xxxxx.

 

However, my script doesn't work well. IT always stop at launching the Outlook and prompt the error 

image.png.37f401db53caf24b805a2adb06468cda.png

Link to comment
Share on other sites

When does #6 happen? I'd guess when you press send.

1-5 can easily be written in water's OutlookEx.au3 (I'm on mobile, will edit with link later)

Edited by seadoggie01
Added link

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

54 minutes ago, seadoggie01 said:

When does #6 happen? I'd guess when you press send.

1-5 can easily be written in water's OutlookEx.au3 (I'm on mobile, will edit with link later)

It's real time check, the plug-in contacts database and constantly scan your input. when ever your text matches pre-defined pattern, the icon of this plug-in turn red

Link to comment
Share on other sites

Hmm... okay. I'm not 100% sure this will work, but you can try using OutlookEx.au3 as previously mentioned. You'll want to look at _OL_ItemCreate to draft a message

#include <OutlookEx.au3>

; Get a reference to Outlook
Local $oOL = _OL_Open()
If @error Then Exit ConsoleWrite("Error opening outlook: " & @error & @CRLF)

; Create an email
Local $oEmail = _OL_ItemCreate($oOL, $olMailItem, Default, "", "To=someone@example.com", "CC=someone@example.com", "Body=SomeText", "OtherProperty=Value")
If @error Then Exit ConsoleWrite("Error creating email: " & @error & @CRLF)

; Display the email (open it in an Inspector)
$oEmail.Display()

Hopefully, if you leave the email displayed for a bit, your plugin will query your database and change the icon red

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

11 hours ago, phuocvo88 said:

IT still show me this error. It just open Outlook and mouse doesn't move to New Mail button

image.png.e27e15c69bb9ba61784d79028c5c7082.png

This appears to be caused from an issue with loading the dll file properly. If I rename my dll I get the same error. I can see your file name and location seem correct so possibly the file got corrupted during download?

Link to comment
Share on other sites

14 hours ago, kjpolker said:

This appears to be caused from an issue with loading the dll file properly. If I rename my dll I get the same error. I can see your file name and location seem correct so possibly the file got corrupted during download?

I think so, too. Just download other package with imagesearch dll and au3 for x64, it works now.

 

thank you everyone for your support. TOpic can be closed now

Link to comment
Share on other sites

16 hours ago, seadoggie01 said:

Hmm... okay. I'm not 100% sure this will work, but you can try using OutlookEx.au3 as previously mentioned. You'll want to look at _OL_ItemCreate to draft a message

#include <OutlookEx.au3>

; Get a reference to Outlook
Local $oOL = _OL_Open()
If @error Then Exit ConsoleWrite("Error opening outlook: " & @error & @CRLF)

; Create an email
Local $oEmail = _OL_ItemCreate($oOL, $olMailItem, Default, "", "To=someone@example.com", "CC=someone@example.com", "Body=SomeText", "OtherProperty=Value")
If @error Then Exit ConsoleWrite("Error creating email: " & @error & @CRLF)

; Display the email (open it in an Inspector)
$oEmail.Display()

Hopefully, if you leave the email displayed for a bit, your plugin will query your database and change the icon red

thanks for your support, I'll try this snippet for my automation test.

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