明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2049|回复: 7

打开系统应用程序

[复制链接]
发表于 2017-8-8 17:48 | 显示全部楼层 |阅读模式
(defun c:xtyy  ();;;打开系统程序
  (setvar "CMDECHO" 0)
  (setq dcl_id (load_dialog (setq Dcl_File (Write_Dcl)))) ;对话框加载
  (vl-file-delete Dcl_File)             ;加载后删除DCL文件
  (new_dialog "Form1" dcl_id)
  (setq key_list '("b11" "b12" "b13" "b14" "b21" "b22" "b23" "b24" "b31" "b32" "b33" "b34" "b35" "b41" "b42" "b51" "b52" "b53" "b54" "help" "cancle")) ;_ 结束setq
  (foreach key  key_list
    (if (eval (read (strcat key "_bak")))
      (set_tile key (eval (read (strcat key "_bak"))))
      )     ;控件内容
    (action_tile key "(done_dialog (atoi (substr $key 2)))")
    ) ;_ 结束foreach
  (action_tile "help" "(help3_button)")
  (action_tile "cancle" "(done_dialog 0)")
  (setq dd (start_dialog))
  (cond
    ((= dd 11) (startapp "control"))    ;控制台
    ((= dd 12) (startapp "control desk.cpl")) ;屏幕分辨率
    ((= dd 13) (startapp "winver"))     ;查看Windows版本
    ((= dd 14) (startapp "control intl.cpl")) ;区域与语言设置
    ((= dd 21) (command "start" "excel"))
    ((= dd 22) (command "start" "winword"))
    ((= dd 23) (startapp "cmd"))        ;运行
    ((= dd 24) (command "start" "write"))   ;写字板
    ((= dd 31) (command "start" "mspaint")) ;画图
    ((= dd 32) (command "start" "notepad")) ;记事本
    ((= dd 33) (command "start" "calc")) ;计算器
    ((= dd 34) (startapp "control hdwwiz.cpl")) ;设备管理器
    ((= dd 35) (startapp "control sysdm.cpl")) ;系统属性
    ((= dd 41) (startapp "control inetcpl.cpl")) ;Internet属性
    ((= dd 42) (startapp "control mmsys.cpl")) ;声音
    ((= dd 51) (command  "start" "explorer")) ;资源管理器
    ((= dd 52) (startapp "control main.cpl")) ;鼠标属性
    ((= dd 53) (startapp "control timedate.cpl")) ;日期和时间
    ((= dd 54) (startapp "control appwiz.cpl")) ;程序和功能
    ) ;_ 结束cond
  (unload_dialog dcl_id)  ;退出时卸载对话框
  (prin1)
  ) ;_ 结束defun

(defun Write_Dcl  (/ Dcl_File file str)
  (setq Dcl_File (vl-filename-mktemp nil nil ".Dcl"))
  (setq file (open Dcl_File "w"))
  (foreach str  '(
    "Form1:dialog"
    "{"
    " label = \"Windows 应用程序  启动---Author:高磊---\";"
    "    :row"
    "    {"
    "        :boxed_column"
    "        {"
    "         key = \"Frame1\" ;"
    "         label = \"应用按钮\" ;"
    "           :row"
    " {"
    "  :button"
    "  {"
    "      key = \"b11\" ;"
    "      label = \"控制面板\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b12\" ;"
    "      label = \"屏幕分辨率\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b13\" ;"
    "      label = \"系统版本信息\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
   "  :button"
    "  {"
    "      key = \"b14\" ;"
    "      label = \"区域与语言设置\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "}"
    " :row"
    "  {"
    "  :button"
    "  {"
    "      key = \"b21\" ;"
    "      label = \"EXCEL启动\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b22\" ;"
    "      label = \"WORD启动\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b23\" ;"
    "      label = \"运行\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b24\" ;"
    "      label = \"写字板\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "}"
    " :row"
    "  {"
    "  :button"
    "  {"
    "      key = \"b31\" ;"
    "      label = \"画图\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b32\" ;"
    "      label = \"记事本\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b33\" ;"
    "      label = \"计算器\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b34\" ;"
    "      label = \"设备管理器\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "}"
    "  :row"
    "  {"
    "  :button"
    "  {"
    "      key = \"b35\" ;"
    "      label = \"系统属性\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b41\" ;"
    "      label = \"Internet属性\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b42\" ;"
    "      label = \"声音\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "}"
    "             :row"
    " {"
    "  :button"
    "  {"
    "      key = \"b51\" ;"
    "      label = \"资源管理器\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b52\" ;"
    "      label = \"鼠标属性\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b53\" ;"
    "      label = \"日期和时间\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "  :button"
    "  {"
    "      key = \"b54\" ;"
    "      label = \"程序和功能\" ;"
    "      width = 9.75 ;"
    "      height = 1.875 ;"
    "      fixed_height = true ;"
    "      fixed_width = true ;"
    "  }"
    "}"
    "            }"
    "          spacer_1;"
    "           :column"
    "            {"
    "           :text"
    "            {"
    "  key = \"Label1\" ;"
    "  width = 13.35 ;"
    "  height = 1.875 ;"
    "  fixed_height = true ;"
    "  fixed_width = true ;"
    "            }"
    "            :button"
    "            {"
    "  key = \"help\" ;"
    "  label = \"帮助\" ;"
    "  width = 16.95 ;"
    "  height = 1.875 ;"
    "  fixed_height = true ;"
    "  fixed_width = true ;"
    "            }"
    "            :button"
    "            {"
    "  key = \"cancel\" ;"
    "  label = \"取消\" ;"
    "  width = 16.95 ;"
    "  height = 1.875 ;"
    "  fixed_height = true ;"
    "  fixed_width = true ;"
    "  is_cancel = true ;"
    "            }"
    "           :text"
    "            {"
    "  key = \"Label2\" ;"
    "  width = 13.35 ;"
    "  height = 1.875 ;"
    "  fixed_height = true ;"
    "  fixed_width = true ;"
    "            }"
    "          }"
    "    }"
    "}"
    )
    (write-line str file)
    ) ;_ 结束foreach
  (close file)
  Dcl_File
  ) ;_ 结束defun

(defun help3_button  ()
  (setq msg
         (strcat
           "\t     [ 应  用  程  序  快  速  启  动 ]  "
           "\n"
           "--------------------------------------------------------------"
           "\nCopyright ㊣ 2017 - 2027  All rights reserved.\n"
           "--------------------------------------------------------------"
           )
        )
  (alert msg)
  )


评分

参与人数 1明经币 +1 收起 理由
USER2128 + 1 赞一个!

查看全部评分

发表于 2017-8-10 08:22 | 显示全部楼层
原始程序对话框是这样的:


优化后:


  1. (defun Write_Dcl  (/ Dcl_File file str)
  2.   (setq Dcl_File (vl-filename-mktemp nil nil ".Dcl"))
  3.   (setq file (open Dcl_File "w"))
  4.   (foreach str  '(
  5.                    "Form1:dialog{"
  6.                    "    label = \"Windows 应用程序  启动---Author:高磊----From:dcl->lsp V1.8.6.1M(beta)\" ;"
  7.                    "    :row {"
  8.                    "        :boxed_column {"
  9.                    "            key = \"Frame1\" ;"
  10.                    "            label = \"应用按钮\" ;"
  11.                    "            :row {"
  12.                    "                :button {"
  13.                    "                    fixed_height = true ;"
  14.                    "                    fixed_width = true ;"
  15.                    "                    height = 1.875 ;"
  16.                    "                    key = \"b11\" ;"
  17.                    "                    label = \"控制面板\" ;"
  18.                    "                    width = 22 ;"
  19.                    "                }"
  20.                    "                :button {"
  21.                    "                    fixed_height = true ;"
  22.                    "                    fixed_width = true ;"
  23.                    "                    height = 1.875 ;"
  24.                    "                    key = \"b12\" ;"
  25.                    "                    label = \"屏幕分辨率\" ;"
  26.                    "                    width = 22 ;"
  27.                    "                }"
  28.                    "                :button {"
  29.                    "                    fixed_height = true ;"
  30.                    "                    fixed_width = true ;"
  31.                    "                    height = 1.875 ;"
  32.                    "                    key = \"b13\" ;"
  33.                    "                    label = \"系统版本信息\" ;"
  34.                    "                    width = 22 ;"
  35.                    "                }"
  36.                    "                :button {"
  37.                    "                    fixed_height = true ;"
  38.                    "                    fixed_width = true ;"
  39.                    "                    height = 1.875 ;"
  40.                    "                    key = \"b14\" ;"
  41.                    "                    label = \"区域与语言设置\" ;"
  42.                    "                    width = 22 ;"
  43.                    "                }"
  44.                    "            }"
  45.                    "            :row {"
  46.                    "                :button {"
  47.                    "                    fixed_height = true ;"
  48.                    "                    fixed_width = true ;"
  49.                    "                    height = 1.875 ;"
  50.                    "                    key = \"b21\" ;"
  51.                    "                    label = \"EXCEL启动\" ;"
  52.                    "                    width = 22 ;"
  53.                    "                }"
  54.                    "                :button {"
  55.                    "                    fixed_height = true ;"
  56.                    "                    fixed_width = true ;"
  57.                    "                    height = 1.875 ;"
  58.                    "                    key = \"b22\" ;"
  59.                    "                    label = \"WORD启动\" ;"
  60.                    "                    width = 22 ;"
  61.                    "                }"
  62.                    "                :button {"
  63.                    "                    fixed_height = true ;"
  64.                    "                    fixed_width = true ;"
  65.                    "                    height = 1.875 ;"
  66.                    "                    key = \"b23\" ;"
  67.                    "                    label = \"运行\" ;"
  68.                    "                    width = 22 ;"
  69.                    "                }"
  70.                    "                :button {"
  71.                    "                    fixed_height = true ;"
  72.                    "                    fixed_width = true ;"
  73.                    "                    height = 1.875 ;"
  74.                    "                    key = \"b24\" ;"
  75.                    "                    label = \"写字板\" ;"
  76.                    "                    width = 22 ;"
  77.                    "                }"
  78.                    "            }"
  79.                    "            :row {"
  80.                    "                :button {"
  81.                    "                    fixed_height = true ;"
  82.                    "                    height = 1.875 ;"
  83.                    "                    key = \"b31\" ;"
  84.                    "                    label = \"画图\" ;"
  85.                    "                    width = 22 ;"
  86.                    "                }"
  87.                    "                :button {"
  88.                    "                    fixed_height = true ;"
  89.                    "                    height = 1.875 ;"
  90.                    "                    key = \"b32\" ;"
  91.                    "                    label = \"记事本\" ;"
  92.                    "                    width = 22 ;"
  93.                    "                }"
  94.                    "                :button {"
  95.                    "                    fixed_height = true ;"
  96.                    "                    height = 1.875 ;"
  97.                    "                    key = \"b33\" ;"
  98.                    "                    label = \"计算器\" ;"
  99.                    "                    width = 22 ;"
  100.                    "                }"
  101.                    "                :button {"
  102.                    "                    fixed_height = true ;"
  103.                    "                    height = 1.875 ;"
  104.                    "                    key = \"b34\" ;"
  105.                    "                    label = \"设备管理器\" ;"
  106.                    "                    width = 22 ;"
  107.                    "                }"
  108.                    "            }"
  109.                    "            :row {"
  110.                    "                :button {"
  111.                    "                    fixed_height = true ;"
  112.                    "                    height = 1.875 ;"
  113.                    "                    key = \"b51\" ;"
  114.                    "                    label = \"资源管理器\" ;"
  115.                    "                    width = 22 ;"
  116.                    "                }"
  117.                    "                :button {"
  118.                    "                    fixed_height = true ;"
  119.                    "                    height = 1.875 ;"
  120.                    "                    key = \"b52\" ;"
  121.                    "                    label = \"鼠标属性\" ;"
  122.                    "                    width = 22 ;"
  123.                    "                }"
  124.                    "                :button {"
  125.                    "                    fixed_height = true ;"
  126.                    "                    height = 1.875 ;"
  127.                    "                    key = \"b53\" ;"
  128.                    "                    label = \"日期和时间\" ;"
  129.                    "                    width = 22 ;"
  130.                    "                }"
  131.                    "                :button {"
  132.                    "                    fixed_height = true ;"
  133.                    "                    fixed_width = true ;"
  134.                    "                    height = 1.875 ;"
  135.                    "                    key = \"b54\" ;"
  136.                    "                    label = \"程序和功能\" ;"
  137.                    "                    width = 22 ;"
  138.                    "                }"
  139.                    "            }"
  140.                    "            :row {"
  141.                    "                :button {"
  142.                    "                    fixed_height = true ;"
  143.                    "                    height = 1.875 ;"
  144.                    "                    key = \"b35\" ;"
  145.                    "                    label = \"系统属性\" ;"
  146.                    "                    width = 22 ;"
  147.                    "                }"
  148.                    "                :button {"
  149.                    "                    fixed_height = true ;"
  150.                    "                    height = 1.875 ;"
  151.                    "                    key = \"b41\" ;"
  152.                    "                    label = \"Internet属性\" ;"
  153.                    "                    width = 22 ;"
  154.                    "                }"
  155.                    "                :button {"
  156.                    "                    fixed_height = true ;"
  157.                    "                    height = 1.875 ;"
  158.                    "                    key = \"b42\" ;"
  159.                    "                    label = \"声音\" ;"
  160.                    "                    width = 22 ;"
  161.                    "                }"
  162.                    "            }"
  163.                    "        }"
  164.                    "        spacer_1;"
  165.                    "        :column {"
  166.                    "            :text {"
  167.                    "                key = \"Label1\" ;"
  168.                    "                width = 13.35 ;"
  169.                    "                height = 1.875 ;"
  170.                    "                fixed_height = true ;"
  171.                    "                fixed_width = true ;"
  172.                    "            }"
  173.                    "            :button {"
  174.                    "                key = \"help\" ;"
  175.                    "                label = \"帮助\" ;"
  176.                    "                width = 16.95 ;"
  177.                    "                height = 1.875 ;"
  178.                    "                fixed_height = true ;"
  179.                    "                fixed_width = true ;"
  180.                    "            }"
  181.                    "            :button {"
  182.                    "                key = \"cancel\" ;"
  183.                    "                label = \"取消\" ;"
  184.                    "                width = 16.95 ;"
  185.                    "                height = 1.875 ;"
  186.                    "                fixed_height = true ;"
  187.                    "                fixed_width = true ;"
  188.                    "                is_cancel = true ;"
  189.                    "            }"
  190.                    "            :text {"
  191.                    "                key = \"Label2\" ;"
  192.                    "                width = 13.35 ;"
  193.                    "                height = 1.875 ;"
  194.                    "                fixed_height = true ;"
  195.                    "                fixed_width = true ;"
  196.                    "            }"
  197.                    "        }"
  198.                    "    }"
  199.                    "}"
  200.                  )
  201.     (write-line str file)
  202.   ) ;_ 结束foreach
  203.   (close file)
  204.   Dcl_File
  205. )

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
回复 支持 1 反对 0

使用道具 举报

发表于 2017-8-8 18:10 | 显示全部楼层
学习了,谢谢分享
发表于 2017-8-8 19:09 | 显示全部楼层
好实用的,谢谢分享!
发表于 2017-8-17 08:35 | 显示全部楼层
学习了,谢谢分享!!!!!
发表于 2019-12-17 23:08 | 显示全部楼层
Thanks for sharing ^^
发表于 2021-5-23 13:54 | 显示全部楼层
Thanks for sharing ^^
发表于 2021-6-3 10:09 | 显示全部楼层
多处缺少分号?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-3-29 16:48 , Processed in 0.179303 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表