WinBatch.exe hangs waiting when new window is opened

Started by jone1joh, October 04, 2017, 07:41:23 PM

Previous topic - Next topic

jone1joh

I would be more specific if I had a clue.  A button is clicked which opens a new window and WinBatch hangs waiting for user interaction with the new window to complete.  The WinBatch program needs to do that interaction but it is hung waiting.   Any ideas are appreciated.  Many year customer but haven't used in years and am porting to a new version of the software being driven by WinBatch.  Thanks.

td

You will need to provide more information.  Are you referring to a WIL dialog button and an action in a callback procedure or are you referring to a button in WinBatch box or are you referring to a button in a third party application or are you referring to a button in a WIL function message box?
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

jone1joh

Thanks for getting back.  I'm referring to a button in a third party application (ArcGIS ArcMap) I'm trying to control via WinBatch.  I'm using a licensed version of WinBatch 2017B and this is running on Windows Server 2012.  This has worked in the past with earlier versions of WinBatch and ArcMAp.

JTaylor

Obviously hard to say but one thing that will do this is if your third-party app doesn't have the focus [at the right time] if you are using SendKey to interact.

Jim

jone1joh

Here is the previous few lines of code up to where WinBatch just hangs waiting (that is it will not proceed to the next line of code in the "wbt" file):

Code (winbatch) Select
TimeDelay(10)
Run("C:\Program Files (x86)\ArcGIS\Desktop10.5\bin\ArcMap.exe",WorkArray[wa_index,0])
TimeDelay(15)
ArcMapStarted = @TRUE

; slowdown key strokes a little
IntControl(35, 100, 100, 0, 0)

; open "Layer Properties" for kriging layer
ControlHandle=DllHwnd(WorkArray[wa_index,1])
cSetFocus(ControlHandle)  ; Activates Window
TimeDelay(1)
cSetFocus(ControlHandle)  ; Activates Window
TimeDelay(1)
cSetFocus(ControlHandle)  ; Activates Window
TimeDelay(5)
SendKey("{F3}")    ;Sends Keystrokes
TimeDelay(2)
SendKey("{DOWN}")  ;Sends Keystrokes
SendKey("{DOWN}")  ;Sends Keystrokes
SendKey("{DOWN}")  ;Sends Keystrokes
SendKey("{DOWN}")  ;Sends Keystrokes
SendKey("{DOWN}")  ;Sends Keystrokes
SendKey("{DOWN}")  ;Sends Keystrokes
SendKey("{DOWN}")  ;Sends Keystrokes
TimeDelay(1)
SendKey("{ENTER}") ;Sends Keystrokes
TimeDelay(2)

; select 2nd tab (Source) in "Layer Properties" for kriging layer
ControlHandle=cWndByWndSpec("#32770","ArcMap",11,0,0,0,0,0,0,1,2,12321,9,12320)
cSetFocus(ControlHandle)  ; Activates Window
window1=cWndByWndSpec("#32770","ArcMap",11,0,0,0,0,0,0,1,2,12321,9,12320)
ControlHandle=cWndByID(window1,12320)
result=cSetTABItem(ControlHandle,2)     ;Sets a Tabbed dialog item
TimeDelay(2)

;Click the "Repair Data &Source(s)" button
window1=cWndByWndSpec("#32770","ArcMap",11,0,0,0,0,0,0,1,2,12321,9,12320)
window2=cWndBySeq(window1,1)
window3=cWndByID(window2,0)
ControlHandle=cWndByID(window3,5506)
cClickButton(ControlHandle)


After the "cClickButton(ControlHandle) line executes (last line in above code), a window does popup that would allow me to "Repair Data Source(s)" if WinBatch hadn't just stopped dead in it's tracks.  The new window appears to have focus.  Are you saying that WinBatch will just hang waiting depending on where the focus is?  How would I change the focus away from this new window when WinBatch is stopped waiting?

I have now confirmed that if I manually interact with the popup window and cancel it, then control resumes in the wbt file.   Help! Please!

jone1joh

I've attached the output from "Windows Analysis" script.  The top window is the popup where the wbt begins to wait.

td

Quote from: jone1joh on October 05, 2017, 12:04:58 PM
...

After the "cClickButton(ControlHandle) line executes (last line in above code), a window does popup that would allow me to "Repair Data Source(s)" if WinBatch hadn't just stopped dead in it's tracks.  The new window appears to have focus.  Are you saying that WinBatch will just hang waiting depending on where the focus is?  How would I change the focus away from this new window when WinBatch is stopped waiting?

I have now confirmed that if I manually interact with the popup window and cancel it, then control resumes in the wbt file.   Help! Please!

It is not very likely that the version of WinBatch is causing your issue.  There is some remote possibility that your targeted program has a focus  related bug that would make the problem focus related.   The most likely explanation is just a sloppily written program or something.

Try using cPostButton instead of cClickButton.  That should remove the "hang", if you are lucky.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

jone1joh

Thank you, cPostButton did the trick.  Looking at my old code, it does use cPostButton in places so I must have known this 12 years ago when I originally wrote it.