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 

Need help making 1 button starting winamp and toggle it

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
T-B0N3



Joined: 24 Nov 2009
Posts: 2

PostPosted: Tue Nov 24, 2009 5:36 pm    Post subject: Need help making 1 button starting winamp and toggle it Reply with quote

I want to have a button that
-Starts winamp if it is not started
- If it is started i want the same button to toggle between activated and minimized.

I have made multiple versions of this script and in the end just copy/pasted what someone made for windows media player. But the button only minimizes winamp, not maximizes. Anyone can see the problem?
Code:

SetTitleMatchMode 2
Launch_Media::
#IfWinNotExist Winamp
  Run C:\Program Files\Winamp\winamp.exe
WinGet, WinampState, MinMax, Winamp
  If (WinampState = -1) ; -1 means minimized
    WinRestore, Winamp
  Else
    WinMinimize, Winamp
return
return


this is my first attempy at autohotkey so i probably made a silly mistake :/
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 1994
Location: GERMANY

PostPosted: Tue Nov 24, 2009 6:09 pm    Post subject: Reply with quote

Try this:
Code:
SetTitleMatchMode 2

Launch_Media::
WinGet, WinampState, MinMax, Winamp
IfWinNotExist Winamp
  Run C:\Program Files\Winamp\winamp.exe
Else if (WinampState < 0) ; -1 means minimized
    WinRestore, Winamp
Else
    WinMinimize, Winamp
return

_________________
AutoHotFile - ToolTip(n,text,title,options) Wink
Back to top
View user's profile Send private message
T-B0N3



Joined: 24 Nov 2009
Posts: 2

PostPosted: Tue Nov 24, 2009 6:26 pm    Post subject: Reply with quote

thanks that works, how did that fix it?
as far as i can see you changed
- #IfWinNotExist to IfWinNotExist
- put WinGet, WinampState, MinMax, Winamp on top
- and made winrestore and minminimize in the same if statement.
- and removed the 2nd return

which of these things fixed it you think?
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 1994
Location: GERMANY

PostPosted: Tue Nov 24, 2009 7:04 pm    Post subject: Reply with quote

Code:
#IfWinNotExist ;is used for case sensitive hotkeys, see help file
WinGet, WinampState, MinMax, Winamp ;This line can be executed anyway and you will have the state when you need it!
if statement ;works here like a switch, makes it easier
return ;there is no way to reach second return!

_________________
AutoHotFile - ToolTip(n,text,title,options) Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
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