Hello,
Is there a way to press enter key programmatically?
Thanks.
Lennox
Hello,
Is there a way to press enter key programmatically?
Thanks.
Lennox
In keydown event
If key = chr(3) Then
//do whatever you want to do
end if
Hi Roger,
Something like this
Pushbutton1.Push that will click Pushbutton1
Now Keyboard.AsyncKeyDown(24).Push is there something like that will simulate a click of the keyboard Enter Key?
Thanks.
Lennox
Move the code to be executed into a separate method and call that method from both the KeyDown event and the other place you want.
In which control ? Which platform ?
OK, this is what I am trying to accomplish…
I have an app with several pages in a PagePanel, 10 pages, macOS Sierra Version 10.12.5
(I already can accomplish this in PC)
I would like to create a .png file of each page sequentially and automatically when I click a pushbutton.
I do not want to use DrawInto because it lacks colour in several areas, so I use this…
[code]dim mshell as new Shell
mshell.Execute "screencapture -W -o -c"
pict = c.Picture[/code]
as part of the routine.
When I click the pushbutton the first picture is ready to be taken, the window is already selected, all I have to do is to physically click the mouse, it is already in position, .png document will be created, then the next picture is ready to be take, I have to click the mouse again, and the cycle goes on until a .png is created for all of the pages, (Sorry about the enter key, I thought that would work.
How can I do a mouse click programatically? Once I can code the mouse click it will be done programatically every time in the for loop.
Thanks.
Lennox
Edit: I just saw this https://forum.xojo.com/12285-move-mouse-cursor-and-click-by-code-for-mac/0 so I will try it.
Tried this too
Regarding the problem of having to call the method twice, I think there might be an error in the 2nd from last line of code. Shouldn’t it read:
CGEventPost( tapLocation, releaseMouse)
and it does not work for me, I still have to click the mouse physically.
Lennox
OK, the code for the LeftMouseClick works with this correction
Regarding the problem of having to call the method twice, I think there might be an error in the 2nd from last line of code. Shouldn’t it read:
CGEventPost( tapLocation, releaseMouse)
if I use it in a mouseEnter event and I move the mouse physically over that pushbutton, so the code works, but in my loop it does not work.
Lennox
IIRC, you are trying to do this within a for…next loop. Until you let go of that idea, this is not going to work for you because this tight loop does not allow the main thread any time to perform its task. Your flow should probably look something like this…
Thanks Roger,
Set the page panel to value = 0 (to show first page)
initiate the process with a click of a button or a menu selection
take the first picture,
fire a timer, which calls the next iteration, to give the system time to perform
flip to pagePanel.value = 1
so far so good
take the next pic =====> I have to do this manually ===> LeftMouseClick fires but does not complete the click, a camera icon comes up and the only thing that works is a manual mouse click
Thanks again.
Lennox
Sometimes, I wonder …
No need to click or press enter. use the DELAYED screen shot with value zero second.
http://osxdaily.com/2010/06/09/screen-capture-in-mac-os-x/
dim mshell as new Shell
mshell.Execute "screencapture -T 0 delayedpic.jpg"
sigh
Thanks Michel, but that will give the whole screen not a particular window, unless somehow, the parameters for that window could somehow be passed.
Apparently, the programatic leftmouseclick needs to be in the shell.
Thanks again.
Lennox
Grab the whole screen, then get only the window part programmatically from the picture. If it is one of your windows, you already have left, top, width and height.
But far from me to deprive you from the pleasure of the hunt of impossible.
Hi Michel,
Sounds as a workable solution, good thought, I will try that and see.
Thanks again.
Lennox
Thanks Michel,
That works great, did not think about that. When you are in you don’t see/think logically.
Thanks again.
Lennox