I'd like to control MobaXterm app with Python and trying to find a way for the code to read and fetch the string from the promp in each tab (terminal).
from pywinauto.application import Application
app = Application(backend='uia').start('"C:\\Program Files (x86)\\Mobatek\\MobaXterm\\MobaXterm.exe"').connect(title='val',timeout=100)
textEditor = app.val.child_window(control_type="Tab").wrapper_object()
print(textEditor.Edit.get_line(0))
textEditor.type_keys("^{TAB 2}")
textEditor.type_keys("test",with_spaces = True)
I tried to use get_line above, but it gives the following error:
print(textEditor.Edit.get_line(0))
AttributeError: 'TabControlWrapper' object has no attribute 'Edit'
Can you help me to find a way?
Related
I m making an Excel automation via pywinauto library. But there is a hard challange for me due to using Excel Oracle add-ins called Smartview.
I need to click 'Private Connections' button, however i can't find any little info in app.Excel.print_control_identifiers() Private Connections
So i tried to use inspector.exe for find ui element regarding private connections button, however i couldn't find any little solvetion inside of inspector.exe's result inspector's result
Then i used another program called UISpy, however i can only find private connection's pane inside of the program. UISpy's result
i tried to find an answer but i couldn't find out anything. So, can you help me to click here?
By the way here is my code :
import pywinauto
from pywinauto import application
from pywinauto.keyboard import send_keys
from pywinauto.controls.common_controls import TreeViewWrapper
program_path = r"C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE"
file_path = r"C:\Users\AytugMeteBeder\Desktop\deneme.xlsx"
app = application.Application(backend="uia").start(r'{} "{}"'.format(program_path, file_path))
# sapp = application.Application(backend="uia").connect(title = 'deneme.xlsx - Excel')
time.sleep(7)
myExcel = app.denemeExcel.child_window(title="Smart View", control_type="TabItem").wrapper_object()
myExcel.click_input()
Panel = app.denemeExcel.child_window(title="Panel", control_type="Button").wrapper_object()
Panel.click_input()
time.sleep(1)
app.denemeExcel.print_control_identifiers()
In pywinauto I am trying to access a nested submenue item that contains.
The Path is Datei->Importieren->Vorlagen->comdirect Musterdepot (attached screenshot)
Any idea how I can get this running?
The code I use:
app = Application(backend = 'uia').connect(path = "PortfolioPerformance.exe")
app.Dialog.Anwendungsmenü.item_by_path('Datei->Importieren->Vorlagen->comdirect Musterdepot').click_input()
The error I receive:
AttributeError: 'NoneType' object has no attribute 'is_active'
Screenshot of Menu:
After spending some time I figured out the following behaviour:
Once I expanded the Datei Menu, the print_control_identifiers updated to include the submenues.
The following code will click the correct, but maybe there are nicer solutions out there:
app = Application(backend = 'uia').connect(path = PROCNAME)
dialog = app.dialog
#first open the Importieren submenu:
dialog.Anwendungsmenü.item_by_path('Datei->Importieren')
# then the submenue appears on top level menues, open the importieren menu:
dialog["Importieren"].item_by_path('Vorlagen->comdirect Musterdepot').select()
I have a python script that use pandas and create dataframe from csv file and i want to display the dataframe information using pandas-profiling package and show the report in the browser once the user run the function .
But the system does not open the browser and display this error:
ValueError: startfile: filepath too long for Windows
code:
def displayDfInfo(self,df):
profile = pp.ProfileReport(df)
html_profile = profile.to_html()
webbrowser.open(html_profile,new=1)
where is the error and how to fix it?
I would simplify it to this:
import webbrowser
html = "myhtml.html"
webbrowser.open(html)
I have a very small application written in PyCharm using python3:
import folium
map = folium.Map(location=[58.1, 23.3], zoom_start=10)
map.save('map2.html')
This will create a map2.html which I can access in my browser by using pycharm and the url looks like: http://localhost:63342/iss-country/map2.html?_ijt=dcsefdg8om4ddfovlt5ooq6ro5
How can I automatically open this in my browser? So when I run the application it does not only generate the html page but also visits it immediatley. I found the webbrowser module which can be useful but how do I know the correct localhost url?
I don't see the issue with using the webbrowser module. Just make the file name and path a variable and call the webbrowser open method.
output_file = "map2.html"
map = folium.Map(location=[58.1, 23.3], zoom_start=10)
map.save(output_file)
webbrowser.open(output_file, new=2) # open in new tab
I've been using the following code to try and create a new playlist in iTunes and a song from the main library - its example code i've found but i keep getting the following error when it runs. I've had a look through the iTunes COM interface documentation and it seems that AddTrack is only available under IITLibraryPlaylist but all of the example code Ive found is as below. Can anyone help>
Error: AttributeError: win32com.ge_py.iTunes 1.13 Type Library.IITPlaylist instance at 0x34035192 object has no attribute 'AddTrack'
Python Code:
import win32com.client
itunes = win32com.client.gencache.EnsureDispatch ("iTunes.Application")
mainLibrary = itunes.LibraryPlaylist
tracks = mainLibrary.Tracks
playlist = itunes.CreatePlaylist("Sonic Jams")
song = tracks.ItemByName('Teen Age Riot')
playlist.AddTrack(song)
in C#
Cast to IITUserPlayList
IITUserPlaylist rclibrary = (IITUserPlaylist)itunes.LibrarySource.Playlists.ItemByName["name"];
rclibrary.AddTrack(item);
i managed to get it using this code if anyone else needs it.
playlist = win32com.client.CastTo(itunes.CreatePlaylist("New List"), 'IITLibraryPlaylist')
song = tracks.ItemByName('Silver Rocket')
playlist.AddTrack(song)