AutoHotkey Community

It is currently May 25th, 2012, 3:31 am

All times are UTC [ DST ]




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 156 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 11  Next
Author Message
 Post subject:
PostPosted: May 2nd, 2007, 3:48 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
But is there a general way to use Methods? I don't understand how to use CoHelper.

_________________
Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 2nd, 2007, 4:11 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 2nd, 2007, 4:26 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
What do you mean? A dll-file? There are lots of files.

_________________
Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 2nd, 2007, 4:38 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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()


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2007, 5:48 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2007, 5:56 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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/viewtop ... 7&start=15

I used File -> View TypeLib/Open menu there, so I didn't have to actually install iTunes.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2007, 10:58 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2007, 1:17 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2007, 1:37 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2007, 2:02 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2007, 2:33 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi Sean,

iTunes seems not to register itself. Your suggestion does not work.

_________________
Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2007, 3:02 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2007, 3:24 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2007, 3:36 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Tekl wrote:
It is connected to the already running iTunes.

That's interesting. Thanks for informing me.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2007, 8:09 pm 
Offline

Joined: May 20th, 2007, 7:48 pm
Posts: 48
What is the proper way to pass a Unicode string ByVal to COM?

The iTunes Create Folder method expects a Unicode string as input instead of a pointer to the string. Though it looks right to me, this code does not work. Any help is greatly appreciated.
Code:
#NoEnv
#Include CoHelper.ahk
CoInitialize()
CLSID_iTunesApp := "{DC0C2640-1415-4644-875C-6F4D769839BA}"
 IID_IiTunes    := "{9DD6680B-3EDC-40DB-A771-E6FE4832E34A}"
piT := CreateObject(CLSID_iTunesApp, IID_IiTunes)

sFldr := "MyNewFldr"
Ansi2Unicode(sFldr, wFldr)
DllCall(VTable(piT, 84), "str", wFldr, "UintP", pPlist)  ; Create Folder

Release(piT)
CoUninitialize()


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 156 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6 ... 11  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: lblb, nothing and 10 guests


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

Search for:
Powered by phpBB® Forum Software © phpBB Group