标题: [文件操作] 批处理可以让qq登陆吗? [打印本页]
作者: sepwolves 时间: 2015-11-17 08:37 标题: 批处理可以让qq登陆吗?
比如我用start "" "d:\...\qq.exe"调用qq之后,出现登陆窗口,我要用什么代码才能让它自己登陆,然后最小化呢?
作者: ads350668398 时间: 2015-11-17 14:40
能 网了怎么做了就是
作者: shuzai 时间: 2015-11-17 15:16
qq登录窗不知道能不能用sendkey,你试试呗
作者: sepwolves 时间: 2015-11-18 08:06
回复 3# shuzai
还有sendkey功能噢
作者: ygqiang 时间: 2015-11-18 18:05
比如我用start "" "d:\...\qq.exe"调用qq之后,出现登陆窗口,我要用什么代码才能让它自己登陆,然后最小化 ...
sepwolves 发表于 2015-11-17 08:37
vbs代码。。。- RunAsAdminstrator
- Function GetQQPath()
- Const HKEY_LOCAL_MACHINE = &H80000002
- Dim s, sREG, sDis, sPath, oReg, fso
- sPath = ""
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set Wss = CreateObject("Wscript.Shell")
- Set oReg = GetObject("Winmgmts:\\.\Root\Default:StdRegProv")
- sREG = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
- oReg.EnumKey HKEY_LOCAL_MACHINE, sREG, s
- If IsNull(s) = False Then
- For i = 0 To Ubound(s)
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "DisplayName", sDis
- If Ucase(sDis) = "腾讯QQ" Then
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "InstallLocation", sPath
- End If
- Next
- End If
- sREG = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
- oReg.EnumKey HKEY_LOCAL_MACHINE, sREG, s
- If IsNull(s) = False Then
- For i = 0 To Ubound(s)
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "DisplayName", sDis
- If Ucase(sDis) = "腾讯QQ" Then
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "InstallLocation", sPath
- End If
- Next
- End If
- If sPath = "" Then
- 'MsgBox "未找到 腾讯QQ 的注册表路径", 4096
- 'CreateObject("Wscript.Shell").Popup "未找到 腾讯QQ 的注册表路径", 5
- Wss.Popup "未找到 腾讯QQ 的注册表路径", 5
- WScript.Quit(1)
- Else
- GetQQPath = fso.BuildPath(sPath, "Bin\QQ.exe")
- If fso.FileExists(GetQQPath) = False Then
- 'MsgBox "未找到 " & GetQQPath, 4096
- 'CreateObject("Wscript.Shell").Popup "未找到 " & GetQQPath, 5
- Wss.Popup "未找到 " & GetQQPath, 5
- WScript.Quit(2)
- End If
- End If
- End Function
-
- Sub RunAsAdminstrator()
- Dim shell, os, arg, ver
- Set shell = CreateObject("Shell.Application")
-
- For Each os In GetObject("WinMgmts:").InstancesOf("Win32_OperatingSystem")
- ver = Left(os.Version, 3)
- Next
- If ver <> "6.1" And ver <> "6.0" And ver <> "6.3" Then Exit Sub
-
- For Each arg In WScript.Arguments.Named
- If LCase(arg) = "uac" Then Exit Sub
- Next
-
- Shell.ShellExecute "wscript.exe", Chr(34) & _
- WScript.ScriptFullName & Chr(34) & " /uac", "", "runas", 1
- WScript.Quit
- End Sub
-
-
- '定义QQ程序路径、帐号、密码
- Dim Program1,a,b,c
-
- Program1 = GetQQPath()
- 'MsgBox Program1
- Set WshShell=createobject("wscript.shell")
-
- '运行QQ主程序
- Set oExec=WshShell.Exec(Program1)
- WScript.Sleep 5000
- '激活QQ窗口
- WshShell.AppActivate "qq"
- wshShell.SendKeys "+{TAB}"
- WScript.Sleep 2000
- '输入帐号
- a="24545640"
- WshShell.SendKeys a
- WScript.Sleep 1000
- WshShell.SendKeys "{TAB}"
- '输入帐号
- a="24545640"
- WshShell.SendKeys a
- WScript.Sleep 1000
- WshShell.SendKeys "{TAB}"
- WScript.Sleep 2000
- '输入密码
- b="245756"
- WshShell.SendKeys b
- WScript.Sleep 2000
-
- WshShell.SendKeys "{ENTER}"
复制代码
作者: yiwuyun 时间: 2015-11-18 19:29
看了一下代码,感觉75行
75.WshShell.AppActivate "qq"
有问题,可能并不能激活qq 对话框,因此下了代码,试了一下,好像真的不能哦。测试环境:WIN10和最新版QQ,如果我没记错,好像应该 用进程ID才行样。(不知是不是我没用对)。
作者: ygqiang 时间: 2015-11-18 22:08
看了一下代码,感觉75行
75.WshShell.AppActivate "qq"
有问题,可能并不能激活qq 对话框,因此下了代码 ...
yiwuyun 发表于 2015-11-18 19:29
win7 64系统环境下,
这个vbs代码,实现自动登录qq。以前好用,
最近就不好用了。。。。
作者: CrLf 时间: 2015-11-18 22:27
QQ 貌似有安全机制,输入密码时用钩子接管键盘输入,对输入有影响(监听会得到乱码),但不知道是否也作用于输出
别问我怎么知道的
作者: yiwuyun 时间: 2015-11-18 22:49
现在的新版QQ启动时至少会出现两个进程,不能用title去激活,而且用title激活原来也很不可靠,所以我以前都是用进程ID去激活程序的。现在也应用进程ID去激活,并且我试了下,QQ只能是进程ID大的那个才行。
作者: ygqiang 时间: 2015-11-19 10:08
回复 9# yiwuyun
你好。。那应该如何修改楼上的那个vbs代码?谢谢了
作者: yiwuyun 时间: 2015-11-19 23:02
本帖最后由 yiwuyun 于 2015-11-20 07:20 编辑
- if ($true){}# == ($true){}# goto ___yiwuyun
- <#BeginBatOperation#
- :___yiwuyun
- @echo off&setlocal&cls
- (echo $yiwuyun_fileName="%~f0"&echo $strPath="%~dp0"&type "%~f0")|powershell -command -
- exit/b 0
- #EndBatOperation#>
-
- <#StartPowerShell#>
- $QQPath=Get-ChildItem -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"|%{if($_.GetValue("DisplayName") -eq "腾讯QQ"){$_.GetValue("InstallLocation");}}
- $QQProgram=Join-Path -Path $QQPath -ChildPath bin\qq.exe;
- $wsh=New-Object -ComObject "wscript.shell";
- $wsh.Exec($QQProgram);
-
- ###此时有10秒中的时间可以作一些其他操作,将焦点转移到其他窗口中去。
- sleep 10;
- while(-not $wsh.AppActivate("qq")){;};
- $wsh.SendKeys("{ESC}");
- while(-not $wsh.AppActivate("qq")){;};
- $wsh.SendKeys("{ENTER}");
- $wsh.SendKeys("{ENTER}");
- ###猜测由于有QQ保护进程作怪,因此上述操作需要重复两次
-
- $wsh.SendKeys("12345678{ENTER}yiwuyun{ENTER}");
-
-
- ###无法解决QQ登陆一次之后记住帐号的情形。我想要彻底解决只有删掉QQ号码下的配置文件才行。这个没有试了。
-
- <#EndPowerShell#>
复制代码
<###
以上代码为批处理,扩展名为bat
vbs我不太熟了,但思路是一样,你可以照写。我前面说的用title会出问题不知是原来我写哪个小程序得出的结论,看来有错。但用进程ID同样能激活QQ。
###>
作者: ygqiang 时间: 2015-11-20 00:13
yiwuyun 发表于 2015-11-19 23:02
你的这个代码,保存成什么扩展名?应该如何运行呢?
作者: sepwolves 时间: 2015-11-23 09:50
谢谢。还要调用vbs啊?
作者: ygqiang 时间: 2015-11-23 10:16
回复 13# sepwolves - RunAsAdminstrator
- Function GetQQPath()
- Const HKEY_LOCAL_MACHINE = &H80000002
- Dim s, sREG, sDis, sPath, oReg, fso
- sPath = ""
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set Wss = CreateObject("Wscript.Shell")
- Set oReg = GetObject("Winmgmts:\\.\Root\Default:StdRegProv")
- sREG = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
- oReg.EnumKey HKEY_LOCAL_MACHINE, sREG, s
- If IsNull(s) = False Then
- For i = 0 To Ubound(s)
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "DisplayName", sDis
- If Ucase(sDis) = "腾讯QQ" Then
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "InstallLocation", sPath
- End If
- Next
- End If
- sREG = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
- oReg.EnumKey HKEY_LOCAL_MACHINE, sREG, s
- If IsNull(s) = False Then
- For i = 0 To Ubound(s)
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "DisplayName", sDis
- If Ucase(sDis) = "腾讯QQ" Then
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "InstallLocation", sPath
- End If
- Next
- End If
- If sPath = "" Then
- 'MsgBox "未找到 腾讯QQ 的注册表路径", 4096
- 'CreateObject("Wscript.Shell").Popup "未找到 腾讯QQ 的注册表路径", 5
- Wss.Popup "未找到 腾讯QQ 的注册表路径", 5
- WScript.Quit(1)
- Else
- GetQQPath = fso.BuildPath(sPath, "Bin\QQ.exe")
- If fso.FileExists(GetQQPath) = False Then
- 'MsgBox "未找到 " & GetQQPath, 4096
- 'CreateObject("Wscript.Shell").Popup "未找到 " & GetQQPath, 5
- Wss.Popup "未找到 " & GetQQPath, 5
- WScript.Quit(2)
- End If
- End If
- End Function
- Sub RunAsAdminstrator()
- Dim shell, os, arg, ver
- Set shell = CreateObject("Shell.Application")
-
- For Each os In GetObject("WinMgmts:").InstancesOf("Win32_OperatingSystem")
- ver = Left(os.Version, 3)
- Next
- If ver <> "6.1" And ver <> "6.0" And ver <> "6.3" Then Exit Sub
-
- For Each arg In WScript.Arguments.Named
- If LCase(arg) = "uac" Then Exit Sub
- Next
-
- Shell.ShellExecute "wscript.exe", Chr(34) & _
- WScript.ScriptFullName & Chr(34) & " /uac", "", "runas", 1
- WScript.Quit
- End Sub
-
- '定义QQ程序路径、帐号、密码
- Dim Program1,a,b,c
- Program1 = GetQQPath()
- 'MsgBox Program1
- Set WshShell=createobject("wscript.shell")
- '运行QQ主程序
- Set oExec=WshShell.Exec(Program1)
- WScript.Sleep 5000
- '激活QQ窗口
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WScript.Sleep 3000
- '输入帐号
- a="qq帐号"
- WshShell.SendKeys a
- WScript.Sleep 1000
- WshShell.SendKeys "{TAB}"
- '输入帐号
- a="qq帐号"
- WshShell.SendKeys a
- WScript.Sleep 1000
- WshShell.SendKeys "{TAB}"
- WScript.Sleep 2000
-
- '输入帐号
- a="qq帐号"
- WshShell.SendKeys a
- WScript.Sleep 1000
- WshShell.SendKeys "{ENTER}"
- WScript.Sleep 1000
-
- '输入密码
- b="qq密码"
- WshShell.SendKeys b
- WScript.Sleep 2000
-
- WshShell.SendKeys "{ENTER}"
复制代码
作者: ygqiang 时间: 2015-11-23 10:16
以上是vbs代码。。。目前基本解决问题了。。
作者: sepwolves 时间: 2015-11-26 21:38
谢谢啊,没想到引起如此深刻的讨论。代码还那么长。。
作者: sepwolves 时间: 2015-11-26 21:39
不过vbs还真看不懂。。。
作者: 906053584 时间: 2015-11-26 22:38
看不懂,这有点复杂
作者: sepwolves 时间: 2015-12-7 09:26
回复 15# ygqiang
可不可以请教一下为什么要三次输入qq账号吗?
作者: ygqiang 时间: 2015-12-7 09:28
回复 19# sepwolves - RunAsAdminstrator
- Function GetQQPath()
- Const HKEY_LOCAL_MACHINE = &H80000002
- Dim s, sREG, sDis, sPath, oReg, fso
- sPath = ""
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set Wss = CreateObject("Wscript.Shell")
- Set oReg = GetObject("Winmgmts:\\.\Root\Default:StdRegProv")
- sREG = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
- oReg.EnumKey HKEY_LOCAL_MACHINE, sREG, s
- If IsNull(s) = False Then
- For i = 0 To Ubound(s)
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "DisplayName", sDis
- If Ucase(sDis) = "腾讯QQ" Then
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "InstallLocation", sPath
- End If
- Next
- End If
- sREG = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
- oReg.EnumKey HKEY_LOCAL_MACHINE, sREG, s
- If IsNull(s) = False Then
- For i = 0 To Ubound(s)
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "DisplayName", sDis
- If Ucase(sDis) = "腾讯QQ" Then
- oReg.GetStringValue HKEY_LOCAL_MACHINE, sREG & "\" & s(i), "InstallLocation", sPath
- End If
- Next
- End If
- If sPath = "" Then
- 'MsgBox "未找到 腾讯QQ 的注册表路径", 4096
- 'CreateObject("Wscript.Shell").Popup "未找到 腾讯QQ 的注册表路径", 5
- Wss.Popup "未找到 腾讯QQ 的注册表路径", 5
- WScript.Quit(1)
- Else
- GetQQPath = fso.BuildPath(sPath, "Bin\QQ.exe")
- If fso.FileExists(GetQQPath) = False Then
- 'MsgBox "未找到 " & GetQQPath, 4096
- 'CreateObject("Wscript.Shell").Popup "未找到 " & GetQQPath, 5
- Wss.Popup "未找到 " & GetQQPath, 5
- WScript.Quit(2)
- End If
- End If
- End Function
-
- Sub RunAsAdminstrator()
- Dim shell, os, arg, ver
- Set shell = CreateObject("Shell.Application")
-
- For Each os In GetObject("WinMgmts:").InstancesOf("Win32_OperatingSystem")
- ver = Left(os.Version, 3)
- Next
- If ver <> "6.1" And ver <> "6.0" And ver <> "6.3" Then Exit Sub
-
- For Each arg In WScript.Arguments.Named
- If LCase(arg) = "uac" Then Exit Sub
- Next
-
- Shell.ShellExecute "wscript.exe", Chr(34) & _
- WScript.ScriptFullName & Chr(34) & " /uac", "", "runas", 1
- WScript.Quit
- End Sub
-
-
- '定义QQ程序路径、帐号、密码
- Dim Program1,a,b,c
-
- Program1 = GetQQPath()
- 'MsgBox Program1
- Set WshShell=createobject("wscript.shell")
-
- '运行QQ主程序
- Set oExec=WshShell.Exec(Program1)
- WScript.Sleep 5000
-
- '激活QQ窗口
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WshShell.SendKeys "{TAB}"
- WScript.Sleep 3000
-
-
- '输入帐号
- a="qq号码"
- WshShell.SendKeys a
- WScript.Sleep 1000
- WshShell.SendKeys "{ENTER}"
- WScript.Sleep 2000
-
- '输入密码
- b="qq密码"
- WshShell.SendKeys b
- WScript.Sleep 2000
-
- WshShell.SendKeys "{ENTER}"
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |