Sykotron Posted August 18, 2011 Share Posted August 18, 2011 I just started work at a place where we were issued a laptop. We do not have admin privileges and the power-saving options put the computer into standby absurdly quickly as well as user account locking due to inactivity. I understand this is likely against their wishes, but I'm working on a script that prevents these. There are also many places where typing user information is required which I'd like to automate. Currently when I press my hotkey to type my user information in it has some unwanted effects. It seems it holds down the hotkey key indefinitely until I manually press it myself (i.e. I press CTRL+= and afterwards I must press CTRL in order to do most anything). I'm trying to simply send the up stroke of the key and blocking user input, but I'm still having issues. Our print screen key is physically disabled but it's copy the screen to the clipboard functionality isn't so I've got a key set up for that. expandcollapse popup; Press Esc to terminate script, Pause/Break to "pause" Global $Paused Global $USERNAME = "removed" Global $ZID = "removed" Global $PASSWORD = "removed" HotKeySet("{PAUSE}", "TogglePause") HotKeySet("!-", "Terminate") ;Alt-- HotKeySet("!=", "Login") ;Alt-= HotKeySet("^=", "LoginZ") ;Ctrl-= HotKeySet("{SCROLLLOCK}", "SS") ;;;; Body of program would go here ;;;; DllCall("kernel32.dll", "DWORD", "SetThreadExecutionState", "DWORD", 2147483651) While 1 BlockInput(1) Send("{CTRLUP}") BlockInput(0) Sleep(120000) BlockInput(1) Send("{PRINTSCREEN}") Send("{CTRLUP}") BlockInput(0) WEnd ;;;;;;;; Func TogglePause() $Paused = NOT $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func Login() BlockInput(1) Send("{CTRLUP}") Sleep(500) Send($USERNAME) Send("{TAB}") Send($PASSWORD) Sleep(200) Send("{CTRLUP}") BlockInput(0) EndFunc Func LoginZ() BlockInput(1) Send("{CTRLUP}") Sleep(500) Send($ZID) Send("{TAB}") Send($PASSWORD) Sleep(200) Send("{CTRLUP}") BlockInput(0) EndFunc Func SS() BlockInput(1) Send("{CTRLUP}") Send("{PRINTSCREEN}") Send("{CTRLUP}") BlockInput(0) EndFunc Link to comment Share on other sites More sharing options...
Bert Posted August 18, 2011 Share Posted August 18, 2011 The problem is this: While 1 BlockInput(1) Send("{CTRLUP}") BlockInput(0) Sleep(120000) BlockInput(1) Send("{PRINTSCREEN}") Send("{CTRLUP}") BlockInput(0) WEnd Your loop is in need of some love here. If anything you should simply have an idle loop and then call your functions on demand. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Sykotron Posted August 18, 2011 Author Share Posted August 18, 2011 Well this is the idle loop that should be running continuously. I want it to hit a key once every 2 minutes to make sure I don't go idle and get logged out/locked. Maybe I don't understand what you're saying though? Link to comment Share on other sites More sharing options...
KaFu Posted August 18, 2011 Share Posted August 18, 2011 (edited) Here's an alternative method that worked for me ... maybe set the sleep even to 10.000 or 60.000 or something like that, then it shouldn't even bother you while working... Edit: Using _Timer_GetIdleTime() might even make it leaner ... #include <Timers.au3> HotKeySet("{ESC}", "_Exit") Global $i While Sleep(500) If _Timer_GetIdleTime() > 30000 Then $i += 1 $aMousePos = MouseGetPos() Switch Mod($i, 2) Case True MouseMove($aMousePos[0] + 1, $aMousePos[1]) Case False MouseMove($aMousePos[0] - 1, $aMousePos[1]) EndSwitch EndIf WEnd Func _Exit() Exit EndFunc ;==>_Exit Edited August 18, 2011 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Sykotron Posted August 18, 2011 Author Share Posted August 18, 2011 Here's an alternative method that worked for me ... maybe set the sleep even to 10.000 or 60.000 or something like that, then it shouldn't even bother you while working... Edit: Using _Timer_GetIdleTime() might even make it leaner ... #include <Timers.au3> HotKeySet("{ESC}", "_Exit") Global $i While Sleep(500) If _Timer_GetIdleTime() > 30000 Then $i += 1 $aMousePos = MouseGetPos() Switch Mod($i, 2) Case True MouseMove($aMousePos[0] + 1, $aMousePos[1]) Case False MouseMove($aMousePos[0] - 1, $aMousePos[1]) EndSwitch EndIf WEnd Func _Exit() Exit EndFunc ;==>_Exit This isn't my main issue. The anti-idling seems to be working just fine. I'm concerned because some keys are getting "stuck"... unless this is all related to that I press print screen once every two minutes which I could easily change to move the mouse by 1 pixel and back. Also, what are some suggestions of keys that do nothing in other applications that I can use as hotkeys. Link to comment Share on other sites More sharing options...
KaFu Posted August 18, 2011 Share Posted August 18, 2011 Take a look here: http://www.autoitscript.com/wiki/FAQ#Keys_virtually_stuck And something like HotKeySet("!+^#f","_Func") should be quite save to use . OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now