autopy-legacy
autopy-legacy copied to clipboard
How to do a double-click?
mouse.click works great. But i can't figure out how to do a double-click. I've tried various ways. I'm on the mac platform.
for _ in range(times):
print "calling mouseclick"
mouse.toggle(True, button)
# sleep(0.1)
mouse.toggle(False, button)
# sleep(0.1)
For example, this doesn't work with or without the sleep calls.
I'd also be interested in being able to click and hold to drag a window for example.
If you want to try dragging then you might try something like mouse.toggle(True) and then later mouse.toggle(False). This does not have the effect of dragging the window smoothly. The window does jump from where it was to Where the mouse is when you you called the second toggle.
For double-click, see my fork at https://github.com/potpath/autopy.
I ported double-click code from cliclick at https://github.com/BlueM/cliclick/blob/master/Actions/DoubleclickAction.m.
Thanks. Is your code cross-platform or does it only work on the Mac?
On Sat, Mar 21, 2015 at 8:45 AM, potpath [email protected] wrote:
For double-click, see my fork at https://github.com/potpath/autopy.
I ported double-click code from cliclick at https://github.com/BlueM/cliclick/blob/master/Actions/DoubleclickAction.m.
— Reply to this email directly or view it on GitHub https://github.com/msanders/autopy/issues/66#issuecomment-84375242.
Michael
Your patch works for me. There were a couple lines you had to change to keep clang happy. I had to switch them back for the same reason. We're probably using different versions of some library.
diff --git a/src/autopy-key-module.c b/src/autopy-key-module.c
index b115321..99ec938 100644
--- a/src/autopy-key-module.c
+++ b/src/autopy-key-module.c
@@ -76,7 +76,7 @@ PyMODINIT_FUNC initkey(void)
"autopy module for working with the "
"keyboard");
#endif
- if (mod == NULL) return NULL; /* Error */
+ if (mod == NULL) return ; /* Error */
/* Needed for type_string(). */
deadbeef_srand_time();
@@ -117,7 +117,7 @@ PyMODINIT_FUNC initkey(void)
PyModule_AddIntMacro(mod, K_SHIFT) < 0 ||
PyModule_AddIntMacro(mod, K_CAPSLOCK) < 0) {
PyErr_SetString(PyExc_ValueError, "Error adding keycode constant
- return NULL;
+ return ;
}
#ifdef PYTHREE
return mod;
diff --git a/src/autopy-mouse-module.c b/src/autopy-mouse-module.c
index 021be2a..4a1944e 100644
--- a/src/autopy-mouse-module.c
+++ b/src/autopy-mouse-module.c
@@ -85,14 +85,14 @@ PyMODINIT_FUNC initmouse(void)
mod = Py_InitModule3("mouse", MouseMethods,
"autopy module for working with the mouse
#endif
- if (mod == NULL) return NULL; /* Error */
+ if (mod == NULL) return ; /* Error */
/* Add mouse button constants for click_mouse(). */
if (PyModule_AddIntMacro(mod, LEFT_BUTTON) < 0 ||
PyModule_AddIntMacro(mod, RIGHT_BUTTON) < 0 ||
PyModule_AddIntMacro(mod, CENTER_BUTTON) < 0) {
PyErr_SetString(PyExc_ValueError, "Error adding constants to mou
- return NULL;
+ return ;
}
deadbeef_srand_time();
I think it might be the Python version. I'm using this one, installed by homebrew:
Python 2.7.8 (default, Oct 24 2014, 11:16:42)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin
I haven't tested it on any platform other than Mac, but I think it should work.
I installed Python by MacPorts:
Python 3.4.3 (default, Mar 10 2015, 14:53:35)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
For me, I think it should be about compiler. This is my clang:
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
I have a similar clang:
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
I think it's likely a python two versus Python three issue.
I implemented triple click in my fork. Let me know if you want want a pull request. Thanks again. This was really helpful.