To: oneclick-talk@lists.westcodesoft.com From: "Kevin Jaques, B.A., LL.B., of the Jaques Law Office" Subject: Re: [OC] Screen diamater Cc: Bcc: X-Attachments: >To use the Click command, how does one go about finding out what the desired pixel location on the screen *is*? I've been playing with a very useful palette for some of my apps, but it'd be more useful if I could get it to stimulate mouse clicks. The normal way is with 'record'. Click where you want. Look at the resulting script to see what coordinates the click or drag used. Unfortunately, you can't designate whether to record in global (relative to screen) or local (relative to active window). I've previously whined about that for the benefit of future versions. Further, since stuff moves around, you want something more specific. Besides, even window and screen size can change. I guess this is the clever part of macro utilities like OneClick. OneClick offers several ways to ensure the script will work even if stuff moves or re-sizes. Your first choice is to act directly on properties. For example, rather than trying to click on the resize box in a window, toggle the window's zoom property (e.g. window.zoom), or set it's location rather than dragging it. Using properties gives you more specific control (e.g., choose full size (window.zoom=1), reduced size (window.zoom=0) or just a toggle (window.zoom). Further, I strongly suspect it is significantly faster. However, to my limited experience, the script recorder isn't intelligent enough to give you a script to do this. Second choice, still very good, is to act directly on the controls. See the stuff under 'menu' and 'mouse' like selectMenu, selectButton, and selectPopUp, and under 'window' for 'scroll' and 'closeWindow'. The script recorder seems to be very intelligent about this, and will pick that up if it is possible. If not, you can try the 'parameters' popup, selecting 'mouse' to get a list of controls. Your third choice is to click relative to something solid. For instance, to hit a button on a toolbar, don't simulate a click on an absolute location (global), simulate a click relative to the location of the toolbar. Recording the click will usually give you a coordinate relative to the upper left corner of the window ('local'). If you want it to be relative to another corner (e.g., for controls at the bottom or right side of the window), so far as I know, you must get the window properties to locate that corner, and make the calculation in your script. Consider this to be another whine for a future feature. You can also get the cursor location with the window properties cursorX and cursorY. You could set up a mouseDown handler to dynamically display the mouse location as you moved the mouse around. Anyway, the command for a simulated click is 'click'. The final choice is to simply click on a global location. And pray. Unless you intend the click to be on the desktop, you can't record a global coordinate. However, use the parameter popup menu, select 'click' and it will tell you where you clicked. >Another queston...is there any way to get OC to return just, say, the first ten characters of something you've saved onto the clipboard without erasing it from the clipboard? That's easy. 'Clipboard' is a system variable which can be retrieved or set. Substring is a function which will return a portion of a string. The first parameter is the text, the 2d is the starting character, and the 3d is the desired length. Use negative numbers to start at the end. So, you want 'substring clipboard 1 10'. There is a catch. As frequently previously discussed on this list, some applications keep a private clipboard, and only update the system clipboard when they feel it is necessary. So, if you have trouble, force the update with the 'convertclip' command. That applies to setting the clipboard too. Incidentally, I do do real work too. I am preparing a demonstration of OneClick for our Mac User's Group and figured the above was basic to its understanding, so I'm killing two birds.