1. Keystrokes simulations

Bom dia para todos.
Good morning for all

I use with success the below code line:

 ii=invokeHandler(PushButton34, w32HClick, {})	

But the next line don't work:

  ii = invokeHandler(PushButton34, VK_TAB, {})

The target is simulates the TAB key to change the focus 
to another objects inside an windows. I also was try :

  ii = invokeHandler(WinMain1, VK_TAB, {})

But, this don't work too.

How can I simulates a keystrok into a progran ?

Many thanks.

Sérgio Gelii - Brasil

new topic     » topic index » view message » categorize

2. Re: Keystrokes simulations

Sergio Gelli wrote:
> 
> Bom dia para todos.
> Good morning for all
> 
> I use with success the below code line:
> 
>  ii=invokeHandler(PushButton34, w32HClick, {})	
> 
> But the next line don't work:
> 
>   ii = invokeHandler(PushButton34, VK_TAB, {})
> 
> The target is simulates the TAB key to change the focus 
> to another objects inside an windows. I also was try :
> 
>   ii = invokeHandler(WinMain1, VK_TAB, {})
> 
> But, this don't work too.
> 
> How can I simulates a keystrok into a progran ?
> 
> Many thanks.
> 
> Sérgio Gelii - Brasil

Hello Sergio,

  w32HClick is an event.
  VK_TAB is an attribute.

  Try: ii = invokeHandler(WinMain1, w32HClick, {})

Don Cole

new topic     » goto parent     » topic index » view message » categorize

3. Re: Keystrokes simulations

don cole wrote:
> 
> Sergio Gelli wrote:
> > 
> > Bom dia para todos.
> > Good morning for all
> > 
> > I use with success the below code line:
> > 
> >  ii=invokeHandler(PushButton34, w32HClick, {})	
> > 
> > But the next line don't work:
> > 
> >   ii = invokeHandler(PushButton34, VK_TAB, {})
> > 
> > The target is simulates the TAB key to change the focus 
> > to another objects inside an windows. I also was try :
> > 
> >   ii = invokeHandler(WinMain1, VK_TAB, {})
> > 
> > But, this don't work too.
> > 
> > How can I simulates a keystrok into a progran ?
> > 
> > Many thanks.
> > 
> > Sérgio Gelii - Brasil
> 
> Hello Sergio,
> 
>   w32HClick is an event.
>   VK_TAB is an attribute.
> 
>   Try: ii = invokeHandler(WinMain1, w32HClick, {})
> 
> Don Cole

Hi Don
ii = invokeHandler(WinMain1, w32HClick, {})
It simulates a mouse click over WinMain1
I need simulates a TAB key down and others 

Thanks

Sérgio Gelli - Brasil

new topic     » goto parent     » topic index » view message » categorize

4. Re: Keystrokes simulations

I goofed up that should have been:

ii = invokeHandler(WinMain1, w32HKeyPress ,{})

Don Cole

new topic     » goto parent     » topic index » view message » categorize

5. Re: Keystrokes simulations

don cole wrote:
> 
> I goofed up that should have been:
> 
> ii = invokeHandler(WinMain1, w32HKeyPress ,{})
> 
> Don Cole

Ok Dan, 

but How the control receives the key TAB ?
Maibe I don't explain my problem exactly.
I need simulates a TAB KEY to change the focus to another
control.
How  I do it?

Sérgio Gelli

new topic     » goto parent     » topic index » view message » categorize

6. Re: Keystrokes simulations

> but How the control receives the key TAB ?
> Maibe I don't explain my problem exactly.
> I need simulates a TAB KEY to change the focus to another
> control.

With what you were doing, you'd have to do this:

VOID = invokeHandler( WinMain1, w32KeyPress, {VK_TAB} )

> How  I do it?

This usually works to force focus to another control.

setFocus( MyControl )


~Greg

new topic     » goto parent     » topic index » view message » categorize

7. Re: Keystrokes simulations

As a general principal, manipulating a program by means of simulating keyboard
input is a bad idea that can lead to a number of difficult problems. There will
almost always be a better way. In this particular case setFocus(id) would seem
the best choice.

Larry Miller

new topic     » goto parent     » topic index » view message » categorize

8. Re: Keystrokes simulations

Greg Haberek wrote:
> 
> > but How the control receives the key TAB ?
> > Maibe I don't explain my problem exactly.
> > I need simulates a TAB KEY to change the focus to another
> > control.
> 
> With what you were doing, you'd have to do this:
> 
> VOID = invokeHandler( WinMain1, w32KeyPress, {VK_TAB} )
> 
> > How  I do it?
> 
> This usually works to force focus to another control.
> 
> setFocus( MyControl )
> 
> 
> ~Greg
> 
> 
Hello Greg,

I try it :
VOID = invokeHandler( WinMain1, w32KeyPress, {VK_TAB} )
But it does nothing.

I need change the focus control without setFocus() because
it not make the Windows lost the exhibition order of the controls focus.
Ex: I have 1,2,3,4 controls. The focus is on number 1.
After do a setFocus(3)
if press a Tab Key the focus go to the 2 controls, instead the 4.

Pehalps don't exists how do a simulate Keystrokes in Win32 ?

Sérgio Gelli

new topic     » goto parent     » topic index » view message » categorize

9. Re: Keystrokes simulations

Sergio Gelli wrote:
> 
> don cole wrote:
> > 
> > I goofed up that should have been:
> > 
> > ii = invokeHandler(WinMain1, w32HKeyPress ,{})
> > 
> > Don Cole
> 
> Ok Dan, 
> 
> but How the control receives the key TAB ?
> Maibe I don't explain my problem exactly.
> I need simulates 

This I don't undestand what you mean. I'm not critisizing because your English
  is much better than my Portuguese but "I need simulates" dosen't mean anything in
  English. Do you mean that you want a tab control to come to the top when key is
  pressed. Or do you want an icon to dance around or something when you hit a tab
  key?

>a TAB KEY to change the focus to another
> control.
> How  I do it?
> 
> Sérgio Gelli


Don Cole

new topic     » goto parent     » topic index » view message » categorize

10. Re: Keystrokes simulations

Hello Sergio,

Put  
returnValue(-1) 
right before your setfocus()

Don Cole

new topic     » goto parent     » topic index » view message » categorize

11. Re: Keystrokes simulations

don cole wrote:
> 
> Sergio Gelli wrote:
> > I need simulates 
> 
>   This I don't undestand what you mean. I'm not critisizing because your
>   English
> is much better than my Portuguese but "I need simulates" dosen't mean anything
> in English. Do you mean that you want a tab control to come to the top when
> key is pressed. Or do you want an icon to dance around or something when you
> hit a tab key?
> 
> >a TAB KEY to change the focus to another
> > control.
> > How  I do it?
> > 
> > Sérgio Gelli
> 
> 
> Don Cole

O.K Sorry my bad English.  
Perhaps you are not certain on my Portuguese:) smile

Please, forget everything that was written before.  I need to order
a key to an application, by a line of code in Euphotia, not by the keyboard. 

Sérgio Gelli

new topic     » goto parent     » topic index » view message » categorize

12. Re: Keystrokes simulations

Sergio Gelli wrote:
> 
> O.K Sorry my bad English.  
> Perhaps you are not certain on my Portuguese:) smile
> 
> Please, forget everything that was written before.  I need to order
> a key to an application, by a line of code in Euphotia, not by the keyboard.
> 
> 

Sérgio:

  If you want to send a key to window program then look at this
  program code in Archive.

http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=sendkey

Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

13. Re: Keystrokes simulations

> I try it :
> VOID = invokeHandler( WinMain1, w32KeyPress, {VK_TAB} )
> But it does nothing.

Correct. This only does what it says. This invokes the handler for
w32KeyPress on the control WinMain1 with parameter VK_TAB. If you do
not have a handler set up, then nothing will happen.

> I need change the focus control without setFocus() because
> it not make the Windows lost the exhibition order of the controls focus.
> Ex: I have 1,2,3,4 controls. The focus is on number 1.
> After do a setFocus(3)
> if press a Tab Key the focus go to the 2 controls, instead the 4.

Do not use such numbers as 1, 2, or 3. You must use the control id
from create(). So if you want to go from Button1 to Button2, simply
call setFocus( Button2 ) when required.

> Pehalps don't exists how do a simulate Keystrokes in Win32 ?

See Sendkeys by PatRat in the Archive.

http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=sendkeys

~Greg

new topic     » goto parent     » topic index » view message » categorize

14. Re: Keystrokes simulations

Greg Haberek wrote:
> > 
> > Pehalps don't exists how do a simulate Keystrokes in Win32 ?
> 
> See Sendkeys by PatRat in the Archive.
> 
> <a
> href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=sendkeys">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=sendkeys</a>
> 
> ~Greg
> 

Hi Greg 

And thanks to all Eu Forum people
The Sendkeys.ew write By Thomas Parslow, was resolved my problem.

I am learning English so:
send keys = simulate keystroks (in my poor translation):) :_)
Sorry again.


Sérgio Gelli.

new topic     » goto parent     » topic index » view message » categorize

15. Re: Keystrokes simulations

Sergio Gelli wrote:
 
> I use with success the below code line:
> 
>  ii=invokeHandler(PushButton34, w32HClick, {})	
> 
> But the next line don't work:
> 
>   ii = invokeHandler(PushButton34, VK_TAB, {})

That function is used to call the user defined handler for one of the win32lib
event types, and not used to simulate keystrokes.
 
> The target is simulates the TAB key to change the focus 
> to another objects inside an windows.

Here is a sample program that could help you...
include win32lib.ew
without warning

integer Win
integer box1
integer box2
integer box3
integer box4
integer btn1
integer SB

function change_focus(sequence pName)
    integer newid

    newid = getNameId(pName)
    if newid > 0 then
        setFocus(newid)
    end if
    return newid
end function

procedure onFocus_id(atom id, atom event, sequence params)
    setText(SB, "Focus is now on '" & getIdName(id) & "'")
end procedure

procedure Key_Box4(atom id, atom event, sequence params)
    if params[1] = VK_ENTER then
        if change_focus(getText(id)) > 0 then
            setText(id, "") -- clear the name of the control
            returnValue(-1) -- tell win32lib to not auto setfocus on return
        end if
    end if
end procedure

procedure Click_Btn1(atom id, atom event, sequence params)
    setFocus(box1)
end procedure

procedure main()

    Win  = create( Window, "TEST", 0, 50, 50, 300, 200,0 )
    box1 = create( EditText, "Box 1", Win, 5, 10, 90, 22, 0)
    box2 = create( EditText, "Box 2", Win, 5, 40, 90, 22, 0)
    box3 = create( EditText, "Box 3", Win, 5, 70, 90, 22, 0)
    box4 = create( EditText, "Box 4", Win, 105, 10, 90, 22, 0)
    btn1 = create( Button, "Set Focus", Win, 105,110, 90, 22, 0)
    SB   = create( StatusBar, "", Win, 0, 0, 0, 0, 0)

    setText(btn1, "Goto Box 1")
    setHint(box4, "Enter the name of control to set focus to it.")
setHandler({box1,box2,box3,box4,btn1},w32HGotFocus,
    routine_id("onFocus_id"))
    setHandler(btn1, w32HClick, routine_id("Click_Btn1"))
    setHandler(box4, w32HKeyPress, routine_id("Key_Box4"))
    WinMain({Win, box1},Normal)
end procedure

main()


Please note that when the Enter key is pressed in an EditText control, Win32lib
will automatically move focus to the next control.

-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu