Sign in to follow this  
Followers 0
gsb

HotKeySet - compile trouble

3 posts in this topic

Code snippet from my script.

I am trying to allow the user change/add their own HotKeys via the .ini file.

This works fine:

$temp = IniReadSection( @ScriptDir & "/gsbTrace.ini", "HOTKEYS")
MsgBox(64,"Msg", $temp[1][1] & "  " & $temp[1][0] & @CRLF &  $temp[2][1] & "  " & $temp[2][0], 5)
HotKeySet("+!x", "_Exit"); DEFAULT: Shift-Alt-X

...but this does not:

$temp = IniReadSection( @ScriptDir & "/gsbTrace.ini", "HOTKEYS")
If NOT @error Then
    For $i=1 To $temp[0][0]
        HotKeySet( $temp[$i][1], $temp[$i][0] )
    Next
Else
    HotKeySet("+!x", "_Exit"); DEFAULT: Shift-Alt-X
Endif

Yes I am still learning AutoIt but I can not see why!

Any suggestions?

Thanks,

gsb


"Did you ever stop to think? ...and forget to restart!"

Share this post


Link to post
Share on other sites



Code snippet from my script.

I am trying to allow the user change/add their own HotKeys via the .ini file.

This works fine:

$temp = IniReadSection( @ScriptDir & "/gsbTrace.ini", "HOTKEYS")
MsgBox(64,"Msg", $temp[1][1] & "  " & $temp[1][0] & @CRLF &  $temp[2][1] & "  " & $temp[2][0], 5)
HotKeySet("+!x", "_Exit"); DEFAULT: Shift-Alt-X

...but this does not:

$temp = IniReadSection( @ScriptDir & "/gsbTrace.ini", "HOTKEYS")
If NOT @error Then
    For $i=1 To $temp[0][0]
        HotKeySet( $temp[$i][1], $temp[$i][0] )
    Next
Else
    HotKeySet("+!x", "_Exit"); DEFAULT: Shift-Alt-X
Endif

Yes I am still learning AutoIt but I can not see why!

Any suggestions?

Thanks,

gsb

Worked fine for me, is the function spelled correctly in your ini?

$iread = IniReadSection('ini.ini', 'hks')
HotKeySet($iread[1][0], $iread[1][1])

While 1
    Sleep(1000)
WEnd

Func _Exit()
    Exit
EndFunc

[hks]

{f9}=_Exit


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Exactly SmOke_N.

I had not yet defined one of the functions in my script but was testing the set code.

I am still thinking compiled languages.

At least old ones where that type of error would cause a runtime error instead of a compile error.

Wait! That's stupid it is a runtime error... I will blame it on a lack of coffee this morning.

You are a great resource and I thank you again.

Hopefully, most of my questions will not be so stupid. :whistle:

gsb

Edited by gsb

"Did you ever stop to think? ...and forget to restart!"

Share this post


Link to post
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
Sign in to follow this  
Followers 0