中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net  论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

游客:  注册 | 登录 | 命令行 | 会员 | 搜索 | 上传 | 帮助 »
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 【未结,急】强制程序后台运行
作者:
标题: 【未结,急】强制程序后台运行 上一主题 | 下一主题
kioskboy
初级用户





积分 153
发帖 103
注册 2008-3-27
状态 离线
『楼 主』:  【未结,急】强制程序后台运行

有时侯上网时,有的程序只想后台运行,比如进程123.exe,有老板键^h(ctrl+h),按下老板键后会重托盘图标里消失(或出来)
可是当资源管理器崩溃的时候(或其它异常原因),123.exe自动重托盘里面显示出来了

请问大家,怎么用vbs(或其它什么软件)实现下面其中一种效果:
1 监视123.exe,当123.exe在托盘图标里时,WshShell.SendKeys "^h"
(wscript.sleep 15000,每15秒种查看一次)
2 监视123.exe,当别人双击托盘图标的123.exe,123.exe主被激活,任务管理器的 应用进程栏 产生123.exe(进程栏 里也有123.exe)
此时,WshShell.SendKeys "^h"
(wscript.sleep 15000,每15秒种查看一次)
上面的效果只要实现一种就可以了

反正,求个监视的脚本,使托盘里面没有123.exe 的图标,由于修改注册表好像不能实现
以前有个有个tray.dll的文件,是个托盘冒泡的,不能实现不了这种效果。
我拭了几个软件都只能隐藏主界面,不能同时隐藏 软件本身和123.exe 的托盘图标,或者老弹出注册窗口.

[ Last edited by kioskboy on 2008-11-18 at 10:43 ]

2008-10-28 20:46
查看资料  发短消息 网志   编辑帖子  回复  引用回复
everest79
金牌会员

一叶枝头,万树皆春



积分 2564
发帖 1127
注册 2006-12-25
状态 离线
『第 2 楼』:  

我曾经也问过这样的问题,后来慢慢知道的多了,才发现那时自已很无知



49206C6F766520796F752067757973 54656C3A3133383238343036373837
2008-10-29 07:21
查看资料  发短消息 网志   编辑帖子  回复  引用回复
kioskboy
初级用户





积分 153
发帖 103
注册 2008-3-27
状态 离线
『第 3 楼』:  

这样说不行啊,兄弟
说清楚点啊

[ Last edited by kioskboy on 2008-11-5 at 01:28 ]

2008-11-4 13:04
查看资料  发短消息 网志   编辑帖子  回复  引用回复
yishanju
银牌会员

[b]看你妹啊[/b]


积分 1488
发帖 1357
注册 2006-5-20
状态 离线
『第 4 楼』:  

楼主继续再深入学学批处理

系统里自带的命令不太可能实现这样功能的。




有问题请发论坛或者自行搜索,再短消息问我的统统是SB
2008-11-4 17:02
查看资料  发短消息 网志   编辑帖子  回复  引用回复
kioskboy
初级用户





积分 153
发帖 103
注册 2008-3-27
状态 离线
『第 5 楼』:  

那vbs应该行吧,用个dll帮忙也可以呀,希望vb和 vbs高手帮下我

[ Last edited by kioskboy on 2008-11-5 at 05:26 ]

2008-11-5 01:45
查看资料  发短消息 网志   编辑帖子  回复  引用回复
kioskboy
初级用户





积分 153
发帖 103
注册 2008-3-27
状态 离线
『第 6 楼』:  

根据下面的代码,Private Sub Command2_Click() 和Private Sub Command3_Click() 不需要, 怎么改,或其它方法,
算了,不改成vbs,就修改下vb。能达到不使123.exe托盘图标始终(或尽量)不出来 就可以了,如以qq.exe为测试对象(反正按ctrl+alt+z可以再跑出来,或者好象关掉多出的进程*dll就可以了),只需要对qq.exe进行操作
我不知道把”qq.exe“字符串 放在哪个地方?
Option Explicit
Private Const WM_USER = &H400
Private Const TB_BUTTONCOUNT = (WM_USER + 24)
Private Const TB_HIDEBUTTON = (WM_USER + 4)
Private Const TB_GETBUTTONTEXTA = (WM_USER + 45)
Private Const TB_AUTOSIZE = (WM_USER + 33)

Private Const MEM_COMMIT = &H1000
Private Const MEM_RESERVE = &H2000
Private Const MEM_RELEASE = &H8000

Private Const PAGE_READWRITE = &H4

Private Const PROCESS_VM_OPERATION = (&H8)
Private Const PROCESS_VM_READ = (&H10)
Private Const PROCESS_VM_WRITE = (&H20)

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, lParam As Any) As Long
Private Declare Function VirtualAllocEx Lib "kernel32.dll" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long
Private Declare Function VirtualFreeEx Lib "kernel32.dll" (ByVal hProcess As Long, lpAddress As Any, ByRef dwSize As Long, ByVal dwFreeType As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long

Private Sub Command1_Click()  '隐藏
    Dim pIdExplorer As Long, hwnd2 As Long, hExplorer As Long, lpIconText As Long
    Dim i As Integer
    Dim BtnCount As Integer
    Dim IconText As String

    hwnd2 = FindWindow("Shell_TrayWnd", vbNullString)
    hwnd2 = FindWindowEx(hwnd2, 0, "TrayNotifyWnd", vbNullString)
    hwnd2 = FindWindowEx(hwnd2, 0, "SysPager", vbNullString)
    hwnd2 = FindWindowEx(hwnd2, 0, "ToolbarWindow32", vbNullString)

    GetWindowThreadProcessId hwnd2, pIdExplorer
    hExplorer = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, pIdExplorer)
    lpIconText = VirtualAllocEx(ByVal hExplorer, ByVal 0&, Len(IconText), MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)

    BtnCount = SendMessage(hwnd2, TB_BUTTONCOUNT, 0, 0)

    Dim lLen As Long, sBuff As String
    For i = 0 To BtnCount - 1

        IconText = Space$(256)
        lLen = SendMessage(hwnd2, TB_GETBUTTONTEXTA, i, ByVal lpIconText)
        ReadProcessMemory hExplorer, ByVal lpIconText, ByVal IconText, Len(IconText), 0
        If lLen <> -1 Then IconText = Left$(IconText, InStr(1, IconText, Chr$(0)) - 1)
        If IconText = List1.List(List1.ListIndex) Then ' "音量" Then
            SendMessage hwnd2, TB_HIDEBUTTON, i, ByVal True
            SendMessage hwnd2, TB_AUTOSIZE, 0, 0
        End If
    Next
    VirtualFreeEx hExplorer, lpIconText, Len(IconText), MEM_RELEASE
    CloseHandle hExplorer
End Sub

Private Sub Command2_Click()   '显示列表
    Dim pIdExplorer As Long, hwnd2 As Long, hExplorer As Long, lpIconText As Long
    Dim i As Integer
    Dim BtnCount As Integer
    Dim IconText As String

    hwnd2 = FindWindow("Shell_TrayWnd", vbNullString)
    hwnd2 = FindWindowEx(hwnd2, 0, "TrayNotifyWnd", vbNullString)
    hwnd2 = FindWindowEx(hwnd2, 0, "SysPager", vbNullString)
    hwnd2 = FindWindowEx(hwnd2, 0, "ToolbarWindow32", vbNullString)

    GetWindowThreadProcessId hwnd2, pIdExplorer
    hExplorer = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, pIdExplorer)
    lpIconText = VirtualAllocEx(ByVal hExplorer, ByVal 0&, Len(IconText), MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)

    BtnCount = SendMessage(hwnd2, TB_BUTTONCOUNT, 0, 0)

    Dim lLen As Long, sBuff As String
    For i = 0 To BtnCount - 1

        IconText = Space$(256)
        lLen = SendMessage(hwnd2, TB_GETBUTTONTEXTA, i, ByVal lpIconText)
        ReadProcessMemory hExplorer, ByVal lpIconText, ByVal IconText, Len(IconText), 0
        If lLen <> -1 Then IconText = Left$(IconText, InStr(1, IconText, Chr$(0)) - 1)
        If IconText = List1.List(List1.ListIndex) Then  ' "音量" Then
            SendMessage hwnd2, TB_HIDEBUTTON, i, ByVal False
            SendMessage hwnd2, TB_AUTOSIZE, 0, 0
        End If
    Next
    VirtualFreeEx hExplorer, lpIconText, Len(IconText), MEM_RELEASE
    CloseHandle hExplorer
End Sub

Private Sub Command3_Click()  '刷新列表
    List1.Clear
    Dim pIdExplorer As Long, hwnd2 As Long, hExplorer As Long, lpIconText As Long
    Dim i As Integer
    Dim BtnCount As Integer
    Dim IconText As String

    hwnd2 = FindWindow("Shell_TrayWnd", vbNullString)
    hwnd2 = FindWindowEx(hwnd2, 0, "TrayNotifyWnd", vbNullString)
    hwnd2 = FindWindowEx(hwnd2, 0, "SysPager", vbNullString)
    hwnd2 = FindWindowEx(hwnd2, 0, "ToolbarWindow32", vbNullString)

    GetWindowThreadProcessId hwnd2, pIdExplorer
    hExplorer = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, pIdExplorer)
    lpIconText = VirtualAllocEx(ByVal hExplorer, ByVal 0&, Len(IconText), MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)

    BtnCount = SendMessage(hwnd2, TB_BUTTONCOUNT, 0, 0)

    Dim lLen As Long, sBuff As String
    For i = 0 To BtnCount - 1

        IconText = Space$(256)
        lLen = SendMessage(hwnd2, TB_GETBUTTONTEXTA, i, ByVal lpIconText)
        ReadProcessMemory hExplorer, ByVal lpIconText, ByVal IconText, Len(IconText), 0
        If lLen <> -1 Then IconText = Left$(IconText, InStr(1, IconText, Chr$(0)) - 1)
        List1.AddItem IconText

    Next
    VirtualFreeEx hExplorer, lpIconText, Len(IconText), MEM_RELEASE
    CloseHandle hExplorer
End Sub

Private Sub Form_Load()
    Command3_Click
End Sub
[ Last edited by kioskboy on 2008-11-18 at 10:40 ]

2008-11-17 11:07
查看资料  发短消息 网志   编辑帖子  回复  引用回复
HAT
版主





积分 9023
发帖 5017
注册 2007-5-31
状态 离线
『第 7 楼』:  Re 6楼

Q: 如何给代码加code标签?
A: http://www.cn-dos.net/forum/viewthread.php?tid=43735#pid304733
参考:http://www.cn-dos.net/forum/faq.php?page=misc#1



2008-11-17 12:06
查看资料  发短消息 网志   编辑帖子  回复  引用回复
kioskboy
初级用户





积分 153
发帖 103
注册 2008-3-27
状态 离线
『第 8 楼』:  

不以qq.exe为例子也可以
如以internat.exe为例,达到下面的效果就可以了

用vb写个程序,使其托盘图标隐藏,最好这个程序没有窗口
(如根据上面vb代码,关闭进程*dll,可以使其托盘图标重新出来)

[ Last edited by kioskboy on 2008-11-18 at 10:44 ]

2008-11-18 10:42
查看资料  发短消息 网志   编辑帖子  回复  引用回复

请注意:您目前尚未注册或登录,请您注册登录以使用论坛的各项功能,例如发表和回复帖子等。


可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题



论坛跳转: