Sign in to follow this  
Followers 0
JeanMarc

ProcessExists() fails

6 posts in this topic

Hello all,

This is my first post to the AutoIt forums so please be kind :D

I am trying to use the ProcessExists() function but this returns 0 even though the process is up and running!

Could it be because the running process is a 16-bit process? Likewise ProcessList() fails to list this process even though it appears in Task Manager (underneath wowexec.exe).

I've used ProcessExists() for other purposes before so this is not a user issue :D

Any idea what to do? I want to be able to detect that the process is closed before doing other things.

Thanks!

Jean-Marc

Share this post


Link to post
Share on other sites



Might I ask what the name of the process is?


For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Use the forum search. This has come up before (as in a couple of years ago), and is related to trying to get WoW (Win-On-Win, not Warcraft) to enumerate the 16-bit processes running under it. I don't remember if there was a resolution or not, but it was discussed here a LOOOONG time ago.

:D

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

If you have a window associated with this 16bit app and can get the title of this window

even only a constant substring of the title, if the title changes

even if this window is hidden or minimized

you can use the following code...

(I tested it with a 16bit app running under wowexec, which is under ntvdm)

(Tested with WinXP SP3, AutoIt v3.2.0.1)

(To explore existing windows you can use WinExplorer, freeware at http://www.nirsoft.net/utils/winexp.html)

Local $wintitle, $winmatchmode, $reswin

$wintitle = "TheWindowTitle" ; 16 bits app window title, case sensitive

;Here choose the match mode for the 16 bits app window
;$winmatchmode = 1  ; Match the title from the start    for the 16 bits app window title, case sensitive
;$winmatchmode = 2  ; Match any substring in the title  for the 16 bits app window title, case sensitive
$winmatchmode = 3   ; Exact title match                 for the 16 bits app window title, case sensitive

$reswin = WOWAPPEXISTS($wintitle, $winmatchmode)

MsgBox(0, "Result", "Does '" & $wintitle & "' exist? : " & $reswin)

;Tested with WinXP SP3, AutoIt v3.2.0.1
;This will check if an app with a window title = $strtitle is hosted by wowexec
;Return 1 if exists, 0 if not exists
;Not all 16 bits apps seem to be hosted by wowexec and wowexec is itself hosted by ntvdm
;I have an old game running in a DOS console which is hosted by ntvdm without wowexec
Func WOWAPPEXISTS($strtitle, $winmatchmode)
    Local $arrwow, $arrapp, $i, $j

    AutoItSetOption("WinTitleMatchMode", 4)

    $arrwow = WinList("classname=WOWExecClass")
    If $arrwow[0][0] = 0 Then Return 0

    AutoItSetOption("WinTitleMatchMode", $winmatchmode)     

    $arrapp = WinList($strtitle)
    If $arrapp[0][0] = 0 Then Return 0

    For $i = 1 To UBound($arrapp, 1) - 1
        For $j = 1 To UBound($arrwow, 1) - 1
            If WinGetProcess($arrapp[$i][1]) = WinGetProcess($arrwow[$j][1]) Then
                Return 1
            EndIf
        Next
    Next

    Return 0
EndFunc

Share this post


Link to post
Share on other sites

A more complete solution (always using a window of the 16bits app)

AutoItSetOption("MustDeclareVars", 1)

Local $sWinId1, $sWinText1, $iWinMatchMode1, $iWinSearchChildren1, $iTextMatchMode1, $iReswin

;Here choose the title (or a part of the title, or the classname, or the handle) of the 16 bits app window, CASE SENSITIVE
$sWinId1 = "My_16_Bits_App_Window_Title"

;Here choose the match mode for the 16 bits app window
;$iWinMatchMode1 = 1    ; Match the title from the start                    for the 16 bits app window title, CASE SENSITIVE
;$iWinMatchMode1 = 2    ; Match any substring in the title                  for the 16 bits app window title, CASE SENSITIVE
$iWinMatchMode1 = 3     ; Exact title match                                 for the 16 bits app window title, CASE SENSITIVE
;$iWinMatchMode1 = 4    ; Advanced mode (required for classname or handle)  for the 16 bits app window, CASE SENSITIVE

;Here choose if the 16 bits app window should also be searched through children windows
$iWinSearchChildren1 = 0    ; No (quicker)
;$iWinSearchChildren1 = 1   ; Yes (slower, but can be needed if the 16bits app window is not a top level window)

;Here choose the text of the 16 bits app window if you can get it and if it does not change, otherwise leave empty, CASE SENSITIVE
$sWinText1 = ""

;Here choose the text match mode for the 16 bits app window
$iTextMatchMode1 = 1    ; Complete / Slow mode (normal)
;$iTextMatchMode1 = 2   ; Quick mode (less text can be seen)

$iReswin = _WinsAreInSameProcess( _
                $sWinId1, $sWinText1, $iWinMatchMode1, $iWinSearchChildren1, $iTextMatchMode1, _
                "classname=WOWExecClass", "", 4, 0, 1)

MsgBox(0, "Result", "Is '" & $sWinId1 & "' hosted by" & @CR & "wowexec process ?" & @CR & $iReswin)

;Function checks if 2 windows identified by $sWinId1 and $sWinId2 are part of the same process
;Return value is 1 if YES, 0 if NO
Func _WinsAreInSameProcess( _
$sWinId1, $sWinText1, $iWinMatchMode1, $iWinSearchChildren1, $iTextMatchMode1, _
$sWinId2, $sWinText2, $iWinMatchMode2, $iWinSearchChildren2, $iTextMatchMode2)

    Local $arrWin1, $arrWin2, $i, $j

    AutoItSetOption("WinTitleMatchMode", $iWinMatchMode1)
    AutoItSetOption("WinSearchChildren", $iWinSearchChildren1)
    AutoItSetOption("WinTextMatchMode", $iTextMatchMode1)
    $arrWin1 = WinList($sWinId1, $sWinText1)
    If $arrWin1[0][0] = 0 Then Return 0

    AutoItSetOption("WinTitleMatchMode", $iWinMatchMode2)
    AutoItSetOption("WinSearchChildren", $iWinSearchChildren2)
    AutoItSetOption("WinTextMatchMode", $iTextMatchMode2)
    $arrWin2 = WinList($sWinId2, $sWinText2)
    If $arrWin2[0][0] = 0 Then Return 0

    AutoItSetOption("WinSearchChildren", BitOR($iWinSearchChildren1, $iWinSearchChildren2))
    AutoItSetOption("WinTitleMatchMode", 4)
    For $i = 1 To UBound($arrWin1, 1) - 1
        For $j = 1 To UBound($arrWin2, 1) - 1
            If WinGetProcess($arrWin1[$i][1]) = WinGetProcess($arrWin2[$j][1]) Then Return 1
        Next
    Next

    Return 0
EndFunc ; => _WinsAreInSameProcess

Share this post


Link to post
Share on other sites

Might I ask what the name of the process is?

Yes, the process name is Tpsfix.exe

It's a utility that repairs corrupted data files in Topspeed format.

Jean-Marc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0