AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COM Helper
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Wed May 02, 2007 3:00 pm    Post subject: Reply with quote

How can I translate this JS-Code to AHK?

Code:
var iTunesApp = WScript.CreateObject("iTunes.Application");
            iTunesApp.Play();
            iTunesApp.NextTrack();

_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 1359

PostPosted: Wed May 02, 2007 3:42 pm    Post subject: Reply with quote

I don't have a iTunes.
Back to top
View user's profile Send private message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Wed May 02, 2007 3:48 pm    Post subject: Reply with quote

But is there a general way to use Methods? I don't understand how to use CoHelper.
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 1359

PostPosted: Wed May 02, 2007 4:11 pm    Post subject: Reply with quote

Tekl wrote:
But is there a general way to use Methods? I don't understand how to use CoHelper.

Sure. I may try it if you send me the TypeLib file.
Or just tell me where I can download the file.
Back to top
View user's profile Send private message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Wed May 02, 2007 4:26 pm    Post subject: Reply with quote

What do you mean? A dll-file? There are lots of files.
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 1359

PostPosted: Wed May 02, 2007 4:38 pm    Post subject: Reply with quote

Tekl wrote:
What do you mean? A dll-file? There are lots of files.

OK, I found the installer and extracted it. The needed file turned out to be iTunes.exe.
Here is the code.

Code:
#Include CoHelper.ahk

CoInitialize()

CLSID_iTunesApp := "{DC0C2640-1415-4644-875C-6F4D769839BA}"
 IID_IiTunes    := "{9DD6680B-3EDC-40DB-A771-E6FE4832E34A}"

piT := CreateObject(CLSID_iTunesApp, IID_IiTunes)

DllCall(VTable(piT,11), "Uint", piT)         ; Play
DllCall(VTable(piT, 9), "Uint", piT)         ; NextTrack

Release(piT)

CoUninitialize()
Back to top
View user's profile Send private message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Thu May 03, 2007 5:48 am    Post subject: Reply with quote

Big Thanks Sean, that helps me a lot.

Can you tell me how you get the values? Especially the values for Play and NextTrack.

Tekl
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 1359

PostPosted: Thu May 03, 2007 5:56 am    Post subject: Reply with quote

Tekl wrote:
Can you tell me how you get the values? Especially the values for Play and NextTrack.

I used oleview.exe/tlb.exe, mentioned here:
http://www.autohotkey.com/forum/viewtopic.php?t=16187&start=15

I used File -> View TypeLib/Open menu there, so I didn't have to actually install iTunes.
Back to top
View user's profile Send private message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Thu May 03, 2007 10:58 am    Post subject: Reply with quote

Thanks. That's helpful. Is the Codeview of TLB the only way to get the VTable-values?

Another problem: How to get Values/Results? This does not work:

RESULT := DllCall(VTable(piT, 35), "Uint", piT) ; get_SoundVolume

I also tried:

DllCall(VTable(piT, 35), "Uint", piT, "Uint", RESULT) ; get_SoundVolume

Setting the Volume works this way:

DllCall(VTable(piT, 36), "Uint", piT, "Uint", VOLUME) ; set_SoundVolume
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 1359

PostPosted: Thu May 03, 2007 1:17 pm    Post subject: Reply with quote

Tekl wrote:
Thanks. That's helpful. Is the Codeview of TLB the only way to get the VTable-values?

Good, you adapted fastly.
You can infer the indices from the vtable offsets or the ordinal positions.

Quote:
DllCall(VTable(piT, 35), "Uint", piT, "Uint", RESULT) ; get_SoundVolume

I think it is:

Code:
DllCall(VTable(piT, 35), "Uint", piT, "UintP", Volume)
Back to top
View user's profile Send private message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Thu May 03, 2007 1:37 pm    Post subject: Reply with quote

Sean, you made my day. Big thanks!

For interested people here some important values:

Code:
DllCall( VTable( piT, 11 ), "Uint", piT ) ; Play
DllCall( VTable( piT, 14 ), "Uint", piT ) ; PreviousTrack
DllCall( VTable( piT, 9  ), "Uint", piT ) ; NextTrack
DllCall( VTable( piT, 13 ), "Uint", piT ) ; PlayPause
DllCall( VTable( piT, 16 ), "Uint", piT ) ; Rewind
DllCall( VTable( piT, 8  ), "Uint", piT ) ; FastForward

; Volume Up
DllCall( VTable( piT, 35 ), "Uint", piT, "UintP", PlayerVol ) ; get_SoundVolume
PlayerVol := PlayerVol + VolAddSub
DllCall( VTable( piT, 36 ), "Uint", piT, "Uint", PlayerVol )  ; set_SoundVolume

; Volume Down
DllCall( VTable( piT, 35 ), "Uint", piT, "UintP", PlayerVol ) ; get_SoundVolume
PlayerVol := PlayerVol - VolAddSub
DllCall( VTable( piT, 36 ), "Uint", piT, "Uint", PlayerVol )  ; set_SoundVolume

_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 1359

PostPosted: Thu May 03, 2007 2:02 pm    Post subject: Reply with quote

Tekl wrote:
Sean, you made my day. Big thanks!

You're welcome and I'm glad.
BTW, I don't know if iTunes registers itself to ROT or not, but I think it's worth trying.
If you need to connect to the already running iTunes you may try the following, instead of CreateObject():

Code:
piT := GetActiveObject("iTunes.Application")
Back to top
View user's profile Send private message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Thu May 03, 2007 2:33 pm    Post subject: Reply with quote

Hi Sean,

iTunes seems not to register itself. Your suggestion does not work.
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Sean



Joined: 12 Feb 2007
Posts: 1359

PostPosted: Thu May 03, 2007 3:02 pm    Post subject: Reply with quote

Tekl wrote:
iTunes seems not to register itself. Your suggestion does not work.

Ah, that's too bad. I thought it might be an essential feature...
Maybe, there could be some option to force a single instance of iTunes.
What happens if you run CreateObject() while iTune is already running?
Is another instance of iTunes opened, or, is it connected to the already running one?
Back to top
View user's profile Send private message
Tekl



Joined: 24 Sep 2004
Posts: 813
Location: Germany

PostPosted: Thu May 03, 2007 3:24 pm    Post subject: Reply with quote

It is connected to the already running iTunes. I didn't know that creating an object will launch iTunes as I check if iTunes is running with AHK commands.

In the COM SDK of iTunes they always have examples where the object is created before using.
_________________
Tekl
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
Page 2 of 10

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group