Page 1 of 1

How to check if a program has a sub window open

Posted: 14 Aug 2019, 04:48
by europa
I am making a script that
1) Opens X-Ways Forensics
2) Creates a new case
3) Adds a forensic image to the case
4) Runs the task "Refine Volume Snapshot"

The task Refine Volume Snapshot takes random amount of time, depending of the size and complexity of the forensic image.
How can I check if this task is done or not?
After it is done I want to do other things.
examining files.png
examining files.png (308.76 KiB) Viewed 287 times
This is the message that appears when its finished;
OperationComplete.png
OperationComplete.png (14.17 KiB) Viewed 283 times
My script:

Code: Select all

; 1 Read Case Number, evidenceNumber and evidenceFile into variables
FileRead, caseNumber, C:\Users\user\EDBAutomation\_data\current_case_number.txt
FileRead, evidenceNumberClean, C:\Users\user\EDBAutomation\_data\evidence_number_clean.txt
FileRead, evidenceFile, C:\Users\user\EDBAutomation\_data\evidence_file.txt
;MsgBox Case Number is: %caseNumber% and Evidence number is %evidenceNumberClean%


; Start X-Ways
RunAs, user, datakrim
Run "C:\Program Files\X-Ways Forensics\xwforensics64.exe"
WinWait, X-Ways Forensics
WinMaximize ; use the window found above
Send {ESC} ; Ignore any errors


; Create new Case 
Send !l
Send {Down}
Send {Enter}
Send %evidenceNumberClean%
Send {Tab}
FileCreateDir, G:\Cases\%caseNumber%\X-Ways\%evidenceNumberClean%
Sleep, 1000  ; 1 seconds
Send G:\Cases\%caseNumber%\X-Ways\%evidenceNumberClean%
Send {Enter}
Send !O
Sleep, 4000  ; 4 seconds

; Add image to case
Send !l
Send {Up}
Send {Enter}
Sleep, 4000  ; 4 second
Send G:\MirrorFiles\%caseNumber%\%evidenceFile%
Send {Enter}
Sleep, 4000  ; 4 seconds

; Refine Volume Snapshot
Send {ESC} ; Ignore any errors
Send {F10}
Sleep, 1000  ; 1 seconds
Send {Enter}
Send {Enter}
Sleep, 5000  ; 5 seconds

; Check if Refine Volume Snapshot is finished every 60 seconds


Re: How to check if a program has a sub window open

Posted: 14 Aug 2019, 11:36
by Xtra

Code: Select all

WinWait, X-Ways Forensics, Operation Complete.
Not tested verify wintitle and wintext are correct.
HTH

Re: How to check if a program has a sub window open

Posted: 16 Aug 2019, 01:07
by europa
That didnt work.
I tried to get more information from the Window.
It seems to be named "X-Ways_Operation_Complete2.exe".
Can that help?
debug info.png
debug info.png (14.3 KiB) Viewed 201 times
My debug script:

Code: Select all

; Open X-Way
WinWait, X-Ways Forensics
WinMaximize ; use the window found above

; Look
WinGet, this_id

WinActivate, ahk_id %this_id%
WinGetClass, this_class, ahk_id %this_id%
WinGetTitle, this_title, ahk_id %this_id%
MsgBox, 4, , Visiting All Windows`n%A_Index% of %id%`nahk_id %this_id%`nahk_class %this_class%`n%this_title%`n`nContinue?

if (%this_title% = X-Ways Forensics)
    MsgBox OK
else
    MsgBox Not OK

Re: How to check if a program has a sub window open

Posted: 16 Aug 2019, 02:36
by Rohwedder
Hallo,
"X-Ways_Operation_Complete2.exe" seems to be the name of your debug script!
With ahk_class #32770 windows sometimes the wintext parameter does not work as expected.
Perhaps?:

Code: Select all

SetTitleMatchMode, 2
WinWait, X-Ways Forensics ahk_class #32770

Re: How to check if a program has a sub window open

Posted: 16 Aug 2019, 05:07
by europa
Rohwedder : That worked.
But the ahk_class changes every time i run the program.
Can it be dynamic?

Re: How to check if a program has a sub window open

Posted: 16 Aug 2019, 05:41
by Rohwedder
#32770 is the default class for a dialog box.
https://docs.microsoft.com/en-us/windows/win32/winmsg/about-window-classes.
I've never seen the class of a dialog box change before. But if it does, maybe SetTitleMatchMode, Regex helps.

Re: How to check if a program has a sub window open

Posted: 16 Aug 2019, 05:54
by europa
Ok thanks for the help!