I hear you. My favourite trick is to forget to stick the counter increment/decrement line just before the EndWhile statement. I reckon we form a club of the Endless Loop, Jim. *smile* Cheers, Andrew. On 6/05/2012 10:06 PM, Jim Snowbarger wrote: > Yes, I definitely need this insert+windows+f4 item. > I made a cardinal rule, and beat myself over the head with it. Make sure > your loops will terminate. Then, I promptly proceed to break the rule. > > ----- Original Message ----- > From: "Andrew Hart" <ahart@xxxxxxxxxxxxx> > To: <jawsscripts@xxxxxxxxxxxxx> > Sent: Sunday, May 06, 2012 8:54 PM > Subject: [jawsscripts] Re: An interesting scripting problem > > > Awesome tip that about Insert+Windows+F4. I am always forgetting that > and never thought to try it. > > Thanks heaps, > Andrew. > > On 6/05/2012 7:30 PM, Doug Lee wrote: >> My normal way to handle that, at least when looping through windows, >> is to stop if the window handle I get back is null. In this script, >> you can do that by changing the While line to read >> >> while x && hWin1 >> >> This works because hWin1, when treated as a boolean value like that, >> will return True if non-empty and False when empty; and >> getNextWindow() returns null when it runs out of windows. >> >> If you do get stuck in an infinite loop in a modern JAWS version >> though, you can escape it and shut down JAWS by typing >> Insert+Windows+F4. >> >> On Sun, May 06, 2012 at 07:14:42PM -0400, Andrew Hart wrote: >> Correct me if I am wrong, but the while loop in this code makes me >> nervous as it seems rather dangerous. The only way in which it can >> terminate is if a window with the desired control id is found. >> If the loop runs out of sibling windows to search, hWin1 and hWin2 will >> end up with the value 0, but x will never get set to False. >> In that case, the script will continue looping for ever, thus hanging >> JAWS. >> >> If the window is guaranteed to exist, this is ok, but it would be good >> coding practice to include another loop termination condition as a >> safety net in case the application decides to behave badly or a future >> update to the application removes the guarantee that the window is >> always in the expected place. The termination condition could be a >> simple counter to prevent the while loop iterating more than some >> limited number of times that is considered reasonable (e.g. 10 or 20 >> iterations would probably suffice). >> >> Btw, if anything were to go wrong and the script failed to locate a >> window with the desired control id, the only way to recover from the >> infinite loop would be to punch the off button on the machine. I have >> managed to drop JAWS into infinite loops on numerous occasions (due to >> an error in programming logic) and the result is not pretty and >> definitely an occasion for slapping one's forehead and thinking "idiot!" >> Every time I do this I feel like that bowl of petunias in Douglas >> Adam's the Hitch-Hiker's Guide to the Galaxy: "Oh no, not again." >> >> Hth, >> Andrew. >> >> On 6/05/2012 5:30 PM, Steve Matzura wrote: >>> An interesting take. Problem is, if the window isn't there, what kind >>> of error will I get back from the calling line? >>> >>> Anyway, I did solve the problem, and here's the script for it. Sorry >>> about the bad line-wrapping. >>> >>> include "hjconst.jsh" >>> >>> Script FocusSearchList () >>> >>> ; This script, attached to CTRL+Shift+L, ensures >>> ; PC cursor is on a particular control before doing anything else. >>> >>> var handle hWin1, handle hWin2, >>> int x >>> >>> let hWin1 = GetCurrentWindow () >>> if GetControlID (hWin1) != 1001 >>> then >>> SayMessage (ot_jaws_message, "Place the PC Cursor on >>> the search edit field before executing this script.", "PC Cursor to >>> search field first.") >>> return >>> endif >>> >>> let hWin1 = GetParent(hWin1) ; Go up one level. >>> let x = TRUE >>> >>> while x >>> >>> let hWin2 = GetNextWindow (hWin1) ; Go right one window. >>> if GetControlID (hWin2) == 1019 ; Window not accessible via normal tab >>> ; controls >>> then >>> SetFocus (hWin2) ; Force the PC Cursor to that window. >>> let x = FALSE ; Terminate the while condition. >>> else >>> let hWin1 = hWin2 >>> ; Save the current window handle for the next go-round. >>> >>> Endif >>> >>> EndWhile >>> >>> ; Script should always find the window with control ID 1019 this way. >>> ; Question: What value would hWin2 have if it got to the >>> ;rightmost window and couldn't find the one with control ID 1019? >>> >>> EndScript >>> >>> >>> On Sun, 6 May 2012 08:05:10 -0700, you wrote: >>> >>>> You can use the function IsWindowVisible() >>>> That will tell you if it is present or visible rather. >>>> John >>>> -----Original Message----- >>>> From: jawsscripts-bounce@xxxxxxxxxxxxx >>>> [mailto:jawsscripts-bounce@xxxxxxxxxxxxx] On Behalf Of Steve Matzura >>>> Sent: Sunday, May 06, 2012 7:34 AM >>>> To: jawsscripts >>>> Subject: [jawsscripts] An interesting scripting problem >>>> >>>> I'm scripting an application that has a window that's sometimes there, >>>> sometimes not. The first order of business is to check if the window is >>>> there, and if it is, set focus to it. I know the control ID of the >>>> window, >>>> 1019. I'm trying to use FindDescendantWindow with a start handle of 0 to >>>> verify its existence. My script so far looks like this: >>>> >>>> Script ReadSearchStatus () >>>> >>>> var handle hwin >>>> >>>> let hwin = FindDescendantWindow (0, 1019) >>>> >>>> if hwin > 0 >>>> then >>>> Say ("search window present.", ot_jaws_message, false) >>>> >>>> ; Insert code to set focus to the window. Should I even bother ; with >>>> this? >>>> ; Should I just try setting focus and if it fails, assume the window's ; >>>> not >>>> present? >>>> >>>> else >>>> Say ("search window is not present.", ot_jaws_message, false) >>>> >>>> endif >>>> >>>> EndScript >>>> >>>> The problem is, it always comes up saying the window is present, even >>>> when >>>> it's not. >>>> __________o?= >>>> >>>> View the list's information and change your settings at >>>> //www.freelists.org/list/jawsscripts >>>> >>>> __________??? >>>> >>>> View the list's information and change your settings at >>>> //www.freelists.org/list/jawsscripts >>>> >>> __________??? >>> >>> View the list's information and change your settings at >>> //www.freelists.org/list/jawsscripts >>> >>> >>> >> >> >> __________??? >> >> View the list's information and change your settings at >> //www.freelists.org/list/jawsscripts >> > > > __________� > > View the list's information and change your settings at > //www.freelists.org/list/jawsscripts > > > > __________� > > View the list's information and change your settings at > //www.freelists.org/list/jawsscripts > > > __________� View the list's information and change your settings at //www.freelists.org/list/jawsscripts