Author Topic: define accelarator keys using lisp  (Read 8009 times)

0 Members and 1 Guest are viewing this topic.

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: define accelarator keys using lisp
« Reply #15 on: August 13, 2006, 08:19:48 PM »
Thank you, Kerry~
It works, I will try to find more funny in this software, great.
http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)

qjchen

  • Bull Frog
  • Posts: 285
  • Best wishes to all
Re: define accelarator keys using lisp
« Reply #16 on: July 06, 2009, 08:22:06 AM »
psuchewinner 's suggestion is very good, but I have not familiar with menu file's structure before.

These few days, I study some, and with the help of my friend, mccad and lazybone.

http://www.mjtd.com/BBS/dispbbs.asp?boardid=3&replyid=9664&id=18715&page=1&skin=0&landlord=0&Star=1

http://www.mjtd.com/BBS/dispbbs.asp?boardid=3&replyid=82428&id=18715&page=1&skin=0&landlord=0&Star=2

http://www.mjtd.com/BBS/dispbbs.asp?boardid=3&replyid=13016&id=76655&page=1&skin=0&landlord=0&Star=1

http://www.mjtd.com/BBS/dispbbs.asp?boardid=3&replyid=13016&id=76655&page=1&skin=0&landlord=0&Star=2

I feel it do can define function key by lisp, just like psuchewinner said.

The following code is use to define the function keys, such as F1 simulate F8's function. It use the ACCELERATORS of menu file.
This code use mccad and lazybone's function to load a menu file, and what I do is only to define a dynamic temporary mnu file.

But I dont know how to define "TAB" key, "Ctrl+1" key, I hope you could help me.

Code: [Select]
;;This code is based on mccad and lazybone's code
;;http://www.mjtd.com/BBS/dispbbs.asp?boardid=3&replyid=8516&id=18715&page=1&skin=0&landlord=0&Star=2
;;Load the custom menu file to the last but one item
;;the menu name is test.mnu,MENUGROUP=MYTEST
;;based on the upper code, qjchen add the dynamic mnu file generation
;;How to use: Load this function, and it automatic load "ldmu", which is to load menu,  if you want to unload this menu, pls use "uldmu"
;; The definition of the shortcut
;;F1:ortho switch(like F8, I dont know how to write the mnu file with "^L", so I have to use Lisp, thanks to Chuck Gabriel for this lisp code)
;;F2-F5: for zoom
;;ctrl+w:3dorbit
;;ctrl+e:ellipse (this two function is for the learing of ctrl)

;;Load menu file, by mccad and lazybone
(defun c:ldmu (/ pre_filedia CNT)
  (setq pre_filedia (getvar "filedia"))
  (setvar "filedia" 0)
  (command "menuload" (qjchentempmnu))
  (setq CNT 1)
  (while (menucmd (strcat "P" (itoa CNT) ".1=?"))
    (setq CNT (1+ CNT))
  )
  (if (> CNT 1)
    (setq CNT (- CNT 1))
    (setq CNT 1)
  )
  (menucmd (strcat "P" (itoa CNT) "=+MYTEST.pop1"))
  (setvar "filedia" pre_filedia)
  (princ)
)
;;UnLoad menu file, by mccad and lazybone
(defun c:uldmu (/ pre_filedia)
  (setq pre_filedia (getvar "filedia"))
  (setvar "filedia" 0)
  (command "menuunload" "MYTEST")
  (setvar "filedia" pre_filedia)
  (princ)
)

;; dynamic menu file generation, by qjchen
(defun qjchentempmnu(/ mnu_name f)
  (setq mnu_name (strcat (getenv "temp") "\\test" ".mnu")
f (OPEN mnu_name "w")
  )
  (write-line "***MENUGROUP=MYTEST" f)
  (write-line "***POP1" f)
  (write-line "**Alias" f)
  (write-line "[/MMyDraw]" f)
  (write-line "ID_Ellipse [/EEllipse]^c^cEllipse" f)
  (write-line "***ACCELERATORS" f)
  (write-line "[\"F2\"]'_zoom _w" f)
  (write-line "[\"F3\"]'_zoom _p" f)
  (write-line "[\"F4\"]'_zoom _e" f)
  (write-line "[\"F5\"]'_pan" f)
  (write-line "ID_Ellipse [CONTROL+\"E\"]" f)
  (write-line "[CONTROL+\"w\"]'3DORBIT" f)
  (write-line "[\"F1\"](setvar \"ORTHOMODE\" (if (zerop (getvar \"ORTHOMODE\")) 1 0))(princ)" f)
  (close f)
  mnu_name
)

(c:ldmu)






http://qjchen.mjtd.com
My blog http://chenqj.blogspot.com (Chinese, can be translate into English)