Jump to content

All my products and services are free. All my costs are met by donations I receive from my users. If you enjoy using any of my products, please donate to support me. My bare hosting costs are currently not met so please consider donating by either clicking this text or the Patreon link on the right.

Patreon

Recommended Posts

Posted

Hey guys,

this is not Gameex related but I know that someone could help me out with this problem over here (maybe tempest?)

I'm using AHK to have Total Commander open when i press windows key + e

This is my script

#e::Run "C:\Program files\totalcmd\TOTALCMD.EXE"

very simple and it works!

one little thing is not working as supposed to: the window is not active! it starts minimized and i have to click in the taskbar to restore the window. it works for the first window when total commander is launched, but all following windows start minimized.

when i click on the exe of total commander it starts a new window in the foreground.. i was reading the documentation and tried commands like winactivate or winrestore but i can't define a window title since they are all named Total Commander with [n] in front depending of which instance is running.. (eg "[3] Total Commander")

So how could i make this window appear? is run the wrong command?

thanks for any help

Posted

there's probably an easier method that this, but if AHK allows you to call shortcuts, you can make a shortcut for TC and set its attributes so it runs full screen.

Posted

thanks for the input

i pointed ahk to the lnk and i set the shortcut to maximized. it still hasnt focus though. when i click on the window it displays maximized but it still starts up in the background... pretty weird!

Posted

I thought that WinActive would match any substring in the window title? Anyway you can use "SetTitleMatchMode, RegEx" to use a regular expression to match the titlescreen.

Posted

I usually use Process, Exist, <string in process or window title I'm looking for>. Then the ErrorLevel value contains the correct pID I'm interested in (or an error value if it doesn't exist). Then I can use WinActive or any other command to look for that pID.

Better yet, if you are launching the process in the script, just keep track of the pID at time of launch!

Posted

thanks for the link!

i use comspec now.. i still don't know why its not working the direct way but this way it works:

 #e::Run %comspec% /c ""C:\Program files\totalcmd\TOTALCMD.lnk"

I just get this nasty black window from cmd for millisecond .. it's not perfect but this way it works!

Posted
thanks for the link!

i use comspec now.. i still don't know why its not working the direct way but this way it works:

 #e::Run %comspec% /c ""C:\Program files\totalcmd\TOTALCMD.lnk"

I just get this nasty black window from cmd for millisecond .. it's not perfect but this way it works!

Now you can use the parameter to hide the window. That way it doesn't show for that millisecond.

Posted

So you are using an AHK script to launch a batch file? Have you considered just using an AHK script to do the whole thing? I don't know what you are running, so that may not be possible.

Posted

i talked to frequency over im and we figured out that the winkey-e command is a bit problematic.

if i set the script to winkey-q for example everything works great: total commander starts up in the foreground.

with winkey-e total commander always starts up behind the active window (eg firefox)

tempest, if i use the hide command, it hides tc as well... or is there a way to only hide the cmd box?

just to make it clear why i try to have it set to winkey-e... i'm used to this shortcut to open the windows explorer. It seems like a lot of people are looking for a way to reassign winkey-e. Using AHK seems to be the best solution i've come across, it's nice to have a working solution!

I'm happy it works now but the method is still a bit dirty though :)

Posted

Sorry, I had company yesterday. Looking at your first post, you want to use:

SetTitleMatchMode, 2

I also wouldn't use Comspec, you should be able to get it to work with Run

I don't know if that helps you now, or not....

if you want help, post your code.

Posted

Hey Tempest, thanks for your reply!

My command line looks like this:

#e::Run "C:\Program files\totalcmd\TOTALCMD.exe", SetTitleMatchMode, 2

but total commander still opens behind the active window, so not in the foreground. This is happening due to a conflict with winkey-e. It works as supposed to when i set it to winkey-q for example

I'm pretty sure there is a way to get it to work with run, a way to set the window active after opening. I'm just missing the experience with ahk to get it to do what i want :(

Posted

This works for me, using notepad as the .exe

 

#SingleInstance Force
#Persistent
SetTitleMatchMode, 2
SetTimer, OnTop, 50
Exit

#e::
Run Notepad.exe,, Max
Return

OnTop:
IfWinExist, Notepad
Winactivate
return

Posted

hey tempest,

thanks for giving it a try.

the script is not exactly what i'm aiming for though

i should have explained myself better:

I'm not trying to keep a window on top but to open multiple instances of total commander and always have the last total commander window open in the foreground. for some weird reason only the first instance of tc opens in the foreground. all other windows always open behind the active window!

i tried to replicate this problem with notepad ( #e::Run notepad )but notepad behaves correctly and opens every instance in the foreground.

i guess i'll have to stick with comspec... at least that works...

Posted

You need to know the process ID in order to guarantee you have the right window open on top. If you just use a window title, AHK won't know which one you want. If you are launching the process from AHK, you can save the pID for later use.

Posted

i used the following script to retrieve the pid:

Run "C:\Program files\totalcmd\TOTALCMD.exe", , , NewPID
Process, priority, %NewPID%, High
MsgBox The newly launched PID is %NewPID%.

but the pid is different everytime the script is launched.

i guess my script needs to retrieve the process id in order to work with it, right? But how would i do that? I'm just good at changing examples :)

i'm not really an experienced programmer you know... thats probably my problem :lol:

Posted

I'd still like to take a look at it. I would like to download Total Commander to test with... Are you talking about this: http://www.ghisler.com/ or something else?

Tonight, I'm going to party like it's Post#1999!

Edit: I didn't see the post above. You can use the Pid instead of the window name, As in:

WinActivate, ahk_id %NewPID%

Posted

way to go tempest!

yeah i'm talking about the program on the webpage you mentioned!

#e::Run "C:\Program files\totalcmd\TOTALCMD.exe"
WinActivate, ahk_id %NewPID%

is also not working. or do i have to do it differently?

Posted

Exactly! If you know the pID, then you don't care what the window's name is. There can be multiple instances of the same application, but if you know the pID of the one you care about, you can just call that one specifically. Yes, they will absolutely have a different pID each time you call them...that's the whole point ^_^

Just exchange the window name for the pID like Tempest showed in the post above and you should be golden!

Posted

Damn it Chriss, I wanted to use my 2000th post giving someone crap, not helping out!

(Oh, wait, I did just give you crap, so I guess it's ok :P )

Try:

#e::
Run C:\Program files\totalcmd\TOTALCMD.exe,,, NewPid
WinActivate, ahk_pid%NewPid%
Return

Posted

hey man, i just tried the way you posted it but it still opens the tc window behind the active window

congratulations to your 2000th post, mate!!

Posted

I installed Total Commander 7.04a (unregistered)

Using the last script I posted, a new instance of Total Commander opens, Active, and On Top.

The unregistered version has a nag screen that has me press a button to continue, I don't know if that makes a difference, or not.

I am running Win XP Pro SP2.

Maybe you could try a new install? Possibly try it with the nag screen, and see if it makes a difference?

If I can help, let me know...

Posted

I also tried this:

#e::
Run %comspec% /c C:\totalcmd\TOTALCMD.EXE,, hide, NewPid
WinActivate, ahk_pid%NewPid%
Return

The CMD window doesn't show, maybe that will work? I can't test, since it works for me all of the time.

Make sure to adjust your path.

Posted

Another option is to hide the other process(es) when the new one starts. You can hide all old ones by name and then set the new one to be on top.

Posted

it's weird that you got it working with the script... maybe it makes a difference to have the registered or unregistered version since i'm not seeing the nag screen!

i will do some more testing and maybe reinstall, let's see if thats gonna fix this bug!

thanks for the intense testing tempest! much appreciated!

Guest
This topic is now closed to further replies.
×
×
  • Create New...