 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
LazyLarry Guest
|
Posted: Thu Jan 05, 2006 4:59 pm Post subject: Run Notepad / On Top / but not steal focus |
|
|
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
|
Posted: Thu Jan 05, 2006 5:19 pm Post subject: |
|
|
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 |
|
 |
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...
|
Posted: Fri Jan 06, 2006 3:19 am Post subject: Re: Run Notepad / On Top / but not steal focus |
|
|
This works...
| my file.txt wrote: | | my file |
| 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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10480
|
Posted: Fri Jan 06, 2006 4:27 pm Post subject: Re: Run Notepad / On Top / but not steal focus |
|
|
| 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 |
|
 |
Decarlo110
Joined: 15 Dec 2004 Posts: 303 Location: United States
|
Posted: Fri Jan 06, 2006 5:07 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|