找回密码
 加入
搜索
查看: 2099|回复: 3

关于AU3的热字串问题

[复制链接]
发表于 2008-9-5 20:36:56 | 显示全部楼层 |阅读模式
请问一下AU3又没有实现热字串的方法或者代码,就像AutoHotkey的功能一样。
在AutoHotkey中的热字串可以输入 b t w 三个键 然后 打出 by the way这句话,这在很多地方都很便利 比如在发帖的时候写论坛代码可以只输入几个自定义的键就输入完整代码。

有谁知道AU3有相关的脚本或者函数或者任何实现的功能没有,我实在不想怎么弄AutoHotkey了,那语法乱得吓人,烦死人了


我不是要实现以上这些功能啊,只是打个比方,以下是我在官方论坛找来的脚本,发上来吧,也算是解决了。

对了,这个是个脚本地址,下载后把东西解压到一个文件夹,然后里面的example代码有示例,顺便说下他include的那个东西有一个文件名写错了,呵呵
http://www.manadar.com/repository/autoit/hotstrings/hotstrings.zip
原帖地址:http://www.autoitscript.com/foru ... p;amp;hl=Hotstrings




还有是一个人提问,然后自己写了代码
原帖地址 :http://www.autoitscript.com/foru ... p;amp;hl=Hotstrings

HotKeySet("{ESC}", "Terminate")

$buffer = ""
$sleep = 100
$hotString = "btw"
$hotStringReplace = "By The Way"


While 1

Select
    Case _IsPressed(41)
        _KeyPress("a")
    Case _IsPressed(42)
        _KeyPress("b")
    Case _IsPressed(43)
        _KeyPress("c")
    Case _IsPressed(44)
        _KeyPress("d")
    Case _IsPressed(45)
        _KeyPress("e")
    Case _IsPressed(46)
        _KeyPress("f")
    Case _IsPressed(47)
        _KeyPress("g")
    Case _IsPressed(48)
        _KeyPress("h")
    Case _IsPressed(49)
        _KeyPress("i")
    Case _IsPressed('4A')
        _KeyPress("j")
    Case _IsPressed('4B')
        _KeyPress("k")
    Case _IsPressed('4C')
        _KeyPress("l")
    Case _IsPressed('4D')
        _KeyPress("m")
    Case _IsPressed('4E')
        _KeyPress("n")
    Case _IsPressed('4F')
        _KeyPress("o")
    Case _IsPressed(50)
        _KeyPress("p")
    Case _IsPressed(51)
        _KeyPress("q")
    Case _IsPressed(52)
        _KeyPress("r")
    Case _IsPressed(53)
        _KeyPress("s")
    Case _IsPressed(54)
        _KeyPress("t")
    Case _IsPressed(55)
        _KeyPress("u")
    Case _IsPressed(56)
        _KeyPress("v")
    Case _IsPressed(57)
        _KeyPress("w")
    Case _IsPressed(58)
        _KeyPress("x")
    Case _IsPressed(59)
        _KeyPress("y")
    Case _IsPressed('5A')
        _KeyPress("z")

    Case _IsPressed(30)
        _KeyPress("1")
    Case _IsPressed(31)
        _KeyPress("2")
    Case _IsPressed(32)
        _KeyPress("3")
    Case _IsPressed(33)
        _KeyPress("4")
    Case _IsPressed(34)
        _KeyPress("5")
    Case _IsPressed(35)
        _KeyPress("6")
    Case _IsPressed(36)
        _KeyPress("7")
    Case _IsPressed(37)
        _KeyPress("7")
    Case _IsPressed(38)
        _KeyPress("8")
    Case _IsPressed(39)
        _KeyPress("9")

    Case _IsPressed(20); Space
        _KeyPress(" ")
    Case _IsPressed(08); BackSpace
        _KeyPress(" ")
    Case _IsPressed(09); TAB
        _KeyPress(" ")
    Case _IsPressed('0D'); Enter
        _KeyPress(" ")
    Case _IsPressed('2E'); DEL
        _KeyPress(" ")

;~     Case _IsPressed(61)
;~         _KeyPress("a")
;~     Case _IsPressed(62)
;~         _KeyPress("b")
;~     Case _IsPressed(63)
;~         _KeyPress("c")
;    Case Else
;        MsgBox(0, "", "No preceding case was true!")
EndSelect

;~ if _IsPressed(08) Then
;~     _KeyPress(" BACKSPACE ")
;~      sleep($sleep)
;~  Elseif _IsPressed(09) Then
;~     _KeyPress(" TAB ")
;~      sleep($sleep)
;~ Elseif _IsPressed('0D') Then
;~     _KeyPress("  ENTER  ")
;~     sleep($sleep)
;~  EndIf

  Sleep($sleep); You may need to change that value (depending on your computer´s speed)
WEnd


Func _KeyPress($whatWasPressed)
  Select
      Case $whatWasPressed = " "
        $buffer = ""
      Case Else
        $buffer = $buffer & $whatWasPressed
  EndSelect
    if $buffer = $hotString Then
        $buffer = ""
        
        For $i = 1 to stringlen($hotString) Step 1
            Send("{BS}")
        Next
        Send($hotStringReplace)
    EndIf
EndFunc

Func _IsPressed($hexKey)
; $hexKey must be the value of one of the keys.
; _IsPressed will return 0 if the key is not pressed, 1 if it is.

Local $aR
$hexKey = '0x' & $hexKey
$aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
If Not @error And BitAND($aR[0],0x8000) = 0x8000 Then Return 1
Return 0
EndFunc;==>_IsPressed

Func Terminate()
    Exit 0
EndFunc


[ 本帖最后由 brooklyn 于 2008-9-6 12:34 编辑 ]
发表于 2008-9-5 20:56:03 | 显示全部楼层
我想这个事应该交给输入法的说。
硬要用au3也行,定义一系列“标点符”,从cp开始向前查找直到“标点符”,就可以得到一个“缩写”,然后查找“缩写库”中是否有匹配的字符串,然后把“缩写”替换成该字符串即可。
发表于 2008-9-6 01:52:39 | 显示全部楼层
直接用SCITE编辑器的话,本身不是有这个功能吗?
发贴到论坛的时候直接复制SCITE编辑器的代码就行啦。
 楼主| 发表于 2008-9-6 12:33:43 | 显示全部楼层
忘了,还有谢谢你们的回帖,呵呵
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-12 05:38 , Processed in 0.072659 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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