Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Allow script to run only with one keyboard



  • Please log in to reply
3 replies to this topic
Artie
  • Members
  • 12 posts
  • Last active: Dec 15 2015 07:26 AM
  • Joined: 21 Aug 2015

Hello guys. Is there a way to make this script work only as long as I'm typing with the English keyboard?

$+a::
$+e::
    keys(SubStr(A_ThisHotkey,0))
return


keys(k)
{
    static A:=["à","á","â","ä"],E:=["è","é","ê","ë"]
    c:=0    ; counter resets on every use.
    While GetKeyState("Shift","P")
    {
	If GetKeyState(k,"P")
	{
            Send % "{Blind}" (A_Index>1?"{BS}":"") %k%[(c=%k%.MaxIndex())?c:=1:++c]
	    KeyWait, % k
	}
	Sleep 50
    }
}


Artie
  • Members
  • 12 posts
  • Last active: Dec 15 2015 07:26 AM
  • Joined: 21 Aug 2015

I found this similar topic http://autohotkey.co...ctive-language/

Also https://msdn.microso...ibrary/aa912040 For keyboard identifiers, I'm using English (Canada).

I hope you guys could help me with that.



space
  • Members
  • 520 posts
  • Last active:
  • Joined: 12 Aug 2014
✓  Best Answer

This might work, untested, I simply replaced the number to correspond to they Canadian English layout.

 

; question: http://autohotkey.com/board/topic/150272-allow-script-to-run-only-with-one-keyboard/
; code from: http://forum.script-coding.com/viewtopic.php?id=7396
#If (GetKeyboardLayout("A") = 4105) ; 4105 = 0x1009 https://msdn.microsoft.com/en-us/library/aa912040
; your hotkeys here
#If

GetKeyboardLayout(ByRef window)
{
    return DllCall("GetKeyboardLayout", "UInt", DllCall("GetWindowThreadProcessId", "Int", WinExist(window), "Int", 0), "UShort")
}


Artie
  • Members
  • 12 posts
  • Last active: Dec 15 2015 07:26 AM
  • Joined: 21 Aug 2015

Yep, this seems to work just fine. Thank you space.