How to check if a program has a sub window open

Get help with using AutoHotkey and its commands and hotkeys
User avatar
europa
Posts: 14
Joined: 14 Aug 2019, 04:41
Contact:

How to check if a program has a sub window open

14 Aug 2019, 04:48

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 367 times
This is the message that appears when its finished;
OperationComplete.png
OperationComplete.png (14.17 KiB) Viewed 363 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

User avatar
Xtra
Posts: 1417
Joined: 02 Oct 2015, 12:15

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

14 Aug 2019, 11:36

Code: Select all

WinWait, X-Ways Forensics, Operation Complete.
Not tested verify wintitle and wintext are correct.
HTH
User avatar
europa
Posts: 14
Joined: 14 Aug 2019, 04:41
Contact:

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

16 Aug 2019, 01:07

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 281 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
My website CodingFora
Rohwedder
Posts: 2209
Joined: 04 Jun 2014, 08:33
Location: Germany

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

16 Aug 2019, 02:36

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
User avatar
europa
Posts: 14
Joined: 14 Aug 2019, 04:41
Contact:

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

16 Aug 2019, 05:07

Rohwedder : That worked.
But the ahk_class changes every time i run the program.
Can it be dynamic?
My website CodingFora
Rohwedder
Posts: 2209
Joined: 04 Jun 2014, 08:33
Location: Germany

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

16 Aug 2019, 05:41

#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.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Flipeador, Odlanir, toralf, yasqueenslay and 236 guests