wyattbiker Posted October 28, 2013 Share Posted October 28, 2013 Hi, I have an application that you start by clicking a button on the button bar menu of Word. How do I tell autoit, which button on the Word button bar to press? For example the button bar says "Format". Is there a way to navigate there and perform the click (i dont want to write macros in Word). Thanks Link to comment Share on other sites More sharing options...
l3ill Posted October 28, 2013 Share Posted October 28, 2013 What have you tried so far? The tutorial in the help file named "Simple Notepad Automation" will get you plenty far in the direction you are trying to go. Give it a shot and come back if you get stuck... good luck, Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
Solution Jfish Posted October 28, 2013 Solution Share Posted October 28, 2013 (edited) I am not sure that tutorial will work because the key being pressed is inside a control container and you would need to know the control ID for the button (i.e. format) which is being pressed. In the VBA code it is listening for private sub formatbutton_click() or something like that. I don't think the button has an external handle that can be detected (au3info only sees the container). However, if the button in question has a shortcut (i.e. CTRL+Shift+C for format painter) you might be able to use the SEND function with the keyboard shortcut - which is the equivalent of pressing the button. I don't know if VBA would treat that as a "click" (but if you have the code you could test it quickly). Try going into your Word doc with the VBA code and instead of clicking the button in question use the shortcut. If your code executes you can send those keys with AutoIt. ***Edit*** one more thought - if you are trying to automate something in Word by simulating a button that kicks off code from AutoIt perhaps consider the Word UDF or COM API to Word that can do whatever your VBA script does. Edited October 28, 2013 by Jfish wyattbiker 1 Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
wyattbiker Posted October 29, 2013 Author Share Posted October 29, 2013 I am not sure that tutorial will work because the key being pressed is inside a control container and you would need to know the control ID for the button (i.e. format) which is being pressed. In the VBA code it is listening for private sub formatbutton_click() or something like that. I don't think the button has an external handle that can be detected (au3info only sees the container). However, if the button in question has a shortcut (i.e. CTRL+Shift+C for format painter) you might be able to use the SEND function with the keyboard shortcut - which is the equivalent of pressing the button. I don't know if VBA would treat that as a "click" (but if you have the code you could test it quickly). Try going into your Word doc with the VBA code and instead of clicking the button in question use the shortcut. If your code executes you can send those keys with AutoIt. ***Edit*** one more thought - if you are trying to automate something in Word by simulating a button that kicks off code from AutoIt perhaps consider the Word UDF or COM API to Word that can do whatever your VBA script does. Yes, the problem has to do with knowing how to press the button bar. Thanks for your ideas and input. 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