F-Keys Manager

By Zmodem on Aug 27, 2008

This is a basic F-Keys, or Function Keys, Manager for mIRC. It simply allows you to add custom commands to keyboard function keys, ie: F1, CTRL+F8, SHIFT+F9, etc...

Thank you and enjoy!

Screenshot
Image

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Title: F-Keys Manager v1.00
; Author: Zmodem
; Date: 26 August 2008
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

alias -l i return $ini($ifile,keys,$1)
alias -l w writeini $ifile keys $1 $2-
alias -l ifile return $+(",$scriptdirkeys.ini,")
alias -l k return $readini($ifile,$iif($1,p,n),keys,$2-)
alias fkeysman dialog - $+ $iif($dialog(fkeysman),a,m fkeysman) fkeysman
alias -l gitem return $gettok($did(fkeysman,2,$did(fkeysman,2).sel),1,32)
alias -l fkeysman.unload {
  .timerFkeysman* off
  .timerFkeysman 1 0 return $input(Successfully Unloaded Addon! $+ $crlf $+ $crlf $+ Thank you for using!,io,Unload Complete)
  .unload -rs $+(",$nopath($script),")
}
alias -l set.key {
  %t = $input(Please enter a new function for: $gitem $+ $crlf $+ $crlf $+ Note: Leave blank to cancel changes.,ieo,Enter Function)
  if (!%t) { return }
  w $gitem %t
  load.keys $did(2,fkeysman).sel
}
alias -l make.ini {
  var %i = 1, %k = F
  :begin
  while (%i <= 12) {
    w %k $+ %i <NOT_SET>
    inc %i
  }
  if (%k == cF) return
  if (%k == sF) %k = cF
  if (%k == F) %k = sF
  %i = 1
  goto begin
}
alias -l load.keys {
  var %i = 1, %m = $i(0), %v, %d = fkeysman, %k
  did -r %d 2
  did -b %d 3,4
  while (%i <= %m) {
    %k = $k(0,$i(%i))
    did -a %d 2 $i(%i) - $iif(%k,%k,<NOT SET>)
    inc %i
  }
  if ($1) { did -c %d 2 $1 | did -e %d 3,4 }
}

;Function Keys
alias F1 $iif($k(1,F1) == <NOT_SET>,mirc,$k(1,F1))
alias F2 if (($k(1,F2)) && ($v1 != <NOT_SET>)) $k(1,F2)
alias F3 if (($k(1,F3)) && ($v1 != <NOT_SET>)) $k(1,F3)
alias F4 if (($k(1,F4)) && ($v1 != <NOT_SET>)) $k(1,F4)
alias F5 if (($k(1,F5)) && ($v1 != <NOT_SET>)) $k(1,F5)
alias F6 if (($k(1,F6)) && ($v1 != <NOT_SET>)) $k(1,F6)
alias F7 if (($k(1,F7)) && ($v1 != <NOT_SET>)) $k(1,F7)
alias F8 if (($k(1,F8)) && ($v1 != <NOT_SET>)) $k(1,F8)
alias F9 if (($k(1,F9)) && ($v1 != <NOT_SET>)) $k(1,F9)
alias F10 if (($k(1,F10)) && ($v1 != <NOT_SET>)) $k(1,F10)
alias F11 if (($k(1,F11)) && ($v1 != <NOT_SET>)) $k(1,F11)
alias F12 if (($k(1,F12)) && ($v1 != <NOT_SET>)) $k(1,F12)

alias sF1 if (($k(1,SHIFT+F1)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F1)
alias sF2 if (($k(1,SHIFT+F2)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F2)
alias sF3 if (($k(1,SHIFT+F3)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F3)
alias sF4 if (($k(1,SHIFT+F4)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F4)
alias sF5 if (($k(1,SHIFT+F5)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F5)
alias sF6 if (($k(1,SHIFT+F6)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F6)
alias sF7 if (($k(1,SHIFT+F7)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F7)
alias sF8 if (($k(1,SHIFT+F8)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F8)
alias sF9 if (($k(1,SHIFT+F9)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F9)
alias sF10 if (($k(1,SHIFT+F10)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F10)
alias sF11 if (($k(1,SHIFT+F11)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F11)
alias sF12 if (($k(1,SHIFT+F12)) && ($v1 != <NOT_SET>)) $k(1,SHIFT+F12)

alias cF1 if (($k(1,CTRL+F1)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F1)
alias cF2 if (($k(1,CTRL+F2)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F2)
alias cF3 if (($k(1,CTRL+F3)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F3)
alias cF4 if (($k(1,CTRL+F4)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F4)
alias cF5 if (($k(1,CTRL+F5)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F5)
alias cF6 if (($k(1,CTRL+F6)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F6)
alias cF7 if (($k(1,CTRL+F7)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F7)
alias cF8 if (($k(1,CTRL+F8)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F8)
alias cF9 if (($k(1,CTRL+F9)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F9)
alias cF10 if (($k(1,CTRL+F10)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F10)
alias cF11 if (($k(1,CTRL+F11)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F11)
alias cF12 if (($k(1,CTRL+F12)) && ($v1 != <NOT_SET>)) $k(1,CTRL+F12)

;DIALOGS
dialog -l fkeysman {
  title "Function Keys Manager"
  size -1 -1 180 135
  option dbu
  box "Function Keys", 1, 6 6 168 108
  list 2, 10 16 159 93, size hsbar vsbar
  button "&Set...", 3, 30 118 27 12
  button "&Clear", 4, 67 118 27 12
  box "", 5, 107 116 1 14
  button "E&xit", 6, 120 118 27 12, ok
}
;fkeysman Dialog Events
ON *:DIALOG:fkeysman:*:*: {
  var %d = $dname, %e = $devent, %i = $did, %t
  if (%e == init) { load.keys }
  if (%e == sclick) {
    if (%i == 2) { did - $+ $iif($did(2,$did(2).sel),e,b) %d 3,4 }
    if (%i == 3) { set.key } 
    if (%i == 4) { $iif($input(Are you sure you want to clear $gitem $+ 's function?,wy,Confirm F-Key Clear),w $gitem <NOT_SET>) | load.keys $did(2).sel }
  }
  if ((%e == dclick) && (%i == 2)) { set.key }
}

;MENUS
menu menubar,status {
  F-Keys Manager
  .Run...:fkeysman
  .-
  .Unload:$iif($input(Are you sure you want to unload this addon?,wy,Confirm Unload),fkeysman.unload)
}

;;LOAD EVENTS
ON *:LOAD:make.ini | var %q = $input(Function Keys Manager Successfully Loaded! $+ $crlf $+ $crlf Would you like to run it now?,iyvk6,Addon Loaded!) | $iif((%q != $no) && (%q != $timeout),fkeysman,return $input(You can run the addon at any time by typing: /fkeysman,iok6,Additional Help))

Comments

Sign in to comment.
Gummo   -  Oct 12, 2008

It is possible to include function key scripts which are multiple lines, but it involves locating them, replacing their alias with some other one and then adding that to your script..

 Respond  
whobear   -  Oct 08, 2008

sorry forgot a }

Code:
if $isalias(f3) == $true { writeini keys f3 }

quote:
Scripting and coding is like a woman you just have to keep workin her till she feels good
hahahahahahahhaa

 Respond  
whobear   -  Oct 08, 2008

aaaaaaaaaahhh yes very true :+)
then maybe just a if returned as $true a %var set
to set diglog as f2= as it opens
then that would let the user know not to set that one
just a thought

Code:
if $isalias(f3) == $true { writeini keys f3

like a little search engine
hope this helps

 Respond  
Zmodem   -  Oct 07, 2008

whobear: Hey, I'm glad you liked it! Anyway, your suggestion is well-taken and I've tried the $isalias() already. As I've said: the rework of the key function monitor will be somewhat difficult, but not too bad, based on the fact that my script already has xFx loaded as custom aliases, therefore the only way to have this work effectively with other scripts that contain custom function aliases would be to have a second .mrc file loaded that contains the list of F-keys and their entirety, of course removing those which are contained in other files.

There is, however, a catch to actual F-Key denomination. The problem lies within multi-line alias functions. ie:

alias F2 {
   multi-line-code
   is here
   and cannot be retrieved
   by $isalias(F2).alias
   You will only get:
   F2 {
}

I hope this makes sense and that I've been clear. Thanks again!

 Respond  
whobear   -  Oct 06, 2008

first, nice script Zmodem
this should help ya

$isalias(name)
Returns $true if the specified name is an alias command that exists in your aliases or scripts.

Properties: fname, alias

$isalias(join) returns $true if you have an alias for /join
$isalias(join).fname returns the filename in which the alias exists
$isalias(join).alias returns the alias definition for /join

this, if worked in to the script should show the fkeys if pre-existing function keys
exsample: if $isalias(f3) == $true { writeini keys f3 $isalias(f3).alias }
you will have to tweek it to work in your script

enjoy
hope this helps
and yes this is the Whobear from the colorteam.net

 Respond  
Zmodem   -  Aug 28, 2008

Okay, for those of you that have pre-existing function keys, for some reason this will not load those. I've tried $isalias().alias to retrieve your function's alias, but unfortunately when this snippet loads, it preemptively takes over the alias function, thereby making it impossible to retrieve your existing alias for your existing function key. If anyone can find a workaround for this, I'm all ears, but I ran through a series of tests and loops trying to do it and the only way I could even remotely think of would be scanning every script file and alias file for alias F and looking for lines that begin with that, as well as scanning the alias scripts and looking for any lines containing an F sequence, including cF and sF.

 Respond  
Zmodem   -  Aug 28, 2008

Eugenio: I'm still working on it finding the ones that you already have.

 Respond  
Eugenio   -  Aug 28, 2008

Still doesnt display any F-keys that I currently have but atleast it creates the .ini file for me and works.
/me rates 7

 Respond  
Zmodem   -  Aug 28, 2008

^Neptune: haha, it's funny 'cause I keep forgetting about $qt(). I always wind up doing it myself $+(",,") heh.

Update (28 August 2008):

  1. This should make everyone happy, you no longer need to create the keys.ini file manually. When you load the snippet, it will do it for you.
  2. Added a check for the F-Keys to make sure that isn't being returned, in which case you would get /: not connected to server.

I'm still working on finding out what to do about self-defined F-Keys when you load this file. I could use $isalias(), but I'm not sure about how to get the alias commands, especially if your F-Key has a long, drawn-out alias defined (ie: Multiples upon multiple lines). Any ideas are appreciated!

 Respond  
^Neptune   -  Aug 27, 2008

Heh, I think the problem lies with the filename . I had problems like this too. If the filename has spaces in it sometimes mIRC interprets the space as the end of the file.

Just always use $qt around the file to be safe :)

 Respond  
Eugenio   -  Aug 27, 2008

tbh I have to agree with pwnisher3, you should make it create it for us T_T

 Respond  
pwnisher3   -  Aug 27, 2008

looks good but i don't want to make the document to use it

 Respond  
Dodge   -  Aug 27, 2008

Another Good Idea Zmodem. This would obviously be great for someone building a new client.
Keep the new Ideas comeing. Good Work.

 Respond  
Zmodem   -  Aug 27, 2008

Hey, I'll have to check it out, but I'm pretty sure that I know what's wrong. The problem is I wasn't sure how to deal with people who already HAD function keys defined in their own alias/remote areas. This may present a problem, actually. I will return with more info later....

 Respond  
Eugenio   -  Aug 27, 2008

Yes I created the file with no luck
I dont think this worked for EL either......

 Respond  
Zmodem   -  Aug 27, 2008

I GET IT NOW! LoL. Let me redo the script and resubmit.

 Respond  
Zmodem   -  Aug 27, 2008

I cannot duplicate your issue at all, Eugenio. I've tried loading it into long folders and renaming the .mrc file to a long name, as well. I cannot seem to duplicate the issue. Anyone else?

Hopefully you didn't put the ini information in with the script itself. For instance, you've got a folder like this: C:|Program Files|mIRC|Function Keys Manager

Within that folder, you should have 2 files: fkeysman.mrc and keys.ini - (THIS IS NOT OPTIONAL, THE INI FILE MUST BE NAMED KEYS.INI)

So, you've got:

C:|Program files|mIRC|Function Keys Manager|fkeysman.mrc
and
C:|Program files|mIRC|Function Keys Manager|keys.ini

Right? Let me know!

On the other end, does anyone else seem to be having an issue with this?

 Respond  
Eugenio   -  Aug 27, 2008

I already have some Function Keys set but I dont see them in the list also it wont let me set or clear ones I already have since the only button I can press is exit, seems like you dont want me using your script.
/me cries

 Respond  
Zmodem   -  Aug 27, 2008

You did create a file called keys.ini and put all of the ini information, that I've included above the code, into it, right? That's the only time I could see the $null return. Also, make sure the keys.ini file is saved into the same folder as the mIRC script itself.

 Respond  
EL   -  Aug 27, 2008

Dude i got Null on this=\

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.