AutoRun Posted January 24, 2015 Posted January 24, 2015 (edited) Hello everybody! I'm newbie and faced the problem that my simple AutoIt3 script not working properly. When a hotkeys «Ctrl + C» or «Ctrl + V» is pressed nothing is happen. The script running under Windows 7 64bit I had try add #RequireAdmin to script but «Ctrl + C / V» also not give a MsgBox However hotkey "!{ESC}" or "!{HOME}" working fine Just example #include <Clipboard.au3> HotKeySet("^c", "HotKeyPressed") HotKeySet("!{ESC}", "HotKeyPressed") ; Abort script While 1 Sleep(100) WEnd Func HotKeyPressed() Switch @HotKeyPressed Case "^c" local $_clipboard = _ClipBoard_GetData($CF_UNICODETEXT) MsgBox(0, "From the clipboard", $_clipboard) Case "^v" MsgBox(0, "Just message", "HotKey Ctrl + V is pressed") Case "!{ESC}" Exit EndSwitch EndFunc Edited January 24, 2015 by AutoRun
water Posted January 24, 2015 Posted January 24, 2015 Add a MsgBox as first statement in function HotKeyPressed to check it is called at all. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
l3ill Posted January 24, 2015 Posted January 24, 2015 Hi Autorun, working fine here... Environment(Language:0407 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X86) You were missing a Ctrl V HKS Though. #include <Clipboard.au3> HotKeySet("^v", "HotKeyPressed") ; this is missing in yours... HotKeySet("^c", "HotKeyPressed") HotKeySet("!{ESC}", "HotKeyPressed") ; Abort script While 1 Sleep(100) WEnd Func HotKeyPressed() MsgBox(0, "debug", "HotKeyPressed", .5) Switch @HotKeyPressed Case "^c" local $_clipboard = _ClipBoard_GetData($CF_UNICODETEXT) MsgBox(0, "From the clipboard", $_clipboard) Case "^v" MsgBox(0, "Just message", "HotKey Ctrl + V is pressed") Case "!{ESC}" Exit EndSwitch EndFunc cya, Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
AutoRun Posted January 24, 2015 Author Posted January 24, 2015 (edited) MsgBox's added. Only work with "!{ESC}" if any other hotkeys are pressed they call nothing You were missing a Ctrl V HKS Though. Oh, thank you. I wrote that part code for «CTRL+V» combination when already was writing the topic Edited January 24, 2015 by AutoRun
water Posted January 24, 2015 Posted January 24, 2015 Which version of AutoIt do you run? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
AutoRun Posted January 24, 2015 Author Posted January 24, 2015 (edited) AutoIt3Wrapper v.14.801.2025.0 SciTE v.3.4.4.0 But the system has different language and keyboard layouts: Keyboard:00000419 Language:0419 I think it cause problem with a capture letter keys (A-Z) for HotKeySet function. With a single letter "c" or a "!c" or any other letter script does not any action Not working: HotKeySet("c", "HotKeyPressed") What can I do that pressed letter keys were taken correctly? Edited January 24, 2015 by AutoRun
water Posted January 24, 2015 Posted January 24, 2015 419 is cyrillic, right? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
AutoRun Posted January 24, 2015 Author Posted January 24, 2015 Yes it is, but keys are pressed when EN (USA) layout is choosed.
Exit Posted January 24, 2015 Posted January 24, 2015 It is very common that hotkeyset() is not tested for success. I'm using an abbreviation "hk " that produces the following code which checks for errors. _HotKey("{ESC}") _HotKey("{|}") Func _HotKey($hotkey = "") ; ! ALT + SHIFT ^ CONTROL # WinKey Switch @HotKeyPressed Case "{ESC}" Exit 0*MsgBox(64 + 262144, Default, "Exit", 1) Case "{???}" Beep() ; HotKeySet(@HotKeyPressed) ; send("???") ; HotKeySet(@HotKeyPressed,"_Hotkey") Case Else If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed) If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application.") EndSwitch EndFunc ;==>_HotKey While Sleep(100) ; here should be your application. WEnd ; meanwhile, here is a dummy loop. And here the code to test CNTL+c and CNTL+v : _HotKey("{ESC}") _HotKey("^c") _HotKey("^v") Func _HotKey($hotkey = "") ; ! ALT + SHIFT ^ CONTROL # WinKey Switch @HotKeyPressed Case "{ESC}" Exit 0*MsgBox(64 + 262144, Default, "Exit", 1) Case "^c" Beep(1000,200) Case "^v" Beep(2000,200) Case Else If Not IsDeclared("hotkey") Then Return MsgBox(16 + 262144, Default, "No CASE statement defined for hotkey " & @HotKeyPressed) If HotKeySet($hotkey, "_Hotkey") = 0 Then Return MsgBox(16 + 262144, Default, "Hotkey " & $hotkey & " invalid or set by another application.") EndSwitch EndFunc ;==>_HotKey While Sleep(100) ; here should be your application. WEnd ; meanwhile, here is a dummy loop. App: Au3toCmd UDF: _SingleScript()
AutoRun Posted January 26, 2015 Author Posted January 26, 2015 (edited) Sorry for delay with answer, my holiday was being without access to a network. Now the codes is tested and the first returned one error "invalid or set by another application" for "{|}" and the second for both "^v" and "^c" hotkeys. But I haven't idea for what reason it does an error If runing one more copy the script, it also says error for "{ESC}" hotkey. Edited January 26, 2015 by AutoRun
Exit Posted January 26, 2015 Posted January 26, 2015 The first (in the spoiler) is the raw abbreviation code for "hk " where the "|² is a placeholder for the cursor position in the resulting code. It is not intended to be run itself. The second shows, that there is already a hotkey set for Cntl+c and Cntl+v before you run the code. When running it again in parallel, ESC is also already in error due to the hotkeyset in the first run. The conclusion is that you have another program starting before this scripts that has already occupied these two hotkeys. Unfortunately there is no method to get the owner of these hotkeys. Just check your autostart and statup for the program. App: Au3toCmd UDF: _SingleScript()
AutoRun Posted January 26, 2015 Author Posted January 26, 2015 Well, all programs with exception for Rialtek sound driver and ATI Catalyst were deleted from startup. Then reboot. So… I do have installed antivirus KIS 2011. Although now I can launch it only manually, but can antivirus to block keys for an another program by anti-spy reason? Is sense to remove it?
computergroove Posted January 27, 2015 Posted January 27, 2015 I just wrote a script and I used: Send("{CTRLDOWN}v{CTRLUP}") and Send("{CTRLDOWN}c{CTRLUP}") and it tested with a hotkeyset fine. Here is the whole script: ;Makes highlighted text either all upper or all lower case HotKeySet("!+L","LowerCase");shift + alt + L will make highlighted text lower case HotKeySet("!+U","UpperCase");Shift + alt + U will make highlighted text upper case HotKeySet("ESC","Terminate");hit ESC key to exit script While 1;Loop required to keep script running Sleep(100) WEnd Func LowerCase() Send("{CTRLDOWN}c{CTRLUP}");copy selected text to windows clipboard $Clipboard = ClipGet();Set clipboard to a local variable $Lower = Stringlower($Clipboard);convert all text in clipboard to uppercase ClipPut($Lower);put the string into the windows clipboard Send("{CTRLDOWN}v{CTRLUP}");paste over selected text EndFunc Func UpperCase() Send("{CTRLDOWN}c{CTRLUP}");copy selected text to windows clipboard $Clipboard = ClipGet();Set clipboard to a local variable $Upper = Stringupper($Clipboard);convert all text in clipboard to uppercase ClipPut($Upper);put the string into the windows clipboard Send("{CTRLDOWN}v{CTRLUP}");paste over selected text EndFunc Func Terminate Exit 0;exit the script EndFunc Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
Solution AutoRun Posted January 27, 2015 Author Solution Posted January 27, 2015 Thank you guys for all tips and notes, but problem was resolved very easily. Just need to change a code with latin letters a "C" and a "V" to cyrillic a "С" and a "M" and now it work fine. Because as I wrote above the system has a cyrillic keyboard layout. computergroove, little fix and it working fine for me too.
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