Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome General
 PowerHome Messageboard : PowerHome General
Subject Topic: Setting Window Focus Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: November 06 2006 at 16:25 | IP Logged Quote smarty

I am opening www.pandora.com from within PowerHome's web center via the formula: ph_wcopen( 0, "www.pandora.com")

In order to send keystrokes (from my Xlobby front end) to this application, I have to first click on the Gray window WITHIN the PH web center window to "set focus" to the Pandora application.

I need to be able to set the focus remotely. I would like to be able to set the window focus with something like the "ph_switchto" command. However, because of the content of the window, I am guessing that this is not as straight forward as it seems.

From the built in "Spy" of PH, I know that the "grey box" has a class name of "MacromediaFlashPlayerActiveX". From using Winspector, I can see TWO (2) handles with this same class name (maybe that is why the ph_switchto command does not work???).

How can I set focus to the application without doing a local mouse click?

__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: November 06 2006 at 18:25 | IP Logged Quote dhoward

Steve,

I tried playing with this for you but didnt know enough about Pandora and the keystrokes you're trying to send to get everything working. If you give me a little more info, I might be able to figure something out.

In any event, you won't be able to just use the ph_switchto function. You might be able to do something with the ph_setforegroundwindow function or even possibly the ph_sendkeysmq to send directly to the handle. However, when trying the ph_setforegroundwindow with the handle of the Flash control, it returns a 1 meaning that the setforegroundwindow API call failed. You may have to setforegroundwindow with the "Web Center" window or similar.

Anyways, here is the code to get the handle of the flash player activex (mostly):

ph_findwindowex(ph_findwindowex(ph_findwindowex(ph_findwindo wex(ph_findwindowex(ph_findwindowex(ph_findwindowex(ph_handl e(),0,0,"MDIClient",0),0,0,"Web Center",1),0,0,"Button",0),0,0,"Shell Embedding",0),0,0,"Shell DocObject View",0),0,0,"Internet Explorer_Server",0),0,0,"MacromediaFlashPlayerActiveX",0)

After repeated attempts at this, it appears that depending upon how the page loads, it may load 1 or more flashplayer activex controls. If you look at the code above, the "0" just before the "MacromediaFlashPlayerActiveX" controls what instance to return with 0 being the first. I couldnt find any specific way to know what instance was necessary. Sometimes the 0 worked, sometimes a 1, and sometimes a 2.

Maybe a combination of setting the Web Center active and then sending "tab" keystrokes until the ActiveX is active.

Not sure, but if you let me know what keystrokes are valid or what I need to do to get this tested and I might be able to figure something out.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: November 06 2006 at 20:58 | IP Logged Quote smarty

Dave,
There are only a couple of keystrokes that control Pandora. Using Xlobby, I call the keystrokes via the PowerHome Socket Server (thanks go to Manny on showing me how ): "c:\program files\phsscmd\phsscmd.exe"

The control keystrokes for Pandora are:
ph_wcopen(1,"%pandora>link%") <= open Pandora to selected station - the %text% is Xlobby database info.
ph_sendkeys("{downarrow") <=volume down
ph_sendkeys("{uparrow") <=volume up
ph_sendkeys(" ") <=pause/play control
ph_sendkeys("{plus}") <=like present song
ph_sendkeys("{minus}") <=dislike present song
ph_sendkeys("{rightarrow}") <=goto next song
ph_wcclose() <= close Pandora (close webcenter)

All these controls DO WORK once I have set focus to the grey Pandora box.

I was able to get your code to work, and did see that by putting in a "0" or a "1" did change the handle returned.

Now, since one of these handles "must" be right, I think I can write a macro that toggles through the handle choices and sends the pause/play command. I'll have to keep toggling manually until I have the pause/play control - I can live with this.

Next question: How do I use the returned handle number to "set focus" to the window that the handle belongs to?

Edited by smarty - November 06 2006 at 21:00


__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: November 08 2006 at 22:51 | IP Logged Quote smarty

OK, got it figured out!!!! Dave, thanks for the hints!!!

I use ph_wcopen(0,"%pandora>link%") which open the webcenter in a window, and then send PH 6 tabs like:ph_sendkeys("{tab}{tab}{tab}{tab}{tab}{tab}")

This then sets the focus to the proper window and I have keystroke control (and thus button control via Xlobby).

WaaHoooo!!!!    

__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: November 13 2006 at 15:45 | IP Logged Quote dhoward

Steve,

Glad it's working now . I figured it might take something like this (Ive done this alot of times for some webcam software).

If you've got the handle of a window (not a control on the window), then you can use the ph_setforegroundwindow function to give it focus.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum