ActiveX 部件不能创建对象: 'DynamicWrapper'

captivebird 2016-08-19 11:34:05
想实现远程桌面到服务器定时操作一个打印机,自动清空日志和重启
看到VBS sendkeys, 但是远程桌面断开后就失效了。
后来说Postmessage可以,就研究了几天,但是第一句就报错了,但是原作者说是没问题的,求解?不胜感激。。。。
PS: 服务器的版本是Window Server 2003

牛人说没问题但用写字板打开vbs文件第二句就报错的脚本如下:
报错信息:
Windows Scripr Host
ActiveX部件不能创建对象:‘DynamicWrapper’
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0
'
' NAME:
'
' AUTHOR: Microsoft , Microsoft
' DATE : 2014/8/10
'
' COMMENT:
'
'===================定义变量,注册API对象==================================
Dim UserWrap,hWnd

Set UserWrap = CreateObject("DynamicWrapper")
Set ws=WScript.CreateObject("wscript.shell")

WScript.Sleep 500

ws.Run "calc",0

WScript.Sleep 500

'Declare Function ShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
UserWrap.Register "USER32.DLL", "ShowWindow", "I=hl", "f=s", "R=l"

'Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

UserWrap.Register "USER32.DLL", "FindWindow", "I=ss", "f=s", "R=l"

'Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

UserWrap.Register "USER32.DLL", "SetWindowPos", "I=Hllllll", "f=s", "R=l"

'Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
UserWrap.Register "USER32.DLL", "PostMessage", "I=hlls", "f=s", "R=l"

'Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
UserWrap.Register "USER32.DLL", "SetWindowText", "I=Hs", "f=s", "R=l"

'Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
UserWrap.Register "USER32.DLL", "FindWindowEx", "I=llss", "f=s", "R=l"

'Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long

UserWrap.Register "USER32.DLL", "SetCursorPos", "I=ll", "f=s", "R=l"

'===================查找控件或者窗体句柄===============================


hWnd = UserWrap.FindWindow(vbNullString,"计算器")
'hWnd = UserWrap.FindWindow("kugou_ui",vbNullString)

hWnd1 = UserWrap.FindWindowEx(hWnd,0,vbNullString,Edit)

'UserWrap.ShowWindow hWnd,SW_HIDE

'UserWrap.SetWindowText hWnd,"hello world"

MsgBox hWnd
MsgBox hWnd1

'UserWrap.SetWindowPos hWnd, -1, 0, 0, 0, 0, 3

'MsgBox "将鼠标移到左上角"


'UserWrap.SetCursorPos 0,0


'=================定义系统常量===========================

Private Const WM_KEYDOWN = &H100
Private Const wm_keyup= &H101
Private Const WM_CHAR = &H102
Public Const WM_SYSKEYDOWN = &H104
Public Const WM_SYSKEYUP = &H105



'=================发送F1按键=====================
UserWrap.PostMessage hWnd, WM_KEYDOWN, 112, 0

'=================发送1002========================
UserWrap.PostMessage hWnd,WM_KEYDOWN ,97,0
UserWrap.PostMessage hWnd,WM_KEYDOWN ,96,0
UserWrap.PostMessage hWnd,WM_KEYDOWN ,96,0
UserWrap.PostMessage hWnd,WM_KEYDOWN ,98,0

...全文
7911 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2017-10-09
  • 打赏
  • 举报
回复
注册DynamicWrapper对应的DLL或OCX
u012939025 2017-10-06
  • 打赏
  • 举报
回复
问题解决了吗?

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧