Yashied Posted August 17, 2009 Author Share Posted August 17, 2009 I'm trying to use HotKey.au3 to use Win-L to lock the computer and run the screen saver based on a post from Lej. After pressing Win-L the computer locks and the screen saver runs. The problem is after I unlock the computer the keyboard locks up until I hit a modifier key (shift, ctrl, alt, or win). Try this to recreate: Have Notepad open when running the scriptRun the scriptPress Win-LUnlock the computerTry typing in NotepadTyping "l" the first time will allow all the alphanumeric keys to work. Typing "l' the second time will lock the computer without pressing the Win key.#include "HotKey.au3" #include "vkConstants.au3" HotKeySet("{Esc}", "_Quit") _HotKeyAssign(BitOr($CK_WIN, $VK_L), "ScreenSaver") While 1 Sleep(10) WEnd Func ScreenSaver() Local Const $SC_SCREENSAVE = 0xF140 DllCall('user32.dll', 'int', 'LockWorkStation') _SendMessage(_WinAPI_GetDesktopWindow(), $WM_SYSCOMMAND, $SC_SCREENSAVE, 0) EndFunc ;==>ScreenSaver Func _Quit() Exit EndFunc ;==>_Quit The problem isn't specific to Win-L. The same thing happens when I change the script to use Win-K (hitting "k" the second time will lock the computer) Any ideas on what I'm doing wrong? --Jeff On XP everything works fine for me. What are your system? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Jeff West Posted August 17, 2009 Share Posted August 17, 2009 I'm using AutoIt 3.3.0.0 (the latest non-beta version) and XP Professional with Service Pack 3. I just tried running the same script in a Virtual PC running a clean build of XP Profession with Service Pack 2 and had the same problem. Same problem after compiling with 3.3.1.1 and even after rebooting. No I'm really confused. Is anyone else able to duplicate the problem? --Jeff Link to comment Share on other sites More sharing options...
Yashied Posted August 17, 2009 Author Share Posted August 17, 2009 (edited) I'm using AutoIt 3.3.0.0 (the latest non-beta version) and XP Professional with Service Pack 3.I just tried running the same script in a Virtual PC running a clean build of XP Profession with Service Pack 2 and had the same problem. Same problem after compiling with 3.3.1.1 and even after rebooting.No I'm really confused. Is anyone else able to duplicate the problem?--JeffYes, I caught this bug. I think that is to blame Lock Workstation. Apparently stops working hook or something like that. I would think.EDIT:When I wrote this UDF, I not thought that it could be used for this purpose. Edited August 17, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Yashied Posted August 17, 2009 Author Share Posted August 17, 2009 (edited) Try this. expandcollapse popup#Include 'HotKey.au3' #Include 'vkConstants.au3' HotKeySet('{Esc}', '_Quit') _HotKeyAssign(BitOR($CK_WIN, $VK_L), 'ScreenSaver') While 1 Sleep(10) WEnd Func ScreenSaver() Local Const $SC_SCREENSAVE = 0xF140 Local $Timer = TimerInit() DllCall('user32.dll', 'int', 'LockWorkStation') Do Sleep(10) If TimerDiff($Timer) > 1000 Then Return EndIf Until _IsWorkstationLocked() _SendMessage(_WinAPI_GetDesktopWindow(), $WM_SYSCOMMAND, $SC_SCREENSAVE, 0) While _IsWorkstationLocked() Sleep(10) WEnd DllCall('user32.dll', 'int', 'keybd_event', 'int', $VK_L, 'int', 0, 'int', 2, 'ptr', 0) DllCall('user32.dll', 'int', 'keybd_event', 'int', $VK_LWIN, 'int', 0, 'int', 2, 'ptr', 0) DllCall('user32.dll', 'int', 'keybd_event', 'int', $VK_RWIN, 'int', 0, 'int', 2, 'ptr', 0) EndFunc ;==>ScreenSaver Func _IsWorkstationLocked() Local Const $DESKTOP_SWITCHDESKTOP = 0x0100 Local $Result = False $hDesktop = DllCall('user32.dll', 'hwnd', 'OpenDesktop', 'str', 'Default', 'int', 0, 'int', 0, 'int', $DESKTOP_SWITCHDESKTOP) If Not @error Then $Result = DllCall('user32.dll', 'int', 'SwitchDesktop', 'hwnd', $hDesktop[0]) $Result = Not $Result[0] DllCall('user32.dll', 'int', 'CloseDesktop', 'hwnd', $hDesktop[0]) EndIf Return $Result EndFunc ;==>_IsWorkstationLocked Func _Quit() Exit EndFunc ;==>_Quit EDIT: This, incidentally, solves the Lej problem. Edited August 17, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Yashied Posted August 17, 2009 Author Share Posted August 17, 2009 Jeff West, I think the problem is solved? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Jeff West Posted August 17, 2009 Share Posted August 17, 2009 It works great. Thank you for the time you put into solving this problem. --Jeff Link to comment Share on other sites More sharing options...
grega Posted August 18, 2009 Share Posted August 18, 2009 How can I use : Alt+RIGHT ? Link to comment Share on other sites More sharing options...
Yashied Posted August 18, 2009 Author Share Posted August 18, 2009 What is "RIGHT"? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
grega Posted August 18, 2009 Share Posted August 18, 2009 (edited) What is "RIGHT"?It Is : RIGHT ARROW key (VK_RIGHT (0x27))However, my problem is with "Alt" key using Edited August 18, 2009 by grega Link to comment Share on other sites More sharing options...
KaFu Posted August 18, 2009 Share Posted August 18, 2009 According to UDF help-file for _ispressed() ALT = 12 => $VK_MENU = 0x12. msdn says "VK_MENU (0x12) (ALT key)". OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
grega Posted August 18, 2009 Share Posted August 18, 2009 According to UDF help-file for _ispressed() ALT = 12 => $VK_MENU = 0x12. msdn says "VK_MENU (0x12) (ALT key)".I know thisBat : _HotKeyAssign(BitOR($VK_MENU, $VK_RIGHT), 'Message', BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL)) does not want to work _HotKeyAssign(BitOR($СK_MENU, $VK_RIGHT), 'Message', BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL)) too.Can you give example for the use of Buttons' Alt ', together with any button ? Link to comment Share on other sites More sharing options...
KaFu Posted August 18, 2009 Share Posted August 18, 2009 Maybe something like this? _HotKeyAssign(0x12+0x27, 'Message', BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL)) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
grega Posted August 18, 2009 Share Posted August 18, 2009 Maybe something like this?_HotKeyAssign(0x12+0x27, 'Message', BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL))Still not working Link to comment Share on other sites More sharing options...
KaFu Posted August 18, 2009 Share Posted August 18, 2009 Your right, that one's a bugger >_<... _HotKeyAssign(BitOR(0x27, $CK_ALT),'message', BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL)) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
grega Posted August 18, 2009 Share Posted August 18, 2009 By the way : HotKeys 'Ctrl' and 'Shift' working only with : $CK_CONTROL and $CK_SHIFT (bat no working with $VK_CONTROL and $VK_SHIFT ) Link to comment Share on other sites More sharing options...
grega Posted August 18, 2009 Share Posted August 18, 2009 Maybe something like this?_HotKeyAssign(0x12+0x27, 'Message', BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL))Still not workingBy the way :HotKeys 'Ctrl' and 'Shift' working only with : $CK_CONTROL and $CK_SHIFT (bat no working with $VK_CONTROL and $VK_SHIFT ) Link to comment Share on other sites More sharing options...
Yashied Posted August 18, 2009 Author Share Posted August 18, 2009 Still not working By the way : HotKeys 'Ctrl' and 'Shift' working only with : $CK_CONTROL and $CK_SHIFT (bat no working with $VK_CONTROL and $VK_SHIFT ) I suggest you read VERY CAREFULLY the documentation for _HotKeyAssign() within a UDF. _HotKeyAssign(BitOR($CK_ALT, $VK_RIGHT), 'Message') My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
grega Posted August 18, 2009 Share Posted August 18, 2009 I suggest you read VERY CAREFULLY the documentation for _HotKeyAssign() within a UDF. _HotKeyAssign(BitOR($CK_ALT, $VK_RIGHT), 'Message') Thanks,my mistake that I tried to use a non-existent constant: '$CK_MENU' instead of '$CK_ALT' Link to comment Share on other sites More sharing options...
rexx Posted September 11, 2009 Share Posted September 11, 2009 Hi, I want to create a double click hotkey with your hotkeyset And here's how I do it now. It works but i want to know is there a better way to do this? $iFlag = BitOR($iFlag, $HK_FLAG_EXTENDEDCALL) Assign("HotkeyFunc" & $iKey, $sFunc, 2) _HotKeyAssign($iKey, "HotkeyDouble", $iFlag) Func HotkeyDouble($iKey) if $iPriorKey = $iKey and TimerDiff($iPriorKeyTime) < 250 then Call(Eval("HotkeyFunc" & $iKey)) $iPriorKey = $iKey $iPriorKeyTime = TimerInit() EndFunc Link to comment Share on other sites More sharing options...
Yashied Posted September 11, 2009 Author Share Posted September 11, 2009 Hi, I want to create a double click hotkey with your hotkeyset And here's how I do it now. It works but i want to know is there a better way to do this? $iFlag = BitOR($iFlag, $HK_FLAG_EXTENDEDCALL) Assign("HotkeyFunc" & $iKey, $sFunc, 2) _HotKeyAssign($iKey, "HotkeyDouble", $iFlag) Func HotkeyDouble($iKey) if $iPriorKey = $iKey and TimerDiff($iPriorKeyTime) < 250 then Call(Eval("HotkeyFunc" & $iKey)) $iPriorKey = $iKey $iPriorKeyTime = TimerInit() EndFunc I would have done the following: #Include <HotKey_17_beta.au3> Global Const $VK_F12 = 0x7B Global $Timer = 0 _HotKeyAssign($VK_F12, 'Message', BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL, $HK_FLAG_POSTCALL)) While 1 Sleep(10) WEnd Func Message($iKey) If $iKey > 0 Then If ($Timer) And (TimerDiff($Timer) < 250) Then MsgBox(0, 'Hotkey Test Message', 'Hotkey has been pressed!') $Timer = 0 Return EndIf $Timer = TimerInit() EndIf EndFunc ;==>Message HotKey_17_beta.au3 you can download here. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... 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