TC官方合作论坛

标题: 自己写插件!源码! [打印本页]

作者: 冷月无痕    时间: 2012-2-26 23:17
标题: 自己写插件!源码!
貌似现在都没人写TC的专用插件?发个NNN年前的插件源码,有兴趣学插件的朋友可以参考下!

运行环境:VB6.0

测试环境:xp sp2 + vb6.0

测试结果:功能全部可用

DLL 声明部分的全部代码:

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String)
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lplFileName As String) As Long
Private Declare Function WindowFromPoint& Lib "user32" (ByVal X As Long, ByVal Y As Long)
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private 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
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Private Declare Function Module32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As MODULEENTRY32) As Long
Private Declare Function Module32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As MODULEENTRY32) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As rect) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (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
Private Type rect
top As Long
left As Long
endtop As Long
endleft As Long
End Type
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * 1024
End Type
Private Type MODULEENTRY32
dwSize As Long
th32ModuleID As Long
th32ProcessID As Long
GlblcntUsage As Long
ProccntUsage As Long
modBaseAddr As Byte
modBaseSize   As Long
hModule As Long
szModule As String * 256
szExePath As String * 1024
End Type
Private Const TH32CS_SNAPPROCESS = &H2
Private Const TH32CS_SNAPMODULE = &H8
Private Type POINTAPI
X As Long
Y As Long
End Type


这里是所有过程的代码:

Public Function KeyDown(jm) '按下某键
keybd_event jm, 0, 0, 0
End Function
Public Function KeyUp(jm) '弹起某键
keybd_event jm, 0, &H2, 0
End Function
Public Function KeyPress(jm, cs)  '按某键
For c = 1 To cs
keybd_event jm, 0, &H1, 0
Next
End Function
Public Function MouseMove(X, Y)        '移动鼠标
mouse_event &H8000 Or &H1, 0, 0, 0, 0
mouse_event &H1, X, Y, 0, 0
End Function
Public Function MousePressL(cs)        '按鼠标左键
For c = 1 To cs
mouse_event &H2 Or &H4, 0, 0, 0, 0
Next
End Function
Public Function MouseDownL()   '按下鼠标左键
mouse_event &H2, 0, 0, 0, 0
End Function
Public Function MouseUpL()    '弹起鼠标左键
mouse_event &H4, 0, 0, 0, 0
End Function
Public Function MousePressR(cs)          '按鼠标右键
For c = 1 To cs
mouse_event &H8 Or &H10, 0, 0, 0, 0
Next
End Function
Public Function MouseDownR()   '按下鼠标右键
mouse_event &H8, 0, 0, 0, 0
End Function
Public Function MouseUpR()  '弹起鼠标右键
mouse_event &H10, 0, 0, 0, 0
End Function
Public Function MousePressM(cs)        '按鼠标中键
For c = 1 To cs
mouse_event &H20 Or &H40, 0, 0, 0, 0
Next
End Function
Public Function MouseDownM()   '按下鼠标中键
mouse_event &H20, 0, 0, 0, 0
End Function
Public Function MouseUpM()  '弹起鼠标中键
mouse_event &H40, 0, 0, 0, 0
End Function
Public Function MouseXY() '返回现在鼠标位置
Dim p As POINTAPI
GetCursorPos p
MouseXY = p.X & "/" & p.Y
End Function
Public Function Delay(sj) '等待一定时间
Sleep sj
End Function
Public Function DLGetPixel(X, Y) '返回指定坐标的16进制颜色
DLGetPixel = GetPixel(GetDC(0), X, Y)
DLGetPixel = Hex(DLGetPixel)
End Function
Public Function HMouseClickL(hwnd, X, Y) '后台发送鼠标左键命令
Dim lParam As Long
lParam = (Y * &H10000) + X
PostMessage hwnd, &H201, 0&, ByVal lParam
  PostMessage hwnd, &H202, 0&, ByVal lParam
End Function
Public Function HMouseClickR(hwnd, X, Y) '后台发送鼠标右键命令
Dim lParam As Long
lParam = (Y * &H10000) + X
PostMessage hwnd, &H204, 0&, ByVal lParam
  PostMessage hwnd, &H205, 0&, ByVal lParam
End Function
Public Function HMouseClickM(hwnd, X, Y) '后台发送鼠标中命令
Dim lParam As Long
lParam = (Y * &H10000) + X
PostMessage hwnd, &H207, 0&, ByVal lParam
  PostMessage hwnd, &H208, 0&, ByVal lParam
End Function
Public Function HKeyPress(hwnd, jm) '后台发送键盘命令
PostMessage hwnd, &H101, jm, 0
End Function
Public Function DLDir(path)    '判断文件或文件夹是否存在
If Dir(path) = "" Then
DLDir = 0
Else
DLDir = 1
End If
End Function
Public Function INIRead(xj As String, zhi As String, lj As String) '读INI
Dim zs As String * 255
INIRead = left(zs, GetPrivateProfileString(xj, zhi, "", zs, Len(zs), lj))
End Function
Public Function INIWhile(xj As String, zhi As String, nr As String, lj As String) As String '写INI
INIWhile = WritePrivateProfileString(xj, zhi, nr, lj)
End Function
Public Function DLMouseHwnd() '返回鼠标现在指向的窗口句柄
Dim lRet As Long
Dim ptAPI As POINTAPI
GetCursorPos ptAPI
lRet = WindowFromPoint(ptAPI.X, ptAPI.Y)
DLMouseHwnd = lRet
End Function
Public Function DLQTHwnd() '返回现在激活窗口的句柄
DLQTHwnd = GetForegroundWindow
End Function
Public Function FindWin(lei, name) As Long  '返回指定窗口标题或类名的窗口句柄
If lei = 0 Then
lei = vbNullString
End If
FindWin = FindWindow(lei, name)
End Function
Public Function FindWinEx(hWnd1, hWnd2, lei, name) As Long   '查找一个父窗口的子窗口句柄
If lei = 0 Then
lei = vbNullString
End If
If name = 0 Then
name = vbNullString
End If
FindWinEx = FindWindowEx(hWnd1, hWnd2, lei, name)
End Function
Public Function DLPdWin(name) As Long   '判断窗口是否存在
DLPdWin = FindWindow(vbNullString, name)
If DLPdWin = 0 Then
DLPdWin = "no"
Else
DLPdWin = "yes"
End If
End Function
Public Function GetText(ByVal hwnd As Long) As String     '得到指定句柄的标题
longs = SendMessage(hwnd, &HE, 0, 0)
Dim Data As String
Data = String(longs, 0)
SendMessage hwnd, &HD, longs + 1, ByVal Data
GetText = Data
End Function
Public Function GetCName(hwnd) As String '得到指定句柄的类名
Dim sf As String * 254
Dim zf As String
zf = GetClassName(hwnd, sf, 255)
GetCName = Trim$(sf)
End Function
Public Function GetPath(hwnd As Long) As String   '返回指定句柄的路径
hWindow = hwnd
GetWindowThreadProcessId ByVal hWindow, pidWindow
Dim process As PROCESSENTRY32
Dim module As MODULEENTRY32
Dim hpSnapshot As Long
Dim hmSnapshot As Long
hpSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
If hpSnapshot > 0 Then
process.dwSize = Len(process)
If Process32First(hpSnapshot, process) Then
Do
If process.th32ProcessID = pidWindow Then
hmSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, process.th32ProcessID)
If hmSnapshot > 0 Then
module.dwSize = Len(module)
If Module32First(hmSnapshot, module) Then
GetPath = left(module.szExePath, InStr(module.szExePath, Chr(0)) - 1)
End If
CloseHandle (hmSnapshot)
End If
Exit Do
End If
Loop Until (Process32Next(hpSnapshot, process) < 1)
End If
CloseHandle (hpSnapshot)
End If
End Function
Public Function GetDX(hwnd) &#39;返回指定窗口客服区大小
Dim dx As rect
Dim X
X = GetClientRect(hwnd, dx)
GetDX = dx.top & "\" & dx.left & "\" & dx.endtop & "\" & dx.endleft
End Function
Public Function DLActiveWindows(hwnd As Long)   &#39;激活后台窗口(不能激活最小化的窗口)
SetForegroundWindow hwnd
End Function
Public Function DLWindowMax(hwnd As Long)  &#39;把已经最小化的窗口最大话并激活
ShowWindow hwnd, 3
End Function
Public Function DLWindowMIX(hwnd As Long)  &#39;最小化一个窗口
ShowWindow hwnd, 6
End Function
Public Function DLHideWindow(hwnd As Long)    &#39;隐藏一个窗口
SetWindowPos hwnd, 0, 0, 0, 0, 0, &H80
End Function
Public Function DLShowWindow(hwnd As Long)     &#39;显示一个隐藏的窗口
SetWindowPos hwnd, 0, 0, 0, 0, 0, &H40
End Function
Public Function DLMoveWindow(hwnd As Long, X As Long, Y As Long)  &#39;保持大小移动一个窗口到指定坐标
SetWindowPos hwnd, 0, X, Y, 0, 0, &H1
End Function
Public Function DLCloseWindow(hwnd As Long)  &#39;关闭指定窗口
SendMessage hwnd, &H10, 0, 0
End Function


代码完了····附件中有生成好的DLL


代码很简单,只起到抛砖引玉的作用,汗,欢迎大神们劈砖!




作者: 小西    时间: 2012-2-26 23:22
:~都是英文,看不懂:~
作者: 梧桐树下雨    时间: 2012-2-26 23:37
:D有没有 c 写的 vb 看着有点别扭
作者: tclx    时间: 2012-2-26 23:43
回复一下 看看
作者: 冷月无痕    时间: 2012-2-26 23:47
回复 3楼梧桐树下雨的帖子

c 吖 都还给老师老 只怪当年教C语言的老师长得太漂亮 上课只顾看她了:P
作者: stxuhong    时间: 2012-2-26 23:52
简单是我的偶像,想你做我的师父
作者: cylhb    时间: 2012-2-27 00:09
为什么不早2天发呢-。-我前天百度了N久,就想知道怎么写插件。。
搞了一个通宵才搞定,早有这个就不用这么久了。。。
作者: 爱倩柔    时间: 2012-2-27 00:47
kanzhe danteng
作者: lyf1314    时间: 2012-2-27 10:37
不错不错
作者: q79985718    时间: 2012-2-27 15:32
不懂哦
作者: 一生何求    时间: 2012-3-2 11:50
回复 1楼smtmangle的帖子

冷月的东西 支持下
作者: wangyiyouxi    时间: 2012-3-10 14:46
回复 1楼smtmangle的帖子

:smoke:P:-D
作者: 迷糊    时间: 2012-3-13 17:25
弄下来 看看
作者: 表面花心    时间: 2012-3-15 00:24
学习了
作者: hnxy2010    时间: 2012-3-15 01:49
看看,
作者: stevenxiexie    时间: 2012-3-16 19:10
支持.........
作者: atlantic    时间: 2012-3-19 22:09
dfdsfdsfsdf
作者: 乱世尘埃    时间: 2012-3-24 23:45
:D学习学习
作者: zhangopg    时间: 2012-3-26 06:41
看不懂
作者: yangziye    时间: 2012-3-27 02:23
看不懂的小白飘过~加油
作者: dnldnl    时间: 2012-4-3 14:41
学习学习
作者: qsmoon    时间: 2012-4-4 15:59
求有跟进的,想学习!!!
作者: yyjjww67    时间: 2012-4-5 07:32
新手来学习一下
作者: dzh    时间: 2012-4-8 21:55
我要拜师,可否收???
作者: 落花随流    时间: 2012-4-15 12:56
强大
作者: laozeixp    时间: 2012-4-16 00:35
不错的代码
作者: kwwl200601    时间: 2012-4-17 15:18
回复 1楼冷月无痕的帖子

留个脚印,慢慢学习
作者: chenai    时间: 2012-4-20 22:10
看看:-o:-o
作者: loking    时间: 2012-4-28 00:02
:giggle这是好东西
作者: kk595    时间: 2012-4-28 00:26
             虽然看不懂   但是冷月的 必须顶、、、、、、、、、
作者: 龙归_莫言    时间: 2012-4-28 06:31
有C++的吗?VB不会
作者: z0230226    时间: 2012-4-30 20:09
太厉害了啊
作者: zsf414455701    时间: 2012-5-1 09:35
看一下
作者: 4133789    时间: 2012-5-2 21:14
好吧,表示支持一下.
作者: dzb123    时间: 2012-5-3 00:14
这个给力  学习下
作者: qianfeng752    时间: 2012-5-11 16:50
太疯狂了,这就是兰博基尼的效果 。。。。。。。。。
作者: LDKolar    时间: 2012-5-19 12:16
~~~~~~学习学习
作者: meihuhu    时间: 2012-5-24 07:45
学习啦
作者: ksap787523    时间: 2012-5-25 09:58
回复 1楼冷月无痕的帖子

牛逼啊 能出个后台找字、找图、找色的不?
作者: zdy77233647    时间: 2012-6-1 00:47
回复 1楼冷月无痕的帖子

看看
作者: kkkkkkk    时间: 2012-6-1 12:58
回复 1楼冷月无痕的帖子

新人不会用吖
作者: 我喜欢TC    时间: 2012-6-4 19:24
看看
!!看看!!
作者: bucks1964    时间: 2012-6-6 13:08
看不懂的小白飘过~加油
作者: jimye0526    时间: 2012-6-12 16:53
看看看看看
作者: jiangchencong    时间: 2012-6-17 21:41
回复下看看
作者: jiangchencong    时间: 2012-6-17 21:44
这个插件如何在Tc中使用?
作者: 冷月无痕    时间: 2012-6-18 06:42
回复 46楼jiangchencong的帖子

设置一个COM接口,就可以调用了
作者: jiangchencong    时间: 2012-6-18 11:16
初学者
就是不知道如何设置com接口呢~~
作者: feng123144    时间: 2012-6-19 02:12
试看看
作者: 1529949000    时间: 2012-6-20 02:57
***** 该内容需会员回复才可浏览 ********** 该内容需会员回复才可浏览 *****
作者: 1529949000    时间: 2012-6-20 03:08
http://115.com/file/dnoyikfy
作者: zgf1125    时间: 2012-6-25 16:17
刚接触  还看不懂 顶下 有机会一定向你求教
作者: nono2828    时间: 2012-7-11 04:06
:~都是英文,看不懂:~
作者: hackdiy    时间: 2012-7-12 12:28
好东西!!!!
作者: shena    时间: 2012-7-14 20:11
看看 好东西
作者: 453480439    时间: 2012-7-16 08:29
对对对地方反反复复
作者: 阿笨    时间: 2012-7-17 09:30
谢谢分析!
作者: 496274079    时间: 2012-7-20 00:13
原来这样啊~
作者: 6zq555    时间: 2012-7-21 16:55
提示: 作者被禁止或删除 内容自动屏蔽
作者: 古人传    时间: 2012-7-24 02:35
en enen o
作者: haoyuanxin    时间: 2012-7-25 13:53
简单的API
加VB,……………………

其实大家都可以学着做,这个并不难,
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags
   声明:子程序/函数  函数名        库文件名(API)  参数:(AS  数据类型)

As Long, ByVal dwExtraInfo As Long)
作者: bobobo    时间: 2012-8-6 16:14

作者: 无脚本小怪    时间: 2012-8-21 15:49
啊啊啊啊啊啊
作者: hongying1120    时间: 2012-8-24 23:16
回帖是美德
作者: studio    时间: 2012-8-27 02:45
回复一下 看看
作者: charwill    时间: 2012-8-29 09:48
抱走了 谢谢分享
作者: wl_20110226    时间: 2012-8-29 10:09
回复 1楼冷月无痕的帖子

看看
作者: lzwquit    时间: 2012-9-1 11:47
求后台输入法插件
类似  mydll.input(整型 hwnd,字符型 text)
作者: uous    时间: 2012-9-5 11:15
我收了。
作者: chw    时间: 2012-9-9 21:52
看看
作者: sspray    时间: 2012-9-9 22:14
看看
作者: ahxx    时间: 2012-9-11 00:29
11111111111
作者: myismaln    时间: 2012-9-16 19:48
支持写插件给大家用的高手
作者: zhaoogua    时间: 2012-9-17 20:03
不错不错
作者: rwind    时间: 2012-9-29 09:33
回复 1楼冷月无痕的帖子

看看
作者: 187144831    时间: 2012-9-29 13:04
上的
作者: chw    时间: 2012-9-29 23:13
不错,嘻嘻嘻
作者: 1051785287    时间: 2012-10-3 02:07
jumbo
作者: tclhs    时间: 2012-10-15 16:54
楼主太强大了。
作者: xu364073474    时间: 2012-10-18 15:42
领教了
作者: jxwwdt    时间: 2012-10-20 09:45
秒了
作者: molunshang    时间: 2012-10-27 00:17
看不懂啊!!!
作者: 想学坏的小孩    时间: 2012-10-27 22:17
回复 1楼冷月无痕的帖子

看看源码
作者: suweiwang0001    时间: 2012-10-27 22:46
新手 刚开始研究 还是 不怎么懂 怎么办
作者: jxwwdt    时间: 2012-11-18 07:43
请问这插件的功能函数的接口id是?
作者: 418958500    时间: 2012-11-18 17:39
看看
作者: zx2003ok    时间: 2012-11-18 22:51
生成 DLL 通用性如何?
作者: 154691780    时间: 2012-11-26 15:25
这可以是个好东西。
作者: 154691780    时间: 2012-11-26 16:01
回复 50楼1529949000的帖子

我想知道怎么在tc中调用这个dll, 能给出个范例吗?

比如发送鼠标单击动作的例子。
作者: 154691780    时间: 2012-11-26 16:01
我想知道怎么在tc中调用这个dll, 能给出个范例吗?

比如发送鼠标单击动作的例子。
作者: 307443877    时间: 2012-11-29 15:51
看看
作者: 13755281481    时间: 2012-11-29 21:04
回复 1楼冷月无痕的帖子

RE:自己写插件!源码!
作者: 9992374711    时间: 2012-11-29 23:34
有没有用易语言写的插件呢
作者: 1092031358    时间: 2012-12-1 10:37
回复 1楼冷月无痕的帖子

不错
作者: ms5084456    时间: 2012-12-4 21:07
研究研究
作者: zhou1033675108    时间: 2012-12-6 11:53
完全看不懂
作者: zxl19891030    时间: 2012-12-12 09:15

作者: poyo201    时间: 2012-12-12 19:27
回复 1楼冷月无痕的帖子

了解一下
作者: 米老头    时间: 2012-12-14 11:33
NNNNNNNN
作者: yn01    时间: 2012-12-17 16:49
111111111111




欢迎光临 TC官方合作论坛 (http://bbs.52tc.co/) Powered by Discuz! X3.1