Darkbeo Posted January 4, 2013 Posted January 4, 2013 Hello all, is possible to create a script that sets the key to be pressed from information taken from an ini file? AutoIt.au3 HotKeySet( IniRead("file.ini", "Section", "Key", "Hotkey"), "Function" ) file.ini [Section] Key=F5 So the result would be: HotKeySet( "F5", "Function" )
FireFox Posted January 4, 2013 Posted January 4, 2013 (edited) 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 January 4, 2013 by FireFox
FireFox Posted January 4, 2013 Posted January 4, 2013 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 Darkbeo 1
Darkbeo Posted January 8, 2013 Author Posted January 8, 2013 (edited) 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 January 8, 2013 by Darkbeo skijve 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now