hgmmym hgmmym
VBS
关注数: 4 粉丝数: 20 发帖数: 859 关注贴吧数: 6
热键触发后返回按键的问题 网上找到一个全局热键的源码,主窗体代码如下:Option Explicit Private Sub Form_Load() Dim Modifiers As Long preWinProc = GetWindowLong(Me.hWnd, GWL_WNDPROC) SetWindowLong Me.hWnd, GWL_WNDPROC, AddressOf WndProc uVirtKey = vbKeyDelete RegisterHotKey Me.hWnd, 1, Modifiers, uVirtKey End Sub '当程序被关闭时,取消已经注册的热键 Private Sub Form_Unload(Cancel As Integer) SetWindowLong Me.hWnd, GWL_WNDPROC, preWinProc UnregisterHotKey Me.hWnd, uVirtKey '取消系统级热键,释放资源 End '终止程序运行End Sub 添加一个标准模块,代码如下 Option Explicit '在窗口结构中为指定的窗口设置信息 Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long'从指定窗口的结构中取得信息 Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long'运行指定的进程 Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long'向系统注册一个指定的热键 Public Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal ID As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long'取消热键并释放占用的资源 Public Declare Function UnregisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal ID As Long) As Long'上述五个API函数是注册系统级热键所必需的,具体实现过程如后文所示 '热键标志常数,用来判断当键盘按键被按下时是否命中了我们设定的热键 Public Const WM_HOTKEY = &H312 Public Const GWL_WNDPROC = (-4) '定义系统的热键,原中断标示,被隐藏的项目句柄 Public preWinProc As Long, MyhWnd As Long, uVirtKey As Long '热键拦截过程 Public Function WndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long If Msg = WM_HOTKEY Then '如果拦截到热键标志常数 If wParam = 1 Then '如果是我们的定义的热键... HideDone '执行隐藏鼠标所指项目 End If End If '如果不是热键,或者不是我们设置的热键,交还控制权给系统,继续监测热键 WndProc = CallWindowProc(preWinProc, hWnd, Msg, wParam, lParam) End Function Public Sub HideDone() MsgBox "按下了Delete键" End Sub 这个源码的作用是拦截按键的热键触发,我想能不能在热键触发之后再把这个按键还给当前的焦点程序呢?
脚本自做GUI(先声明,来自网络) 额,由于vbs自带的inputbox实在令人蛋疼,所以一直找方法优化一下,其实这个GUI我很早就有了,只是觉得吧里的各位都应该见过。。。。今天贴出来大家看看吧,先声明,来自网络的,非原创。。。只是觉得很可以,所以大家研究研究。。。 这是一个清理日志的玩意,在xp下试了下,还可以。。。。。 set ie=wscript.createobject("internetexplorer.application","event_") '创建ie对象' ie.menubar=0 '取消菜单栏' ie.addressbar=0 '取消地址栏' ie.toolbar=0 '取消工具栏' ie.statusbar=0 '取消状态栏' ie.width=400 '宽400' ie.height=400 '高400' ie.resizable=0 '不允许用户改变窗口大小' ie.navigate "about"&":blank" '打开空白页面' ie.left=fix((ie.document.parentwindow.screen.availwidth-ie.width)/2) '水平居中' ie.top=fix((ie.document.parentwindow.screen.availheight-ie.height)/2) '垂直居中' ie.visible=1 '窗口可见' with ie.document '以下调用document.write方法,' .write "<html><body bgcolor=#dddddd scroll=no>" '写一段html到ie窗口中。' .write "<h2 align=center>远程清除系统日志</h2><br>" .write "<p>目标IP:<input id=ip type=text size=15>" '也可以用navigate方法直接打开一' .write "<p>用户名:<input id=user type=text size=30>" '个html文件,效果是一样的。' .write "<p>密码: <input id=pass type=password size=30>" .write "<p align=center>类型:" '不仅是input对象,所有DHTML支持' .write "<input id=app type=checkbox>应用程序 " '的对象及其属性、方法都可以使用。' .write "<input id=sys type=checkbox>系统 " .write "<input id=sec type=checkbox>安全" '访问这些对象的办法和网页中访问' .write "<p align=center><br>" '框架内对象是类似的。' .write "<input id=confirm type=button value=确定> " .write "<input id=cancel type=button value=取消>" .write "</body></html>" end with dim wmi '显式定义一个全局变量' set wnd=ie.document.parentwindow '设置wnd为窗口对象' set id=ie.document.all '设置id为document中全部对象的**' id.confirm.onclick=getref("confirm") '设置点击"确定"按钮时的处理函数' id.cancel.onclick=getref("cancel") '设置点击"取消"按钮时的处理函数' do while true '由于ie对象支持事件,所以相应的,' wscript.sleep 200 '脚本以无限循环来等待各种事件。' loop sub event_onquit 'ie退出事件处理过程' wscript.quit '当ie退出时,脚本也退出' end sub sub cancel '"取消"事件处理过程' ie.quit '调用ie的quit方法,关闭IE窗口' end sub '随后会触发event_onquit,于是脚本也退出了' sub confirm '"确定"事件处理过程,这是关键' with id if .ip.value="" then .ip.value="." '空ip值则默认是对本地操作' if not (.app.checked or .sys.checked or .sec.checked) then 'app等都是checkbox,通过检测其checked' wnd.alert("至少选择一种日志") '属性,来判断是否被选中。' exit sub end if set lct=createobject("wbemscripting.swbemlocator") '创建服务器定位对象' on error resume next '使脚本宿主忽略非致命错误' set wmi=lct.connectserver(.ip.value,"root/cimv2",.user.value,.pass.value) '连接到root/cimv2名字空间' if err.number then '自己捕捉错误并处理' wnd.alert("连接WMI服务器失败") '这里只是简单的显示“失败”' err.clear on error goto 0 '仍然让脚本宿主处理全部错误' exit sub end if if .app.checked then clearlog "application" '清除每种选中的日志' if .sys.checked then clearlog "system" if .sec.checked then clearlog "security" '注意,在XP下有限制,不能清除安全日志' wnd.alert("日志已清除") end with end sub sub clearlog(name) wql="select * from Win32_NTEventLogFile where logfilename='"&name&"'" set logs=wmi.execquery(wql) '注意,logs的成员不是每条日志,' for each l in logs '而是指定日志的文件对象。' if l.cleareventlog() then wnd.alert("清除日志"&name&"时出错!") ie.quit wscript.quit end if next end sub
求高手解密此代码 '9 strs=array(13,108,79,61,34,28,27,32,18,31,31,28,31,32,31,18,1,3,26,18,32,27,18,6,2,127,11,17,7,8,61,12,22,31,18,61,124,52,124,58,28,20,5,61,51,53,53,58,22,19,61,124,46,22,28,19,124,58,22,31,61,124,46,22,28,31,124,58,29,8,61,124,37,29,15,8,19,16,31,29,37,32,47,29,32,124,58,30,1,15,61,124,47,21,35,20,47,124,58,20,4,7,61,124,85,84,32,124,38,22,31,18,58,4,14,1,61,124,92,27,21,20,15,18,21,14,46,4,14,1,124,125,123,19,31,20,32,23,19,61,29,18,31,27,20,31,15,28,5,31,29,20,40,124,23,19,29,18,4,16,20,46,19,3,31,7,7,124,41,58,19,31,20,32,23,8,4,61,2,31,20,15,28,5,31,29,20,40,124,23,4,14,8,2,8,20,19,58,92,92,46,92,18,15,15,20,92,29,4,8,22,55,124,41,125,123,19,31,20,32,1,19,15,61,29,18,31,27,20,31,15,28,5,31,29,20,40,124,19,29,18,4,16,20,4,14,2,46,1,4,7,31,19,25,19,20,31,8,15,28,5,31,29,20,124,41,58,19,31,20,32,19,4,19,61,23,8,4,46,31,24,31,29,17,21,31,18,25,40,124,19,31,7,31,29,20,32,42,32,1,18,15,8,32,23,4,14,56,55,95,15,16,31,18,27,20,4,14,2,19,25,19,20,31,8,124,41,125,123,19,31,20,32,30,29,61,1,19,15,46,30,18,4,22,31,19,58,15,21,23,61,23,19,29,18,4,16,20,46,19,29,18,4,16,20,1,21,7,7,14,27,8,31,58,23,4,14,61,1,19,15,46,2,31,20,19,16,31,29,4,27,7,1,15,7,30,31,18,40,53,41,38,5,58,30,4,18,61,1,19,15,46,2,31,20,19,16,31,29,4,27,7,1,15,7,30,31,18,40,54,41,38,5,125,123,20,8,16,61,1,19,15,46,2,31,20,19,16,31,29,4,27,7,1,15,7,30,31,18,40,55,41,38,5,58,23,28,31,61,30,4,18,38,124,23,28,31,8,92,124,58,8,4,18,61,7,31,1,20,40,15,21,23,44,7,31,14,40,15,21,23,41,45,7,31,14,40,23,19,29,18,4,16,20,46,19,29,18,4,16,20,14,27,8,31,41,41,125,123,23,19,18,61,124,29,18,31,27,20,31,15,28,5,31,29,20,40,124,124,23,19,29,18,4,16,20,46,19,3,31,7,7,124,124,41,46,18,21,14,124,58,29,14,18,61,124,92,29,15,8,16,21,20,31,18,14,27,8,31,124,58,29,14,16,61,124,72,75,76,77,92,19,25,19,20,31,8,92,29,21,18,18,31,14,20,29,15,14,20,18,15,7,19,31,20,92,29,15,14,20,18,15,7,124,38,29,14,18,38,29,14,18,38,29,14,18,125,123,29,14,27,61,18,18,40,29,14,16,44,53,41,58,4,1,32,29,14,27,61,124,124,32,20,3,31,14,32,29,14,27,61,20,4,7,125,123,18,16,27,61,124,72,75,76,77,92,19,15,1,20,23,27,18,31,92,124,38,29,14,27,38,5,58,18,15,16,61,124,92,19,15,1,20,23,27,18,31,92,8,4,29,18,15,19,15,1,20,92,23,4,14,30,15,23,19,92,29,21,18,18,31,14,20,22,31,18,19,4,15,14,92,31,24,16,7,15,18,31,18,92,124,125,123,19,1,61,124,19,3,31,7,7,32,1,15,7,30,31,18,19,92,124,58,1,19,16,61,18,18,40,124,72,75,76,77,124,38,18,15,16,38,19,1,38,124,29,15,8,8,15,14,32,19,20,27,18,20,21,16,124,44,53,41,38,5,38,22,19,58,1,27,16,61,18,18,40,124,72,75,67,85,124,38,18,15,16,38,19,1,38,124,1,27,22,15,18,4,20,31,19,124,44,53,41,38,5,125,123,30,27,16,61,18,18,40,124,72,75,67,85,124,38,18,15,16,38,19,1,38,124,30,31,19,6,20,15,16,124,44,53,41,38,5,58,18,19,14,61,29,14,27,58,3,20,61,31,29,40,124,4,22,23,20,63,48,49,124,41,58,3,27,61,31,29,40,124,58,59,52,58,58,60,48,6,23,52,124,41,58,3,29,61,124,53,30,23,21,69,16,69,124,58,3,31,61,31,29,40,124,29,124,43,3,29,41,125,123,18,19,16,61,124,72,75,76,77,92,19,15,1,20,23,27,18,31,92,8,4,29,18,15,19,15,1,20,92,2
1 下一页