Can you share your setting?
I've made something similar on the B247D to drive oil shutter and carb heat, and I did not use myevent.txt, but only declared [LVaroffsets] and [Buttons] sections in FSUIPC7.ini
It's working well and has no link with window focus.
[Buttons.B247D]
0=CR(-F,6)F,4,Cx2100A001,x0000000A -{offset ubyte decrement, offset A001 (Decr=10, Limit=0)}-
1=CR(-F,6)F,4,Cx2100A002,x0000000A -{offset ubyte decrement, offset A002 (Decr=10, Limit=0)}-
2=CR(-F,6)F,5,Cx1100A001,x0064000A -{offset ubyte increment, offset A001 (Incr=10, Limit=100)}-
3=CR(-F,6)F,5,Cx1100A002,x0064000A -{offset ubyte increment, offset A002 (Incr=10, Limit=100)}-
4=CR(+F,6)F,4,Cx1100A003,x0064000A -{offset ubyte increment, offset A003 (Incr=10, Limit=100)}-
5=CR(+F,6)F,4,Cx1100A004,x0064000A -{offset ubyte increment, offset A004 (Incr=10, Limit=100)}-
6=CR(+F,6)F,5,Cx2100A003,x0000000A -{offset ubyte decrement, offset A003 (Decr=10, Limit=0)}-
7=CR(+F,6)F,5,Cx2100A004,x0000000A -{offset ubyte decrement, offset A004 (Decr=10, Limit=0)}-
[LvarOffsets.B247D]
1=L:LEVER OIL SHUTTER 1=UBA001
2=L:LEVER OIL SHUTTER 2=UBA002
3=L:LEVER CARBURETOR HEAT 1=UBA003
4=L:LEVER CARBURETOR HEAT 2=UBA004
5=L:ENG THROTTLE 1=UB0xA010
6=L:ENG THROTTLE 2=UB0xA011
7=L:ENG MIXTURE 1=UB0xA012
8=L:ENG MIXTURE 2=UB0xA013
9=L:ENG PROPELLER 1=UB0xA014
10=L:ENG PROPELLER 2=UB0xA015