Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #12570 > unrolled thread

Detecting Ctrl-Alt-Del in Windows

Started byDen <patentsvnc@gmail.com>
First post2011-09-01 08:52 -0700
Last post2011-09-03 07:47 +1000
Articles 16 — 10 participants

Back to article view | Back to comp.lang.python


Contents

  Detecting Ctrl-Alt-Del in Windows Den <patentsvnc@gmail.com> - 2011-09-01 08:52 -0700
    Re: Detecting Ctrl-Alt-Del in Windows Nobody <nobody@nowhere.com> - 2011-09-02 01:10 +0100
      Re: Detecting Ctrl-Alt-Del in Windows Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-09-01 22:19 -0700
      Re: Detecting Ctrl-Alt-Del in Windows Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-09-02 18:19 +1200
    Re: Detecting Ctrl-Alt-Del in Windows Stephen Hansen <me+list/python@ixokai.io> - 2011-09-02 00:06 -0700
    Re: Detecting Ctrl-Alt-Del in Windows Chris Angelico <rosuav@gmail.com> - 2011-09-02 17:55 +1000
      Re: Detecting Ctrl-Alt-Del in Windows Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2011-09-03 12:51 +1200
      Re: Detecting Ctrl-Alt-Del in Windows Nobody <nobody@nowhere.com> - 2011-09-03 08:49 +0100
    Re: Detecting Ctrl-Alt-Del in Windows Thomas Jollans <t@jollybox.de> - 2011-09-02 12:01 +0200
    Re: Detecting Ctrl-Alt-Del in Windows sjm <sjmsoft@gmail.com> - 2011-09-02 05:27 -0700
      Re: Detecting Ctrl-Alt-Del in Windows Den <patentsvnc@gmail.com> - 2011-09-02 09:19 -0700
      Re: Detecting Ctrl-Alt-Del in Windows Den <patentsvnc@gmail.com> - 2011-09-02 09:20 -0700
    Re: Detecting Ctrl-Alt-Del in Windows Web Dreamer <webdreamer@nospam.fr> - 2011-09-02 14:38 +0200
      Re: Detecting Ctrl-Alt-Del in Windows Tim Golden <mail@timgolden.me.uk> - 2011-09-02 13:45 +0100
    Re: Detecting Ctrl-Alt-Del in Windows Den <patentsvnc@gmail.com> - 2011-09-02 09:26 -0700
      Re: Detecting Ctrl-Alt-Del in Windows Chris Angelico <rosuav@gmail.com> - 2011-09-03 07:47 +1000

#12570 — Detecting Ctrl-Alt-Del in Windows

FromDen <patentsvnc@gmail.com>
Date2011-09-01 08:52 -0700
SubjectDetecting Ctrl-Alt-Del in Windows
Message-ID<6e602a19-8cca-4924-bd95-df08615662d2@c8g2000prn.googlegroups.com>
Obviously, this is a windows-based question.  I know that Ctrl-Alt-Del
is handled deep inside the OS, and I'm not trying to interrupt that.
But is there some way to detect that a C-A-D has been pressed?

Also, is there a corresponding key-sequence in Mac and Linux?  And how
might one detect those too?

Den

[toc] | [next] | [standalone]


#12594

FromNobody <nobody@nowhere.com>
Date2011-09-02 01:10 +0100
Message-ID<pan.2011.09.02.00.10.14.153000@nowhere.com>
In reply to#12570
On Thu, 01 Sep 2011 08:52:49 -0700, Den wrote:

> Obviously, this is a windows-based question.  I know that Ctrl-Alt-Del
> is handled deep inside the OS, and I'm not trying to interrupt that.
> But is there some way to detect that a C-A-D has been pressed?

Not reliably. You might infer that Ctrl-Alt-Del has been used by the way
that certain operations behave, but that's fairly error-prone.

> Also, is there a corresponding key-sequence in Mac and Linux?  And how
> might one detect those too?

I don't know about Mac. Linux has some support for Ctrl-Alt-Del on the
console, and the optional "Magic SysRq" feature. But there's no easy way
to detect these (if the sequence is recognised by the kernel, it's not
reported by the usual mechanisms).

[toc] | [prev] | [next] | [standalone]


#12616

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2011-09-01 22:19 -0700
Message-ID<mailman.686.1314941112.27778.python-list@python.org>
In reply to#12594
On Fri, 02 Sep 2011 01:10:14 +0100, Nobody <nobody@nowhere.com>
declaimed the following in gmane.comp.python.general:

> On Thu, 01 Sep 2011 08:52:49 -0700, Den wrote:
> 
> > Obviously, this is a windows-based question.  I know that Ctrl-Alt-Del
> > is handled deep inside the OS, and I'm not trying to interrupt that.
> > But is there some way to detect that a C-A-D has been pressed?
> 
> Not reliably. You might infer that Ctrl-Alt-Del has been used by the way
> that certain operations behave, but that's fairly error-prone.
> 
	No kidding... <ctrl-alt-del> is used to open the Login/password
screen in Windows specifically because it does not propagate to user
applications. Otherwise someone could write a trojan program that
emulated the login/password window and capture someone's
username/password.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#12621

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2011-09-02 18:19 +1200
Message-ID<9cbashF8buU1@mid.individual.net>
In reply to#12594
> On Thu, 01 Sep 2011 08:52:49 -0700, Den wrote:
> 
>>Also, is there a corresponding key-sequence in Mac and Linux?

The nearest equivalent in MacOSX is Command-Option-Escape, which
brings up the force-quit dialog. I don't know how deep down in
the system it's implemented.

It's possible to use SetSystemUIMode to put an app into a "kiosk
mode" where force-quitting is disabled, but I don't know whether
the app can intercept Command-Option-Escape in that situation and
do something else with it.

-- 
Greg

[toc] | [prev] | [next] | [standalone]


#12622

FromStephen Hansen <me+list/python@ixokai.io>
Date2011-09-02 00:06 -0700
Message-ID<mailman.695.1314947185.27778.python-list@python.org>
In reply to#12570

[Multipart message — attachments visible in raw view] — view raw

On 9/1/11 8:52 AM, Den wrote:
> Obviously, this is a windows-based question.  I know that Ctrl-Alt-Del
> is handled deep inside the OS, and I'm not trying to interrupt that.
> But is there some way to detect that a C-A-D has been pressed?

IIUC, by definition, Ctrl-Alt-Delete can't be responded to in any way.
Its the entire point of the sequence: when you type it you can be
entirely, totally, 100% certain that what happens next is the true OS
and not any app faking things.

That's why you have to hit CAD to get to the login form in some versions
of Windows. The whole point of that secure sequence is that the OS and
only the OS responds.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

[toc] | [prev] | [next] | [standalone]


#12626

FromChris Angelico <rosuav@gmail.com>
Date2011-09-02 17:55 +1000
Message-ID<mailman.697.1314951544.27778.python-list@python.org>
In reply to#12570
On Fri, Sep 2, 2011 at 5:06 PM, Stephen Hansen <me+list/python@ixokai.io> wrote:
> That's why you have to hit CAD to get to the login form in some versions
> of Windows. The whole point of that secure sequence is that the OS and
> only the OS responds.
>

Although I heard somewhere that that's more gimmick than guarantee,
and that it IS possible for an app to hook CAD - just that it's a lot
harder than building a simple window that looks like the login... but
it's pretty easy to fool a lot of people. Just look at the emails in
your spam box one day, find the ones spoofing a bank, and see what a
poor job they do. And yet they work.

ChrisA

[toc] | [prev] | [next] | [standalone]


#12683

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2011-09-03 12:51 +1200
Message-ID<9cdc00Fnq3U1@mid.individual.net>
In reply to#12626
Chris Angelico wrote:

> Although I heard somewhere that that's more gimmick than guarantee,
> and that it IS possible for an app to hook CAD - just that it's a lot
> harder than building a simple window that looks like the login...

And of course it's possible that someone has snuck in
during the night and installed Linux on the machine,
with a program that fakes a Windows login screen,
with Ctrl-Alt-Delete and everything...

-- 
Greg

[toc] | [prev] | [next] | [standalone]


#12694

FromNobody <nobody@nowhere.com>
Date2011-09-03 08:49 +0100
Message-ID<pan.2011.09.03.07.49.49.294000@nowhere.com>
In reply to#12626
On Fri, 02 Sep 2011 17:55:41 +1000, Chris Angelico wrote:

>> That's why you have to hit CAD to get to the login form in some versions
>> of Windows. The whole point of that secure sequence is that the OS and
>> only the OS responds.
> 
> Although I heard somewhere that that's more gimmick than guarantee,
> and that it IS possible for an app to hook CAD

It's possible to configure how CAD is handled, but this requires
Administrator privilege, so it's not exploitable (i.e. it doesn't gain you
anything you can't obtain by other means).

[toc] | [prev] | [next] | [standalone]


#12630

FromThomas Jollans <t@jollybox.de>
Date2011-09-02 12:01 +0200
Message-ID<mailman.699.1314957682.27778.python-list@python.org>
In reply to#12570
On 01/09/11 17:52, Den wrote:
> Obviously, this is a windows-based question.  I know that Ctrl-Alt-Del
> is handled deep inside the OS, and I'm not trying to interrupt that.
> But is there some way to detect that a C-A-D has been pressed?
> 
> Also, is there a corresponding key-sequence in Mac and Linux?  And how
> might one detect those too?

On Linux Ctrl+Alt+Delete is typically configured to reboot the machine
when in console mode. In X11 (graphical), as far as I know, it's no
different than other keys. To catch it globally, you'd probably have to
go through the individual window manager.

As m'colleague Nobody mentions, there's also the SysRq feature, but that
always goes straight to the kernel and is, like Ctrl+Alt+Delete on
Windows, impossible to handle in userspace code.

Thomas

[toc] | [prev] | [next] | [standalone]


#12633

Fromsjm <sjmsoft@gmail.com>
Date2011-09-02 05:27 -0700
Message-ID<c287acc8-8fec-4f3d-ad64-bea090ed8eae@w28g2000yqw.googlegroups.com>
In reply to#12570
On Sep 1, 12:52 pm, Den <patents...@gmail.com> wrote:
> Obviously, this is a windows-based question.  I know that Ctrl-Alt-Del
> is handled deep inside the OS, and I'm not trying to interrupt that.
> But is there some way to detect that a C-A-D has been pressed?

If you manage to write a program that can detect CTRL-ALT-DEL, please
report it as a bug in Windows!  CTRL-ALT-DEL is Windows' "secure
attention sequence" which must only be handled by the OS.

-- Steve

[toc] | [prev] | [next] | [standalone]


#12647

FromDen <patentsvnc@gmail.com>
Date2011-09-02 09:19 -0700
Message-ID<4310f6ad-8aab-481b-9e68-3931f67b49b6@m4g2000pri.googlegroups.com>
In reply to#12633
On Sep 2, 5:27 am, sjm <sjms...@gmail.com> wrote:
> On Sep 1, 12:52 pm, Den <patents...@gmail.com> wrote:
>
> > Obviously, this is a windows-based question.  I know that Ctrl-Alt-Del
> > is handled deep inside the OS, and I'm not trying to interrupt that.
> > But is there some way to detect that a C-A-D has been pressed?
>
> If you manage to write a program that can detect CTRL-ALT-DEL, please
> report it as a bug in Windows!  CTRL-ALT-DEL is Windows' "secure
> attention sequence" which must only be handled by the OS.
>
> -- Steve

I have already done that, in AutoHotKey ... or at least it used to
work.  AHK can detect when a window opened.  And when CAD was pressed
the ... well, I've forgotten what it was called ... but a window
opened asking if you wanted to open the task manager, or quit or log
off or what.  Then you would know that CAD was pressed.  There was
nothing you could do to stop it, but you could at least detect that it
had been pressed.

That's why I was wondering if there was a similar technique which
could be used in Python.

Den

[toc] | [prev] | [next] | [standalone]


#12648

FromDen <patentsvnc@gmail.com>
Date2011-09-02 09:20 -0700
Message-ID<2ab915f4-a0cb-42ed-8d4b-5bd16a9ee9ca@x21g2000prd.googlegroups.com>
In reply to#12633
On Sep 2, 5:27 am, sjm <sjms...@gmail.com> wrote:
> On Sep 1, 12:52 pm, Den <patents...@gmail.com> wrote:
>
> > Obviously, this is a windows-based question.  I know that Ctrl-Alt-Del
> > is handled deep inside the OS, and I'm not trying to interrupt that.
> > But is there some way to detect that a C-A-D has been pressed?
>
> If you manage to write a program that can detect CTRL-ALT-DEL, please
> report it as a bug in Windows!  CTRL-ALT-DEL is Windows' "secure
> attention sequence" which must only be handled by the OS.
>
> -- Steve

I'm not trying to hook it or stop it, just detect it.

Den

[toc] | [prev] | [next] | [standalone]


#12634

FromWeb Dreamer <webdreamer@nospam.fr>
Date2011-09-02 14:38 +0200
Message-ID<4e60ce59$0$18107$426a74cc@news.free.fr>
In reply to#12570
Den a écrit ce jeudi 1 septembre 2011 17:52 dans <6e602a19-8cca-4924-bd95-
df08615662d2@c8g2000prn.googlegroups.com> :

> Obviously, this is a windows-based question.  I know that Ctrl-Alt-Del
> is handled deep inside the OS, and I'm not trying to interrupt that.
> But is there some way to detect that a C-A-D has been pressed?
> 
> Also, is there a corresponding key-sequence in Mac and Linux?

Ctrl-Alt-Syst <- while keeping these 3 pressed alternately press S (Sync 
disks) then U (Unmount all partitions) then B (Boot).
For this to work you Need to have it enabled in the kernel and to have the 
line:
kernel.sysrq = 1
in /etc/sysctl.conf

> And how
> might one detect those too?

I "think" you can't as explained by others in this thread.

-- 
Web Dreamer

[toc] | [prev] | [next] | [standalone]


#12635

FromTim Golden <mail@timgolden.me.uk>
Date2011-09-02 13:45 +0100
Message-ID<mailman.702.1314967544.27778.python-list@python.org>
In reply to#12634
>> Obviously, this is a windows-based question.  I know that Ctrl-Alt-Del
>> is handled deep inside the OS, and I'm not trying to interrupt that.
>> But is there some way to detect that a C-A-D has been pressed?

Others have pointed out that this shouldn't really be possible for
reasons of security. (And I agree). However, if what you're really
after is to detect a session switch or a logon then this might
be of some use:

http://timgolden.me.uk/python/win32_how_do_i/track-session-events.html

TJG

[toc] | [prev] | [next] | [standalone]


#12649

FromDen <patentsvnc@gmail.com>
Date2011-09-02 09:26 -0700
Message-ID<d5a699af-83ae-48ca-b32c-3aedc4a96d2a@s2g2000prm.googlegroups.com>
In reply to#12570
On Sep 1, 8:52 am, Den <patents...@gmail.com> wrote:
> Obviously, this is a windows-based question.  I know that Ctrl-Alt-Del
> is handled deep inside the OS, and I'm not trying to interrupt that.
> But is there some way to detect that a C-A-D has been pressed?
>
> Also, is there a corresponding key-sequence in Mac and Linux?  And how
> might one detect those too?
>
> Den

I've been doing some more thinking on what I want.  This may be a
better explanation.  Is there a way of detecting if my program has
lost "focus" (I'm not sure the correct term)?  For example, if someone
is typing in my program, but some other program takes control (or CAD
has been pressed) I would like simply to log that.  I have no interest
in trying to hijack or interfere with anything, simply log it.

Den

[toc] | [prev] | [next] | [standalone]


#12676

FromChris Angelico <rosuav@gmail.com>
Date2011-09-03 07:47 +1000
Message-ID<mailman.722.1315000077.27778.python-list@python.org>
In reply to#12649
On Sat, Sep 3, 2011 at 2:26 AM, Den <patentsvnc@gmail.com> wrote:
> I've been doing some more thinking on what I want.  This may be a
> better explanation.  Is there a way of detecting if my program has
> lost "focus" (I'm not sure the correct term)?  For example, if someone
> is typing in my program, but some other program takes control (or CAD
> has been pressed) I would like simply to log that.  I have no interest
> in trying to hijack or interfere with anything, simply log it.

Ah, then yes most definitely! If you're writing a GUI program, a
LostFocus event is a normal thing to be able to catch.

Now, if you're writing a console program, that mightn't be so easy.
But certainly you can detect loss of focus to any window that you
control.

ChrisA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web