Jump to content

Recommended Posts

Posted

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.au3Fetching info... ImageSearchDLL.dllFetching info...

Posted (edited)

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
Posted

I've tried to put ImageSearch.au3 and ImageSearchDLL.dll into Includes folder still no luck. Now, it just launches Outlook and prompt the error, it can't find the button "New Email" to hit

files in include folder.png

Posted
  On 10/12/2021 at 8:42 AM, 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.

Expand  

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 

 

Posted

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)

 

Posted
  On 10/12/2021 at 10:23 AM, phuocvo88 said:

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

Expand  

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.

  Reveal hidden contents
Posted
  On 10/12/2021 at 5:25 PM, 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)

 

Expand  

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

image.png.e27e15c69bb9ba61784d79028c5c7082.png

Posted
  On 10/12/2021 at 7:42 PM, 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

Expand  

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

Posted (edited)

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.

  Reveal hidden contents
Posted
  On 10/13/2021 at 8:48 AM, 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)

Expand  

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

Posted

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.

  Reveal hidden contents
Posted
  On 10/13/2021 at 1:34 AM, 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

Expand  

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?

Posted
  On 10/13/2021 at 12:39 PM, 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?

Expand  

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

Posted
  On 10/13/2021 at 10:10 AM, 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

Expand  

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

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