设为首页收藏本站淘宝杂货铺

从F到0 - From F to 0

 找回密码
 注册已关闭
搜索
查看: 2792|回复: 8
收起左侧

送几种常用的按键精灵代码

[复制链接]
发表于 2017-9-19 20:17:19 | 显示全部楼层 |阅读模式

  1. ==============================

  2. 字符串系列函数

  3. 1.取出文本中某字符串的左边的所有文本

  4. //函数代码

  5. Function 取文本左边(源文本, 查找文本)
  6. 位置 = InStr(源文本, 查找文本)
  7. 取文本左边 = Left(源文本, 位置 - 1)   
  8. End Function

  9. //测试代码

  10. TracePrint 取文本左边("按键你好|呵呵", "|")

  11. 2.取出文本中某字符串的右边的所有文本


  12. //函数代码

  13. Function 取文本右边(源文本, 查找文本)
  14. 位置 = InStr(源文本, 查找文本)
  15. 取文本右边 = Right(源文本, Len(源文本)-位置)   
  16. End Function
  17. //测试代码

  18. TracePrint 取文本右边("按键你好|呵呵", "|")


  19. 3.取出文本中两个字符串中间的文本

  20. 函数代码//

  21. Function 取文本中间(源文本, 左边文本, 右边文本)
  22. 左边位置 = InStr(源文本, 左边文本)
  23. 右边位置 = InStrRev(源文本, 右边文本)
  24. 宽度 = 右边位置 - 左边位置-1
  25. 取文本中间 = MID(源文本, 左边位置+1, 宽度)
  26. End Function

  27. 测试代码//

  28. TracePrint 取文本中间("你好A按键B精灵","A","B")


  29. 4.判断文本是否重复
  30. ////参数一: 所有文本。 参数二:待查询的文本
  31. ////返回:重复返回1,不重复返回2
  32. Function 文本_是否重复(参数_文本, 参数_查询字符)
  33. If Instr(参数_文本, 参数_查询字符)>0 Then
  34.     文本_是否重复 = 1
  35. Else
  36. 文本_是否重复 = 0
  37. End If
  38. End Function
  39. /////////测试代码
  40. TracePrint 文本_是否重复("你好", "你")
  41. TracePrint 文本_是否重复("你好", "按键")

  42. 5.分割出单个字符
  43. /////////参数一:待分割的文本
  44. /////////返回:含分隔符的文本
  45. Function 文本_逐字分割(参数_待分割)
  46. For i = 1 To len(参数_待分割)
  47.     文本_逐字分割 = 文本_逐字分割 & mid(参数_待分割, i, 1) & "‰"
  48. Next
  49. End Function
  50. /////////测试代码
  51. 文本 = 文本_逐字分割("你好。+-2017aabbcc")
  52. 数组 = split(文本, "‰")
  53. For i = 0 To UBound(数组) - 1
  54.     TracePrint "当前位置:" & i + 1 & "->" & 数组(i)
  55. Next
  56. ---------------------------------------------------------------
  57. 密码输入类【前台】
  58. str = "abcABC..!!@@#¥"
  59. For i = 1 To len(str)
  60. If asc(mid(str, i, 1)) >= 35 and asc(mid(str, i, 1)) <= 37 Then
  61. KeyDown 16, 1
  62. KeyPress asc(mid(str, i, 1)) + 16,1
  63. KeyUp 16, 1
  64. ElseIf asc(mid(str, i, 1)) >= 123 and asc(mid(str, i, 1)) <= 125 Then
  65. KeyDown 16, 1
  66. KeyPress asc(mid(str, i, 1)) + 96,1
  67. KeyUp 16, 1
  68. ElseIf asc(mid(str, i, 1)) >= 62 and asc(mid(str, i, 1)) <= 63 Then
  69. KeyDown 16, 1
  70. KeyPress asc(mid(str, i, 1)) + 128,1
  71. KeyUp 16, 1
  72. ElseIf asc(mid(str, i, 1)) >= 65 and asc(mid(str, i, 1)) <= 90 Then
  73. KeyDown 16, 1
  74. KeyPress asc(mid(str, i, 1)),1
  75. KeyUp 16, 1
  76. ElseIf asc(mid(str, i, 1)) = 33 Then
  77. KeyDown 16, 1
  78. KeyPress 49,1
  79. KeyUp 16, 1
  80. ElseIf asc(mid(str, i, 1)) = 64 Then
  81. KeyDown 16, 1
  82. KeyPress 50,1
  83. KeyUp 16, 1
  84. ElseIf asc(mid(str, i, 1)) = 94 Then
  85. KeyDown 16, 1
  86. KeyPress 54,1
  87. KeyUp 16, 1
  88. ElseIf asc(mid(str, i, 1)) = 38 Then
  89. KeyDown 16, 1
  90. KeyPress 55,1
  91. KeyUp 16, 1
  92. ElseIf asc(mid(str, i, 1)) = 42 Then
  93. KeyDown 16, 1
  94. KeyPress 56,1
  95. KeyUp 16, 1
  96. ElseIf asc(mid(str, i, 1)) = 41 Then
  97. KeyDown 16, 1
  98. KeyPress 48,1
  99. KeyUp 16, 1
  100. ElseIf asc(mid(str, i, 1)) = 40 Then
  101. KeyDown 16, 1
  102. KeyPress 57,1
  103. KeyUp 16, 1
  104. ElseIf asc(mid(str, i, 1)) = 95 Then
  105. KeyDown 16, 1
  106. KeyPress 189,1
  107. KeyUp 16, 1
  108. ElseIf asc(mid(str, i, 1)) = 43 Then
  109. KeyDown 16, 1
  110. KeyPress 187,1
  111. KeyUp 16, 1
  112. ElseIf asc(mid(str, i, 1)) = 60 Then
  113. KeyDown 16, 1
  114. KeyPress 188,1
  115. KeyUp 16, 1
  116. ElseIf asc(mid(str, i, 1)) = 126 Then
  117. KeyDown 16, 1
  118. KeyPress 192,1
  119. KeyUp 16, 1


  120. ElseIf asc(mid(str, i, 1)) = -23644 or asc(mid(str, i, 1)) = -24089 Then ///¥ $
  121. KeyDown 16, 1
  122. KeyPress 52,1
  123. KeyUp 16, 1
  124. ElseIf asc(mid(str, i, 1)) >= 97 and asc(mid(str, i, 1)) <= 122 Then
  125. KeyPress asc(mid(str, i, 1)) - 32,1
  126. ElseIf asc(mid(str, i, 1)) >= 44 and asc(mid(str, i, 1)) <= 47 Then
  127. KeyPress asc(mid(str, i, 1)) + 144,1
  128. ElseIf asc(mid(str, i, 1)) >= 91 and asc(mid(str, i, 1)) <= 93 Then
  129. KeyPress asc(mid(str, i, 1)) + 128,1
  130. ElseIf asc(mid(str, i, 1)) = 96 Then
  131. KeyPress 192,1
  132. ElseIf asc(mid(str, i, 1)) = 61 Then
  133. KeyPress 187,1
  134. ElseIf asc(mid(str, i, 1)) = 59 Then
  135. KeyPress 186,1
  136. ElseIf asc(mid(str, i, 1)) = 39 Then
  137. KeyPress 222,1
  138. Else
  139. KeyPress asc(mid(str, i, 1)),1
  140. End If
  141. Delay 10
  142. Next
  143. -------------------------------------------------------------------------------------------
  144. 计时的信息框
  145. Declare Function MessageBoxTimeout Lib "user32.dll" Alias "MessageBoxTimeoutA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long, ByVal wlange As Long, ByVal dwTimeout As Long) As Long
  146. hwnd = Plugin.Window.MousePoint()
  147. ////////1000表示1s
  148. MessageBoxTimeout 0, "你好,欢迎使用", "提示", 0, 1, 1000
  149. -------------------------------------------------------------------------------------------
  150. 复制Word中的图片
  151. lsFileName = "C:\1.doc"'请将此处替换为word文档地址
  152. Set wordObj = CreateObject("Word.Application")'调用word应用类
  153. wordObj.Visible = False'设置为不可见
  154. wordObj.Documents.Open (lsFileName)'打开word文档
  155. wordobj.Selection.WholeStory
  156. wordobj.Selection.Copy
  157. wordObj.Quit '退出word应用类
  158. Set wordObj = Nothing'销毁word应用类

  159. ==============================
复制代码


发表于 2017-9-19 21:11:20 | 显示全部楼层
常回帖看看
发表于 2017-9-20 00:03:28 | 显示全部楼层

你也看不懂,那我也应该看不懂的。
发表于 2017-9-21 11:07:49 | 显示全部楼层
我也看看呢
发表于 2018-4-22 16:09:10 | 显示全部楼层
这么多回复可见
发表于 2018-4-24 09:13:13 | 显示全部楼层
这是什么梗了回复可见
发表于 2018-10-3 18:46:29 | 显示全部楼层
不知道什么梗
您需要登录后才可以回帖 登录 | 注册已关闭

本版积分规则

QQ|手机版|Archiver|从F到0 ( 蒙ICP备17002595号-1 )
蒙公网安备15010402000325号

腾讯云安全认证

GMT+8, 2024-4-25 18:10 , Processed in 0.864049 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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