Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

screen control script


  • Please log in to reply
17 replies to this topic

#1 umeaguy

umeaguy

    Seeker

  • Active Members
  • 14 posts

Posted 11 October 2011 - 07:27 AM

Hej,

This is my first posting. I searched the forum but am a little lost at present (I can do some programming but am not an IT expert or Windows programmer).

I stumbled upon autoit looking for a way to turn my laptop screen off, on and then off again with specific intervals at the push of a button, on WinXP. I have determined that this is apparently quite simple in *nix but want to use the current laptop.

So again: *press hotkey*
turn screen off
delay(1)
turn screen on
delay(2)
turn screen off

Then I should be able to turn the screen back on with the motion of the mouse, keyboard or hotkey

PS as a bonus but perhaps misdirected question for this forum:
* I want to check and ideally control the intensity of backlighting on my screen (i.e. the pwm if that is what's going on). This does not have to be from a script - just generally wondering how to check this.
* I want to make sure the backlight is completely off during the "off" state.

I have a PackBell ZG5, LED backlighting.

I am looking for a somewhat "quick and dirty" solution - although the following may be a good little project to start learning autoit.

Thanks!







#2 Mat

Mat

    43 38 48 31 30 4E 34 4F 32

  • MVPs
  • 5,059 posts

Posted 11 October 2011 - 07:30 AM

This looks about right: http://autoitscript.com/forum/topic/57559-monitor-onoff-example/

#3 umeaguy

umeaguy

    Seeker

  • Active Members
  • 14 posts

Posted 11 October 2011 - 12:04 PM

Thanks Mat, I turned that script around and post results below (not tested yet)

Just a couple of questions:

(1) are the values of the following universal on XP/Windows (hardware independent?):

Global Const $lciWM_SYSCommand = 274
Global Const $lciSC_MonitorPower = 61808
Global Const $lciPower_Off = 2
Global Const $lciPower_On = -1

(2) the sleep function takes an int as input. I assume this is seconds. Is there a function with msec resolution? How fast is typical response of the monitor/screen to on/off calls? How can I check this?

AutoIt         
#NoTrayIcon Global Const $lciWM_SYSCommand = 274 Global Const $lciSC_MonitorPower = 61808 Global Const $lciPower_Off = 2 Global Const $lciPower_On = -1   Global $MonitorIsOff = False   Global Const $Delay_1 = 1     HotKeySet("{F10}", "_Monitor_OFF") HotKeySet("{F11}", "_Flicker") HotKeySet("{Esc}", "_Quit")   MsgBox(64, "Monitor On/Off", "Press F10 to turn the monitor off." & @LF & _         "Press F11 to flicker." & @LF & _                                   "Press ESC to turn on the monitor and exit program.")   While 1     Sleep(10) WEnd     Func _Flicker()     _Monitor_ON()     Sleep($Delay_1)     _Monitor_OFF() EndFunc     Func _Monitor_ON()      $MonitorIsOff = False       Local $Progman_hwnd = WinGetHandle('[CLASS:Progman]')               DllCall('user32.dll', 'int', 'SendMessage', _                           'hwnd', $Progman_hwnd, _       'int', $lciWM_SYSCommand, _     'int', $lciSC_MonitorPower, _         'int', $lciPower_On) EndFunc   Func _Monitor_OFF()     $MonitorIsOff = True        Local $Progman_hwnd = WinGetHandle('[CLASS:Progman]')             While $MonitorIsOff = True              DllCall('user32.dll', 'int', 'SendMessage', _                                     'hwnd', $Progman_hwnd, _                                          'int', $lciWM_SYSCommand, _                                     'int', $lciSC_MonitorPower, _                                     'int', $lciPower_Off)               _IdleWaitCommit(0)              Sleep(20)       WEnd EndFunc   Func _IdleWaitCommit($idlesec)      Local $iSave, $LastInputInfo = DllStructCreate ("uint;dword")       DllStructSetData ($LastInputInfo, 1, DllStructGetSize ($LastInputInfo))     DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))      Do              $iSave = DllStructGetData ($LastInputInfo, 2)               Sleep(60)               DllCall ("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr ($LastInputInfo))      Until (DllStructGetData ($LastInputInfo, 2)-$iSave) > $idlesec Or $MonitorIsOff = False     Return DllStructGetData ($LastInputInfo, 2)-$iSave EndFunc   Func _Quit()        _Monitor_ON()       Exit EndFunc

Edited by umeaguy, 11 October 2011 - 12:06 PM.


#4 umeaguy

umeaguy

    Seeker

  • Active Members
  • 14 posts

Posted 11 October 2011 - 12:12 PM

I'd like to add for anyone interested:

The idea is to generate "laptopograms": use my laptop screen to expose photosensitive paper. The paper can be quite sensitive, exposure times may need to be short. Also, I need to avoid background light and need strict control over screen illumination and exposure time.

Waste of time? Only if it's not fun!

I'll keep you posted if this works...

#5 Mat

Mat

    43 38 48 31 30 4E 34 4F 32

  • MVPs
  • 5,059 posts

Posted 11 October 2011 - 12:14 PM

They are always going to be the same, and can be found here.

Edit: waste of time? Time enjoyed wasting is not wasted time.

Edited by Mat, 11 October 2011 - 12:15 PM.


#6 somdcomputerguy

somdcomputerguy

  • Active Members
  • PipPipPipPipPipPip
  • 2,852 posts

Posted 11 October 2011 - 01:31 PM

umeaguy, your project sounds quite interesting, and the Sleep() function parameter is in milliseconds. At least, that what it says in the Help file (hint)(hint).

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.


#7 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 11 October 2011 - 01:45 PM

Interesting concept.
Why even bother turning of your display at all?
I have a small Screen Cleaner app that I use which is essentially just a GUI with the popup style (Created slightly larger than the desktop) and a solid black background, triggered using hotkeys. So all you have to do is roll the mouse off-screen (in fact you can just hide the cursor) and then use hotkeys and timers to Show/Hide the GUI.
GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"

#8 umeaguy

umeaguy

    Seeker

  • Active Members
  • 14 posts

Posted 11 October 2011 - 01:48 PM

Thanks Mat, that's clearer now. For future reference:

when calling DllCall, as in the following

DllCall('user32.dll', 'int', 'SendMessage', _ 'hwnd', $Progman_hwnd, _ 'int', $lciWM_SYSCommand, _ 'int', $lciSC_MonitorPower, _ 'int', $lciPower_On)

the hex value "0x0112" equivalent to integer "274" refers to the (the method?) "WM_SYSCommand."

The $lciWM_SYSCommand is the constant placeholder for this numeric value.

Edited by umeaguy, 11 October 2011 - 02:23 PM.


#9 umeaguy

umeaguy

    Seeker

  • Active Members
  • 14 posts

Posted 11 October 2011 - 02:03 PM

Hi GEOSoft, that may work - where can I get the cleaner to check it out?
It's important however that I have no background illumination at all - a "black" screen may still radiate significantly while on, particularly bad if the pixels are colored toward the blue/UV part of the spectrum instead of red (maybe a red screen would work better in fact as a "blank" background, as in a red darkroom light). I checked the "black" color generated by the screen using powerpoint: during a slide show the edges outside a slide are "black" but the pixels are clearly not "off" ie. there is some illumination, the color is closer to a very dark grey. This will produce what photographers call fog or even worse ruin the paper while not exposed to the image of interest. The idea is to expose for a fraction to a small number of seconds. My initial experiments suggest I have to keep exposures very short. I still have some kinks to work out but perhaps it'll turn out simpler than it currently looks.

#10 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 11 October 2011 - 02:05 PM

Just in case you decide to look at it again later here is the code I use for that Screen Cleaner.
Plain Text         
HotKeySet("c", "_ToggleColor") HotKeySet("{F1}", "_Help") $bHelp = False $bDark = True $iColor = 1 HotKeySet("z", "_Cycle") GUICreate("", @DesktopWidth +40, @DesktopHeight +40, -1, -1, 0x80000000, 0x00000008) GUISetBkColor(0x000000) $s_Label_Txt = "Press C to toggle between dark and light" & @CRLF &@CRLF & "Press Z to cycle through colors" & @CRLF & @CRLF & "Press {Esc} to Exit" $lbl_Hlp = GUICtrlCreateLabel($s_Label_Txt, 120, 120, 350, 200) GUICtrlSetColor($lbl_Hlp, 0xFFFFFF) GUICtrlSetFont($lbl_Hlp, 12, 600) GUICtrlSetState($lbl_Hlp, 32) GUISetState() While 1 If GUIGetMsg() = -3 Then Exit WEnd Func _Help() $bHelp = NOT $bHelp If $bHelp Then   GUICtrlSetState($lbl_Hlp, 16) Else   GUICtrlSetState($lbl_Hlp, 32) EndIf EndFunc Func _ToggleColor() $bDark = NOT $bDark If $bDark Then   GUISetBkColor(0x000000)   GUICtrlSetColor($lbl_Hlp, 0xFFFFFF) Else   GUISetBkColor(0xFFFFFF)   GUICtrlSetColor($lbl_Hlp, 0x000000) EndIf EndFunc   Func _Cycle() Local $iSet Switch $iColor   Case 1    $iSet = 0xFF0000    GUICtrlSetColor($lbl_Hlp, 0xFFFF00)   Case 2    $iSet = 0xFFFF00    GUICtrlSetColor($lbl_Hlp, 0x000000)   Case 3    $iSet = 0x00FF00    GUICtrlSetColor($lbl_Hlp, 0x000000)   Case 4    $iSet = 0xFF00FF    GUICtrlSetColor($lbl_Hlp, 0x000000)   Case 5    $iSet = 0x0000FF    GUICtrlSetColor($lbl_Hlp, 0xFFFFFF) EndSwitch $iColor += 1 If $iColor >= 6 Then $iColor = 1 GUISetBkColor($iSet) EndFunc


Obviously you don't need any of the functions I have or the help label. All you would have to do is create it with Black and write a function to Show/Hide the GUI which would be called by a combination of your timers and a hotkey.

EDIT:
If you add the line
GUISetCursor(16)
just before the GUISetState() then it will hide the cursor for you so you don't have to worry about moving the mouse off screen at all.

Edited by GEOSoft, 11 October 2011 - 02:12 PM.

GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"

#11 umeaguy

umeaguy

    Seeker

  • Active Members
  • 14 posts

Posted 11 October 2011 - 02:19 PM

Thanks GEOSoft, I'll give this a shot ....

#12 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 11 October 2011 - 03:01 PM

No problem and I had a minute so I did up the code for you. Be sure to read the commented line at the top. and it's {F2} to show/hide the GUI.

Plain Text         
;; To exit the script when it's hidden you just press Shift + {Esc}.  If the Window is active then {Esc} by itself will work. HotKeySet("{F2}", "_Set_State") HotKeySet("+{Esc}", "_Goodbye") $bState = False $Frm = GUICreate("", @DesktopWidth +40, @DesktopHeight +40, -1, -1, 0x80000000, 0x00000008) GUISetBkColor(0x000000) GUISetCursor(16) While 1     If GUIGetMsg() = -3 Then _Goodbye() WEnd   Func _Set_State()     $bState = NOT $bState         If $bState Then           GUISetState(@SW_SHOW, $Frm)         Else            GUISetState(@SW_HIDE, $Frm)         EndIf EndFunc   Func _Goodbye()     Exit EndFunc


Edit: Depending on what you are doing; you may want to set the screen color to White or use a function to switch it which would be the _ToggleColor() function in the first script. Remember to set the hotkey to handle it.

Edited by GEOSoft, 11 October 2011 - 03:05 PM.

GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"

#13 umeaguy

umeaguy

    Seeker

  • Active Members
  • 14 posts

Posted 11 October 2011 - 08:12 PM

Thanks to everyone who provided feedback.

I managed to acquire my first (successful) laptopogram. Exposure time was 200 msec (thanks somdcomputerguy)

I ended up using the modified script I posted above which turns the screen on and off. The script from Geosoft worked but as I suspected there was still too much backlight wiith the screen on.

The execution of the script was a little glitchy (not responding always to the F10 and F11 keys as expected), probably due to conflicts with other software, and I was unable to display an image in full screen mode while running the script, but some modification would probably allow that.

Cheers!

Edited by umeaguy, 11 October 2011 - 08:18 PM.


#14 somdcomputerguy

somdcomputerguy

  • Active Members
  • PipPipPipPipPipPip
  • 2,852 posts

Posted 12 October 2011 - 12:59 PM

Thanks to everyone who provided feedback. I managed to acquire my first (successful) laptopogram. Exposure time was 200 msec (thanks somdcomputerguy)

Are you going to scan these and make the images 'publically viewable' somewhere? I look forward to seeing the results.

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.


#15 umeaguy

umeaguy

    Seeker

  • Active Members
  • 14 posts

Posted 12 October 2011 - 04:00 PM

I tried to post the image here but no luck.

I've posted a copy on flicker:
http://www.flickr.com/photos/68588636@N04/

Let me know if this doesn't work.

#16 AdmiralClaws

AdmiralClaws

    Where is the fish?

  • Active Members
  • PipPipPipPipPipPip
  • 4,679 posts

Posted 12 October 2011 - 05:55 PM

@umeaguy

Hi neighbour!

#17 umeaguy

umeaguy

    Seeker

  • Active Members
  • 14 posts

Posted 12 October 2011 - 07:46 PM

Hejsan!

#18 umeaguy

umeaguy

    Seeker

  • Active Members
  • 14 posts

Posted 14 October 2011 - 06:14 PM

An update: this was so much fun I wanted to share it - it is now an instructable: http://www.instructables.com/id/Laptopogram/

If you have any suggestions on how to improve the script please let me know.

Thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users