Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Dec 14, 2018 3:29 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Wed Nov 21, 2012 6:36 am 
Offline
User avatar

Joined: Thu Sep 10, 2009 2:50 am
Posts: 418
Location: Santa Cruz, CA, USA
DaveS wrote:
the only difference is I want to "click".... since Finder already intercepts "right click"

AppleEvents notifiies of when the click occurs.

You want to position this window only when clicking the icon?

If so I use this event in Application to trap when the icons been clicked. Using System.Mouse you can get a rough idea where that is.

Function HandleAppleEvent(theEvent As AppleEvent, eventClass As String, eventID As String) As Boolean
#pragma Unused theEvent

if eventID = "rapp" and eventClass = "aevt" then

dim w As new Window1
w.Top = System.MouseY - w.Height - 20
w.Left = System.MouseX - w.Width / 2

end

return false
End Function


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Wed Nov 21, 2012 8:56 am 
Offline
User avatar

Joined: Sat Nov 11, 2006 2:43 pm
Posts: 1221
Location: This poster has left the forums
Thom McGrath wrote:
Pretty confident you're not going to find a way to do this.

jranieri wrote:
It uses the accessibility APIs that I mentioned.


uh-oh, fight :lol:

Image

_________________
%Invalidforumsignatureexception% user signature not found


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Wed Nov 21, 2012 10:03 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
doofus wrote:
DaveS wrote:
the only difference is I want to "click".... since Finder already intercepts "right click"

AppleEvents notifiies of when the click occurs.

You want to position this window only when clicking the icon?

If so I use this event in Application to trap when the icons been clicked. Using System.Mouse you can get a rough idea where that is.

Function HandleAppleEvent(theEvent As AppleEvent, eventClass As String, eventID As String) As Boolean
#pragma Unused theEvent

if eventID = "rapp" and eventClass = "aevt" then

dim w As new Window1
w.Top = System.MouseY - w.Height - 20
w.Left = System.MouseX - w.Width / 2

end

return false
End Function



That gives me a Point INSIDE the icon... but does not give me the exact LEFT/TOP

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Wed Nov 21, 2012 10:04 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
pony wrote:
Thom McGrath wrote:
Pretty confident you're not going to find a way to do this.

jranieri wrote:
It uses the accessibility APIs that I mentioned.


uh-oh, fight :lol:

Image


Any fight is now interenal to RS :)
I have found dozens of examples using the API mentioned... but all in XCode and I'm not sure how to translate into DECLARE like code

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Wed Nov 21, 2012 10:10 am 
Offline
User avatar

Joined: Mon Feb 05, 2007 5:21 pm
Posts: 600
Location: New York, NY
Post some of that code, or provide a link to it?

_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Wed Nov 21, 2012 10:22 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
http://stackoverflow.com/questions/6684278/getting-the-position-of-my-applications-dock-icon-using-cocoas-accessibility-a

there were a few others... most pointed to APPLE docs which didn't give an "answer", just details of the Cocoa functions that would be involved.

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Wed Nov 21, 2012 11:24 am 
Offline
Site Admin
User avatar

Joined: Tue May 06, 2008 1:07 pm
Posts: 1464
Location: NotEvenOnTheMap, CT
pony wrote:
Thom McGrath wrote:
Pretty confident you're not going to find a way to do this.

jranieri wrote:
It uses the accessibility APIs that I mentioned.


uh-oh, fight :lol:

Image

Haha, no. Joe knows way more about this stuff than I do.

_________________
Thom McGrath - @tekcor
Web Framework Architect, Real Software, Inc.


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Wed Nov 21, 2012 1:28 pm 
Offline

Joined: Wed Feb 04, 2009 1:43 pm
Posts: 427
I ones needed this too. I asked many people (including experienced xcode coders) and the answer is simple:
It is NOT possible to do this 100% accurate (with Xcode and RealBasic). There are tricks but it can have odd effects on different systems setups and different OSX versions.


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Fri Nov 23, 2012 1:02 pm 
Offline

Joined: Sat Jun 04, 2011 2:28 pm
Posts: 67
Dave there might be a way to achieve what you want with the NSDockTile class in the AppKit Framework, but at
first glance it may be a big MIGHT.

Dont know if you can access Cocoa Framework classes from RB, as I'm a novice with RB.
But I will have a play with the NSDockTile class using ObjC over the weekend if your interested.

Regards Mark


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Sun Nov 25, 2012 3:56 pm 
Offline

Joined: Sat Jun 04, 2011 2:28 pm
Posts: 67
No joy with the NSDockTile class, it allows you to manipulate the Image and Badge content, but returns {0.0, 0.0} for the x and y postions for the origin, of the contentView properties frame or bounds, which s a bit odd, as all other NSView classes normally return there x and y postions within there superviews, even after moving the Dock Tile too a new position in the Dock, the NSDockTile class still only returns zero for both the x and y positions, and will only reveal its size width and height dimensions, so after a bit of experimentation, I came to the conclusion that Apple have deliberatly made this particular class keep its screen position a secret.

On a different tack, I have done some reading on the Accessability Framework, and as jranieri has suggested, it would be possable to access the Dock Icon screen position with this API, but as to wether it could be accessed from an RB app, I have my doubts, but it may be possable to create a Command Line tool that could be called from a RB app, if I get some time this week, I may experiment a bit with this idea, so I will post any info if it looks promising.

Regards Mark


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Fri Nov 30, 2012 2:15 pm 
Offline

Joined: Sat Jun 04, 2011 2:28 pm
Posts: 67
Hi Dave.

There's good news and bad news.

The good news is.

If your still interested in a solution to this problem, let me know because I have wrote a command line tool, that will
return the application dock icon position for any running app, its still a prototype Xcode project that I only completed
today, but it does work, although i need to test it a bit more, and also put it on a diet at the weekend, as there is still a
lot of dubug code in there, and a lot of OTT error checking and memory management, so I think there will be about half
the code in the finished tool.

The basis for the methods came from the code snippet you posted a link too, which I have altered slightly to work from
the shell command line.

So anyway, after I have done some clean up work, compiled and tested from Terminal and Applescript, I would be happy
to give you a copy for your project, where you could test it from an RB application, and let me know if changes are needed.

The bad news is.

in order for the Accessibility Framework to work, the Enable Access for Assistive Devices has to be enabled by the User,
this is not just the case for my tool, but for any application that wants to get access to other application proccess, its
part of the sandboxing rules that are enforced by the OS, I am trying to find a way to automate the switching on and off
of this setting, but drawn a blank so far, see this other forum post associated with this problem.

http://forums.realsoftware.com/viewtopic.php?f=7&t=45612

Regards Mark


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Mon Jan 21, 2013 10:19 am 
Offline

Joined: Mon Jan 17, 2011 4:51 pm
Posts: 131
Thom McGrath wrote:
You'll probably have more luck taking a screenshot and literally searching for your icon. Needless to say, performance will suck, and you'll have trouble even taking the screenshot without relying on something outside of the product.




Nah. Mac OS X has a built-in screenshot CL utility called screencapture. It's fast, and you can do all kinds of neat things with it. Just pull up the man file for all of it's options. I used screencapture in my "Magic Script Creator" app that is for sale in the MAS, written with Real Studio.


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Mon Jan 21, 2013 11:06 am 
Offline
Site Admin
User avatar

Joined: Tue May 06, 2008 1:07 pm
Posts: 1464
Location: NotEvenOnTheMap, CT
I didn't mean the screenshot will perform poorly, I meant searching for the icon will.

_________________
Thom McGrath - @tekcor
Web Framework Architect, Real Software, Inc.


Top
 Profile  
Reply with quote  
 Post subject: Re: Detect where my App is in DOCK
PostPosted: Sun Mar 03, 2013 9:46 am 
Offline

Joined: Thu Dec 01, 2011 2:13 pm
Posts: 288
Why don't you just hack you into the Apple servers, deliver a new OSC update with a changed dock which makes this possible and then easily do it? Easiest way here.

_________________
Mac OS X 10.3-10.8
Windows 2000 (I know it sucks)
Windows Server 2007

You want a bunch of new classes and web styles? realstudiodevspot.com (search there for Web Styles Plugin)
Folderitem is too hard? File Bin Class
I hate cows.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group