AutoHotkey Community

It is currently May 27th, 2012, 3:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: May 19th, 2010, 5:14 am 
Offline

Joined: May 31st, 2008, 3:22 pm
Posts: 47
Code:
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
DetectHiddenWindows On
DetectHiddenText, On

F1::
;Process, Exist, uTorrent.exe
;AssholePID=%Errorlevel%
WinGet, aI, ID, A
WinGetClass, aC,  A ;i know active class
WinGetTitle, aT, A ;i even know active window title!
MsgBox %aI% `n%aC% `n%aT%
;but how get path and exe of above?
;Run, %ActiveWindowPath%
return
!x::ExitApp


4exampl: i open file new text.txt on drive C:\ and accidenlty close browser window, need get **** path!



http://yfrog.com/gi20100519074151ap


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 19th, 2010, 6:15 am 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
http://www.autohotkey.com/forum/viewtopic.php?t=18550

Look at --> Full filename by process ID (GetModuleFileNameEx() function)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 19th, 2010, 8:31 am 
Offline

Joined: May 31st, 2008, 3:22 pm
Posts: 47
too complex to me... maybe write easy example?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 19th, 2010, 2:15 pm 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
Got it fetching executable name & pathname :)
Code:
; Press Ctrl-Space to view process details for current window...

  ^Space::
    WinGet, ProcessID, PID, A

    ProcessName := GetProcessName(ProcessID)
    ProcessPathName := GetModuleFileNameEx(ProcessID)

    MsgBox Window's executable name = %ProcessName%
    MsgBox Window's executable pathname = %ProcessPathName%
  Return

  #Include %A_ScriptDir%\ProcessInfo.ahk

Now the hard bit - fetching the path of the open document...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 19th, 2010, 2:20 pm 
Offline

Joined: December 23rd, 2006, 6:02 pm
Posts: 424
Location: Russia
Easy enough? :)
Code:
F11::
    PID = 0
    WinGet, hWnd,, A
    DllCall("GetWindowThreadProcessId", "UInt", hWnd, "UInt *", PID)
    hProcess := DllCall("OpenProcess",  "UInt", 0x400 | 0x10, "Int", False
                                     ,  "UInt", PID)
    PathLength = 260
    VarSetCapacity(FilePath, PathLength, 0)
    DllCall("Psapi.dll\GetModuleFileNameExA", "UInt", hProcess, "Int", 0
                                 , "Str", FilePath, "UInt", PathLength)
    DllCall("CloseHandle", "UInt", hProcess)
    MsgBox, %FilePath%
Return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 1st, 2010, 8:24 pm 
Offline

Joined: May 31st, 2008, 3:22 pm
Posts: 47
a_h_k, YMP thank you very much 4Urs codes, that happy


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn and 17 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