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 

iTunes Anywhere (keyboard shortcuts)
Goto page Previous  1, 2, 3, 4, 5, 6  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Harrow
Guest





PostPosted: Mon Sep 21, 2009 8:21 pm    Post subject: Reply with quote

Is it possible to create a spam bar for iTunes using autohotkey, by spam bar i mean something that would look like this: *Harrow Playing: [Song Name] by [Artist]. So basically a script that can read the current song name and details and then paste it when i call the script.
Back to top
Dan
Guest





PostPosted: Sat Nov 07, 2009 4:37 pm    Post subject: Reply with quote

I have play, pause, stop, next, previous buttons on my Logitech keyboard on the right next to the num bad. How can I get these to work with iTunes? They work when it's open but not when minimized or in the tray?
Back to top
nathan.c
Guest





PostPosted: Sat Nov 21, 2009 11:37 am    Post subject: i am with dan Reply with quote

I have a logitech keyboard also, and by the with this script is great, and I would love it even more if the hotkeys on my keyboard could be mapped to perform skipping functions in itunes instead of the "win + < >" keys. I am an untter newbie and I tried to use some kind of keyboard mapping script but that would not run because I think the keyboard drivers are prohibiting it. How would I frist, go about mapping those special hot keys? and then how would I script them to work rather than the already predefined ones?? Thanks for your help.
Back to top
Harker
Guest





PostPosted: Thu Jan 07, 2010 9:19 pm    Post subject: Reply with quote

Thanks for the script Smile

Works awesomely with my dell laptop buttons.

<3
Back to top
Daemon
Guest





PostPosted: Fri Jan 15, 2010 10:53 pm    Post subject: Re: iTunes Anywhere (keyboard shortcuts) Reply with quote

Sorry, but I'm terribly stupid with this, where do I put this script?

polyphenol wrote:
Just a little script for controlling iTunes from any window using keyboard shortcuts. Feel free to change them to your liking, of course. Changed it to use winkey[#]. You could change it to ctrl[^] or ctrl-alt[^!] or ctrl-shift[^+],etc. . Man, I love AutoHotkey.

Let me know of any problems or ideas. I am just getting aquainted with an app called 'Winspector Spy', mentioned somewhere in these here forums.


Hotkey List
--------------------------

winkey + \ = launch iTunes or hide/show
winkey + . = next song
winkey + , = previous song
winkey + / = play/pause toggle
winkey + ; = volume up
winkey + ' = volume down
winkey + = = preview song every 10 sec
winkey + - = stop preview mode

--------------------------

Peace, Dave


Code:
; iTunes Anywhere
; AutoHotkey Version: 1.x
; Language:       English
; Platform:       Win9x/NT
; Author:        Polyphenol <myemail@nowhere.com>
;
; Script Function:
;   Control iTunes from anywhere with hotkeys
;

#NoTrayIcon
#SingleInstance force
DetectHiddenWindows, on

#\::
IfWinNotExist, ahk_class iTunes
{
Run %ProgramFiles%\iTunes\iTunes.exe  ;launch program
return
}

IfWinExist, ahk_class iTunes ; toggle minimize/restore
{
IfWinNotActive ; restores window
WinActivate
Else
WinMinimize ; minimizes windows
return
}

#.::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{RIGHT}  ; > next
return

#,::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{LEFT}  ; < previous
return

#/::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, {SPACE}  ; play/pause toggle
return

#;::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{UP}  ; vol up
return

#'::
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{DOWN}  ; vol down
return

#=::
SetTimer, songpreview, 10000 ; change song every 10 sec
songpreview:
IfWinExist, ahk_class iTunes
ControlSend, ahk_parent, ^{RIGHT}
return

#-::
SetTimer, songpreview, Off
return

;endofscript
Back to top
Jorgos9
Guest





PostPosted: Tue Feb 16, 2010 1:26 pm    Post subject: ThankZ! Reply with quote

ThankZ! for The CodeZ! Cool
Back to top
046585119
Guest





PostPosted: Sun May 30, 2010 6:55 am    Post subject: Function keys Reply with quote

Is it possible to use the F keys as the ones that control itunes outside of the window? I have a mac keyboard that i use with my PC and it has the controls for itunes written on the F keys.
thanks
Back to top
jpaneasy



Joined: 06 Aug 2010
Posts: 1

PostPosted: Fri Aug 06, 2010 4:44 pm    Post subject: 5 years strong! Reply with quote

wow, year after year this code continues to pique interest. I have to say it is one of my favorite shortcuts!

Quick note/observation:

In Windows 7 x64, the volume up/down shortcuts only work when the player is:
1) open on desktop (mini player/or maximized)
2) minimized to taskbar

The shortcuts stop working when:
1) minimized to system tray (setting in preferences)
2) itunes toolbar is active (setting in taskbar toolbar)

doesn't look like anyone has mentioned it, although I didnt read all comments here, but thought it was something to mention. Everything else works beautifully!

Many thanks for the script; it really is one of my favorite windows shortcuts! Very Happy
Back to top
View user's profile Send private message
jamesvdm
Guest





PostPosted: Tue Aug 31, 2010 1:10 am    Post subject: Reply with quote

Thanks for the script, I've been wanting this for so long.
Back to top
vaderag



Joined: 22 Mar 2010
Posts: 39

PostPosted: Sun Sep 05, 2010 9:17 pm    Post subject: Reply with quote

Peter Johnston wrote:
Hey, got the iTunes COM interface working with Dell Media buttons. This can rate your current track too, with #1, #2, etc. As far as I can tell, this works no matter what status iTunes is in - maximised/minimised/toolbar.

I'm assuming I'm doing things correctly with the WS - all that's required for this script is for ws4ahk.ahk to be included somewhere.

The only thing is that once AHK takes control of your volume buttons, they don't get passed through to your system (or to other programs). There's probably some code that could be added that sorts that though.

I still need to change the volume control to use COM, but that'll happen soon I expect.

Code:
#Include C:\Program Files\AutoHotKey\ws4ahk.ahk

; Necessary initialization
WS_Initialize("JScript")
itunes := WS_CreateObject("iTunes.Application")
WS_AddObject(itunes, "itunesapp")
WS_ReleaseObject(itunes)

; ############## iTunes ##############
;
; Media keys as normal.
;
; Rate current song:
; win+0 -> no stars
; win+1 -> *
; win+2 -> **
; win+3 -> ***
; win+4 -> ****
; win+5 -> *****

Media_Play_Pause::
WS_Exec("itunesapp.PlayPause()")
return

Media_Next::
WS_Exec("itunesapp.NextTrack()")
return

Media_Prev::
WS_Exec("itunesapp.PreviousTrack()")
return

Media_Stop::
WS_Exec("itunesapp.Stop()")
return

Volume_Mute::
;Toggles mute - I think this is really elegant. :)
WS_Exec("itunesapp.Mute ^= 1")
return

Volume_Down::
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{down}, iTunes ahk_class iTunes
DetectHiddenWindows, Off
return

Volume_Up::
DetectHiddenWindows, On
ControlSend, ahk_parent, ^{up}, iTunes ahk_class iTunes
DetectHiddenWindows, Off
return

#0::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 0")
WS_ReleaseObject(currtrack)
return

#1::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 20")
WS_ReleaseObject(currtrack)
return

#2::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 40")
WS_ReleaseObject(currtrack)
return

#3::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 60")
WS_ReleaseObject(currtrack)
return

#4::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 80")
WS_ReleaseObject(currtrack)
return

#5::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 100")
WS_ReleaseObject(currtrack)
return

; Required cleanup
WS_Uninitialize()


I'm trying to get this to work from within my current AHK script, but I get the error "Windows Scripting has not been initialised! Exiting the application"

Anyone know what may cause this? It works fine when I run it as it's own script...

Thanks
Back to top
View user's profile Send private message
vaderag



Joined: 22 Mar 2010
Posts: 39

PostPosted: Mon Sep 06, 2010 4:34 pm    Post subject: Reply with quote

Sorted - you need to make sure that the top bit is right at the start of your file...

Code:
#Include C:\Program Files\AutoHotKey\ws4ahk.ahk

; Necessary initialization
WS_Initialize("JScript")
itunes := WS_CreateObject("iTunes.Application")
WS_AddObject(itunes, "itunesapp")
WS_ReleaseObject(itunes)
Back to top
View user's profile Send private message
vaderag



Joined: 22 Mar 2010
Posts: 39

PostPosted: Wed Sep 15, 2010 7:22 pm    Post subject: Reply with quote

I've been using this, but i've discovered that if you run it before iTunes runs, it basically prevents iTunes from starting... anyone had this?
Back to top
View user's profile Send private message
MV1990
Guest





PostPosted: Tue Mar 22, 2011 4:10 pm    Post subject: Reply with quote

Hi,

I'm trying to use the same one as Vaderag, I too am getting the 'Windows Scripting is not initialized' error however.

I have that piece of code at the beginning and I do have ws4ahk.ahk in the right folder.

Any help? On top of that, is it difficult to change the code to do:
Current Song Rate = 1,2,3,4,5
Skip song

As a second shortcut?

thanks alot
Back to top
brohan
Guest





PostPosted: Sat Mar 26, 2011 11:16 am    Post subject: Reply with quote

I had this script working (I added ratings as well, I'll show you in a sec.) but I reformatted my computer and now I am getting the 'Windows Scripting has not initialized!' error as well. From what I've read around, it might have something to do with a file called msscript.ocx but I've added it and I still can't make it work.
It is currently in Windows\System32 and I am referencing it in the WS_Initialize command. I ran a regsvr32 on it, but still no luck. Any help would be greatly appreciated!

Here is my rating code, btw. There is also a skip command which overrides the iTunes behavior for counting skips and plays:
Code:

#0::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 0")
WS_ReleaseObject(currtrack)
return

#1::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 20")
WS_ReleaseObject(currtrack)
return

#2::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 40")
WS_ReleaseObject(currtrack)
return

#3::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 60")
WS_ReleaseObject(currtrack)
return

#4::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 80")
WS_ReleaseObject(currtrack)
return

#5::
WS_Exec("currtrack=itunesapp.CurrentTrack")
WS_Exec("currtrack.Rating = 100")
WS_ReleaseObject(currtrack)
return

#x::
WS_Exec("var currtrack = itunesapp.CurrentTrack;")
WS_Exec("var currtime = itunesapp.PlayerPosition;")
WS_Exec("var endtime = currtrack.Finish;")
WS_Exec("var elapsedperc = 100*(currtime/endtime);")
WS_Exec("if (elapsedperc > 60){currtrack.PlayedCount = currtrack.PlayedCount + 1;} else {itunesapp.PlayerPosition = 10;} itunesapp.NextTrack();")
WS_ReleaseObject(currtrack)
return
Back to top
brohan
Guest





PostPosted: Sun Mar 27, 2011 3:07 pm    Post subject: Figured it out-sort of Reply with quote

I did away with ws4ahk.ahk (sorry developer!) and just used the built in COM in AutoHotkey_L.

This simplified the code tremendously and seems to work just as well.

Code:

#SingleInstance, Force

itunes := ComObjCreate("iTunes.Application")

;Display the current track and playlist
#c::
trackname := itunes.CurrentTrack.Name
artist := itunes.CurrentTrack.Artist
ToolTip, %artist%: %trackname%
SetTimer, RemoveToolTip, 2000
return

RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
return

#space::
itunes.PlayPause()
return

#x::
currtrack := itunes.CurrentTrack
currtime := itunes.PlayerPosition
endtime := currtrack.Finish
elapsedperc := 100*(currtime/endtime)
if (elapsedperc > 60)
   currtrack.PlayedCount := currtrack.PlayedCount + 1
else
   itunes.PlayerPosition := 10
itunes.NextTrack()
return

#z::
itunes.PreviousTrack()
return

#0::
currtrack := itunes.CurrentTrack
currtrack.Rating := 0
return

#1::
currtrack := itunes.CurrentTrack
currtrack.Rating := 20
return

#2::
currtrack := itunes.CurrentTrack
currtrack.Rating := 40
return

#3::
currtrack := itunes.CurrentTrack
currtrack.Rating := 60
return

#4::
currtrack := itunes.CurrentTrack
currtrack.Rating := 80
return

#5::
currtrack := itunes.CurrentTrack
currtrack.Rating := 100
return
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 4 of 6

 
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