I'd like this to work...
Code: Select all
GetProcessIds>iexplore*,arrIEs
If>arrIEs_count>0
Let>k=0
Repeat>k
Let>k=k+1
Let>this_id=arrIEs_%k%
Until>k=arrIEs_count
Moderators: JRL, Dorian (MJT support)
Code: Select all
GetProcessIds>iexplore*,arrIEs
If>arrIEs_count>0
Let>k=0
Repeat>k
Let>k=k+1
Let>this_id=arrIEs_%k%
Until>k=arrIEs_count
Code: Select all
ProcessExists>chrome.exe,haveChrome
If>haveChrome=True
GetProcessIDs>chrome.exe,myArr
Endif
Code: Select all
VBSTART
Dim list
Dim tmp
'returns the number of copies of ProcessName that are running
'will return 0 if ProcessName is not running
Function GenerateProcessList()
Set objSWbemServices = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colSwbemObjectSet = objSWbemServices.ExecQuery("Select * From Win32_Process")
list = ""
tmp = ""
For Each objProcess in colSWbemObjectSet
'Wscript.Echo "Process Name: " & objProcess.Name
tmp = objProcess.Name
list = list &","& tmp
'Wscript.Echo list
Next
End Function
Function GetProcessList()
GetProcessList = list
End Function
VBEND
'find iexplore.exe
Let>findProcess=xplo
VBRun>GenerateProcessList
VBEval>GetProcessList,list
Position>%findProcess%,%list%,0,i
If>i>0
'do what you need to
MidStr>%list%,{%i%-10},40,process
MessageModal>Found process %process%
EndIf
Code: Select all
'**NOTE: Change "Running" in Position>Running,%wText%,1,iPos to Not Responding
'to test leave as Running
'Have Notepad open to test this
VBSTART
Dim list
Dim tmp
'returns the number of copies of ProcessName that are running
'will return 0 if ProcessName is not running
Function GenerateProcessList()
Set objSWbemServices = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colSwbemObjectSet = objSWbemServices.ExecQuery("Select * From Win32_Process")
list = ""
tmp = ""
For Each objProcess in colSWbemObjectSet
'Wscript.Echo "Process Name: " & objProcess.Name
tmp = objProcess.Name
list = list &","& tmp
'Wscript.Echo list
Next
End Function
Function GetProcessList()
GetProcessList = list
End Function
VBEND
'find notepad.exe
Let>findProcess=tepad
Let>appName=Notepad
VBRun>GenerateProcessList
VBEval>GetProcessList,list
Position>%findProcess%,%list%,0,i
WaitReady>0
**BREAKPOINT**
If>i>0
Run>cmd /c taskkill /im taskmgr.exe /f
Wait>2
'Run taskmgr
Let>fileName=C:\Windows\System32\taskmgr.exe
Run>cmd /c START "" "%fileName%"
WaitReady>0
Wait>2
'do what you need to
Let>findHandleFor=Windows Task Manager
GoSub>Get_WinHandle
Let>WIN_USEHANDLE=1
SetFocus>%hWndResult%
Position>%,%hWndResult%,1,i
If>i=0
Let>ObjName=SysListView32
Let>ObjIndex=1
GoSub>Get_WindowObjectVars
Position>Running,%wText%,1,iPos
If>iPos>0
'Find your app name here from the returned value in wText
Separate>%wText%,%CRLF%,wTextList
Let>i=1
Repeat>i
Add>i,1
Position>%appName%,wTextList_%i%,1,iPos
If>iPos>0
'found
'Now do what you need to
**BREAKPOINT**
Let>foundThis=wTextList_%i%
MessageModal>found %foundThis%
'EXIT LOOP
Let>i=%wTextList_Count%
EndIf
Until>i=%wTextList_Count%
EndIf
EndIf
EndIf
SRT>Get_WinHandle
Let>WIN_USEHANDLE=0
Let>hWndResult=%
GetWindowHandle>%findHandleFor%,hWndResult
END>Get_WinHandle
SRT>Get_WindowObjectVars
'-------------------------------------------
'|RETURN VALUES FROM SPEICIFIED OBJECT
'E.G DATAGRID,FIELD,LABEL ETC
'-------------------------------------------
'ALWAYS from hWndResult handle. Get_WinHandle will return hWndResult
'Returns wText with the text in the object
'X1,Y1,X2,Y2 returns the position of the object on the screen
'hWnd returns handle of object
FindObject>%hWndResult%,%ObjName%,,%ObjIndex%,ObjhWnd,X1,Y1,X2,Y2,result
'set x y and bottom pos of Object
Let>posX=%X1%+10
Let>posY=%Y1%+10
Let>posB=%Y2%
Let>WIN_USEHANDLE=1
GetTextInit
'Capture text for the object using the returned ObjhWnd handle
GetWindowTextEx>%ObjhWnd%,wText
END>Get_WindowObjectVars