AutoHotkey Community

It is currently May 26th, 2012, 9:10 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: June 20th, 2009, 4:59 am 
Offline

Joined: September 16th, 2008, 1:40 pm
Posts: 11
Hi,

I need a tool to minimize window to tray, then exit itself. And double-click tray icon to restore.

Such as:

ToTray.exe [/Restore] <Title | Class | PID | Process name | Foreground window> | /StartToTray <Program Path>


Last edited by tireless on June 20th, 2009, 2:30 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 5:13 am 
that´s not possible!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 5:22 am 
Offline

Joined: September 16th, 2008, 1:40 pm
Posts: 11
Z_Gecko wrote:
that´s not possible!


I had tried Min2Tray.ahk, it can minimize window to tray. Click tray menu "Quit only", it'll leave the minmized tray icon, double-click the minmized tray icon, window will restore... So I think it can be a command line tool.


Last edited by tireless on June 20th, 2009, 5:28 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 5:25 am 
are you shure, it exits?
please link that script, so i can take a look.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 2:13 pm 
Offline

Joined: September 16th, 2008, 1:40 pm
Posts: 11
Min2Tray v1.7.7 - minimize window to tray & much more!
http://www.autohotkey.com/forum/viewtopic.php?t=4418


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 2:54 pm 
OK, this script starts a new process for every window that is minimized,
so the initializing process can be ended.

it should be no problem to change this scripts, to be initially run from the cmd-line.

this should give you a start:
paste the code in the Min2Tray Script (new code colored red, surrounding old code black):
Code:
If ( %0% < 1 )   ; cmdline: no args -> behaviour: starter
{
   ;=========================================================================
   ; started as hotkey-launcher (starter)
   Goto, h_InitStarter
   Return
}
; end of auto-execution for starter here!
;============================================================================

;============================================================================
; function as tray menu for minimized window (helper) starts here

;----------------------------------------------------------------------------


;-------cmd-line part-----
if ( %1% = "hide")
{
   whoami := "cmd_line_hide"
   Loop, %0%   ; go thru all arguments on command line
   {
      if (A_Index = 1)
         continue
      cmdLine .= A_Loopfield
      if (A_Index < %0%)
         cmdLine .= A_Space
   }
   
      ; find AutoHotkey.exe and save its path to a variable for later use
   If ( Not A_IsCompiled ) {
      RegRead, h_ahkFullPath, HKLM, SOFTWARE\AutoHotkey, InstallDir
      h_ahkFullPath = %h_ahkFullPath%\AutoHotkey.exe
      IfNotExist, %h_ahkFullPath%
      {
         h_ahkFullPath := f_FindFile( "AutoHotkey.exe", A_ProgramFiles )
         If ( h_ahkFullPath = "" )
         {   ; search windir
            StringSplit, tmparray, A_WinDir, \
            h_ahkFullPath := f_FindFile( "AutoHotkey.exe", tmparray1 )
            If ( h_ahkFullPath = "" )
               Goto, ExitWithAHKError
         }
      }
   }
   
   If ( A_IsCompiled )
      Run, "%A_ScriptFullPath%" %cmdLine%, , UseErrorLevel, h_newPID
   Else
      Run, "%h_ahkFullPath%" "%A_ScriptFullPath%" %cmdLine%, , UseErrorLevel, h_newPID
   
   If ( ErrorLevel = "ERROR" )   ; helper could not be started
      ExitApp, "ERROR"
   Else
      ExitApp, %h_newPID%
      
}
;--end--cmd-line part-----



; Helper -- init
;

whoami := "helper"
f_SetLanguage( whoami )

h_ID0 = 0
Loop, %0%   ; go thru all arguments on command line
{
   tmp := %A_Index%

   If InStr( tmp, "0x", TRUE ) = 1
   {  ; get several (at least one) window id
      h_ID0++
      h_ID%h_ID0% = %tmp%
   }
   Else If ( h_ID0 = 0 ) {
      If ( tmp = "__justTriggerAction__")
         h_JTA := TRUE
      Else  ; get title for multi window mode
         h_MultiTitle = %tmp%
   }
}



Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 3:47 pm 
Offline

Joined: September 16th, 2008, 1:40 pm
Posts: 11
Thanks.

But how to use? I insert the red code you give into Min2Tray.ahk, execute 'm2t.ahk IrfanView', it prompt:

Error: First parameter must be a number!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 3:59 pm 
which process showed the error?
the one you started,
or the one that was started by the script you started?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 4:17 pm 
Offline

Joined: September 16th, 2008, 1:40 pm
Posts: 11
I execute 'm2t.ahk IrfanView' in the Command Prompt Window, prompt the error.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2009, 4:43 pm 
Quote:
which process showed the error?
the one you started,
or the one that was started by the script you started?

i told you already that:
Quote:
this script starts a new process for every window that is minimized,
so the initializing process can be ended.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 3rd, 2009, 8:20 pm 
Offline

Joined: July 11th, 2005, 10:13 pm
Posts: 108
Location: Germany
here's my suggestion to solve the prob:

if you would like to use Min2Tray to hide the window away, you can use a little snipped of script code like this:
Code:
; get WinID of a window and hide it
WinGet, winID, ID, <name of your window>
Run, "C:\AutoHotkey\AutoHotkey.exe" "C:\Min2Tray\Min2Tray.ahk" %winID%
; or with the compiled version of Min2Tray
Run, "C:\Min2Tray\Min2Tray.exe" %winID%

does what the comment says *g*, you just have to adopt the paths!

unhiding is not scriptable, ATM.

Junyx

_________________
C.R.E.A.M.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Exabot [Bot], krajan, patgenn123 and 59 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