; AutoHotkey Script for switching between last.fm player and WinAmp. ; Copyright (C) 2007 Tadhg O'Higgins ; This program is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License ; as published by the Free Software Foundation; either version 2 ; of the License, or (at your option) any later version. ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; You should be able to access the GNU General Public License at ; http://www.gnu.org/copyleft/gpl.html; if not, write to the Free Software ; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ; AutoHotkey Version: 1.x ; Language: English ; Platform: Win9x/NT ; Author: Tadhg O'Higgins ; Contact: tadhg(at)tadhg(dot)com ; Site: http://tadhg.com/ ; Script Function: ; Controls the Last.fm player ;Last.fm Control Functions ControlLastFM(Command) { ;Valid values for Command: ; "Toggle" to switch between playing and stopping. ; "Skip" to skip the current track. ; "Profile" to toggle the "My Profile" panel. ; "Recommend" to open the recommendation dialog. ; "Tag" to open the tag dialog. ; "Love" to mark the current track as loved. ; "Ban" to mark the current track as banned. ; "IsPlaying" to return 1 if it's playing and 0 otherwise. ;Last.fm player widget values: Toggle := "QWidget2" Skip := "QWidget5" Profile := "QWidget14" Recommend := "QWidget12" Tag := "QWidget11" Love := "QWidget9" Ban := "QWidget8" Station := "stationTimeBar" ;Get the variable value (using the above list kind of like a HashMap, or JavaScript object in the object["keyname"] style). CommandRef = % %Command% if (Command == "IsPlaying") { IfWinNotExist, Last.fm return 0 } ;Make sure the window exists. IfWinNotExist, Last.fm return else { ; Toggle and Profile don't need to know if it's playing a the moment or not. if (Command == "Toggle"||Command == "Profile") { ControlClick, %CommandRef%, Last.fm, , , , NA } else { ;Find out whether it's playing at the moment. ControlGet, lfmPlaying, Visible, , stationTimeBar, Last.fm ;If we just want to know whether it's playing or not, return that. if (Command == "IsPlaying") { return %lfmPlaying% } ;If it is playing, apply the command. if (lfmPlaying == 1) { ControlClick, %CommandRef%, Last.fm, , , , NA } if (lfmPlaying == 0) { ;Do nothing. } } } return }