AutoHotkey Community

It is currently May 27th, 2012, 2:51 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: November 25th, 2009, 5:31 pm 
Offline

Joined: November 25th, 2009, 5:23 pm
Posts: 3
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]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 25th, 2009, 6:23 pm 
change the Open With default program with .ahk extension


Report this post
Top
  
Reply with quote  
PostPosted: November 25th, 2009, 6:30 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
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?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 25th, 2009, 6:34 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
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 :wink:


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 26th, 2009, 12:43 am 
Offline

Joined: November 25th, 2009, 5:23 pm
Posts: 3
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2009, 8:44 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
It is a bit trickier that simply copying notepad.exe read more about it here
http://www.ultraedit.com/forums/viewtop ... pad#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 FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 26th, 2009, 9:41 pm 
Offline

Joined: February 17th, 2008, 7:09 am
Posts: 536
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 27th, 2009, 2:56 pm 
Offline

Joined: November 25th, 2009, 5:23 pm
Posts: 3
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.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn, XstatyK and 23 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