remin Posted November 1, 2013 Posted November 1, 2013 (edited) This is my function to put round brackets "()" around a selected text: HotKeySet("^+9", "Encl") While 1 Sleep(10000) WEnd Func Encl() ClipPut("") Send( "^x" ) Sleep(200) local $ClipEncl = ClipGet() Switch @HotKeyPressed Case "^+9" $ClipEncl = '(' & $ClipEncl & ')' EndSwitch ClipPut($ClipEncl ) Send("^v") EndFunc The problem is that many times the ctrl or shift or ctrl-shift key is stuck after I invoke the above hotkey and I have to push the ctrl, shift or both keys again to be able to use these as before. Does anyone know what I did wrong in this function? Edited November 1, 2013 by remin
Blue_Drache Posted November 1, 2013 Posted November 1, 2013 (edited) Is copy/paste and Clipget() the only way you can get the text you want into a variable before manipulation of the text? What program are you working with? There may be an easier way. Edited November 1, 2013 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
remin Posted November 1, 2013 Author Posted November 1, 2013 Is copy/paste and Clipget() the only way you can get the text you want into a variable before manipulation of the text? What program are you working with? There may be an easier way. I use this hotkey in various applications as my email client, text editors (vim, notepad etc) , word
BrewManNH Posted November 1, 2013 Posted November 1, 2013 http://www.autoitscript.com/wiki/FAQ#Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script.3F remin 1 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 GudeHow 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
remin Posted November 2, 2013 Author Posted November 2, 2013 (edited) http://www.autoitscript.com/wiki/FAQ#Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script.3F Thank you. Do I have to change send("my_value") to _SendEx($ss, $warn = "") ? And to clear lock down keys I have to put ControlSend("", "", "", "text", 0) at the end of the function isn't it? ps: There is nothing wrong in my script? Why does this script lock down keys and my other scripts don't? Has it to do also with the sleep value (10000)? Edited November 2, 2013 by remin
BrewManNH Posted November 2, 2013 Posted November 2, 2013 You're using a Control key as a modifier for your hotkey sequence, and in your Send sequence. The link I posted tells you how to avoid having that scenario cause the keys to "stick". Read it thoroughly as it explains it quite well. 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 GudeHow 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
remin Posted November 2, 2013 Author Posted November 2, 2013 I don't understand it very well but I suppose I did it well in my previous reply. There is no info where to place ControlSend("", "", "", "text", 0). I still don't know what is the problem in my function and why my function stucks the ctrl and/or shift key and why other functions using the same commands don't.
MHz Posted November 2, 2013 Posted November 2, 2013 (edited) AutoIt has always suffered from what we call ShiftState. I am not aware of the ctrl key or alt key doing this though I do not see everything. Can you not avoid shift, you know the thing that supports locking shift? Edit: or is it shiftlock, got me thinking now. Edited November 2, 2013 by MHz remin 1
remin Posted November 2, 2013 Author Posted November 2, 2013 (edited) I would like to avoid the shift key but my "(" character is invoked by using Ctrl-Shift-9 on my keyboard (US international keyb) It is easier to remember to use the hotkey of the character I want to put around the selected text. Edited November 2, 2013 by remin
Blue_Drache Posted November 2, 2013 Posted November 2, 2013 I would like to avoid the shift key but my "(" character is invoked by using Ctrl-Shift-9 on my keyboard (US international keyb) It is easier to remember to use the hotkey of the character I want to put around the selected text. Why not just ... not use the shift? Use Ctrl+9 ... remin 1 Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache
remin Posted November 3, 2013 Author Posted November 3, 2013 Why not just ... not use the shift? Use Ctrl+9 ... Because in my function in my question I deleted (for clarity reasons) other characters I use to put around selected text. p.e. Quotes and Double Quotes. They are both under the same key on my keyboard. Btw I noted that when I remove Sleep(200) I have less problems with shift key stuck. Why? Blue_Drache.. do you know if I did well in my previous reply:
Iczer Posted November 3, 2013 Posted November 3, 2013 Why just not avoid this happening by using: #include-once #include <WinAPIEx.au3> ;====================================================================================================================================================================================================== Func Press_COPY_Macross() _WinAPI_Keybd_Event(0x11, 0) ; CTRL Down _WinAPI_Keybd_Event(0x41, 0) ; a Down Sleep(8) _WinAPI_Keybd_Event(0x41, 2) ; a Up _WinAPI_Keybd_Event(0x11, 2) ; CTRL Up Sleep(8) _WinAPI_Keybd_Event(0x11, 0) ; CTRL Down _WinAPI_Keybd_Event(0x43, 0) ; c Down Sleep(8) _WinAPI_Keybd_Event(0x43, 2) ; c Up _WinAPI_Keybd_Event(0x11, 2) ; CTRL Up EndFunc ;==>Press_COPY_Macross ;====================================================================================================================================================================================================== Func Press_CTRL_C_Macross($t = 8) _WinAPI_Keybd_Event(0x11, 0) ; CTRL Down _WinAPI_Keybd_Event(0x43, 0) ; c Down Sleep($t) _WinAPI_Keybd_Event(0x43, 2) ; c Up _WinAPI_Keybd_Event(0x11, 2) ; CTRL Up EndFunc ;==>Press_CTRL_C_Macross you get idea
remin Posted November 4, 2013 Author Posted November 4, 2013 I changed send("my_value") to _SendEx($ss, $warn = "") in all my functions. It seems to work fine now. Is it correct what I've done???
Solution MHz Posted November 4, 2013 Solution Posted November 4, 2013 You change Send("my_value") to _SendEx("my_value") Here is a change to your code with the use of the linked code that BrewManNH posted to sleep until the Shift-Ctrl-Alt keys are released. I guess it shows that using the keyboard while using Send can activate the issue with key state. Best to deactivate the hotkey while the sleep happens else the queue can still be added to. #include < Misc.au3 > HotKeySet("^+9", "Encl") While 1 Sleep(10000) WEnd Func Encl() ClipPut("") HotKeySet(@HotKeyPressed) While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") Sleep(10) WEnd Send("^x") Sleep(200) local $ClipEncl = ClipGet() Switch @HotKeyPressed Case "^+9" $ClipEncl = '(' & $ClipEncl & ')' EndSwitch ClipPut($ClipEncl) Send("^v") HotKeySet(@HotKeyPressed, "Encl") EndFunc I have not been able to create the issue with testing this though if you like playing your keyboard like a piano then the _SendEx() is probably best to use to ensure all sends are covered. remin 1
Hondadriver1234 Posted February 22, 2016 Posted February 22, 2016 This is how i solved it dont know if this will help anyone. I was having to press the ctrl key manually after the script had ran. And for some reason separating the individual calls was causing it to freeze with the ctrl on. it seems like the delays were the problem from the get go... sleep(1000) -----this is what i originally had and it would bring up the open file window but would put the RCTRL key in constant state of DOWN, and thought i could call a "manual" ctrl up after it opened the window. but that didnt work... send("{rCTRL down}{o down}") sleep(100) send("{o up}{rCTRL up}") sleep(1000) send("{rCTRL down}{rCTRL up}") send("{RCTRL down}{o down}{o up}{RCTRL up}") -------This worked for me----
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