 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
tireless
Joined: 16 Sep 2008 Posts: 11
|
Posted: Sat Jun 20, 2009 3:59 am Post subject: Help write a command line tool to minimize window to tray |
|
|
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 Sat Jun 20, 2009 1:30 pm; edited 2 times in total |
|
| Back to top |
|
 |
Z_Gecko Guest
|
Posted: Sat Jun 20, 2009 4:13 am Post subject: |
|
|
| thatīs not possible! |
|
| Back to top |
|
 |
tireless
Joined: 16 Sep 2008 Posts: 11
|
Posted: Sat Jun 20, 2009 4:22 am Post subject: |
|
|
| 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 Sat Jun 20, 2009 4:28 am; edited 2 times in total |
|
| Back to top |
|
 |
Z_Gecko Guest
|
Posted: Sat Jun 20, 2009 4:25 am Post subject: |
|
|
are you shure, it exits?
please link that script, so i can take a look. |
|
| Back to top |
|
 |
tireless
Joined: 16 Sep 2008 Posts: 11
|
|
| Back to top |
|
 |
Z_Gecko Guest
|
Posted: Sat Jun 20, 2009 1:54 pm Post subject: |
|
|
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%
}
}
|
|
|
| Back to top |
|
 |
tireless
Joined: 16 Sep 2008 Posts: 11
|
Posted: Sat Jun 20, 2009 2:47 pm Post subject: |
|
|
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! |
|
| Back to top |
|
 |
Z_Gecko Guest
|
Posted: Sat Jun 20, 2009 2:59 pm Post subject: |
|
|
which process showed the error?
the one you started,
or the one that was started by the script you started? |
|
| Back to top |
|
 |
tireless
Joined: 16 Sep 2008 Posts: 11
|
Posted: Sat Jun 20, 2009 3:17 pm Post subject: |
|
|
| I execute 'm2t.ahk IrfanView' in the Command Prompt Window, prompt the error. |
|
| Back to top |
|
 |
Z_Gecko Guest
|
Posted: Sat Jun 20, 2009 3:43 pm Post subject: |
|
|
| 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. |
|
|
| Back to top |
|
 |
Junyx
Joined: 11 Jul 2005 Posts: 103 Location: Germany
|
Posted: Fri Jul 03, 2009 7:20 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|