On Fri, 14 Feb 2020 14:19:09 +0100, "R.Wieser"
declaimed the following:
>I've got a Python 3 script which I start by clicking a shortcut on the
>desktop. I would like to be able to have the script show a dialog (with
>options) when I click the link while the SHIFT, CTRL or ALT key is being
>held down.
>
>Question: is this possible, and if so, how.
First question: is this a GUI application (Tkinter, wxPython, other),
or a console application?
Potential difficulties:
First: any modifier keys held down when clicking on an icon would be
intercepted and processed by the window/file manager/launcher itself -- so
that manager would need features to allow different command lines when
launching an application based on modifier keys so the command lines could
set option flags (Python sys.argv contents) allowing the application to
then take different routes.
If it is a console application, all input is via sys.stdin, and that
channel is normally in "cooked" mode -- you receive a line of processed
text when is pressed. No indicator of modifier and base key. In
fact, most console I/O does NOT generate anything for modifier keys on
their own -- only modifier in conjunction with some other key. Converting
the channel to "raw" mode /might/ let you detect modifier keys -- but I
suspect not; mostly it lets you catch keys without waiting for and
maybe without echoing to the console, catch / as characters.
Essentially, if it doesn't show up as a "character" in the character map,
it is not passed to the application. At the lowest level, you might get a
byte indicating modifier keys and a second byte with the keyboard keycode.
If it is a GUI application, the event loop may be able to detect
modifier keys on their own (M$ Windows: pressing the key activates
the application menu bar shortcuts [underlined letter] so entering one of
those letters next will open the menu). You will have to study the details
of the GUI library being used. Note that this does not result in activation
on launch -- the app has to start first and /then/ detect a modifier key.
cf: https://wxpython.org/Phoenix/docs/html/wx.KeyboardState.html
https://wxpython.org/Phoenix/docs/html/wx.KeyEvent.html
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|