bettersaid 0 Light Poster

hello!

i've been trying to create an automated task which it should:

1. open Print
2. choose Printer
3. change Paper Size ( i want to print my doc in all paper size)

but i find my code too long and oh i dont know, and i want to simplify it. put it in classes or rather try generic coding. but my mind is mess up right now. i need help. Seriously

import os
from appscript import *



os.system("open /Applications/TextEdit.app")
app(u'System Events').application_processes[u'TextEdit'].menu_bars[1].menu_bar_items[u'File'].menus[1].menu_items[u'Print'].click()
 
# -- click pop_up_button paper_size -- # 
 
app(u'System Events').application_processes[u'TextEdit'].windows[u'Untitled'].sheets[1].pop_up_buttons[1].click() 

app(u'System Events').application_processes[u'TextEdit'].windows[u'Untitled'].sheets[1].pop_up_buttons[1].menus.menu_items[u'#10 Envelope'].click()
 
app(u'System Events').application_processes[u'TextEdit'].windows[u'Untitled'].sheets[1].pop_up_buttons[1].click() 

app(u'System Events').application_processes[u'TextEdit'].windows[u'Untitled'].sheets[1].pop_up_buttons[1].menus.menu_items[u'#9 Envelope'].click()

app(u'System Events').application_processes[u'TextEdit'].windows[u'Untitled'].sheets[1].pop_up_buttons[1].click() 
 
app(u'System Events').application_processes[u'TextEdit'].windows[u'Untitled'].sheets[1].pop_up_buttons[1].menus.menu_items[u'A2 Envelope'].click()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.