- 注册时间
- 2008-8-11
- 最后登录
- 2009-4-5
②入门
- 积分
- 53
|
伪·文字输入框
——Defanive
更新 Version 1.1 :
修正了窗口进程被杀导致的游戏卡死
现在的输入法都不怎么方便用,而且还要附带一些DLL和EXE,用起来实在麻烦。。。
利用MsHta弄了个伪劣假冒的文字输入框。。。
话说本来只有5行核心代码的,结果问题太多了,一加代码就多起来。。。
10s问题耗了我5行左右,结果编码问题又浪费了好多时间。。。
目前提示信息不支持中文,但返回信息支持中文。。。
足够了。。。
最新测试:
本脚本兼容VX,只需将55行Graphics.update删去即可
贴图预览:
- #==============================================================================# # ■ Code_Input
- #
- #------------------------------------------------------------------------------
- #
- # 伪·文字输入框 Version 1.1
- #
- #==============================================================================
- #==============================================================================
- #
- # 伪·文字输入框
- # —— By Defanive
- #
- # 能够弹出一个InputBox窗口,输入完成后返回值
- #
- # Version 1.1 修正:
- # 防止窗口进程被杀导致的游戏卡死
- #
- # 目前的缺陷:
- # input参数不支持中文
- #
- #------------------------------------------------------------------------------
- #
- # 使用:
- # 变量 = Input(提示, 标题, 默认值)
- #
- #==============================================================================
- #==============================================================================
- # API Functions
- #==============================================================================
- Shell=Win32API.new('kernel32','WinExec','pl','l')
- M2w=Win32API.new('kernel32','MultiByteToWideChar','ilpipi','i')
- W2m=Win32API.new('kernel32','WideCharToMultiByte','ilpipipp','i')
- Find=Win32API.new('user32','FindWindowA','p,p','l')
- IsWnd=Win32API.new('user32','IsWindow','l','l')
- #==============================================================================
- # Main Function
- #==============================================================================
- def input(text,title,strs)
-   tdir=Dir.getwd+"/input.tmp"
-   sname='mshta vbscript:createobject("scripting.filesystemobject").opentextfile("'+tdir+'",2,True).write(inputbox("'+text+'","'+title+'","'+strs+'"))(window.close)'
-   Shell.call(sname,1)
-   sleep(1)
-   hw=Find.call(nil,title)
-   while true
-   Graphics.update
-   break if IsWnd.call(hw)==0
-   end
-   s=text_conv(File.open(tdir).read)
-   return s[0,s.size-1]
- end
- #==============================================================================
- # Convert Function
- #==============================================================================
- def text_conv(text)
-   len=M2w.call(0,0,text,-1,nil,0)
-   buf="\0"*(len*2)
-   M2w.call(0,0,text,-1,buf,buf.size/2)
-   len=W2m.call(65001,0,buf,-1,nil,0,nil,nil)
-   ret="\0"*len
-   W2m.call(65001,0,buf,-1,ret,ret.size,nil,nil)
-   return ret
- end
复制代码
需要使用时 变量 = Input(提示, 标题, 默认值)
具体参考Ver1.1范例:
XP:http://bbs.66rpg.com/upload_prog ... er1.1_119447684.rar
VX:http://bbs.66rpg.com/upload_prog ... er1.1_119449275.rar |
|