| View previous topic :: View next topic |
| Author |
Message |
heinous
Joined: 25 Nov 2009 Posts: 3
|
Posted: Wed Nov 25, 2009 4:31 pm Post subject: Run preferred text editor when notepad.exe is called |
|
|
I'm brand new to AutoHotkey and was hoping to get a simple problem solved. I use UltraEdit as a text editor, but some programs call notepad.exe (under the Windows folder) directly. This is not only annoying, it can be problematic.
My thought was to create a script and save it as notepad.exe in C:\WINDOWS\system32. That part I've accomplished. What I'm still having trouble with is the script content.
I get UltraEdit to run, but its current directory is not correct. I need a way to set the current directory to what I want (e.g. C:\Temp).
When notepad.exe is run, the format of the command is always "notepad.exe [path to file]". I'm not sure what the right way to pass the path to UltraEdit would be. I had been trying to simply pass "%1% %2%" and so on up to %9%, but that's a kludge. It actually seems to work, but it results in extra spaces being sent because some of those vars will be empty.
Any help would be appreciated. I know this is embarrassingly simple for hardcore scripters but this is where I'm at.[/url] |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Nov 25, 2009 5:23 pm Post subject: |
|
|
| change the Open With default program with .ahk extension |
|
| Back to top |
|
 |
jaco0646
Joined: 07 Oct 2006 Posts: 3113 Location: MN, USA
|
Posted: Wed Nov 25, 2009 5:30 pm Post subject: Re: Run preferred text editor when notepad.exe is called |
|
|
| heinous wrote: | | My thought was to create a script and save it as notepad.exe in C:\WINDOWS\system32. | Why not copy UltraEdit and save it as Notepad.exe? |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
Posted: Wed Nov 25, 2009 5:34 pm Post subject: Re: Run preferred text editor when notepad.exe is called |
|
|
| jaco0646 wrote: | | heinous wrote: | | My thought was to create a script and save it as notepad.exe in C:\WINDOWS\system32. | Why not copy UltraEdit and save it as Notepad.exe? |
You would need to copy all the dlls and folder structure as well, I think.
Try this solution (not tested).
Instead %1% %2%...
You can do: | Code: | p1=%1%
p2=%1%
p3=%1%
p4=%1%
p5=%1%
;....
Loop %0%
{
params.= """" . p%A_Index% . """" . A_Space
}
Run,uedit32.exe %params% |
_________________ AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun  |
|
| Back to top |
|
 |
heinous
Joined: 25 Nov 2009 Posts: 3
|
Posted: Wed Nov 25, 2009 11:43 pm Post subject: Re: Run preferred text editor when notepad.exe is called |
|
|
| jaco0646 wrote: | | heinous wrote: | | My thought was to create a script and save it as notepad.exe in C:\WINDOWS\system32. | Why not copy UltraEdit and save it as Notepad.exe? |
Because it won't work. It's not a standalone EXE you can just copy off. And the working dir issue would still exist.
I've decided to simply restore the original, crappy notepad.exe. This is far too much hassle. Thanks anyway. |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Thu Nov 26, 2009 7:44 am Post subject: |
|
|
It is a bit trickier that simply copying notepad.exe read more about it here
http://www.ultraedit.com/forums/viewtopic.php?f=7&t=5909&p=31274&hilit=notepad#p31274
It used to be easy as they provided a little utility to do it for you but they no longer do. There is a batch file solution as described in the thread above.
Re: Opening a list of files, see the UE help file, command line parameters:
File containing list of files to be opened
You may specify that the filename on the command line contains a list of files to open by using a "/f" parameter on the command line. In this case, UltraEdit will read each line of the files on the command line, and attempt to open each file. The file specified on the command line when the "/f" parameter is used must contain only filenames, and each filename must be on a separate line. _________________ AHK Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
rtcvb32
Joined: 17 Feb 2008 Posts: 289
|
Posted: Thu Nov 26, 2009 8:41 pm Post subject: |
|
|
Something to consider. Notepad++ has a loader that replaces the default notepad program. You could also follow the steps for which notepad.exe to replace/delete, and when windows complains about the non-authentic version, simply refuse to have it get fixed.
Alternatively you could change the program you want to load, which will only be 1 per extension. |
|
| Back to top |
|
 |
heinous
Joined: 25 Nov 2009 Posts: 3
|
Posted: Fri Nov 27, 2009 1:56 pm Post subject: |
|
|
Thank you all. I run WinXP and actually had been using the notepad.exe that the UltraEdit author used to provide. That's when I encountered trouble. When some applications would run notepad.exe, UE would be launched, but it would not find my user settings; UE would run under a different user context, and would start with the nasty default configuration. (Copying my UE user settings to the NetworkService %appdata% directory doesn't work and isn't what I want to do.)
I think I'm going to find a decent alternative (such as the suggested Notepad++) and use that as a literal notepad.exe replacement, while keeping UE installed for applications that aren't stupid enough to ignore file associations.
Incidentally, Bitsum.com offers a freeware console program called WfpDeprotect, and it can be used to disable Windows File Protection for one minute on selected files/folders. Very handy.
Thanks again, all.
Edit: I decided to use Notepad2. I simply downloaded it, renamed it to notepad.exe, and put it under C:\WINDOWS\system32. (I had already removed the native notepad.exe using the aforementioned WfpDeprotect.) It works fine. |
|
| Back to top |
|
 |
|