Jump to content

Dynamic HotKeySet


Recommended Posts

Hi,

Yes, but you need to use valid key combinations according to the function HotKeySet (explained for the function Send in the helpfile), so it would be {F5} here.

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

I've tried some ways and not getting expected result.

You gave the code...just need to write into the ini.

IniWrite("file.ini", "Section", "Key", "{F5}")

HotKeySet(IniRead("file.ini", "Section", "Key", ""), "Function")

While 1
Sleep(1000)
WEnd

Func Function()
ConsoleWrite("toto" & @crlf)
EndFunc
Link to comment
Share on other sites

Thanks, worked perfectly as I wanted.

File.ini

[Section1]
Key1=Alt+F1
Key2=Ctrl+F1

Func KeySets($pSection, $pKey, $pFunc)
    #comments-start
        ! = Alt
        + = Shift
        ^ = Ctrl
    #comments-end
    If StringInStr( IniRead($arq, $pSection, $pKey, ""), "+" ) > 0 Then
        $cKey = StringLeft( IniRead($arq, $pSection, $pKey, ""), StringInStr( IniRead($arq, $pSection, $pKey, ""), "+" )-1 )
        Switch $cKey
            Case "Ctrl"
                $cReturn = "^{"& StringRight ( IniRead($arq, $pSection, $pKey, ""), StringInStr( IniRead($arq, $pSection, $pKey, ""), "+" )-2 ) &"}"
            Case "Alt"
                $cReturn = "!{"& StringRight ( IniRead($arq, $pSection, $pKey, ""), StringInStr( IniRead($arq, $pSection, $pKey, ""), "+" )-2 ) &"}"

            Case "Shift"
                $cReturn = "+{"& StringRight ( IniRead($arq, $pSection, $pKey, ""), StringInStr( IniRead($arq, $pSection, $pKey, ""), "+" )-2 ) &"}"
        EndSwitch
    Else
        $cReturn = "{"&IniRead($arq, $pSection, $pKey, "")&"}"
    EndIf
    HotKeySet( $cReturn, $pFunc)
EndFunc

KeySets("Section1", "Key1", "FuncA") -=> HotKeySet("!{F1}", "FuncA")
KeySets("Section1", "Key2", "FuncB") -=> HotKeySet("^{F1}", "FuncB")
Edited by Darkbeo
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

×
×
  • Create New...