Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Auto Clickers
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Bantymom" data-source="post: 1758785" data-attributes="member: 392446"><p>@RazOrEdge @Slydude</p><p></p><p>Update:</p><p>I have managed to get FF to work with this, so I've given up on Safari so the above problem is not longer an issue. I have removed these lines:</p><p></p><p> delay 1</p><p> key code 55 using { command down }</p><p></p><p>And it is running fine. Thank you so much for trying to find a fix for me.</p><p></p><p>Now I want to click in two different places. I pulled the edges of the window until they touched the bottom of the menu bar and all the edges, so that everything is always is the same place, and I found the location of the two things I want clicked. </p><p></p><p>My original concept for modification was this:</p><p></p><p>on idle</p><p> delay (random number from 1 to 5)</p><p> tell application "System Events"</p><p><span style="color: #FF0000"> (tell the mouse to move to specific coordinates here)</span></p><p> key code 87</p><p> delay 15</p><p><span style="color: #FF0000"> (tell the mouse to move to specific coordinates here)</span></p><p> key code 87</p><p> delay 15</p><p> end tell</p><p> return 10</p><p>end idle</p><p></p><p>but there just doesn't seem so be a simple way to tell the cursor where to move to. *sigh*</p><p></p><p>I thought I would be able to do this on my own. I mean, really, I'm not trying to do something very complicated. I've spent 2 days trying to figure out how to move the mouse to those two locations, but searches brought up only very complicated scripts, scripts nested inside other scripts, or scrips requiring a combination of scripting languages. Is it really so difficult to just move the mouse/cursor? </p><p></p><p>This is an example:</p><p>set x to 30</p><p>set y to 5</p><p>set l to 50 -- click same location 50 times</p><p>do shell script "</p><p>/usr/bin/python <<END</p><p>import sys</p><p>import time</p><p>from Quartz.CoreGraphics import *</p><p>def mouseEvent(type, posx, posy):</p><p> theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)</p><p> CGEventPost(kCGHIDEventTap, theEvent)</p><p>def mousemove(posx,posy):</p><p> mouseEvent(kCGEventMouseMoved, posx,posy);</p><p>def mouseclick(posx,posy):</p><p> mouseEvent(kCGEventLeftMouseDown, posx,posy);</p><p> mouseEvent(kCGEventLeftMouseUp, posx,posy);</p><p>ourEvent = CGEventCreate(None);</p><p>currentpos=CGEventGetLocation(ourEvent); # Save current mouse position</p><p>for x in range(0, " & l & "):</p><p> mouseclick(" & x & "," & y & ");</p><p>mousemove(int(currentpos.x),int(currentpos.y)); # Restore mouse position</p><p>END"</p><p></p><p>Below is the most simple one I found: </p><p></p><p>tell application "Safari"</p><p> activate</p><p>end tell</p><p>repeat with i from 1 to 10</p><p> delay 5</p><p> tell application "System Events"</p><p> tell process "Safari"</p><p> click at {46, 239}</p><p> end tell</p><p> end tell</p><p>end repeat</p><p></p><p>Additionally, all of my experiments have been refused by Accessibility, which I had to use to run the original script. I tried to add it to the permissions, and it ignored me. (And now I can't seem to find that window) I thought I would be very clever and just edit my ideas into the script that is already there, but anything involving locations gives me a notice that it isn't allowed or some such thing.</p><p></p><p></p><p>Help? It is really so complicated. I am just looking for a simple way to do a simple thing.</p><p>Do I need Applescript Toolbox for this?</p></blockquote><p></p>
[QUOTE="Bantymom, post: 1758785, member: 392446"] @RazOrEdge @Slydude Update: I have managed to get FF to work with this, so I've given up on Safari so the above problem is not longer an issue. I have removed these lines: delay 1 key code 55 using { command down } And it is running fine. Thank you so much for trying to find a fix for me. Now I want to click in two different places. I pulled the edges of the window until they touched the bottom of the menu bar and all the edges, so that everything is always is the same place, and I found the location of the two things I want clicked. My original concept for modification was this: on idle delay (random number from 1 to 5) tell application "System Events" [COLOR="#FF0000"] (tell the mouse to move to specific coordinates here)[/COLOR] key code 87 delay 15 [COLOR="#FF0000"] (tell the mouse to move to specific coordinates here)[/COLOR] key code 87 delay 15 end tell return 10 end idle but there just doesn't seem so be a simple way to tell the cursor where to move to. *sigh* I thought I would be able to do this on my own. I mean, really, I'm not trying to do something very complicated. I've spent 2 days trying to figure out how to move the mouse to those two locations, but searches brought up only very complicated scripts, scripts nested inside other scripts, or scrips requiring a combination of scripting languages. Is it really so difficult to just move the mouse/cursor? This is an example: set x to 30 set y to 5 set l to 50 -- click same location 50 times do shell script " /usr/bin/python <<END import sys import time from Quartz.CoreGraphics import * def mouseEvent(type, posx, posy): theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft) CGEventPost(kCGHIDEventTap, theEvent) def mousemove(posx,posy): mouseEvent(kCGEventMouseMoved, posx,posy); def mouseclick(posx,posy): mouseEvent(kCGEventLeftMouseDown, posx,posy); mouseEvent(kCGEventLeftMouseUp, posx,posy); ourEvent = CGEventCreate(None); currentpos=CGEventGetLocation(ourEvent); # Save current mouse position for x in range(0, " & l & "): mouseclick(" & x & "," & y & "); mousemove(int(currentpos.x),int(currentpos.y)); # Restore mouse position END" Below is the most simple one I found: tell application "Safari" activate end tell repeat with i from 1 to 10 delay 5 tell application "System Events" tell process "Safari" click at {46, 239} end tell end tell end repeat Additionally, all of my experiments have been refused by Accessibility, which I had to use to run the original script. I tried to add it to the permissions, and it ignored me. (And now I can't seem to find that window) I thought I would be very clever and just edit my ideas into the script that is already there, but anything involving locations gives me a notice that it isn't allowed or some such thing. Help? It is really so complicated. I am just looking for a simple way to do a simple thing. Do I need Applescript Toolbox for this? [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Auto Clickers
Top