Jump to content
Sign in to follow this  
temp00

Turn off monitor and block keyboard & mouse

Recommended Posts

temp00

I'm trying to writing a script which should function like:

Press a hotkey, monitor is turned off and keyboard/mouse input is blocked (except the hotkey);

Press the hotkey again, monitor is turned on and blocking is removed.

For turning off monitor, I use function like:

Func _Monitor_OFF()
Local $Progman_hwnd = WinGetHandle('[CLASS:Progman]')
DllCall('user32.dll', 'int', 'SendMessage', _
'hwnd', $Progman_hwnd, _
'int', $WM_SYSCmd, _
'int', $SC_MonitorPower, _
'int', $Power_Off)
EndFunc

and for keyboard & mouse blocking, I tried _BlockInputEx().

However, the keyboard and mouse can be blocked but the monitor cannot stay turned-off when keyboard or mouse is touched. So, any solution?

Share this post


Link to post
Share on other sites
water

Can you please tell us what you need this for? Sounds a bit strange.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

It could be used for when you walk away from your PC you want it to go dark and locked. Seems logical to me.

So why not use Ctrl-Alt-Del or - even faster - Win+L? That's what it was made for, wasn't it?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
water

So he wants to kill two birds with one stone? Lock the screen and go into power saving mode (darken the screen)?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
JLogan3o13

Temp00, I can see the monitor bit, and locking the screen if you don't want someone on the PC, but can you please explain why you want to completely block all user input?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
temp00

Temp00, I can see the monitor bit, and locking the screen if you don't want someone on the PC, but can you please explain why you want to completely block all user input?

Mainly for security, when monitor goes blank, any input except for the unlock hotkey should be deemed as invalid~

Share this post


Link to post
Share on other sites
MouseSpotter

Mainly for security, when monitor goes blank, any input except for the unlock hotkey should be deemed as invalid~

See the quote regarding "Ctrl-Alt-Del".

Autoit is just another program to windows ... it can block all input ... however Ctrl-Alt-Del will still work.

Only the windows OS can lock out a user.

So ... the question is ... why do you want to turn off the monitor?

A locked user shows the login screen only.

Share this post


Link to post
Share on other sites
careca

:

As for the monitor, i would use NirCmd, don't know how to do it in autoit,

never tried, Command is: nircmd.exe monitor off

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
temp00

See the quote regarding "Ctrl-Alt-Del".

Autoit is just another program to windows ... it can block all input ... however Ctrl-Alt-Del will still work.

Only the windows OS can lock out a user.

So ... the question is ... why do you want to turn off the monitor?

A locked user shows the login screen only.

 

Yes I know that, I believe the fact Ctrl-Alt-Del cannot be blocked is legitimate. I'd like the monitor be turned-off both for energy-saving and for work convenience. I don't like a bright monitor shining in front of me when I read paper work, it's distracting.

Share this post


Link to post
Share on other sites
MouseSpotter

In which case - you do not need a hotkey .... this will do ...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
local $gui = GUICreate("",@DesktopWidth+100,@DesktopHeight+100,Default,Default,$WS_POPUP)
GUISetBkColor(0x000000)
GUISetState()

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()
Edited by MouseSpotter

Share this post


Link to post
Share on other sites
careca

Did you post this code in autoitcode? Because when i copy paste this, it will be a very long string, and the line feeds are not copied.

EDIT: btw theres a missing endif

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
JLogan3o13

I do not see a missing EndIf?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
BrewManNH

 

EDIT: btw theres a missing endif

There's no missing EndIf in that code, it's a single line If...Then statement which doesn't require, and can't use, an Endif statement.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
MouseSpotter

Did you post this code in autoitcode? Because when i copy paste this, it will be a very long string, and the line feeds are not copied.

EDIT: btw theres a missing endif

The copy&paste missed the end bracket in the last line "GUIDelete(" ... which I have now fixed.

The code copies & pastes from the webpage fine for me.

I used the AutoIt code type from the forum editor "code" icon.

Share this post


Link to post
Share on other sites
Queener

sounds phishy... like creating a temporary bug or more of a virus/hi-jack creation. If it doesn't accept user input; how will you turn the pc on to the stage where you can input user password?

Edited by asianqueen

Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.")

Share this post


Link to post
Share on other sites
temp00

 

In which case - you do not need a hotkey .... this will do ...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
local $gui = GUICreate("",@DesktopWidth+100,@DesktopHeight+100,Default,Default,$WS_POPUP)
GUISetBkColor(0x000000)
GUISetState()

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

 

Ah...we can call this a work-around, though not pretty

Share this post


Link to post
Share on other sites
temp00

sounds phishy... like creating a temporary bug or more of a virus/hi-jack creation. If it doesn't accept user input; how will you turn the pc on to the stage where you can input user password?

 

What do you mean by "phishy"? I think you should read my first post again~ A hotkey is excluded from blocking for toggle the monitor/keyboard&mouse

Share this post


Link to post
Share on other sites
JLogan3o13

sounds phishy... like creating a temporary bug or more of a virus/hi-jack creation. If it doesn't accept user input; how will you turn the pc on to the stage where you can input user password?

 

After your thread yesterday, where you refused to give the title of the window you were trying to manipulate, should you really be casting doubt on anyone else's post? ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×