Pb中利用热键将所需的文本输入到当前程序的输入框中_第1页
Pb中利用热键将所需的文本输入到当前程序的输入框中_第2页
Pb中利用热键将所需的文本输入到当前程序的输入框中_第3页
Pb中利用热键将所需的文本输入到当前程序的输入框中_第4页
Pb中利用热键将所需的文本输入到当前程序的输入框中_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Pb中利用热键将所需的文本输入到当前程序的输入框中用户对象forwardglobal type uo_ime from nonvisualobjectend typeend forwardshared variables/简体中文constant long IME_CHOTKEY_IME_NONIME_TOGGLE = 16 /切换中英文输入法constant long IME_CHOTKEY_SHAPE_TOGGLE = 17 /切换半角和全角constant long IME_CHOTKEY_SYMBOL_TOGGLE = 18 /切换中文标点和英文标点constant long IME_

2、CHOTKEY_LAST = 47end variablesglobal type uo_ime from nonvisualobject autoinstantiateend typetype prototypesfunction long ImmSimulateHotKey(long h,long hkey) library 'IMM32.dll'function long GetKeyboardLayout(long h) library 'user32.dll'function boolean ImmIsIME(long h) library '

3、IMM32.dll'end prototypestype variablesend variablesforward prototypespublic subroutine of_to_chinese (long h)public subroutine of_to_english (long h)public function boolean of_is_chinese (long h)end prototypespublic subroutine of_to_chinese (long h);long lcurrent_imelcurrent_ime = getkeyboardlay

4、out(0)if not immisime(lcurrent_ime) thenImmSimulateHotKey(h, IME_CHOTKEY_IME_NONIME_TOGGLE)/ hkey)end ifend subroutinepublic subroutine of_to_english (long h);long lcurrent_imelcurrent_ime = getkeyboardlayout(0)if immisime(lcurrent_ime) thenImmSimulateHotKey(h, IME_CHOTKEY_IME_NONIME_TOGGLE)end ifen

5、d subroutinepublic function boolean of_is_chinese (long h);long lcurrent_imelcurrent_ime = getkeyboardlayout(0)return immisime(lcurrent_ime)end functionon uo_ime.createcall super:createTriggerEvent( this, "constructor" )end onon uo_ime.destroyTriggerEvent( this, "destructor" )cal

6、l super:destroyend onevent constructor;/*中英文输入法切换对象:of_to_chinese( /*long h */) return (None)功能:把句柄为h的窗口的输入法切换为中文of_to_english( /*long h */) return (None)功能:把句柄为h的窗口的输入法切换为英文of_is_chinese( /*long h */) return boolean功能:判断句柄为h的窗口的输入法是否为中文New by njz Jysoft 2006-09-02*/end event主窗体forwardglobal type w_

7、main from windowend typetype st_2 from statictext within w_mainend typetype st_1 from statictext within w_mainend typetype sle_1 from singlelineedit within w_mainend typeend forwardglobal type w_main from windowinteger width = 2075integer height = 720boolean titlebar = truestring title = "按F3将文

8、本框内容复制到其他程序中"boolean controlmenu = trueboolean minbox = trueboolean maxbox = trueboolean resizable = truelong backcolor = 67108864string icon = "AppIcon!"boolean center = truest_2 st_2st_1 st_1sle_1 sle_1end typeglobal w_main w_maintype prototypesFUNCTION Integer GlobalAddAtom(ref str

9、ing lpString) LIBRARY "kernel32.dll" ALIAS FOR "GlobalAddAtomA"/hwnd参数用于指定使用本热键的窗口句柄,id参数用于指定一个惟一的ID,fsModifiers参数指明辅助键值(Alt、Ctrl、Shift等),vk参数指明虚拟键的ASCII码FUNCTION ulong RegisterHotKey(ulong hwnd,ulong id,ulong fsModifiers,ulong vk) LIBRARY "user32.dll"FUNCTION ulong Unr

10、egisterHotKey( ulong hWnd, ulong id ) LIBRARY "user32.dll" Function int GetKeyState(integer VirtualKeycode) Library "User32.dll"SUBROUTINE keybd_event(INT bvk,INT bscan,INT dwflags, INT dwextrainfo) LIBRARY "user32.dll"FUNCTION ulong GetForegroundWindow() LIBRARY "

11、user32.dll"FUNCTION ulong GetWindowText(ulong hwnd,ref string lpString,ulong cch) LIBRARY "user32.dll" ALIAS FOR "GetWindowTextA"Function long SendMessage(long hwnd,long wMsg,long wParam,string lParam) Library "user32.dll" Alias for "SendMessageA"end prot

12、otypestype variablesint atomidconstant integer MOD_ALT = 1constant integer MOD_CONTROL = 2constant integer MOD_SHIFT = 4/键盘常用ASCII码 /键Constant integer VK_BackQuote = 192/_-键Constant integer VK_Dash = 189/+=键Constant integer VK_Equal = 187/键Constant integer VK_LeftBracket = 219/键Constant integer VK_R

13、ightBracket = 221/|键Constant integer VK_BackSlash = 220/?/键Constant integer VK_Slash = 191/:;键Constant integer VK_SemiColon = 186/"'键Constant integer VK_Quote = 222/<,键Constant integer VK_Comma = 188/>.键Constant integer VK_Period = 190/ESC键 Constant integer VK_ESCAPE = 27/回车键 Constant

14、 integer VK_Enter = 13/TAB键 Constant integer VK_TAB = 9/Caps Lock键 Constant integer VK_CapsLock = 20/Shift键 Constant integer VK_SHIFT = 16/Ctrl键 Constant integer VK_CONTROL = 17/Alt键 Constant integer VK_MENU = 18/空格键 Constant integer VK_Spacebar = 32/退格键 Constant integer VK_BACK = 8/左徽标键 Constant in

15、teger VK_LWIN = 91/右徽标键 Constant integer VK_RWIN = 92/鼠标右键快捷键:Constant integer VK_APPS = 93 /Insert键 Constant integer VK_INSERT = 45/Home键 Constant integer VK_HOME = 36/PageUp Constant integer VK_PageUp = 33/PageDown Constant integer VK_PageDown = 34/End键 Constant integer VK_END = 35/Delete键 Constan

16、t integer VK_DELETE = 46/方向键() Constant integer VK_LEFTArrow = 37/方向键() Constant integer VK_UPArrow = 38/方向键() Constant integer VK_RightArrow = 39/方向键() Constant integer VK_DOWNArrow = 40/F1键 Constant integer VK_F1 = 112/F2键 Constant integer VK_F2 = 113/F3键 Constant integer VK_F3 = 114/F4键 Constant

17、integer VK_F4 = 115/F5键 Constant integer VK_F5 = 116/F6键 Constant integer VK_F6 = 117/F7键 Constant integer VK_F7 = 118/F8键 Constant integer VK_F8 = 119/F9键 Constant integer VK_F9 = 120/F10键 Constant integer VK_F10 = 121/F11键 Constant integer VK_F11 = 122/F12键 Constant integer VK_F12 = 123/Num Lock键

18、Constant integer VK_NUMLOCK = 144/小键盘0 Constant integer VK_NUMPAD0 = 96/小键盘1 Constant integer VK_NUMPAD1 = 97/小键盘2 Constant integer VK_NUMPAD2 = 98/小键盘3 Constant integer VK_NUMPAD3 = 99/小键盘4 Constant integer VK_NUMPAD4 = 100/小键盘5 Constant integer VK_NUMPAD5 = 101/小键盘6 Constant integer VK_NUMPAD6 = 1

19、02/小键盘7 Constant integer VK_NUMPAD7 = 103/小键盘8 Constant integer VK_NUMPAD8 = 104/小键盘9 Constant integer VK_NUMPAD9 = 105/小键盘. Constant integer VK_DECIMAL = 110/小键盘* Constant integer VK_MULTIPLY = 106/小键盘+ Constant integer VK_ADD = 107/小键盘- Constant integer VK_SUBTRACT = 109/小键盘/ Constant integer VK_D

20、IVIDE = 111/Pause Break键 Constant integer VK_PAUSE = 19/printscreenconstant integer VK_PRINTSCREEN = 44/Scroll Lock键 Constant integer VK_SCROLL = 145end variablesforward prototypespublic subroutine wf_char_code (string as, ref integer ai_vk, ref boolean ab_shift)public subroutine wf_paste (string as

21、)end prototypespublic subroutine wf_char_code (string as, ref integer ai_vk, ref boolean ab_shift);choose case ascase ' 'ai_vk = VK_Spacebarab_shift = falsecase ''ai_vk = VK_BackQuoteab_shift = truecase ''ai_vk = VK_BackQuoteab_shift = falsecase '_'ai_vk = VK_Dashab_s

22、hift = truecase '-'ai_vk = VK_Dashab_shift = falsecase '+'ai_vk = VK_Equalab_shift = truecase '='ai_vk = VK_Equalab_shift = falsecase ''ai_vk = VK_LeftBracketab_shift = truecase ''ai_vk = VK_LeftBracketab_shift = falsecase ''ai_vk = VK_RightBracketab_s

23、hift = truecase ''ai_vk = VK_RightBracketab_shift = falsecase '|'ai_vk = VK_BackSlashab_shift = truecase ''ai_vk = VK_BackSlashab_shift = falsecase '?'ai_vk = VK_Slashab_shift = truecase '/'ai_vk = VK_Slashab_shift = falsecase ':'ai_vk = VK_SemiColonab

24、_shift = truecase ''ai_vk = VK_SemiColonab_shift = falsecase '"'ai_vk = VK_Quoteab_shift = truecase "'"ai_vk = VK_Quoteab_shift = falsecase '<'ai_vk = VK_Commaab_shift = truecase ','ai_vk = VK_Commaab_shift = falsecase '>'ai_vk = VK_Pe

25、riodab_shift = truecase '.'ai_vk = VK_Periodab_shift = falsecase elseif isnumber(as) then ai_vk = asc(as)ab_shift = falseelseif len(as) <> 1 then ai_vk = 0returnend ifchoose case asc(as)case 65 to 90 /大写字母ai_vk = asc(as)ab_shift = truecase 97 to 122 /小写字母ai_vk = asc(UPPER(as)ab_shift =

26、 falsecase elseai_vk = 0returnend chooseend ifend chooseend subroutinepublic subroutine wf_paste (string as);int i, j, vkboolean lb_s, lb_capslockuo_ime lnstring lsls = space(255)GetWindowText(GetForegroundWindow(), ls, 255)/以下功能暂时没有实现/if not ln.of_is_chinese(GetForegroundWindow() then /如果目标程序使用的是中文

27、输入法,则切换到英文/keybd_event(VK_CONTROL,0,0,0)/keybd_event(VK_Spacebar,0,0,0)/keybd_event(VK_Spacebar,0,2,0)/keybd_event(VK_CONTROL,0,2,0)/end iflb_capslock = GetKeyState(VK_CapsLock) = 1j = len(as)for i = 1 to jwf_char_code( mid(as, i, 1), vk, lb_s)if vk <= 0 then continueif vk >= 65 and vk <= 9

28、0 thenif (lb_capslock and lb_s) or (not lb_capslock and not lb_s) thenkeybd_event(vk,0,0,0)keybd_event(vk,0,2,0)elsekeybd_event(VK_SHIFT,0,0,0)keybd_event(vk,0,0,0)keybd_event(vk,0,2,0)keybd_event(VK_SHIFT,0,2,0)end ifelseif not lb_s thenkeybd_event(vk,0,0,0)keybd_event(vk,0,2,0)elsekeybd_event(VK_S

29、HIFT,0,0,0)keybd_event(vk,0,0,0)keybd_event(vk,0,2,0)keybd_event(VK_SHIFT,0,2,0)end ifend ifnextend subroutineon w_main.createthis.st_2=create st_2this.st_1=create st_1this.sle_1=create sle_1this.Control=this.st_2,&this.st_1,&this.sle_1end onon w_main.destroydestroy(this.st_2)destroy(this.st

30、_1)destroy(this.sle_1)end onevent open;long ll-RCstring ls-strls-str = "My atom ID"atomid = GlobalAddAtom(ls-str) /得到惟一的ID,保证不和其他应用程序发生冲突ll-RC = RegisterHotKey(Handle(this), atomid, 0, 114) / 114为F3,注册的热键为F3if ll-RC = 0 then messagebox("错误","错误信息")end if end eventevent

31、other;IF wparam = atomid THEN/在这里编写处理程序if not keydown(keyf3!) then returnpost WF_PASTE(sle_1.text)END IFend eventevent close;UnregisterHotKey(handle(this),atomid)end eventtype st_2 from statictext within w_maininteger x = 69integer y = 140integer width = 965integer height = 64integer textsize = -9int

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论