 	Send {``}
 	If (BTickLangChange = 1)
 	{
-		ToggleLanguage()
+		ToggleKeyboard("")
 	}
 	Return
 
 ; ====================================================================
 
 Capslock::
-	ToggleLanguage()
+	ToggleKeyboard("")
 	Return
 
 <^Capslock::

	PostMessage, 0x50, 0, %LangId%,, A
}

ToggleLanguage()
{
	Lang := LastLangId & 0xFFFF
	If (Lang = Lang_Eng)
	{
		SetKeyboard(Keybd_Pes_Std)
	}
	Else If (Lang = Lang_Pes Or Lang = Lang_Arb)
	{
		SetKeyboard(Keybd_Eng_DV)
	}
	Else
	{
		MsgBox Unknown language.
	}
}

ToggleKeyboard(Direction)
{
	Lang := LastLangId & 0xFFFF
	If (Lang = Lang_Eng)
	{
		If (Direction <> "")
		{
			If (Direction = "Left")
			{
				SetKeyboard(Keybd_Eng_DVL)
			}
			Else If (Direction = "Right")
			{
				SetKeyboard(Keybd_Eng_DVR)
			}
			Else
			{
				MsgBox Invalid Direction.
			}
		}
		Else
		{
			If (LastLangId = Keybd_Eng_US)
			{
				SetKeyboard(Keybd_Eng_DV)
			}
			Else If (LastLangId = Keybd_Eng_DV Or LastLangId = Keybd_Eng_DVL Or LastLangId = Keybd_Eng_DVR)
			{
				SetKeyboard(Keybd_Eng_US)
			}
			Else
			{
				MsgBox Unknown keyboard.
			}
		}
	}
	Else If (Lang = Lang_Pes Or Lang = Lang_Arb)
	{
		If (Direction <> "")
		{
			MsgBox No directional keyboard defined.
		}
		Else
		{
			If (LastLangId = Keybd_Pes_Std)
			{
				SetKeyboard(Keybd_Pes)
			}
			Else If (LastLangId = Keybd_Pes)
			{
				SetKeyboard(Keybd_Arb_101)
			}
			Else If (LastLangId = Keybd_Arb_101)
			{
				SetKeyboard(Keybd_Pes_Std)
			}
			Else
			{
				MsgBox Unknown keyboard.
			}
		}
	}
	Else
	{
		MsgBox Unknown language.
	}
}

; ====================================================================


	Return

+Capslock::
	ToggleKeyboard("Normal")
	Return

!Capslock::
