Problem with launching programs from current directory

The behaviour described in the bug report is either by design, or would be far too complex/time-consuming to be changed

Moderators: Hacker, petermad, Stefan2, white

User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Redundant Code.
Last edited by Balderstrom on 2010-10-11, 00:12 UTC, edited 2 times in total.
reflex
Junior Member
Junior Member
Posts: 20
Joined: 2009-01-23, 22:40 UTC

Post by *reflex »

@Balderstrom:
thanks for your feedback & your effort!
How many bad side-effects do you count?

Try this: Ctrl+Enter -> Enter
No cmdline focus, still executes cmdline - and this is how i use it.

@karlchen: If you are sure that .\ works always, you can change the script and make it simpler.
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Redundant Code.
Last edited by Balderstrom on 2010-10-11, 00:12 UTC, edited 2 times in total.
reflex
Junior Member
Junior Member
Posts: 20
Joined: 2009-01-23, 22:40 UTC

Post by *reflex »

@Balderstrom: your script does not work.

Testcase:
Ctrl + Enter -> moves "Auto Hotkey.exe" to cmdline
Ctrl + Enter -> moves "te st.ahk" to cmdline
Cmdline now looks like "Auto Hotkey.exe" "te st.ahk"
Enter

PS:I did not check the side-effects of your script :wink:
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

I'm not changing Ctrl+Enter, TC is copying whatever is under the cursor to the commandline.
All my snippet does is let Ctrl+Enter do whatever TC thinks it should, and if the focus is on the Left or Right Panel when you press Ctrl+Enter, then focus on the Command-Line next.

As far as your script goes, you are hotkey'ing Enter - Which can also be used on ContextMenu's or the BreadCrumb Bar, or the AddressBar or the QuickSearch field among possibly other places. It's not "safe" for people to use. As well there is no "rtrim()" function in AHK.

When you offer up scripts to the public they shouldn't have so many bad side-effects, which I already mentioned in my previous post.

With your script you can't even do an inplace-rename on a file if any text exists in TC's Command-Line.
reflex
Junior Member
Junior Member
Posts: 20
Joined: 2009-01-23, 22:40 UTC

Post by *reflex »

You are right - Rtrim is only available in the Lexikos build.

I couldnt find any "bad" side-effect. I wrote the script for me - not for all possible users out there. You can take it as good/bad example, make your own (hopefully working), use it etc. And maybe you should get yours working before complaining?
User avatar
Balderstrom
Power Member
Power Member
Posts: 2148
Joined: 2005-10-11, 10:10 UTC

Post by *Balderstrom »

Final Rewrite, Much cleaner to just trigger on Ctrl+Enter.

Code: Select all

#SingleInstance force
#NoEnv
SetBatchLines, -1

#ifwinactive, ahk_class TTOTAL_CMD
{
	^$Enter::
		if(!TC_TControlActive(aControl)) 
		{
			Send, ^{Enter}
		return
		}
		ControlGet, cID, HWND,, Edit1, ahk_class TTOTAL_CMD
		ControlGetText, sCMDLine,, ahk_id %cID%
		Send, ^{Enter}
		sCMDLine:=RegExReplace(sCMDLine, "^[ ]+", "")
		if( sCMDLine )
			return
		ControlGetText, sCMDLine,, ahk_id %cID%
		RegExMatch(sCMDLine, "i)^([ ]+)?(.*\.exe[ ]?)$", sTmp)
		if( !sTmp2 )
			return
		ControlSetText,, % ".\" sTmp2, ahk_id %cID%
		ControlClick,, ahk_id %cID%
	return
return
}


TC_TControlActive( byRef activeControl, cName="" )
{
	if( !WinActive("ahk_class TTOTAL_CMD") )
		return !(ErrorLevel:=4)
	ControlGetFocus, aControl, A
	if( !cName && cName:="TMyListBox" )
		cName .= ( TC_TControlExist("TMyListBox3") ? "[23]" : "[12]" )
	if( RegExMatch( aControl, cName ) )
		ControlGet, activeControl, HWND,, %aControl%
	return ( ErrorLevel ? 0 : activeControl )
}

TC_TControlExist( controlName )
{
	ControlGet, cID, HWND,, %controlName%, A
return (cID ? cID : !(ErrorLevel:=1))
}
Post Reply