## 说明:
本案例是使用clsWindow2.2框架自动化操作腾讯课堂,根据指定课堂ID进入直播。
## 测试环境:
>[info]win7x64 + clsWindow2.2 + 腾讯课堂客户端V1.5.4.35
**说明:** 如果不能用可能是您的版本太旧,或者操作系统版本不一样,请仔细检查并修改相应代码。以下代码2020-02-28测试通过,本代码不保证更新。
## 声明:
>[warning]本代码免费,可用于任何商业用途,但请勿做非法用途,所引起的一切后果由使用者本人承担。
## 代码:
请向窗口添加按钮Command1,复制下面代码后,打开腾讯课堂并登录,然后运行。
```
'点击相应菜单打开窗口“打开课堂”
Private Sub Command1_Click()
Dim w As New clsWindow
If w.GetWindowByTitleEx("腾讯课堂", 1).Hwnd <> 0 Then
w.Focus
w.ClickPoint 30, 30, , , 100, 500 '点击左上角坐标拉出菜单,也就是图中1处
w.ClickPoint 30, 150, , , 100, 500 '点击菜单“更多”坐标,也就是图中2处
w.ClickPoint 230, 150, , , 100, 500 '点击菜单“上课ID进入课堂”坐标,也就是图中3处
End If
End Sub
'输入ID进入课堂
Private Sub Command2_Click()
Dim w As New clsWindow
If w.GetWindowByTitle("打开课堂", 1).Hwnd <> 0 Then
w.Focus
SendKeys "100140792" & vbTab & vbCrLf '制表符表示切换到按钮,然后发送回车表示点击确定
End If
End Sub
```
第一个按钮是找到腾讯课堂窗口然后点击一些列菜单打开课堂窗口,第二个按钮是自动输入id然后进入的。
![](https://img.kancloud.cn/91/e4/91e4ce9e074ec7603edebaa48a539f7d_518x168.png)
**按钮1操作如下图所示:**
![](https://img.kancloud.cn/3e/f8/3ef840617c9487d6e44033ee4fde235f_369x323.png)
**按钮2操作如下图所示:**
![](https://img.kancloud.cn/32/a8/32a83f4899ed6c89c70746e42b5efbf2_312x180.png)
**工程打包下载地址:** https://pan.baidu.com/s/1p6e8drFmSriuyHS_uZw4HA 提取码: pjyf
- 关于clsWindow
- 一、获取窗口
- GetWindowByTitle 函数
- GetWindowByTitleEx 函数
- GetWindowByClassName 函数
- GetWindowByClassNameEx 函数
- GetWindowByPoint 函数
- GetWindowByAppName 函数
- GetWindowByAppNameEx 函数
- GetWindowByCursorPos 函数
- GetWindowByPID 函数
- GetWindowByHwnd 函数
- Load 函数(同GetWindowByHwnd)
- 二、操作窗口
- Focus 方法
- SetFocus 方法(同Focus)
- FadeIn 方法
- FadeOut 方法
- Transparent 函数
- SetTransparent 函数(同Transparent)
- MakeTransparent 函数(同Transparent)
- Shake 方法
- CloseWindow 函数
- ClassName 属性
- Caption 属性
- Text 属性(同Caption)
- Title 属性(同Caption)
- Value 属性(同Caption)
- ZOrder 方法
- Left 属性
- Top 属性
- Width 属性
- Height 属性
- Visible 属性
- Enabled 属性
- WindowState 属性
- AlphaBlend 属性
- TransparentColor 属性
- CheckWindow 函数
- Move 函数
- MoveToCenter 函数
- Show 函数
- Hide 函数
- Refresh 方法
- SetPosBottom 函数
- SetPosFront 函数
- SetPosNormal 函数
- SetTop 函数
- IsTopMost 函数
- IsForegroundWindow 属性
- Maximized 函数
- Minimized 函数
- Normal 函数
- Restore 函数(同Normal)
- 三、操作控件
- GetElementHwndByText 函数
- GetElementHwndByClassName 函数
- GetElementTextByText 函数
- GetElementTextByClassName 函数
- GetClassNameByHwnd 函数
- GetTextByHwnd 函数
- GetCaptionByHwnd 函数(同GetTextByHwnd)
- SetElementTextByText 函数
- SetElementTextByClassName 函数
- SelectComboBoxIndex 函数
- AppendElementTextByClassName 函数
- Click 函数
- ClickElementByText 函数
- ClickElementByClassName 函数
- SendKeys 方法
- Paste 方法
- FileToClipboard 函数
- ClipboardSetText 函数
- 四、鼠标坐标相关
- ClickCurrentPoint 方法
- ClickPoint 方法
- ClickPointBackground 方法
- SetCursor 方法
- MoveCursor 方法(同SetCursor)
- MoveCursorTo 方法(同SetCursor)
- SetPoint 方法(同SetCursor)
- GetCursorPoint 函数
- GetCursorPosCurrent 函数(同GetCursorPoint)
- MouseLeftDown 方法
- MouseLeftUp 方法
- MouseRightDown 方法
- MouseRightUp 方法
- DragTo 方法
- DragToEx 方法
- 五、应用程序相关
- AppPath 函数
- AppName 函数
- IsWin64 函数
- CommandLine 函数
- AppCommandLine 函数(同CommandLine)
- CloseApp 函数
- ProcessID 函数
- PID 函数(同ProcessID)
- 六、公有方法属性等
- hWnd 公有变量
- DebugMe 公有变量
- Wait 方法
- Version 方法
- 使用范例
- 01 控制微信发送消息
- 02 控制QQ发送消息
- 03 QQ登录器
- 04 花式调用计算器
- 05 用鼠标在画图工具上画圆
- 06 控制记事本输入并保存
- 07 随机移动鼠标防锁屏
- 08 根据ID进入腾讯课堂
- 09 限制程序重复打开
- 10 控制c2p软件将ceb转换为pdf格式
- 11 实战:微便签-窗口特效
- 12 实战:窗口图钉-窗口置顶
- 13 实战:微型按键精灵,录制和播放鼠标动作
- 一些Q&A
- 01 这个框架是免费的吗?
- 02 无句柄的控件元素如何操作?
- 03 目标窗体中有相同类名输入框如何区分填写?
- 04 为什么win10下最大化不生效?
- 05 如何确定绝对或相对坐标?
- 06 相同标题的窗口如何得到所有句柄?
- 联系我们