Hi Yuri,
Here's a form that does (for me) what you've outlined in your example ...
set typeahead to 20
o1 = createobject( "myform" )
o1.show()
on key label esc clear events
on key label f2 o1.stuff_it()
read events
on key label esc
on key label f2
define class myform as form
add object lbl1 as label with autosize = .t., ;
caption = "[F2] stuff it [Esc] exit"
add object lst1 as listbox with top = 40, ;
multiselect = .t.
proc init
for i = 1 to 30
thisform.lst1.Additem( transform( m.i, "@L 9999" ) )
next
proc queryunload
clear events
proc stuff_it
thisform.lst1.setfocus()
thisform.lst1.selected(1) = .t.
keyboard "{shift+end}{shift+enter}"
keyboard "{shift+home}"
do while chrsaw()
doevents
enddo
thisform.lst1.topitemid = 15
enddefine
>Ok, if wait window after keyboard .. is confusing, then we may consider another example.
>
>Let us suppose I have a multiselect listbox on the form and I want to select all and then make a topindex, say to 15:
>
>
>with thisform.List1
> .setfocus
> .Selected(1) = .t.
> KEYBOARD '{SHIFT+END}{SHIFT+HOME}'
>
> .TopItemid=15
>....
>
>
>
>Whether it is not obvious that .TopItemid=15 need to be implemented AFTER all items are selected with the keyboard? But it is not, it goes first! (Yes, I know there is another way to select all; it is here just to play with the keyboard command.)
>
>
>
>>I'm running a "custom" PC with an 800 mhz Intel processor, Windows ME (all my other OS's are currently trashed due to various circumstances) and VFP 7 SP1.
>>
>>As far as I'm concerned, the 3 lines of code I showed you "work" (the _VFP.Autoyield property is not important ... It was something I thought was a factor, but clearing the "hello" from the command window indicates it was not).
>>
>>Not sure what you mean by: "how to control the behavior" ? You mean clearing "hello" from the command window ? I would look into this but only once you can reproduce "my behavior"; ie. it works with the 3 lines I showed and one clears the command window between each iteration.
>>
>>In any event, in a "live" application, the command window should not be a factor.
>>
>>I can mock up a simple form, read events, etc, and probably prove to you that the "3 lines of code" would work in a regular application, if you wanted me to ...
>>
>>
>>
>>>Gerry, thanks
>>>
>>>Any clue on how to control the behavior?
>>>Could you give more details on what is the PC, Windows version, VFP version?
>>>
>>>>I get "hello" in the popup window and "hello" in the command window ...
>>>>
>>>>However, running the same little program repeatedly I start getting inconsistent results, UNLESS I clear the "Hello" from the command window first.
>>>>
>>>>>Just to make sure:
>>>>>Do you get "hello" in the popup window and "hello" on the command window?
>>>>>Or do you get "ello" on the command window?
>>>>>
>>>>>>Funny ... seems to work for me ... with a "clean" start of VFP 7.0.
>>>>>>
>>>>>>There may be another environment setting that is impacting you :(
>>>>>>
>>>>>>>Thank you, but still no luck.
>>>>>>>
>>>>>>>>Insure
>>>>>>>>
>>>>>>>>_VFP.Autoyield = .T.
>>>>>>>>
>>>>>>>>
>>>>>>>>prior to running that section of code.
>>>>>>>>
>>>>>>>>>No, it does not help.
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>KEYBOARD "hello"
>>>>>>>>>>DOEVENTS
>>>>>>>>>>WAIT WINDOW "hello"
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>Looks like this always works in revert order:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>KEYBOARD "hello"
>>>>>>>>>>>WAIT WINDOW "hello"
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>What should be done to delay the second line execution until keyboard is completed?