mIRC Home    About    Download    Register    News    Help

Print Thread
#208412 20/01/09 12:45 PM
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
In my addon script, I am trying to let the user configure the Function Key that will activate my script, however I am finding out that if i define the aliases 'alias F1 { if (%functionkey == F1) { myCommand } }' then even if the %functionkey is not F1, the script does not launch the default F1 key actions. as well, if another addon script has a function key alias defined, these aliases will render the other scripts aliases non functional. Does any one know a way to make everything thing work without issues?

MTec007 #208414 20/01/09 02:37 PM
Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
Well, I just did some testing of my own, but I don't think it's possible without specifically redefining F1 in an else-statment.
As soon as F1 is defined as an alias, it stays that way.

HOWEVER, if there are other scripts that use F1 (so not the default help file popping up), you could try using...
Code:
alias F1 {
  if (%functionkey != F1) { return }
  else { myCommand }
}

...but I doubt it'll work.

MTec007 #208419 20/01/09 03:16 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
There's no way to define an F-key alias and still have mIRC's default action. What you can do is use the /alias command to remove the /f1 alias when %functionkey is changed to a different key and create it again when it's changed back to f1.

eg.
Code:
on *:EVENT WHERE %FUNCTIONKEY WILL BE CHANGED:{
  ; Remove f-key alias for old %functionkey value
  alias %functionkey
  
  %functionkey = %NEW_FKEY_VALUE_HERE
  ; Create f-key alias for new %functionkey value
  alias %functionkey myCommand
}


The /alias command can only create/remove single-line commands, however seeing as you're most likely only creating a convenience alias that calls the 'proper' command that shouldn't be an issue.

Last edited by starbucks_mafia; 20/01/09 03:29 PM.

Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Feb 2007
Posts: 234
M
MTec007 Offline OP
Fjord artisan
OP Offline
Fjord artisan
M
Joined: Feb 2007
Posts: 234
Originally Posted By: starbucks_mafia
etc...


That did not work for me but that gave me an idea to use groups (for the first time I may add) and that works great, so thank you.

MTec007 #208435 20/01/09 07:46 PM
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I just messed around with this.

I'm sure you can do this with a text file.

/writeini file.ini alias f1 msg $1 Hi Room!

alias f1 $eval($readini(file.ini,alias,f1))


Ex: //f1 #

MTec007 #209301 09/02/09 03:46 PM
Joined: Jan 2009
Posts: 9
C
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
C
Joined: Jan 2009
Posts: 9
Just thought i'd give a suggestion. When letting the user set a function key why don't you have the script check to see if it is already used by another script. if it is inform the user to choose another function key, Another script is using this key.

Code:

;//echo is function used: $FunctionUsed(F2)

Alias FunctionUsed { return $isalias($1) }


MTec007 #209302 09/02/09 05:00 PM
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
starbucks_mafia is spot on. I'm not sure if you misunderstood what he was trying to tell you, but the easiest way to add/remove aliases dynamically is by using the /alias command, like he showed you.

To add a function key:

Code:
alias addfkey { alias F1 echo -a I just added this alias by a script! }
alias remfkey { alias F1 }


Type /addfkey and then hit F1.
Then type /remfkey and then hit F1.


Link Copied to Clipboard