Press a combination of

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
NikosKont
Posts: 1
Joined: 11 Dec 2020, 02:58

Press a combination of

11 Dec 2020, 03:10

Hi, can anyone help by writing a script that clicks a specific combination of
keys (LShift+LAlt) at a specific interval (configurable) but for example's sake
lets say every 22 minutes.

That should occur ONLY if a specific keyboard language is already selected
or the main keyboard language is not selected. (in case there are more than 2
languages)

Thanx in advance
Kontogouris Nick
madsounds
Posts: 59
Joined: 31 May 2019, 08:14

Re: Press a combination of

13 Dec 2020, 05:25

Well I tried but it doesn't work :-) Something wrong with ids comparison.

Code: Select all

global LocaleIdentifiers := Map( ;https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/a29e5c28-9fb9-4c49-8e43-4b9b8e733a05
	                             ;https://www.autohotkey.com/docs/misc/Languages.htm
	"Afrikaans", 0x0436,
	"Albanian", 0x041c,
	"Arabic_Saudi_Arabia", 0x0401,
	"Arabic_Iraq", 0x0801,
	"Arabic_Egypt", 0x0c01,
	"Arabic_Libya", 0x1001,
	"Arabic_Algeria", 0x1401,
	"Arabic_Morocco", 0x1801,
	"Arabic_Tunisia", 0x1c01,
	"Arabic_Oman", 0x2001,
	"Arabic_Yemen", 0x2401,
	"Arabic_Syria", 0x2801,
	"Arabic_Jordan", 0x2c01,
	"Arabic_Lebanon", 0x3001,
	"Arabic_Kuwait", 0x3401,
	"Arabic_UAE", 0x3801,
	"Arabic_Bahrain", 0x3c01,
	"Arabic_Qatar", 0x4001,
	"Armenian", 0x042b,
	"Azeri_Latin", 0x042c,
	"Azeri_Cyrillic", 0x082c,
	"Basque", 0x042d,
	"Belarusian", 0x0423,
	"Bulgarian", 0x0402,
	"Catalan", 0x0403,
	"Chinese_Taiwan", 0x0404,
	"Chinese_PRC", 0x0804,
	"Chinese_Hong_Kong", 0x0c04,
	"Chinese_Singapore", 0x1004,
	"Chinese_Macau", 0x1404,
	"Croatian", 0x041a,
	"Czech", 0x0405,
	"Danish", 0x0406,
	"Dutch_Standard", 0x0413,
	"Dutch_Belgian", 0x0813,
	"English_United_States", 0x0409,
	"English_United_Kingdom", 0x0809,
	"English_Australian", 0x0c09,
	"English_Canadian", 0x1009,
	"English_New_Zealand", 0x1409,
	"English_Irish", 0x1809,
	"English_South_Africa", 0x1c09,
	"English_Jamaica", 0x2009,
	"English_Caribbean", 0x2409,
	"English_Belize", 0x2809,
	"English_Trinidad", 0x2c09,
	"English_Zimbabwe", 0x3009,
	"English_Philippines", 0x3409,
	"Estonian", 0x0425,
	"Faeroese", 0x0438,
	"Farsi", 0x0429,
	"Finnish", 0x040b,
	"French_Standard", 0x040c,
	"French_Belgian", 0x080c,
	"French_Canadian", 0x0c0c,
	"French_Swiss", 0x100c,
	"French_Luxembourg", 0x140c,
	"French_Monaco", 0x180c,
	"Georgian", 0x0437,
	"German_Standard", 0x0407,
	"German_Swiss", 0x0807,
	"German_Austrian", 0x0c07,
	"German_Luxembourg", 0x1007,
	"German_Liechtenstein", 0x1407,
	"Greek", 0x0408,
	"Hebrew", 0x040d,
	"Hindi", 0x0439,
	"Hungarian", 0x040e,
	"Icelandic", 0x040f,
	"Indonesian", 0x0421,
	"Italian_Standard", 0x0410,
	"Italian_Swiss", 0x0810,
	"Japanese", 0x0411,
	"Kazakh", 0x043f,
	"Konkani", 0x0457,
	"Korean", 0x0412,
	"Latvian", 0x0426,
	"Lithuanian", 0x0427,
	"Macedonian", 0x042f,
	"Malay_Malaysia", 0x043e,
	"Malay_Brunei_Darussalam", 0x083e,
	"Marathi", 0x044e,
	"Norwegian_Bokmal", 0x0414,
	"Norwegian_Nynorsk", 0x0814,
	"Polish", 0x0415,
	"Portuguese_Brazilian", 0x0416,
	"Portuguese_Standard", 0x0816,
	"Romanian", 0x0418,
	"Russian", 0x0419,
	"Sanskrit", 0x044f,
	"Serbian_Latin", 0x081a,
	"Serbian_Cyrillic", 0x0c1a,
	"Slovak", 0x041b,
	"Slovenian", 0x0424,
	"Spanish_Traditional_Sort", 0x040a,
	"Spanish_Mexican", 0x080a,
	"Spanish_Modern_Sort", 0x0c0a,
	"Spanish_Guatemala", 0x100a,
	"Spanish_Costa_Rica", 0x140a,
	"Spanish_Panama", 0x180a,
	"Spanish_Dominican_Republic", 0x1c0a,
	"Spanish_Venezuela", 0x200a,
	"Spanish_Colombia", 0x240a,
	"Spanish_Peru", 0x280a,
	"Spanish_Argentina", 0x2c0a,
	"Spanish_Ecuador", 0x300a,
	"Spanish_Chile", 0x340a,
	"Spanish_Uruguay", 0x380a,
	"Spanish_Paraguay", 0x3c0a,
	"Spanish_Bolivia", 0x400a,
	"Spanish_El_Salvador", 0x440a,
	"Spanish_Honduras", 0x480a,
	"Spanish_Nicaragua", 0x4c0a,
	"Spanish_Puerto_Rico", 0x500a,
	"Swahili", 0x0441,
	"Swedish", 0x041d,
	"Swedish_Finland", 0x081d,
	"Tamil", 0x0449,
	"Tatar", 0x0444,
	"Thai", 0x041e,
	"Turkish", 0x041f,
	"Ukrainian", 0x0422,
	"Urdu", 0x0420,
	"Uzbek_Latin", 0x0443,
	"Uzbek_Cyrillic", 0x0843,
	"Vietnamese", 0x042a
)

global PERIOD := 22 * 60 * 1000 ;22 minutes (in ms)

;TimerOnLayouts is an array containing the list of layouts that will trigger 22-minutes timer to go on;
;for the rest of layouts, listed above in LocaleIdentifiers object, the timer will pause.
global TimerOnLayouts := [ "Spanish_Traditional_Sort"
                         , "German_Standard"
                         , "no layout" ] ;Also continue timer if there's no active layout
                                         ;(remove/comment this string if not needed)

LayoutCheck()
{

	static LastLayoutId := 0
	     , PrevTickCount := A_TickCount
         , CurTickCount := A_TickCount
         , Counter := 0 ;in ms
         , LayoutIsFound := false
    local Layout := ""

	CurTickCount := A_TickCount
	LayoutIsFound := false

	try
	{
		local ActiveWindowId := WinGetID( "A" )
	}
	catch
	{
		local ActiveWindowId := WinGetID( "ahk_class WorkerW" )
	}

	local ActiveWindowThreadProcessId := DllCall( "GetWindowThreadProcessId"
	                                            , "uint", ActiveWindowId
	   	                                        , "uint", 0 )
	local ActiveWindowLayoutId := DllCall( "GetKeyboardLayout"
	                                     , "uint", ActiveWindowThreadProcessId
	                                     , "uint" )

	if ! ActiveWindowLayoutId
	{
		ActiveWindowLayoutId := "no layout"
	}

	for Layout in TimerOnLayouts
	{
		if ActiveWindowLayoutId == LocaleIdentifiers[Layout]
		{
			Counter += CurTickCount - PrevTickCount
			LayoutIsFound := true
			TrayTip "Counter of desired layouts: " Counter " ms`n"
		          . "Current layout id: " ActiveWindowLayoutId "`n"
		          . "Current layout name: " LocaleIdentifiers[Layout]
		    break
		}
	}

	if ! LayoutIsFound
	{
		TrayTip "Counter of desired layouts: " counter " ms (paused)`n"
		      . "Current layout id: " ActiveWindowLayoutId "`n"
	}
	
	if Counter >= PERIOD
	{
		Send "{Shift down}Your keys here.{Shift up}"
		Counter := 0
	}

	PrevTickCount := CurTickCount

}

SetTimer( "LayoutCheck", 500 )

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: richd1 and 59 guests