Inline.
Joe
On 2/4/20 4:12 PM, Yekutiel ben Heshel wrote:
> Joe,
>
> *Thank you very much* for spending your time to work on this problem
> for me. I appreciate that very much. I am often amazed that small
> amounts of computer code can take large amount of time to produce. I
> try to remind myself that E=MC2 (that is, energy equals mass times the
> speed of light squared) is a very simple formula. Yet it took a
> non-trivial amount of time to arrive at.
>
>
> Regarding the script that you sent me named *ybh.py*….
>
> Please see the attachment to this message named, *ybh_version_b.py*,
> which, of course, is a modified version of ybh.py. I suppose you can
> test it very easily in a browser of your choosing such as Vivaldi,
> Chromium, Pale Moon, etc.
>
> *ybh_version_b.py* actually works properly for me except for the
> following minor annoyance. In case
ebay.com is open in a browser
> window then ybh_version_b.py will behave as I would like: the script
> will switch to the browser window with
ebay.com. Yet—after switching
> correctly to that window which already had
ebay.com open in it—an
> AutoKey error message pops up which, is extraneous, at least from my
> perspective.
There are two issues with your version of the script:
1) You didn't see/recognize the comment in it (lines starting with a #)
which said you were supposed to edit it replacing "YOUR_WEB_BROWSER"
with the actual name of your browser.
2) Blocks of code are defined by indenting them in Python.
The following 3 lines (no matter what your email program does to them
here - that's why I sent it as an attachment) :
# Please replace YOUR_WEB_BROWSER below with the web browser installed
on your machine which you want this script to use to open the URL below.
For example, you might replace YOUR_WEB_BROWSER below with "vivaldi" or
"Firefox" or "google-chrome-stable"
subprocess.Popen(["YOUR_WEB_BROWSER", "--new-window",
"
https://www.ebay.com/"])
need to each be indented four spaces so they become part of the else:
and are only executed if the condition of the if statement fails.
The way they are now, you have an empty else: (which is probably an
error by itself) and the next two statements are always executed (if it
doesn't die on the empty else:.)
I don't see the original code, so I don't know if I screwed it up of if
you inadvertently changed it.
>
> In other words, this AutoKey error message does not appear to
> interfere with the functionality of the script yet, obviously, it is a
> minor annoyance. After all, who wants error messages popping up
> unnecessarily?
>
>
> Regarding the script what you sent me named *ybh3.py*...
>
> Please see the attachment to this message named, *ybh3_version_b.py*,
> which, unsurprisingly, is a modified version of ybh3.py.
>
> In case
ebay.com is currently open—in a window in the web browser I am
> testing this with (google-chrome-stable)—ybh3_version_b.py will switch
> to that window as I would like. However, in case
ebay.com is currently
> not open (that is, in case
ebay.com is currently closed)
> ybh3_version_b.py fails to open a new window in my web browser with
>
ebay.com.
>
ybh3_version_b.py has the same sorts of errors as the other script.
YOUR_WEB_BROWSER needs to be replaced with the name of your actual
browser. The comment line is probably fine, but would be better if it
were indented eight spaces to match indentation of the surrounding code.
There's another bug in there that looks like I did it. The two activate
commands are looking for "ebay", but the subprocess command is opening
https://www.youtube.com/ . They should all be either ebay or youtube -
not a mix of the two.
**
> Finally, I am baffled that Google Chrome lacks two simple features:
> one that would allow users to lock the contents of a browser window
> (thereby preventing a user from adding or removing tabs to or from
> that window), and another that would prevent a browser window from
> being closed without user consent (which, for example, would be
> analogous to the dialog box that normally pops up when a user tries to
> close a window in a document in a text editor that has unsaved text in
> it).
>
> Around five or six years ago I used to run an add-on in Pale Moon that
> had this sort of functionality. That was before Firefox changed their
> policies regarding add-ons which rendered most add-ons inoperable.
Warning: I'm a big Vivaldi fan!
I don't use a lot of tabs at once, but if you do, check out the Vivaldi
browser. It can use most Chrome extensions and it has very powerful
tools for working with tabs. It also doesn't mine all of your data and
send it home to Google. I've been using it for at least three years now
and love it. Until I switched to it, I didn't particularly like any
browser after Firefox 3.x when they started breaking more things than
they fixed.
I just looked in Vivaldi. It has two full screens worth of settings just
for tabs, but not the two you want. You can pin tabs (maybe what you
want) and control what it does if you try to close the last tab in a
window. When I close my last tab, I have it set to display my home page
instead of exiting.
It also has general options you can set to have it ask what you want it
to do when you try to close a tab or when you try to exit the browser.
The community is very friendly and helpful. The developers are also very
responsive and, if you make a feature request that enough other users
like, there's a fair chance it will get implemented if it's not super
hard to do.
The aim is to make it the most configurable/customizable browser
available - which they have achieved. They try to make it so you don't
need any add-ons, but they allow you to add them if you do. It's the
exact opposite of some other browsers which have a sort of minimalist
vibe where what you get is all you get and you'd better like it that way.
Even though it has tons of options, its defaults are pretty intelligent,
so you can use it "out of the box" effectively without having to
customize everything first and having to learn what all the options do.
>
> Thanks,
>
> Yekutiel
>
>
>
> Le lundi 3 février 2020 15:49:40 UTC-8, Yekutiel ben Heshel a écrit :
>
> I want a script that will switch to or launch a URL in a web page
> just like the script I have that will switch to or launch a local
> application .
>
> The following script *_works_* as I intend it to work.
>
> It will start Audacious if it is unopen or switch to Audacious if
> it is open.
>
> import subprocess
> command = 'wmctrl -l'
> output = system.exec_command(command, getOutput=True)
>
> if 'Audacious' in output:
> window.activate('Audacious',switchDesktop=True)
>
> else:
> subprocess.Popen(["/usr/bin/audacious"])
>
>
>
>
> However, the following script *_does not work_* as I intend it to
> work.
>
> The following script will switch to a window with "To Do" in the
> window title *_if such a window exists_* and then launch
>
https://www.youtube.com/ (which is the URL I am using for testing
> purposes, but not the URL I ultimately want it to launch) in
> Google Chrome. In such a case I *_do want_* the following script
> to switch to a window with "To Do" in the window title *_if such a
> window exists_* but in such a case I *_do not want_* it the
> following script to launch
https://www.youtube.com/.
>
> Furthermore, the following script will not run (will give an error
> message) *_if a window does not exist_* with "To Do" in the window
> title
>
>
> import subprocess
>
> command = 'wmctrl -a "To Do"'
> output = system.exec_command(command, getOutput=True)
> if "'To Do'" in output:
> window.activate("'To Do'",switchDesktop=True)
>
> else:
> subprocess.Popen(["google-chrome-stable",
> "
https://www.youtube.com/"])
>
>
> Do you have any advice for me regarding the problem indicated above?
>
> Thanks,
>
> Yekutiel
>
>
https://groups.google.com/d/msgid/autokey-users/16ba8a7a-bb5b-4c03-837d-a53daa41fa3d%40googlegroups.com
> <
https://groups.google.com/d/msgid/autokey-users/16ba8a7a-bb5b-4c03-837d-a53daa41fa3d%40googlegroups.com?utm_medium=email&utm_source=footer>.