How application get mouse movement when using pyautogui - pyautogui

When I move mouse without pyautogui pass by a application, for example windows calculator, button of calculator will change it's color. It seems that, calculator captured the movement of my mouse.
Like this, you can see button 9 color changed to gray:
But when I use pyautogui, invoke pyautogui.moveTo function. I can see the mouse cursor move to the correct location, but button 9's color keep white.
I'm sure that the x,y possion pass to function pyautogui.moveTo is correct. If I invoke pyautogui.click(), number 9 is showed on calculator.
Is there any way to ensure that application recognize the movement triggered by pyautogui?
Thank you

Well Although I don't really see a problem here if it bugs you that much try to use the third argument for the moveTo() function.
>>> pyautogui.moveTo(100, 200, 2) # moves mouse to X of 100, Y of 200 over 2 seconds
Here it will slide over slowly in two seconds and will give the hover effect.
If the duration is less than pyautogui.MINIMUM_DURATION the movement will be instant. By default, pyautogui.MINIMUM_DURATION is 0.1.
Hope this helps.

Related

Raycasting on moving objects

I would like to create some mouse interactions on several moving planes and for that, I need to know which planes I'm hovering on. I've implemented the Raycasting method like in your example here but it seems like I'm hovering all my planes in the center of the canvas, just like if the raycasting method wasn't considering my position.set() modifications.
You can see here an example of what I did here, I logged the result of the hits array at the end of the canvasSlider.js file and all planes are logging when hovering in the center.
Is there a way around that? Or I'm I doing something wrong? Thanks a lot.
The main issue is that you are setting the z scale to 0.
plane.scale.set(1, size.height/size.width, 0);
Replace the 0 with a 1 to enable the hit tests to function.
Another issue I noticed was that your mouse values are relative to the screen and not the canvas. As the canvas is on a scrolling page it may not be taking up the full screen at all times.

How to re-spawn particles randomly in Away3D

I'm attempting to create a particle effect using Sparticle and Away3d. The effect is a little burst of bubbles that float up to the top of the screen when items are clicked.
I have the effect loaded and working and it looks good, but unfortunately the effect always spawns the bubbles with the same random velocities each time. The velocities seem to be set when the animation first runs and then never changes.
How do I restart the animation with new velocities each time?
I've tried calling stop and start on the animator, and resetTime but I suspect it's just moving the time back to 0 and that's why the animation isn't actually restarting properly.
i.e.
particleGroup.animator.stop();
particleGroup.animator.start();
The reset method doesn't do anything because it expects an animation name, and the animation name set in the sparticle editor doesn't seem to be available.

Quartz Composer and Origami: Can't get X value to change with Interaction2 patch

I'm learning Quartz Composer and Origami. I have a simple interaction set up like this:
I have an interaction2 patch attached to the image layer and a transition patch. On clicking the image layer, it should trigger a transition from 0 to 100. The output of the transition patch is wired to the x-position of the layer. So, presumably, when clicking the image layer, its x-position should go from 0 to 100.
However, the image layer just flickers quickly to an x-position of 100 but does permanently move.
Can anybody explain why this is happening and how to fix it?
Thanks!
You will have to drag in a switch patch from the patch library, and hook it up between your interaction patch and transition patch.
In your example the X Position of the layer is going from 0 to 100, but not when you're expecting it to. It seems like you are expecting the the value to go from 0 to 100 and then stay there, but instead it is going from 0 to 100 on mouse up and then back to 0. This is because the click is producing a signal, a value of 1 for a single frame.
Try connecting the [Interaction 2] Down -> Progress [Transition] (meaning the Progress input port of the Transition node) and you'll see the layer move 100 in X when the mouse is down and then snap back to 0 when the mouse is up. To get the behavior you expect you need to flip a switch with the signal coming from the mouse and then set the range of that value.

as3: mouse_move event in full screen mode and mouseLock on slow mouse movements

With flash and AS3 it seems to be a problem with mouse move event in full screen mode and mouseLock activated that I don't understand how to solve.
When I enter in full screen mode with Stage.mouseLock property enabled and i make very slow movements with the mouse, the two properties to determine the location of the mouse (MouseEvent.movementX and MouseEvent.movementY) return zero (0).
A print of the event event.toString() returns:
[MouseEvent type="mouseMove" bubbles=true cancelable=false eventPhase=2 localX=0 localY=0 stageX=0 stageY=0 relatedObject=null ctrlKey=false altKey=false shiftKey=false buttonDown=false delta=0]
"The mouse can be moved as far as I want always returning 0 for x and y if the mouse are moved very slow, so it's impossible to determine the movement of the mouse." (*) After a better test I've added a correction of this sentence, below in the "Note".
It's very strange because the event are fired correctly when the mouse is moved (also with slow movements), but the returning movement is 0. Seems like the movement is < 1 but are reported only integer movements, so the values are always returned 0.
I've tried also changing mouse settings of OS (Mac OSX) without success.
If you want I can give you sample code to enter in fullscreen mode and activate Stage.mouseLock properties.
Thank you for any suggestion.
Note:
After testing better I've found that flash player (my flash player version is 11,7,700,203) has a behavior that looks like a bug: if the current mouse movement (movementX and movementY) is equals to the previous movement, than flash return movementX=0 and movementY=0. The next mouse movement will be the correct value because it will be different from zero.
Because of this, with a constant movement always in the same direction (with a very slow movement is easier to reproduce), the player show "zero values" every two events fired.
At this link you can test a working example (faster than code yourself an example).
If the behavior I've found is correct, than it's easy to modify the code to rectify this problem, anyway IMHO it remain a bug. I'll report it to adobe.
At this other link (thank you to #nemostein) there is another working example.
I try to explain me better: if you move the cursor very slowly (i.e. to the right direction) you'll receive the output Movement( X:1 Y:0 ) when you move the cursor enough. If you move again the cursor enough to the right you'll receive the output Movement( X:0 Y:0 ). If you repeat the micro movements you'll receive the movements report always with this pattern: (x:1,y:0),(x:0,y:0),(x:1,y:0),(x:0,y:0)... instead of (x:1,y:0),(x:1,y:0),(x:1,y:0)...
I think it's wrong to receive a movement like (x:0,y:0) and seems to me that this values are returned every time when you make a movement equals (both the x and the y) to your previous movement.
I hope this is understandable.
There is no bug, but the MouseEvent.movementX/Y (alongside with MouseEvent.localX/Y and MouseEvent.stageX/Y) are somewhat misleading...
Although they are Numbers, not ints, there is no such thing like "half pixel", so they always reports int values.
The precision you're looking for (e.g.: movementX == 0.75) can't be achieved.
I couldn't reproduce the behavior you described at the note ("current mouse movement equals to the previous") and here is a working example of Stage.mouseLock = true and Stage.displayState = StageDisplayState.FULL_SCREEN.
Note that if you move the cursor very slowly you'll, eventually, receive an MouseEvent.movementX/Y == 1 (when you moved the cursor enough).
I've asked in adobe forum and they told me to open a bug.
Here is the link: https://bugbase.adobe.com/index.cfm?event=bug&id=3575123

Flex Smooth Drag of Objects

I'm trying to create an object which can be moved in Flex 4.
I tried http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf64595-7fed.html but in this most examples actually leaves the actual object (at pause) until the drag is completed, but I'm looking for something where the update will be done/shown while the drag is still on ... in those lines I've tried: Problems replicating drag-and-drop with mouse events ... but here I dint understand 'what are MouseHelper & EventHelpers'.
Also tried this: Flash AS3 custome Dragging using MOUSE_MOVE event but the movement is not smooth, very jig-jag.
Any suggestions are most welcome.
Regards
here's an example with 5 ways of dragging (four are commented out):
* MouseEvent.MOUSE_MOVE
* Event.ENTER_FRAME
* startDrag(true)
* Timer(10) which sets x = mouseX y = mouseY every 10ms
* Timer(100) which creates a tween to mouseX, mouseY instead of applying values
If i move the mouse fast enough all of those modes (at 30fps) look as if a sprite is chasing mouse cursor, not being dragged, and also the animation is not smooth at all. However the smoothest animation is provided by tweener, but that mode shows a bigger average distance between mouse cursor and the sprite being dragged.
and btw fast dragging e.g. windows explorer also makes it blink because it doesn't have enough time for rendering at every position