 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Wed May 02, 2007 3:00 pm Post subject: |
|
|
How can I translate this JS-Code to AHK?
| Code: | var iTunesApp = WScript.CreateObject("iTunes.Application");
iTunesApp.Play();
iTunesApp.NextTrack(); |
_________________ Tekl |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1359
|
Posted: Wed May 02, 2007 3:42 pm Post subject: |
|
|
| I don't have a iTunes. |
|
| Back to top |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Wed May 02, 2007 3:48 pm Post subject: |
|
|
But is there a general way to use Methods? I don't understand how to use CoHelper. _________________ Tekl |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1359
|
Posted: Wed May 02, 2007 4:11 pm Post subject: |
|
|
| 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 |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Wed May 02, 2007 4:26 pm Post subject: |
|
|
What do you mean? A dll-file? There are lots of files. _________________ Tekl |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1359
|
Posted: Wed May 02, 2007 4:38 pm Post subject: |
|
|
| 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 |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Thu May 03, 2007 5:48 am Post subject: |
|
|
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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1359
|
Posted: Thu May 03, 2007 5:56 am Post subject: |
|
|
| 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 |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Thu May 03, 2007 10:58 am Post subject: |
|
|
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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1359
|
Posted: Thu May 03, 2007 1:17 pm Post subject: |
|
|
| 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 |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Thu May 03, 2007 1:37 pm Post subject: |
|
|
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 |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1359
|
Posted: Thu May 03, 2007 2:02 pm Post subject: |
|
|
| 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 |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Thu May 03, 2007 2:33 pm Post subject: |
|
|
Hi Sean,
iTunes seems not to register itself. Your suggestion does not work. _________________ Tekl |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1359
|
Posted: Thu May 03, 2007 3:02 pm Post subject: |
|
|
| 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 |
|
 |
Tekl
Joined: 24 Sep 2004 Posts: 813 Location: Germany
|
Posted: Thu May 03, 2007 3:24 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|