Mrvaandpyt
Mrvaandpyt

Reputation: 47

Resize and move window, using python

So I need to launch chrome from within Python (Preferably as a new window, not a tab), and then resize the window, move it and go to a specific URL.

I think I almost have it, it just won't launch chrome.

from pywinauto import application
app = application.Application()
app.start("Chrome.exe")
dlg_spec = app.window()
dlg_spec.move_window(x=None, y=None, width=500, height=500, repaint=True)

Any ideas?

Upvotes: 1

Views: 3015

Answers (1)

Mrvaandpyt
Mrvaandpyt

Reputation: 47

So I found a solution to my problem, and here is my process:

  • I went on discord (Python channel) and asked for suggestion, and someone wrote: "use selenium".
  • After a ton of google, reading, and youtube videos here is my solution.
  • Watch this video if you have trouble with the web driver for selenium.
  • https://www.youtube.com/watch?v=o3tYiyE_OXE
from selenium import webdriver


driver = webdriver.Chrome(executable_path="C:\webdriver\chromedriver.exe")
driver.set_window_position(0,375)
driver.set_window_size(1920,705)
driver.get('https://dk.docendo.dk/calendar#/')

This code will do the following:

  • Import web driver
  • Get the web driver for chrome
  • Launch chrome
  • Move chrome window to given coordinates
  • Resize the windows
  • Go to the suggested URL

Hope this helps someone!

Upvotes: 2

Related Questions