Sign in to follow this  
Followers 0
Ármányos Kő

Hot to manipulate Menu on unknown language Office softwares?

6 posts in this topic

Hi,

Developing macros for Word, Powerpoint, Excel and others, I ran into the problem of Babel.

For example German Windows says Datei instead of File. And needs different ALT + KEY to invoke.

WinMenuSelectItem is something, but the point is that I do not know the actual text on a given menubar.

I only know the position of it, like ALT puts me up to the menu, two times LEFT, then 3 times down.

OK, but what happens, if personal menu is set, so that the menus are shortened?

Also, how can I be sure of my position if walking through menus this blind?

Is there a way of reading menutexts like doing in ControlCommand?

Or even better, is there a way of actually asking Word/Powerpoint/Excel, others to do something as if it was hit from the menu?

Thanks...

Share this post


Link to post
Share on other sites



You can use the menus library in Auto3Lib to walk through the menu items and read the text of each one. You can also click by accelerator or menu position.


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Or even better, is there a way of actually asking Word/Powerpoint/Excel, others to do something as if it was hit from the menu?

You are on the right track with this question. The answer is yes, but before I go into much more detail I would ask that you provide a better explanation of what you are trying to accomplish.

Share this post


Link to post
Share on other sites

Ok, let's see.

I have a webpage of holding a translation memory database. When you see a sentence for translation (because you are a translator maybe and doing your job) you highlight the sentence in question and hit WIN+Q. This grabs the text and changes window to the webpage, copies it into the querybox, hits enter.

From the answer side of the list you get you copy the translated text and hit WIN+A. This grabs the new text, changes window to the one you came from and drops the text to the original place.

CTRL+V is not the best you can do to drop the text. In some softwares it is OK, but in word, for example, it tries to keep formatting of grabbed text and ruins your work.

OK, I can go for the "Unicode unformatted text" route with hitting ALT+E, S, ALT+P, ALT+A, {END} , {ENTER}

Now the problem comes with different language softwares as this menu navigation is under different shortcuts.

The mistery actually came in while using Adobe FrameMaker which is a 10 ys old software, but kind of industry standard. Although using the same english software on two computers, the Paste Special window itself belongs to the Office and titles do change according to the OS language. This problem I could solve, because to open the Paste Special window is still based on the english language software's shortcuts. (Manipulating of Paste Special window was a different issue, but also solved. See http://www.autoitscript.com/forum/index.php?showtopic=35694 )

Now the question is>

How can I start Paste Special window in Word (Excel, Powerpoint) on any language computer?

Share this post


Link to post
Share on other sites

Sorry for the late reply, I haven't had much time the last couple weeks. Below is an example of what I think you are trying to do. I included several comments that will hopefully make the code easier to understand. If you have anymore question please feel free to ask.

#include <IE.au3>
#include <Word.au3>

; Here we copy google's webpage
$oIE = _IECreate("www.google.com")
$oBody = $oIE.document.body
$HWND = _IEPropertyGet($oIE, "hwnd")
_IEAction($oBody, "focus")
ControlSend($HWND, "", "Internet Explorer_Server1", "^a")
ControlSend($HWND, "", "Internet Explorer_Server1", "^c")
_IEQuit($oIE)

; This is the constant for the paste special dialog box
Const $wdDialogEditPasteSpecial = 111

$oWordApp = _WordCreate ()
; Here we get a reference to the dialog box
$oDialog = $oWordApp.Dialogs ($wdDialogEditPasteSpecial)

With $oDialog
    ; These are all the available options for this dialog box
    ConsoleWrite("IconNumber = " & .IconNumber & @CR)
    ConsoleWrite("Link = " & .Link & @CR)
    ConsoleWrite("DisplayIcon = " & .DisplayIcon & @CR)
    ConsoleWrite("Class = " & .Class & @CR)
    ConsoleWrite("DataType = " & .DataType & @CR)
    ConsoleWrite("IconFileName = " & .IconFileName & @CR)
    ConsoleWrite("Caption = " & .Caption & @CR)
    ConsoleWrite("Floating = " & .Floating & @CR & @CR)
    
    ; Here we will change the DataType value
    .DataType = "Unicode"
    
    ; Here we verify that it changed
    ConsoleWrite("DataType New = " & .DataType & @CR)
    
    ;Here we execute the dialog box
    .Execute
EndWith

Share this post


Link to post
Share on other sites

Thanks big daddy!

This looks something promosing judging it from the fact that I do not understand it from the first blink.

So this is probably solving the issue on the way as I wished. (And the methods I knew to solve the issue have been tried without success, probably this will be ok...)

I will let you know the results...

Thanks

Share this post


Link to post
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
Sign in to follow this  
Followers 0