0

I am trying to make a program that will automatically close a web tab or the Web browser. :/

3
  • What kind of browser are you using? Chrome? Firefox? IE? Commented Mar 27, 2012 at 3:10
  • You should use this webbrowser docs.python.org/library/webbrowser.html, but if you have implemented it, just use Popen from subprocess. Commented Mar 27, 2012 at 3:21
  • or is there a way to only close a certain tab from chrome? Commented Mar 27, 2012 at 3:33

1 Answer 1

2

Depends on what you want but you can try to kill the process(assuming your running windows, here's a sample)

import os
os.system("taskkill /F /IM chrome.exe")

I have read that you maybe able to use browser.py or subproceses to do this also.

Sign up to request clarification or add additional context in comments.

3 Comments

i tried this but it does not close the window, it only kills all the Chrome apps, but leaves the actual window open.
Thats strange, can you try to kill it in task manager? is it chrome.exe or maybe its something else? Also play with the options /F and /IM. Basically launch the windows commandline and run taskkill /? and look at the options, you may have to tweak this a bit.
Awesome, glad to hear! Welcome to site and feel free to ask any questions you are stumped with and don't forget to help others who are stumped with problems as well. Its a really great community.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.