Jump to content

Send("{F12}") not working


Recommended Posts

Hi There Memebers

Very grateful for any troubleshooting tips.

I have a situation where Send("{F12}") does not work from within a script.

The context is with an open Word, Excel or other program for which F12 brings up the "Save As" DB.

Manually entering F12 from one of these programs duly brings up the Save As DB.

But sending F12 from within the script seems to do nothing.

If after invoking the script I then press F12 manually from the keyboard the script moves on to invoke the next line of conde which is WinWaitActive("Save As").

The script then goes on to save the file as the new filename in the way intended.

So I know that the script is hanging waitng for the "Save As" DB which never appears.

The script used to work not sure what has changed.

I realise this could have many different possible causes.

It is troubleshooting ideas I am hoping for here.

I have tested other send key items in place of my F12 including these and they work as expected:

Send("{ENTER}")

or this sequence brings up Help:

Send("Sleep 500 then F5 then sleep 500 then exit")
Sleep(500)
Send("{F1}")
Sleep(500)
Exit

Many thnks for any rpelies whatsoever....

Link to comment
Share on other sites

Why not use the Word UDF that comes with AutoIt to automate Word?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thankyou...

JohnOne yes indeed the correct window is active. For instance it might be word for which I am wanting the Save As DB to be invoked. I am not sure I understand the 500ms comment. I usually for not have sleep cmd in there at all. I have put them in to see if it helped...

Water - What is word UDF? I seached AutoIT help and got a hit on _WordErrorHandlerRegister.... Is that what you are getting at? I will read up on it...

 

Link to comment
Share on other sites

In the full Help file, go to the section down the bottom, named 'User Defined Function Reference'.

Open that, and down the bottom you will find 'Word Management'.

As for Active Window, you are mistaking what JohnOne said.

If you have the Word window up and running, and then got to another Window to double-click on your script, then the Word window has lost focus and is no longer active. You need to make sure, that your 'F12' is directed at the Word window, by making it active, with some of the Win commands (WinActivate, WinWaitActive, etc). You will also need to have a delay (sleep) in there to give time for the Word window to become active.

Note - I haven't really looked at your code, so you may have some of that already, but obviously not enough or with understanding.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

In the full Help file, go to the section down the bottom, named 'User Defined Function Reference'.

Open that, and down the bottom you will find 'Word Management'.

You can also type word in the Index tab, open one of the pages and click back to Contents tab to see where it is.
Link to comment
Share on other sites

Very true, but I'm a click man .... and avoid typing as much as I can ..... :muttley: ........ ;) ;)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

AutoIt comes with a UDF (User Defined Functions Library) to automate Word. If you need to work with Word 2007 or later you could have a look at my WordEx UDF (for download please see my signature).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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