AutoHotkey Community

It is currently May 27th, 2012, 6:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: January 5th, 2006, 5:59 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2006, 6:19 pm 
Offline

Joined: December 15th, 2004, 10:24 pm
Posts: 303
Location: United States
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>>


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 6th, 2006, 4:19 am 
Offline
User avatar

Joined: December 20th, 2004, 12:19 pm
Posts: 798
Location: LooseChange911.com Ask Questions, Demand Answers █ The WTC bldgs █ shouldn't have fallen █ that fast
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.

_________________
AutoHotkey-Hotstring.ahk - Helping the world spell "AutoHotkey" correctly! (btw, it's a lowercase k!)


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 6th, 2006, 5:27 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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 January 7th, 2006, 1:47 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2006, 6:07 pm 
Offline

Joined: December 15th, 2004, 10:24 pm
Posts: 303
Location: United States
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>>


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], hd0202 and 59 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