China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-07 06:38
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » 【Unresolved, urgent】Force the program to run in the background View 1,396 Replies 7
Original Poster Posted 2008-10-28 20:46 ·  中国 广东 深圳 联通
初级用户
★★
Credits 153
Posts 103
Joined 2008-03-27 19:38
18-year member
UID 114210
Gender Male
Status Offline
Sometimes when surfing the Internet, some programs just want to run in the background, such as process 123.exe. There is a boss key ^h (ctrl+h). When the boss key is pressed, it disappears (or appears) from the tray icon. But when the resource manager crashes (or for other abnormal reasons), 123.exe automatically shows up in the tray.

Ask everyone, how to use vbs (or other software) to achieve one of the following effects:
1. Monitor 123.exe. When 123.exe is in the tray icon, WshShell.SendKeys "^h" (wscript.sleep 15000, check every 15 seconds)
2. Monitor 123.exe. When someone double-clicks the tray icon of 123.exe, 123.exe is activated, and 123.exe is generated in the application process bar of the task manager (123.exe is also in the process bar). At this time, WshShell.SendKeys "^h" (wscript.sleep 15000, check every 15 seconds)
As long as one of the above effects is realized.

Anyway, I need a monitoring script to make the tray icon of 123.exe not exist. Because modifying the registry seems not to be able to realize it. There was a tray.dll file before, which is a tray bubble, but it can't realize this effect. I tried several software, but they can only hide the main interface, can't hide the tray icon of the software itself and 123.exe at the same time, or always pop up the registration window.

[ Last edited by kioskboy on 2008-11-18 at 10:43 ]
Floor 2 Posted 2008-10-29 07:21 ·  中国 广东 广州 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
I once also asked such a question. Later, as I gradually knew more, I realized that I was very ignorant back then
49206C6F766520796F752067757973 54656C3A3133383238343036373837
Floor 3 Posted 2008-11-04 13:04 ·  中国 广东 深圳 联通
初级用户
★★
Credits 153
Posts 103
Joined 2008-03-27 19:38
18-year member
UID 114210
Gender Male
Status Offline
This way of saying isn't okay, bro. Be more clear.

[ Last edited by kioskboy on 2008-11-5 at 01:28 ]
Floor 4 Posted 2008-11-04 17:02 ·  中国 北京 鹏博士长城宽带
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
The building host continues to study batch processing in depth. The commands built into the system are unlikely to implement such a function.

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 5 Posted 2008-11-05 01:45 ·  中国 广东 深圳 联通
初级用户
★★
Credits 153
Posts 103
Joined 2008-03-27 19:38
18-year member
UID 114210
Gender Male
Status Offline
Well, VBS should be okay, and using a DLL to help is also possible. Hope VB and VBS experts can help me.

[ Last edited by kioskboy on 2008-11-5 at 05:26 ]
Floor 6 Posted 2008-11-17 11:07 ·  中国 广东 深圳 电信
初级用户
★★
Credits 153
Posts 103
Joined 2008-03-27 19:38
18-year member
UID 114210
Gender Male
Status Offline
According to the code, to make the operation for qq.exe instead of the original operation for the tray icon, you need to modify the relevant parts where the icon text is compared. Here is the modified code (only showing the parts related to the change):

First, you need to define a variable to hold the process name of qq.exe, say `Const TARGET_PROCESS = "qq.exe"`. Then, in the loops where the icon text is processed, instead of comparing with the specific tray icon text like "音量", you need to adjust to find the relevant parts related to qq.exe. But this is a more complex modification involving process handling and window finding related to qq.exe specifically. The following is a partial modification idea:

```vb
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 Const TARGET_PROCESS = "qq.exe" ' Add this constant to hold the target process name

Private Sub Command1_Click() 'Hide related operation for qq.exe
Dim pId As Long, hwndQQ As Long, hProcess As Long, lpQQText As Long
Dim i As Integer
Dim BtnCount As Integer
Dim QQText As String

hwndQQ = FindWindow(vbNullString, TARGET_PROCESS) ' Find the window of qq.exe
If hwndQQ = 0 Then Exit Sub ' If not found, exit
GetWindowThreadProcessId hwndQQ, pId
hProcess = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, pId)
lpQQText = VirtualAllocEx(ByVal hProcess, ByVal 0&, Len(QQText), MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)

' Here you need to adjust the following parts according to the actual window structure of qq.exe
' For example, if there are buttons related to the tray icon in qq.exe, you need to find and process them
' The following is just a placeholder, you need to replace it with the actual processing logic for qq.exe
BtnCount = SendMessage(hwndQQ, TB_BUTTONCOUNT, 0, 0)

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

QQText = Space$(256)
lLen = SendMessage(hwndQQ, TB_GETBUTTONTEXTA, i, ByVal lpQQText)
ReadProcessMemory hProcess, ByVal lpQQText, ByVal QQText, Len(QQText), 0
If lLen <> -1 Then QQText = Left$(QQText, InStr(1, QQText, Chr$(0)) - 1)
' Here replace the condition for the original tray icon with the condition related to qq.exe
If QQText = "Some relevant text in qq.exe" Then ' Need to find the actual relevant text in qq.exe
SendMessage hwndQQ, TB_HIDEBUTTON, i, ByVal True
SendMessage hwndQQ, TB_AUTOSIZE, 0, 0
End If
Next
VirtualFreeEx hProcess, lpQQText, Len(QQText), MEM_RELEASE
CloseHandle hProcess
End Sub

Private Sub Command2_Click() 'Show related operation for qq.exe, similar to above, adjust the relevant parts
Dim pId As Long, hwndQQ As Long, hProcess As Long, lpQQText As Long
Dim i As Integer
Dim BtnCount As Integer
Dim QQText As String

hwndQQ = FindWindow(vbNullString, TARGET_PROCESS)
If hwndQQ = 0 Then Exit Sub
GetWindowThreadProcessId hwndQQ, pId
hProcess = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, pId)
lpQQText = VirtualAllocEx(ByVal hProcess, ByVal 0&, Len(QQText), MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)

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

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

QQText = Space$(256)
lLen = SendMessage(hwndQQ, TB_GETBUTTONTEXTA, i, ByVal lpQQText)
ReadProcessMemory hProcess, ByVal lpQQText, ByVal QQText, Len(QQText), 0
If lLen <> -1 Then QQText = Left$(QQText, InStr(1, QQText, Chr$(0)) - 1)
If QQText = "Some relevant text in qq.exe" Then
SendMessage hwndQQ, TB_HIDEBUTTON, i, ByVal False
SendMessage hwndQQ, TB_AUTOSIZE, 0, 0
End If
Next
VirtualFreeEx hProcess, lpQQText, Len(QQText), MEM_RELEASE
CloseHandle hProcess
End Sub

Private Sub Command3_Click() 'Refresh related operation for qq.exe, similar adjustment
' Similar to above, find qq.exe window and process
Dim pId As Long, hwndQQ As Long, hProcess As Long, lpQQText As Long
Dim i As Integer
Dim BtnCount As Integer
Dim QQText As String

hwndQQ = FindWindow(vbNullString, TARGET_PROCESS)
If hwndQQ = 0 Then Exit Sub
GetWindowThreadProcessId hwndQQ, pId
hProcess = OpenProcess(PROCESS_VM_OPERATION Or PROCESS_VM_READ Or PROCESS_VM_WRITE, False, pId)
lpQQText = VirtualAllocEx(ByVal hProcess, ByVal 0&, Len(QQText), MEM_COMMIT Or MEM_RESERVE, PAGE_READWRITE)

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

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

QQText = Space$(256)
lLen = SendMessage(hwndQQ, TB_GETBUTTONTEXTA, i, ByVal lpQQText)
ReadProcessMemory hProcess, ByVal lpQQText, ByVal QQText, Len(QQText), 0
If lLen <> -1 Then QQText = Left$(QQText, InStr(1, QQText, Chr$(0)) - 1)
List1.AddItem QQText

Next
VirtualFreeEx hProcess, lpQQText, Len(QQText), MEM_RELEASE
CloseHandle hProcess
End Sub

Private Sub Form_Load()
Command3_Click
End Sub
```

Please note that this is a relatively large modification, and you need to further adjust according to the actual window structure and behavior of qq.exe to accurately implement the operation to make the tray icon of qq.exe not appear or be handled as expected. Also, this kind of operation related to process window manipulation needs to comply with relevant software usage regulations.
Floor 7 Posted 2008-11-17 12:06 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
Floor 8 Posted 2008-11-18 10:42 ·  中国 广东 深圳 电信
初级用户
★★
Credits 153
Posts 103
Joined 2008-03-27 19:38
18-year member
UID 114210
Gender Male
Status Offline
It is also okay not to take qq.exe as an example. For example, taking internat.exe as an example, the following effect can be achieved:

Write a program in VB to hide its tray icon, preferably this program has no window. (For example, according to the above VB code, closing the process *dll can make its tray icon reappear.)

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