AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Run Notepad / On Top / but not steal focus

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
LazyLarry
Guest





PostPosted: Thu Jan 05, 2006 4:59 pm    Post subject: Run Notepad / On Top / but not steal focus Reply with quote

I looked at the Help, and search but did not find a way to run a text file, in Notepad and stay on top but not take the focus away from the active window.

Maybe I am missing something simpleL
Back to top
Decarlo110



Joined: 15 Dec 2004
Posts: 303
Location: United States

PostPosted: Thu Jan 05, 2006 5:19 pm    Post subject: Reply with quote

Try:
Code:

SetTitleMatchMode 2
Run, C:\some_folder\my_file.txt, , Hide
WinWait my_file.txt
WinShow
WinSet Topmost
return

or
Code:

SetTitleMatchMode 2
Run, <notepad_directory_path>\Notepad.exe "my_file.txt", , Hide
WinWait my_file.txt
WinShow
WinSet Topmost
return

untested
_________________
1) The Open Source Definition http://www.opensource.org/docs/definition_plain.php

2) Intuitive. Logical. Versatile. Adaptable. <<AutoHotkey>>
Back to top
View user's profile Send private message
JSLover



Joined: 20 Dec 2004
Posts: 541
Location: LooseChange911.com... the WTC attacks were done by the US Gov't... the official story is a lie...

PostPosted: Fri Jan 06, 2006 3:19 am    Post subject: Re: Run Notepad / On Top / but not steal focus Reply with quote

This works...

my file.txt wrote:
my file

np aot nf.ahk wrote:
Code:
F7::
File=my file.txt
Program=notepad

if Program
   Program:=Program " "
Run, %Program%%File%, , hide, pid      ; pid not available when running file
DetectHiddenWindows, on
WinWait, ahk_pid %pid%
WinSet, AlwaysOnTop
WinMove, , , % A_ScreenWidth-200, 100, 200, % A_ScreenHeight-200
WinShow
return

F8::Reload

Chris...
  • I originally designed it to not require a Program, but without it AHK can't find the pid?...is there any way for you to try & acquire the pid when "running a file"?

  • When the code was...

    Code:
    F7::
    File=my file.txt
    ;Program=notepad

    Run, %Program% %File%, , hide, pid
    ;...etc...

    ...I get an error about the space between "%Program%" & "%File%" (when I remove it it works), but when it's...

    Code:
    F7::
    File=my file.txt
    Program=notepad

    Run, %Program%%File%, , hide, pid
    ;...etc...

    ...it don't work without the space, (if I add it back, it works, but...) the only way to make it happy (in both cases) is like I did with the "iffy" space addition...can this be improved at all?...of course I ended up always needing a Program, but if the 1st bullet point can be fixed, then this matters again.

_________________

Home • Click image! • Blog
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Fri Jan 06, 2006 4:27 pm    Post subject: Re: Run Notepad / On Top / but not steal focus Reply with quote

JSLover wrote:
without [an explicit exe file] AHK can't find the pid
This is a documented limitation: "The variable will be made blank if the PID could not be determined, which usually happens if a system verb, document, or shortcut is launched rather than a direct executable file."

Since I don't know any way to improve on it yet, the script would have to discover the PID some other way, such as WinGet.

JSLover wrote:
the only way to make it happy (in both cases) is like I did with the "iffy" space addition...can this be improved at all?
It could be improved by omitted whitespace when passing the command line to the API for launching. However, I think this would break any script that relies on the ability to launch files whose names start with spaces.

Last edited by Chris on Sat Jan 07, 2006 12:47 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Decarlo110



Joined: 15 Dec 2004
Posts: 303
Location: United States

PostPosted: Fri Jan 06, 2006 5:07 pm    Post subject: Reply with quote

The code i gave works also, it was just missing the following line at the top:
Code:
DetectHiddenWindows on

i occasionally forget script settings when posting since i have the habit of letting my auto-execute take care of the common settings. (i use my .ini file for all my scripts)
_________________
1) The Open Source Definition http://www.opensource.org/docs/definition_plain.php

2) Intuitive. Logical. Versatile. Adaptable. <<AutoHotkey>>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group