After the FindWindow, hwnd will either be 0 or initailized, rendering your else case there impossible. Try this: ---------- script CheckTrunk801() var handle hwnd let hwnd = findWindow(getAppMainWindow(getFocus()), "TfcImageBtn", "801") if !hwnd then sayString("Window not found.") return endIf saveCursor() jawsCursor() saveCursor() if moveToWindow(hwnd) then sayString("Successful move. Current handle "+intToString(getCurrentWindow())+", hwnd "+intToString(hwnd)) else sayString("Failed move. visible "+intToString(isWindowVisible(hwnd))+", obscured: "+intToString(isWindowObscured(hwnd))+", disabled: "+intToString(isWindowDisabled(hwnd))) endIf endScript ---------- On Tue, 6 Jul 2010 15:20:15 +1000, Geoff Chapman wrote: > Hi Scripters. > Wondered if any of you might have time/energy, if you would mind squizzing > through the below code, complete with some debug conditions, just to also > show I've been trying to do that, > and perhaps tell me if you see anything amiss with it? or even non-optimally > coded? > I'm getting intermittent and unreliable successful MoveToWindow results, > even though I'm getting 100 percent successful WindowFinds, and, this just > doesn't make any sense to me. I"ve worked for some time trying to get to the > bottom of it, with multiple to no pause statements etc, but, it's just not > seeming to be returning me reliable results. > When I seek to execute a few identical scripts as the below, obviously > looking for diferent handles, even though I well realize this code is not > going to work across multiple sessions, because it's only looking for literal > handles, which I realize change every program run, > but, I thought I should at least be able to get this much to work > successfully, before embarking on some more complex way of uniquely > finding/identifying the necessary window buttons I have to click on. > The control ID's are the same as the handles in this application. > So I guess if I take this method I'm eventually going to have to do some > totally never embarked on methodology of counting windows along at a certain > level or some such crazyness, but, for now, let's just work on this immediate > problem of why my moveToWindows keep intermittently returning unsuccessfully? > even though it's got a perfectly valid handle to work with? so far as I can > see? > > So when I execute multiple identical scripts with hotkeys as the below, > many times I'm hearing the message, MoveToWindow not successful, even though > it reports that it finds the correct window handle after the first FindWindow > function. > and, the hTrunk has the same value, after the findWindow, whether the > MoveToWindow is successful or not! > > it just doesn't make sense to me, why, if it's got the right window handle, > that it's reporting an unsuccessful moveToWindow! > > But, when the MoveTo is unsuccessful, and I hear that message as in the code > below, the window text and name that it reads me, is indeed, the wrong > window, and the mouse remains in the wrong window too, > even though, it supposedly still has the handle of the correct window, that > it's supposed to be moving to! > So, I just don't get that! > > The only thing I can figure that might be responsible for this, > , is that perhaps, this FindWindow function, doesn't do an absolute equals > reference, on the WindowName parameter? however one should express that? But > rather, perhaps it only does a StringContains type thing? because, all the > buttons/windows are the same class of TfcImageBtn, and the wrong window that > the mouse ends up in, when the moveToWindow returns 0, does contain, the > windowName string, of, say 801, in below script, that constitutes the entire > name, of the window it's supposed to be moving to. > > > I know this probbly doesn't make a lot of sense, maybe looking at the code > will be easier for people than following my hopeless explanation of the > problem? bottom line is, it's not reliable a lot of the time, and, if there's > any stupid logic errors I'm making, then, yeah, be absolutely helpful for me > to know what they might be. > > One question about the below code I do have straight up, is, do I actually > need the separate hTrunk Handle to do what I'm wanting to do below? or is > that redundant/superfluous, and I could just happily keep reusing hwnd for > everything? > > here comes the spagheti code, as a scripter lady I know would probably deem > this. > <smile.> > > > > Script CheckTrunk801 () ; alt+1 > > ; single click manually reports the Color status of the corresponding Trunk > to the number key pressed. > > ; DoubleClick Will execute a mouseClick on that Trunk. > > ; well, it would it the jolly thing worked properly! > > var > > > > Handle hTrunk, > > > > string sTemp, > > > > handle hwnd > > > > if IsSameScript () then ; doublePress code > > let hwnd = GetAppMainWindow(GetFocus()) > > > > JawsCursor () > > > > let hTrunk = FindWindow (hwnd, "TfcImageBtn", "801") > > ; could I have used hwnd twice in the above line, and eliminated the need for > the secondary hTrunk? or not. > > > > ; and, does FindWindow do a totally equals value on the windowName string, or > does it only do a StringContains check? > > > > if hTrunk == 395774 then > > > > ; this is the absolute handle of the window I want it to move to and click > in, even though I realize this won't work as a final solution. > > > > ; we presume correct 801 window was found for this session so tell user > > > > let sTemp = "After the first stage of locating window, the handle found is: " > + IntToString (hTrunk) + "\n" > > > > CopyToClipboard (sTemp) > > > > SayInteger (hTrunk) > > > > SayString ("correctWindow found") > > > > ElIf hTrunk == 0 then > > > > SayString ("hTrunk = 0, no window found") > > > > else ; couldn't find it so tell me. > > > > SayString ("Window not found") > > > > EndIf ; Which window found check @@@for DebugTest > > > > ;pause () > > > > ;Pause () > > SayWindow (hTrunk, 0) > > > > MoveToWindow (hTrunk) > > > > if MoveToWindow (hTrunk) == 1 then > > > > let sTemp = "After a successful MoveToWindow, the handle is: " + IntToString > (hTrunk) + "\n" > > > > let sTemp = sTemp + "The text in this window is: " + GetWindowText (hTrunk, > 0) + "\n" > > > > let sTemp = sTemp + "The name of this window with handle hTrunk, is: " + > GetWindowName (hTrunk) > > > > AppendToClipboard (sTemp, true) > > > > SayString ("moved to Window successfully") > > > > else > > > > let sTemp = "After an unsuccessful moveToWindow attempt, the handle of the > window is: " + IntToString (hTrunk) + "\n" > > > > let sTemp = sTemp + "The text in this window is: " + GetWindowText (hTrunk, > 0) + "\n" > > > > let sTemp = sTemp + "The name of this window with handle hTrunk, is: " + > GetWindowName (hTrunk) > > > > AppendToClipboard (sTemp, true) > > > > SayString ("MoveToWindow Not successful") > > > > EndIf ; Move to Window accuracy check@@@for DebugTest > > > > SayWindow (hTrunk, 0) > > > > SayUsingVoice (VCTX_JAWSCURSOR, "Click Trunk1", OT_String) > > > > ; I realize I should not use an absolute hard coded trunk value here, and > make the voice repeat what trunk/window button it's actually found. > > > > LeftMouseButton () > > > > ; I also realize I should not click if the moveTo is unsuccessful. and should > move that code into the if Statement. > > > > PcCursor () > > > > else ; SinglePress code > > > > QueryThisTrunk (1) > > > > EndIf ; IsSameScriptCheck > > > > EndScript > > > > > > __________� > > View the list's information and change your settings at > http://www.freelists.org/list/jawsscripts __________� View the list's information and change your settings at http://www.freelists.org/list/jawsscripts