eohalloran Posted December 18, 2008 Posted December 18, 2008 Hi, New to this forum. I have a problem in that if Caps Lock is on, when I send commands to a particular GUI, the {ENTER} commands are being ignored, meaning my script fails. If I manually switch the Caps lock off, the script works great. I have used the following: #include <Constants2.au3> #include <Misc.au3> If _GetScrollLock() = 1 Then Send("{SCROLLLOCK Toggle}"); 0 = Off / 1 = On Func _GetScrollLock(); Checks to see if Scroll Lock is on Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_SCROLL) Return $ret[0] EndFunc If _GetNumLock() = 1 Then Send("{NUMLOCK Toggle}"); 0 = Off / 1 = On Func _GetNumLock(); Checks to see if Scroll Lock is on Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_NUMLOCK) Return $ret[0] EndFunc If _GetCapsLock() = 1 Then Send("{CAPSLOCK Toggle}"); 0 = Off / 1 = On Func _GetCapsLock(); Checks to see if Scroll Lock is on Local $ret $ret = DllCall("user32.dll","long","GetKeyState","long",$VK_CAPITAL) Return $ret[0] EndFunc I looked in the Include folder for the VK declarations and none existed for VK_SCROLL, VK_CAPITAL or VK_NUMLOCK, so I created the following in Constants2.au3 (wouldn't let me create them in Constants.au3) Global Const $VK_SCROLL = 0x91 Global Const $VK_NUMLOCK = 0x90 Global Const $VK_CAPITAL = 0x14 When I run the script, the Number lock and Scroll lock work perfectly, but Caps lock does not switch off. I ran a code scanner to interrogate the Caps lock key and know that it is definitely 0X14, so my script is correct. Has anyone else managed to resolve this problem????
MrCreatoR Posted December 18, 2008 Posted December 18, 2008 That strange, just the Send("{CAPSLOCK Toggle}") doesnt working itself... and BTW, you can use one function to check all 3 keys Global Const $VK_SCROLL = 0x91 Global Const $VK_NUMLOCK = 0x90 Global Const $VK_CAPITAL = 0x14 If _Key_Is_On($VK_SCROLL) Then Send("{SCROLLLOCK Toggle}") If _Key_Is_On($VK_NUMLOCK) Then Send("{NUMLOCK Toggle}") If _Key_Is_On($VK_CAPITAL) Then Send("{CAPSLOCK Toggle}") Func _Key_Is_On($nVK_KEY, $vDLL = 'User32.dll') Local $a_Ret = DllCall($vDLL, "short", "GetKeyState", "int", $nVK_KEY) Return Not @error And BitAND($a_Ret[0], 0xFF) = 1 EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
MrCreatoR Posted December 18, 2008 Posted December 18, 2008 But this seems to work fine: Opt("SendCapslockMode", 0) Global Const $VK_SCROLL = 0x91 Global Const $VK_NUMLOCK = 0x90 Global Const $VK_CAPITAL = 0x14 If _Key_Is_On($VK_SCROLL) Then Send("{SCROLLLOCK Toggle}") If _Key_Is_On($VK_NUMLOCK) Then Send("{NUMLOCK Toggle}") If _Key_Is_On($VK_CAPITAL) Then Send("{CAPSLOCK Toggle}") Func _Key_Is_On($nVK_KEY, $vDLL = 'User32.dll') Local $a_Ret = DllCall($vDLL, "short", "GetKeyState", "int", $nVK_KEY) Return Not @error And BitAND($a_Ret[0], 0xFF) = 1 EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
eohalloran Posted December 18, 2008 Author Posted December 18, 2008 MrCreatoR, you're the bees knees mate!!!! Works perfectly Best Regards
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