tecc Posted September 13, 2018 Share Posted September 13, 2018 I'm using this script #include <Clipboard.au3> While ProcessExists("3CXWin8Phone.exe") HotKeySet("{F11}", "GetNumber") WEnd Func GetNumber() Send("^c") $n = ClipGet() $n = StringRegExpReplace("0" & $n , _ '^(?:0\+49|0\d|(0)\+(\d\d))(?:\h*\(0\))?\D*0?(\d+)\D*(\d+)\D*', "0$1$2$3$4") WinActivate("3CX - ") WinWaitActive("3CX - ") Send($n & "{ENTER}") EndFunc Exit to dial a number I've highlighted in a mail, a PDF or elsewhere. It works just fine but I'd like to use a different hotkey, preferrably Capslock since I don't ever use it. However, when I replace F11 by CAPSLOCK the script behaves erratically, sometimes the Capslock LED flickers, sometimes text instead of digits gets pasted into the softophone client etc. Is there a way to use capslock reliably from a script? I would like to use it as a hotkey only and have it immediately turned off so I don't type in caps afterwards. Alternatively, how would I use SHIFT+1 as a hotkey or better yet FN+1? Link to comment Share on other sites More sharing options...
Danp2 Posted September 13, 2018 Share Posted September 13, 2018 A few suggestions -- 1) Move your HotKeySet command before you While loop. No reason to keep setting it again and again. 2) Check to see if the softphone offers the option to dial selected numbers using a hotkey. As far as using Capslock for the hotkey, note this entry from the help file -- Quote When you set a hotkey, AutoIt captures the key-press and does not pass it on to the active application, with one exception: the Lock keys (NumLock, CapsLock, and ScrollLock) still toggle their respective state! You will need to look for a way to intercept or cause this keypress to be ignored. Xandy 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
tecc Posted September 15, 2018 Author Share Posted September 15, 2018 Mmh, I don't get the logic behind the loop then. I did as you suggested and it still works which is nice but how exactly does a loop work if there's no commands inside the keywords? While ProcessExists("3CXWin8Phone.exe") WEnd As far as I can tell, the softphone does not offer a hotkey for this. OTOH I might suck at searching cause I didn't find any way to intercept keypresses for Capslock and Co on this forum nor for these workarounds: - what command reliably sets the Capslock key to it's usual off state? - how can I set SHIFT+1 as a hotkey instead? HotKeySet("{SHIFT}+1", "GetNumber") does not work. Link to comment Share on other sites More sharing options...
Danp2 Posted September 15, 2018 Share Posted September 15, 2018 Without the loop, your script would just exit. I would suggest adding a Sleep(10) inside the loop to reduce demand on the system. Found the following via Google for hotkeys -- https://www.3cx.com/user-manual/calls/#h.dhgiz52kkyvm Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
tecc Posted September 16, 2018 Author Share Posted September 16, 2018 Thanks, but I've seen this and it did not work initially. After Windows and 3CX having been updated, the hotkey works but since I was planning on starting with AutoIt anyway, I thought this would be a good first program. With it I can reduce the amount of clicks from 3 (CTRl+V, hotkey, ENTER) to 1 (my hotkey) as well as format the numbers that I get from email signatures etc; in a few cases 3CX would not dial the way they were formatted. So, I'd really appreciate it if someone could answer my questions concerning the workaround to my Capslock problem. I'm thinking of another widget to code where setting a hotkey like SHIFT+1 would come in handy. Link to comment Share on other sites More sharing options...
Danp2 Posted September 16, 2018 Share Posted September 16, 2018 Have you tried this? HotKeySet("+1", "GetNumber") Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
tecc Posted September 22, 2018 Author Share Posted September 22, 2018 (edited) That works, thx! If anyone has an idea on how to remap the FN or CAPSLOCK key, I'd still be interested. Edited September 22, 2018 by tecc Link to comment Share on other sites More sharing options...
nend Posted September 23, 2018 Share Posted September 23, 2018 @tecc Look at this (helpfile) script https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_SetWindowsHookEx.htm I'm not sure it can capture FN key but I'm sure it can do the capslock. 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