phuocvo88 Posted October 11, 2021 Share Posted October 11, 2021 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. ImageSearch.au3 ImageSearchDLL.dll Link to comment Share on other sites More sharing options...
kjpolker Posted October 11, 2021 Share Posted October 11, 2021 (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 October 11, 2021 by kjpolker Link to comment Share on other sites More sharing options...
phuocvo88 Posted October 12, 2021 Author Share Posted October 12, 2021 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 Link to comment Share on other sites More sharing options...
phuocvo88 Posted October 12, 2021 Author Share Posted October 12, 2021 13 hours ago, kjpolker said: 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 I also tried your suggestion link. It didn't work too Link to comment Share on other sites More sharing options...
Danp2 Posted October 12, 2021 Share Posted October 12, 2021 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. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
phuocvo88 Posted October 12, 2021 Author Share Posted October 12, 2021 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 More sharing options...
kjpolker Posted October 12, 2021 Share Posted October 12, 2021 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 More sharing options...
seadoggie01 Posted October 12, 2021 Share Posted October 12, 2021 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 functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
phuocvo88 Posted October 13, 2021 Author Share Posted October 13, 2021 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 Link to comment Share on other sites More sharing options...
phuocvo88 Posted October 13, 2021 Author Share Posted October 13, 2021 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 Link to comment Share on other sites More sharing options...
seadoggie01 Posted October 13, 2021 Share Posted October 13, 2021 (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 October 13, 2021 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 functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
phuocvo88 Posted October 13, 2021 Author Share Posted October 13, 2021 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 More sharing options...
seadoggie01 Posted October 13, 2021 Share Posted October 13, 2021 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 functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
kjpolker Posted October 13, 2021 Share Posted October 13, 2021 11 hours ago, phuocvo88 said: IT still show me this error. It just open Outlook and mouse doesn't move to New Mail button 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 More sharing options...
phuocvo88 Posted October 14, 2021 Author Share Posted October 14, 2021 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 More sharing options...
phuocvo88 Posted October 14, 2021 Author Share Posted October 14, 2021 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 More sharing options...
Zedna Posted October 14, 2021 Share Posted October 14, 2021 Try to force 32bit compilation of your EXE (when using 32bit DLL) by #AutoIt3Wrapper_UseX64=n or #pragma compile(x64, False) phuocvo88 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now