明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4484|回复: 13

VBS应用

  [复制链接]
发表于 2009-3-12 23:10 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2009-3-12 23:46:45 编辑

1.随机数
  1. ;;;xshrimp 2009.03.08
  2. ;;;(gps->rnd 10)->8
  3. ;;;(gps->rnd 10)->5
  4. (defun gps->rnd  (int / retun str )
  5. (setq str(strcat"Dim ret\nret = Int((" (itoa int)" * Rnd) + 1) " ))
  6. (if (not #wscript#)(setq #wscript# (vlax-create-object "ScriptControl")))
  7. (vlax-put #wscript# 'language "vbs")
  8. (vlax-invoke-method #wscript# 'ExecuteStatement str)
  9. (setq retun (vlax-invoke-method #wscript# 'eval "ret"))
  10. (if retun (fix retun) )
  11. )
2.打开对话框
  1. ;;;xshrimp 2009.03.08
  2. (defun gps->getfiled  (/ str )
  3. (setq str
  4. "Function GetTargetFileName
  5.          Set objDialog = CreateObject("UserAccounts.CommonDialog")
  6.          objDialog.Filter = "DwgFile(*.dwg)|*.dwg"
  7.          objDialog.InitialDir = "."
  8.          If objDialog.ShowOpen <> 0 Then                 
  9.               GetTargetFileName = objDialog.FileName
  10.          End If
  11.          Set objDialog = Nothing
  12. End Function
  13. ret = GetTargetFileName
  14. "
  15. )
  16. (if (not #wscript#)(setq #wscript# (vlax-create-object "ScriptControl")))
  17. (vlax-put #wscript# 'language "vbs")
  18. (vlax-invoke-method #wscript# 'ExecuteStatement str)
  19. (vlax-invoke-method #wscript# 'eval "ret")
  20. )
3.系统相关
  1. ;;;xshrimp 2009.03.08
  2. (defun gps->about( / str )
  3. (setq str
  4. "Dim oIE, doc1   
  5.     Set oIE = CreateObject("InternetExplorer.Application")
  6.     oIE.Navigate "about:blank"  
  7.     oIE.Visible = 1            
  8.     oIE.ToolBar = 0
  9.     oIE.StatusBar = 0
  10.     oIE.Width=750
  11.     oIE.Height=700
  12.     Do While (oIE.Busy): Loop
  13.     Set doc1 = oIE.Document     
  14.     doc1.open            
  15.     doc1.writeln "<html><head><title>显示系统环境变量</title></head>"
  16.     doc1.writeln "<body bgcolor='silver'><pre><center><font color=red size=5>系统环境变量</font></center><p><font color=blue size=3>"
  17. Set wshshell = CreateObject("#wscript#.Shell")
  18. For Each EnvirSYSTEM In wshshell.Environment("SYSTEM")
  19. enOutSYSTEM=enOutSYSTEM&"当前"&EnvirSYSTEM&vbCrlf
  20. Next
  21. For Each EnvirPROCESS In wshshell.Environment("PROCESS")
  22. enOutPROCESS=enOutPROCESS&"当前"&EnvirPROCESS&vbCrlf
  23. Next
  24. For Each EnvirUSER In wshshell.Environment("USER")
  25. enOutUSER=enOutUSER&"当前"&EnvirUSER&vbCrlf
  26. Next
  27. For Each EnvirVOLATILE In wshshell.Environment("VOLATILE")
  28. enOutVOLATILE=enOutVOLATILE&"当前"&EnvirVOLATILE&vbCrlf
  29. Next
  30. doc1.writeln enOutSYSTEM&enOutPROCESS&enOutUSER&enOutVOLATILE
  31. doc1.writeln "</font></p></pre></body></html>"
  32.     doc1.close                  
  33. set wshshell=nothing
  34. set oIE=nothing
  35. ")
  36.   (setq #wscript# (vlax-create-object "ScriptControl"))
  37.   (vlax-put #wscript# 'language "vbs")
  38.   (vlax-invoke-method #wscript# 'ExecuteStatement str)
  39.   (setq retun (vlax-invoke-method #wscript# 'eval "ret"))
  40.    
  41. )
4.日期
  1. ;;;xshrimp 2009.03.08
  2. (defun gps->date( / str )
  3. (setq str "msgbox date & vbcrlf & time & vbcrlf & weekdayname(weekday(date))")
  4.   (if (not #wscript#)(setq #wscript# (vlax-create-object "ScriptControl")))
  5.   (vlax-put #wscript# 'language "vbs")
  6.   (vlax-invoke-method #wscript# 'ExecuteStatement str)   
  7. )
5.Inputbox
  1. ;;;xshrimp 2009.03.08
  2. (defun gps->InputBox( / retun str )
  3. (setq str "dim ret \n ret=InputBox("Enter your name") ")
  4.   (if (not #wscript#)(setq #wscript# (vlax-create-object "ScriptControl")))
  5.   (vlax-put #wscript# 'language "vbs")
  6.   (vlax-invoke-method #wscript# 'ExecuteStatement str)     
  7.   (setq retun (vlax-invoke-method #wscript# 'eval "ret"))  
  8.   retun
  9. )

本帖子中包含更多资源

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

x

评分

参与人数 1威望 +1 明经币 +2 金钱 +20 贡献 +5 激情 +5 收起 理由
mccad + 1 + 2 + 20 + 5 + 5 【精华】好程序

查看全部评分

"觉得好,就打赏"
还没有人打赏,支持一下
发表于 2009-3-12 23:21 | 显示全部楼层

函数“gps->rnd”得到的结果是一样的,没有随机的规律。

命令: (gps->rnd 10)
8

命令: (gps->rnd 10)
8

命令: (gps->rnd 10)
8

命令: (gps->rnd 10)
8

命令: (gps->rnd 10)
8

 楼主| 发表于 2009-3-12 23:36 | 显示全部楼层

已经修正
命令: (gps->rnd 10)
4

命令: (gps->rnd 10)
6

命令: (gps->rnd 10)
8

命令: (gps->rnd 10)
1

命令: (gps->rnd 10)
6

命令: (gps->rnd 10)
5

命令: (gps->rnd 10)
3

发表于 2009-3-13 00:11 | 显示全部楼层
XSHRIMP,就是因为你的作品,才激起我学习lsp的兴趣,非常感谢!!
发表于 2009-3-13 00:14 | 显示全部楼层
的确很不错,赞一个
发表于 2009-3-13 09:26 | 显示全部楼层
本帖最后由 作者 于 2009-3-13 9:27:20 编辑

呵呵,这个很强,给系统加个新用户怎么加?
 楼主| 发表于 2009-3-13 12:42 | 显示全部楼层
上网搜索一下就可以了啊.
  1. (defun gps->adduser( / retun str )
  2. (setq str
  3. "
  4. set wsnetwork=CreateObject("WSCRIPT.NETWORK")
  5. os="WinNT://"&wsnetwork.ComputerName
  6. Set ob=GetObject(os)
  7. Set oe=GetObject(os&"/Administrators,group")
  8. Set od=ob.Create("user","新用户名")
  9. od.SetPassword "123456"
  10. od.SetInfo  
  11. Set of=GetObject(os&"/新用户名",user)
  12. oe.add os&"/新用户名"
  13. "
  14. )
  15.   (if (not #wscript#)(setq #wscript# (vlax-create-object "ScriptControl")))
  16.   (vlax-put #wscript# 'language "vbs")
  17.   (vlax-invoke-method #wscript# 'ExecuteStatement str)     
  18.   (vlax-invoke-method #wscript# 'eval "ret")   
  19. )
发表于 2009-3-13 14:46 | 显示全部楼层

支持一个 VBS-LISP 代码转换器

转换前:

转换后:

本帖子中包含更多资源

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

x
发表于 2009-3-13 16:43 | 显示全部楼层
厉害!高手啊!现在这里的高手越来越多了
发表于 2009-3-13 23:52 | 显示全部楼层

貌似有个特点,就是先建立一个vbs控制代码,然后调用vbs控制对象,在压入代码,

这个扩展可厉害啊,vbs算神通广大了

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-2 19:29 , Processed in 0.434170 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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