AutoHotkey Community

It is currently May 26th, 2012, 9:36 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: May 14th, 2005, 10:21 pm 
Offline

Joined: May 9th, 2005, 2:42 am
Posts: 7
Thanks to Chris for adding functions!

Below is some of the code I'm using in my AutoHotkey.ini. I think organizing the code this way makes it very readable and easily adjustable for other users' purposes. On top are some hotkeys which rely on code later in the file. The main thing I'm demonstrating here is the function RunRestoreHideApp which does like it says: runs an app that doesn' t already have an instance, barring that, finds the instance and either activates it, or if already active, minimizes it. Note the function returns what it actually did to the app. My #s macro launches a "sponsor-ware" app, then kills the nag message.

Code:
#g::RunRestoreHideApp("Microsoft Visual","C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe") ; goto RunRestoreVS
#a::RunRestoreHideApp2("Microsoft Outlook","Outlook","Microsoft Office Outlook")
^!a::goto HideAIM
#z:: run, "c:\Program Files\Autohotkey\fw", "c:\Program Files\Autohotkey"
^!n::RunRestoreHideApp("Notepad","Notepad")
#s::
if RunRestoreHideApp("Yahoo! All-Seeing Eye","C:\Program Files\The All-Seeing Eye\eye.exe") = ran
{
   WinWaitActive, Invalid code, ,5
   Sleep, 0
   Send, {tab}{space} ; click "no"
}
return

;//////////////// Control Media Player //////////////////////////////////
^+c::
IfWinExist, Windows Media Player
   ControlSend, ahk_parent, ^p
return
^+v::
IfWinExist, Windows Media Player
   ControlSend, ahk_parent, ^f
return

KillActive:
WinGet, pid, PID , A
if (pid)
   Process, Close, %pid%
;WinKill, A
return

RunRestoreHideApp2(title1, app, title2)
{
   DetectHiddenWindows, On
   SetTitleMatchMode, 2
   app = "%app%"
   If WinExist(title1) or (title2 <> "" and WinExist(title2))
   {
      IfWinActive
      {
         WinMinimize
         return min
      }
      else
      {
         WinActivate
         return act
      }
   }
   else
   {
      Run, %app%
      return ran
   }
}

RunRestoreHideApp(title1, app)
{
   RunRestoreHideApp2(title1, app, "")
}

HideAIM:
DetectHiddenWindows, On
SetTitleMatchMode, 2
IfWinExist, Default Away Message
{
   WinActivate
   ;WinWaitActive
   Send, {Enter}
}
else IfWinExist, Buddy List
{
   ;WinActivate
   SendMessage, 0x111, 24003, 0
   ;WinMenuSelectItem, Buddy List,,My AIM,Away Message,Default Away Message
   ;MsgBox, Buddy
}
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 14th, 2005, 10:28 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Looks useful. Thanks for posting it.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], stevep, Stigg and 13 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