Jump to content

Using Capslock or FN as hotkey


tecc
 Share

Recommended Posts

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

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.

Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...