AutoHotkey Community

It is currently May 27th, 2012, 2:46 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: November 24th, 2009, 6:36 pm 
Offline

Joined: November 24th, 2009, 6:05 pm
Posts: 2
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 :/


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 24th, 2009, 7:09 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
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

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 24th, 2009, 7:26 pm 
Offline

Joined: November 24th, 2009, 6:05 pm
Posts: 2
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 24th, 2009, 8:04 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
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!

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], rbrtryn, XstatyK and 21 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