why can't use the commands in Abbyy Finereader?
I made a code that automatically opens one pdf file at a time with the help of the FineReader.exe program
yes, the file opens, but the key combination does not work in the code (although it works perfectly from the keyboard). is there something wrong with my code?
this is the key combination i want to use:
- "Ctr+Shift+S" (open File from the FineaReader menu)
- "Alt+T" (tab the transition to the combo in which the file extensions)
- "T" (Choose to save in Text format)
- "Enter" (Save actually)
This is my Python code:
import os
import subprocess
import time
from pywinauto.application import Application
# Directorul cu fisierele PDF
pdf_dir = r'g:\1\2'
# Calea catre executabilul ABBYY FineReader
abbyy_path = r'"c:\Program Files (x86)\ABBYY FineReader 15\FineReader.exe"'
# Obtine o lista cu toate fisierele PDF din director
pdf_files = [f for f in os.listdir(pdf_dir) if f.endswith('.pdf')]
pdf_files.sort() # Sorteaza lista de fisiere
# Deschide fiecare fisier PDF cu ABBYY FineReader
for pdf_file in pdf_files:
pdf_path = os.path.join(pdf_dir, pdf_file)
# Adauga ghilimele in jurul caii fisierului
subprocess.run(abbyy_path + ' "' + pdf_path + '"', shell=True)
# Asteapta ca ABBYY sa proceseze fisierul
time.sleep(10)
# Conecteaza-te la aplicatia ABBYY
app = Application().connect(path=abbyy_path)
# Trimite combinația de taste 'Ctrl+Shift+S' pentru a deschide meniul 'Save As'
app.send_keystrokes('^+s')
time.sleep(1)
# Trimite tasta Alt și tasta 't' pentru a accesa meniul de tipuri de fișiere
app.send_keystrokes('%t')
time.sleep(1)
# Trimite tasta 't' pentru a selecta 'Txt document'
app.send_keystrokes('t')
time.sleep(1)
# Trimite tasta Enter pentru a confirma
app.send_keystrokes('{ENTER}')
time.sleep(1)
# Așteaptă un moment pentru a te asigura că fișierul a fost salvat
time.sleep(5)
# Închide ABBYY înainte de a continua cu următorul fișier
app.send_keystrokes('%{F4}')
time.sleep(1)
Can you confirm that the GUI of the application you want to operate is focused?
How can I tell that the GUI of the Abbyy Fine Reader is focused?
Is focused the same with "open with maximize"?
at first glance, when I run Python code, the Abbyy Fine Reader opens automatically in the foreground, and I only have to wait for the keys to activate.
These are the corect keys
https://help.abbyy.com/en-us/finereader/16/user_guide/hotkeys/
Can you try to add calling set_focus method of the GUI element (...Wrapper object) before the first keystroke?
Good ideea, but how can I do that? How should i write this in python, in my code?
Maybe app.top_window().find().set_focus().
In my project, I do not use Application, but use the root window's children and descendants methods to get the target window.
That is why I said "Maybe".
I did not actually run the Python code, but inferred it from pywinauto's production code.
https://github.com/pywinauto/pywinauto/blob/bf7f789d01b7c66ccd0c213db0a029da7e588c9e/pywinauto/windows/application.py#L246
https://github.com/pywinauto/pywinauto/blob/bf7f789d01b7c66ccd0c213db0a029da7e588c9e/pywinauto/base_application.py#L888-L912
https://github.com/pywinauto/pywinauto/blob/bf7f789d01b7c66ccd0c213db0a029da7e588c9e/pywinauto/base_application.py#L264-L299