Commits

Ed Blake committed 5129452

Tweaked Control.Click.

  • Participants
  • Parent commits 8d47e22

Comments (0)

Files changed (3)

 :Description: Python ctypes wrapper around AutoHotKey dll.
 :License: BSD-style, see `LICENSES.txt`_
 :Author: Ed Blake <kitsu.eb@gmail.com>
-:Date: Sep. 4 2012
-:Revision: 4
+:Date: Sep. 6 2012
+:Revision: 5
 
 Introduction
 ------------
         """
         cmd = "Click {0}".format(button)
         if x or y: # Could fail for x&y = 0
-            cmd += "{0},{1} ".format(x, y)
+            cmd += ", {0}, {1}".format(x, y)
         # Click count must occur "somewhere right of the coordinates"
         if count != 1:
-            cmd += "{0} ".format(count)
+            cmd += ", {0}".format(count)
         execute(cmd+'\n')
 
     def winActivate(self, title="", text="", 
         The control arg can be a class name, window handle, or text string.
         Alternately pos as a (x, y) tuple may be provided indicating the mouse
         coordinates relative to the top-left corner of the application window
-        in which to click. control and pos are mutually exclusive.
+        in which to click. If both control and pos are provided pos is 
+        interpreted relative to the indicated control.
 
         Default is a single left click, but you can send left/right/middle,
         wheel up or down left or right with a repeat count.
             title, text, extitle, extext = self.params
 
         if pos:
-            # Position wins, overwrite control
-            control = "X{0[0]} Y{0[1]}".format(pos)
+            pos = "X{0[0]} Y{0[1]}".format(pos)
             # Add pos option to force coordinate interpretation
+            options += " pos"
+            if not control:
+                control = pos
+            else:
+                options += " " + pos
         # Setup window id args
         cmd = "ControlClick, {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}"
         execute(cmd.format(control, title, text, button, count, 

File test/test_ahk.py

         # Add lines by file path
         with open(self.tempfilename, 'w') as tmp:
             tmp.write("test := test+5")
+
         addr = ahk.add_lines(filename=self.tempfilename)
         #NOTE depends on ahk.exec_line
         ahk.exec_line(addr, wait=True)