VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Moving cursor position to previous field (https://forums.vandyke.com/showthread.php?t=12361)

ShawnVW 05-19-2016 02:45 PM

Moving cursor position to previous field
 
Is there a way to change the cursor position? I'm using secureCRT 7.3.3 and VBS.

I need to be able to move the cursor from the current field to the one preceding it. Manually, the only way to move the cursor back is with the Up Arrow key.

I tried recording a script, used Up Arrow to get to the desired field, and got this:

crt.Screen.Send chr(27) & "[A" & chr(13)


But playing it back does not do anything.

bgagnon 05-20-2016 08:37 AM

Hi ShawnVW,

So it sounds like you are working inside some menued application, correct?

It might be difficult to accomplish this task via scripting because the tasks are dependent on timing. You have to be able to detect the cursor is in the "wrong field" before pressing the Up arrow would accomplish the objective.

How do you know when the cursor is in the "wrong" field?

ShawnVW 05-20-2016 10:09 AM

Quote:

Originally Posted by bgagnon (Post 45834)

How do you know when the cursor is in the "wrong" field?

It depends on whether the script changes the value in the Zip Code field. If it does, the screen automatically fills in the City, State, and Country fields, and the cursor proceeds to Phone Number. That's the "wrong field" because I occasionally need to go back and change City, State, or Country.

I did find a workaround: I can change the Zip, finish and save the screen, then start over. This time the script won't change the Zip, so it can tab down to City, State, or Country and change it if needed.

If you still know a way of "tabbing backwards", I'm sure it will come in handy at some point.

bgagnon 05-20-2016 10:56 AM

Hi ShawnVW,

Thanks for the clarification. I am glad to hear you found a workaround.

You probably would use SendKeys() instead of Send() to simulate the up arrow:

Code:

  crt.Screen.SendKeys "{UP}"


All times are GMT -6. The time now is 01:36 PM.