语言数字 v2.0

tech2022-09-05  112

为了快速输入身份证号码、电话号码、银行账号等数字时确保正确又不用检查, 输入数字时同时发声是很好的方法,所以我制作了这个”语音数字“脚本,非常好用。 注:本脚本需配合”0—9和点“的语音文件一起使用,可下载类似读数软件从中提取。

;---------------------------- ; 语言数字 v2.0 By FeiYue ; ; 说明:将本脚本和语音文件放在同一目录编译即可 ;---------------------------- #NoEnv #SingleInstance force Menu, Tray, Icon, Shell32.dll, 15 Menu, Tray, NoStandard Menu, Tray, Add, 帮助, Help Menu, Tray, Add, 暂停使用, DoSuspend Menu, Tray, Add, 退出, ExitSub Menu, Tray, Default, 暂停使用 Menu, Tray, Click, 1 Loop, 10 { n:=A_Index-1 Hotkey, *Numpad%n%, sound } Hotkey, *NumpadDot, sound Critical return sound: k:=SubStr(A_ThisHotkey,0) if (k="t") { SendInput . PlaySound(10) } else { SendInput %k% PlaySound(k) } ; 播放时间需要仔细微调 Sleep, 300 return Help: MsgBox, 4096, 使用帮助, ( `n 语音数字(作者:飞跃)`n `n 本程序的作用:输入右边小键盘的数字 `n (0—9)和点(.)时会读出声音。 `n 暂停使用:左键点一下右下脚的程序图标。 `n 退出程序:右键点击程序图标选择退出。 `n 【当用小键盘输入QQ密码时要暂停使用】 ), 30 return DoSuspend: Suspend return ExitSub: ExitApp ^CtrlBreak:: Suspend Return ;========= 下面是函数 ============ ;-- 限制单进程运行函数 OnlyOne(flag="") { local static init:=OnlyOne("YuYinShuZi") DetectHiddenWindows, % (dhw:=A_DetectHiddenWindows) ? "On":"On" hash:=0 Loop, Parse, flag hash:=(hash*31+Asc(A_LoopField))&0xFFFFFFFF Name:="Ahk_OnlyOne_" hash While Mutex:=DllCall("OpenMutex","int",0x100000,"int",0,"str",Name) { DllCall("CloseHandle", "Ptr",Mutex) While WinExist("<<" flag ">> ahk_class AutoHotkey") { WinGet, pid, PID WinClose,,, 3 IfWinExist { Process, Close, %pid% Process, WaitClose, %pid%, 3 } } } DllCall("CreateMutex", "Ptr",0, "int",0, "str",Name) IfEqual, A_LastError, 0xB7, ExitApp pid:=DllCall("GetCurrentProcessId") WinSetTitle, ahk_pid %pid% ahk_class AutoHotkey,, <<%flag%>> DetectHiddenWindows, %dhw% } ;-- 异步播放内存中的声音 PlaySound(n="") { static static init:=PlaySound() if (!arr) { arr:=[], SND_ASYNC:=0x1, SND_MEMORY:=0x4 Loop, 11 { n:=A_Index-1 if (!A_IsCompiled) FileRead, p%n%, *c %A_AhkPath%\..\语音数字\%n%.wav else if !LoadSound(p%n%, n) { MsgBox, 4096, 提示, `n读取声音文件错误! ExitApp } arr[n]:=&p%n% } DllCall("LoadLibrary", "str","winmm.dll") return } else if arr.HasKey(n) DllCall("winmm\sndPlaySound", "Ptr",arr[n], "int",1|4) } ;-- 把程序资源中的声音载入内存 LoadSound(ByRef pn, n) { fn:=Format("{:d}.WAV", n), Ptr:="Ptr" if (h:=DllCall("GetModuleHandle", Ptr,0, Ptr)) && (rc:=DllCall("FindResource", Ptr,h, "str",fn, Ptr,10, Ptr)) && (sz:=DllCall("SizeofResource",Ptr,h, Ptr,rc, "uint")) && (hr:=DllCall("LoadResource", Ptr,h, Ptr,rc, Ptr)) && (lp:=DllCall("LockResource", Ptr,hr,Ptr)) { VarSetCapacity(pn, sz+8) DllCall("RtlMoveMemory", Ptr,&pn, Ptr,lp, Ptr,sz) DllCall("FreeResource", Ptr,hr) return 1 } return 0 } ; 这个不执行,只用于编译时加入程序的资源中 if (false) { FileInstall, 0.wav, ~ FileInstall, 1.wav, ~ FileInstall, 2.wav, ~ FileInstall, 3.wav, ~ FileInstall, 4.wav, ~ FileInstall, 5.wav, ~ FileInstall, 6.wav, ~ FileInstall, 7.wav, ~ FileInstall, 8.wav, ~ FileInstall, 9.wav, ~ FileInstall, 10.wav, ~ }
最新回复(0)