AutoHotkey Community

It is currently May 27th, 2012, 6:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 81 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject:
PostPosted: September 21st, 2009, 9:21 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 7th, 2009, 5:37 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject: i am with dan
PostPosted: November 21st, 2009, 12:37 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2010, 10:19 pm 
Thanks for the script :)

Works awesomely with my dell laptop buttons.

<3


Report this post
Top
  
Reply with quote  
PostPosted: January 15th, 2010, 11:53 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject: ThankZ!
PostPosted: February 16th, 2010, 2:26 pm 
ThankZ! for The CodeZ! 8)


Report this post
Top
  
Reply with quote  
 Post subject: Function keys
PostPosted: May 30th, 2010, 7:55 am 
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


Report this post
Top
  
Reply with quote  
 Post subject: 5 years strong!
PostPosted: August 6th, 2010, 5:44 pm 
Offline

Joined: August 6th, 2010, 5:27 pm
Posts: 1
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! :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 31st, 2010, 2:10 am 
Thanks for the script, I've been wanting this for so long.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 5th, 2010, 10:17 pm 
Offline

Joined: March 22nd, 2010, 1:40 pm
Posts: 39
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2010, 5:34 pm 
Offline

Joined: March 22nd, 2010, 1:40 pm
Posts: 39
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)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 15th, 2010, 8:22 pm 
Offline

Joined: March 22nd, 2010, 1:40 pm
Posts: 39
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 22nd, 2011, 5:10 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 26th, 2011, 12:16 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject: Figured it out-sort of
PostPosted: March 27th, 2011, 4:07 pm 
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


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 81 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo and 20 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