Path of active window
Edited by TheSaint, 26 June 2006 - 04:24 PM.
Posted 26 June 2006 - 04:21 PM
Edited by TheSaint, 26 June 2006 - 04:24 PM.
Posted 26 June 2006 - 04:29 PM
Edited by MHz, 26 June 2006 - 04:38 PM.
Posted 26 June 2006 - 04:49 PM
$path = _WinGetPath() MsgBox(0,WinGetTitle(""),$path) Func _WinGetPath($Title="", $strComputer='localhost') $win = WinGetTitle($Title) $pid = WinGetProcess($win) $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.ExecutablePath Then Return $objItem.ExecutablePath Next EndIf EndFunc
Edited by gafrost, 26 June 2006 - 04:57 PM.
SciTE for AutoItDirections for Submitting Standard UDFs
Don't argue with an idiot; people watching may not be able to tell the difference.
Posted 26 June 2006 - 05:12 PM
Posted 26 June 2006 - 05:33 PM
Interesting. Wonder if even possible to get the path.
Edit:
Oh, as in a rightclick extension does. That is taken fron that instance then and passed to the registry, then onwards to your application. You can set the path to be sent to your application via the registry from the main branch of the rightclick menu. If you want a submenu, AutoIt would not be able to make a shell extension for that purpose. The registry can pass on the parameters just like the SendTo menu does.
Posted 26 June 2006 - 05:38 PM
beta
Edited by TheSaint, 26 June 2006 - 05:42 PM.
Posted 26 June 2006 - 05:45 PM
My reply was mainly to the path of a highlighted file, rather then a window. So may have been incorrect to your needs. As to get the info from a window on a rightclick would be a nice trick indeed to know with using Autoit. Gary has given some nice code to get it outright of the path from the active window.Thanks for your response MHz
I'm not quite sure how to apply what you seem to be saying - but I shall ponder upon it?
Posted 26 June 2006 - 05:46 PM
SciTE for AutoItDirections for Submitting Standard UDFs
Don't argue with an idiot; people watching may not be able to tell the difference.
Posted 26 June 2006 - 06:02 PM
Yeah I cut it and changed it from something done along time ago
http://www.autoitscript.com/forum/index.ph...st&p=114302
Posted 26 June 2006 - 06:34 PM
beta
Posted 27 June 2006 - 05:00 AM
MsgBox(0,'FilePath',_WinGetPath('Untitled - Notepad','localhost')) Func _WinGetPath($Title="", $strComputer='localhost') $win = WinGetTitle($Title) $pid = WinGetProcess($win) $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.ExecutablePath Then Return StringReplace($objItem.ExecutablePath,"\notepad.exe", "\",1);StringRegExpReplace ("*\.exe", "*\.exe", "\") Next EndIf EndFunc
Edited by WTS, 27 June 2006 - 05:02 AM.
Posted 27 June 2006 - 05:12 AM
MsgBox(0,'FilePath',StringRegExpReplace(_WinGetPath('Untitled - Notepad','localhost'), "\A*\.exe", "")) Func _WinGetPath($Title="",$strComputer='localhost') $win = WinGetTitle($Title) $pid = WinGetProcess($win) $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.ExecutablePath Then Return $objItem.ExecutablePath;StringRegExpReplace ($objItem.ExecutablePath, "\A*.exe", "") Next EndIf EndFunc
Edited by WTS, 27 June 2006 - 05:19 AM.
Posted 27 June 2006 - 12:11 PM
MsgBox(0,'FilePath',_WinGetPath('Untitled - Notepad','localhost')) Func _WinGetPath($Title="", $strComputer='localhost') $win = WinGetTitle($Title) $pid = WinGetProcess($win) $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.ExecutablePath Then $path = "" $tmp = StringSplit($objItem.ExecutablePath,"\") For $x = 1 To $tmp[0] - 1 $path &= $tmp[$x] & '\' Next Return $path EndIf Next EndIf EndFunc
SciTE for AutoItDirections for Submitting Standard UDFs
Don't argue with an idiot; people watching may not be able to tell the difference.
Posted 28 June 2006 - 12:32 AM
$a_path = _WinGetPath('Untitled - Notepad','', 'localhost') If Not @error Then For $x = 1 To $a_path[0] MsgBox(0, 'Window File Path Info:', $a_path[$x]) Next EndIf ;********************************************************* ; if error returns empty string and sets error ; returns array containing ; 1 = Title ; 2 = PID ; 3 = Path ; 4 = Exe name ;********************************************************* Func _WinGetPath($Title = "",$Text="", $strComputer = 'localhost') Local $path[5] = [5, "", -1, "", ""] If StringLen($Text) > 0 Then $path[1] = WinGetTitle($Title,$Text) Else $path[1] = WinGetTitle($Title) EndIf $path[2] = WinGetProcess($path[1]) $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $path[2], "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.ExecutablePath Then $tmp = StringSplit($objItem.ExecutablePath, "\") For $x = 1 To $tmp[0] - 1 $path[3] &= $tmp[$x] & '\' Next $path[4] = $tmp[UBound($tmp) - 1] Return $path EndIf Next EndIf SetError(1) Return "" EndFunc ;==>_WinGetPath
SciTE for AutoItDirections for Submitting Standard UDFs
Don't argue with an idiot; people watching may not be able to tell the difference.
Posted 01 July 2006 - 06:07 PM
Sorry people, I've been away a few days. However I have now tried the above examples, but with very little success.I think this would be more appropriate, returns more info
$a_path = _WinGetPath('Context Options','', 'localhost')
what I want returned isD:\Projects\AutoIt 3\Context Options
Please note that I am not working with an executable ... unless you consider a folder is always opened by C:\Windows\Explorer.exeD:\Projects\AutoIt 3
Using your latest code I get 4 dialogs and an error!D:\Projects\AutoIt 3\Context Options
Dialog 2 displaysContext Options
Dialog 3 displays4084
Dialog 4 displaysC:\Windows\
Then I get an error messageExplorer.exe
Array variable has incorrect number of subscripts or subscript dimension range exceeded
Edited by TheSaint, 01 July 2006 - 06:09 PM.
Posted 01 July 2006 - 06:48 PM
Edited by evilertoaster, 01 July 2006 - 06:48 PM.
Posted 01 July 2006 - 07:37 PM
so essentailly all you want is WinGetTitle("") and then use stringsplit or other string manamgement to strip it at the first '/' from the right?
Posted 01 July 2006 - 08:55 PM
$a_path = _WinGetPath('Untitled - Notepad','', 'localhost') If Not @error Then For $x = 1 To $a_path[0] MsgBox(0, 'Window File Path Info:', $a_path[$x]) Next EndIf ;********************************************************* ; Function Name: _WinGetPath() ; Parameter(s): $Title = Window Title ; $Text = Window Text ; $strComputer = Computer Name ; Return Value(s): 1 = Title ; 2 = PID ; 3 = Path ; 4 = Exe name ; Comment(s): If error returns empty string and sets error ; returns array containing ; Author(s): Gary Frost ;********************************************************* Func _WinGetPath($Title = "",$Text="", $strComputer = 'localhost') Local $path[5] = [4, "", -1, "", ""] If StringLen($Text) > 0 Then $path[1] = WinGetTitle($Title,$Text) Else $path[1] = WinGetTitle($Title) EndIf $path[2] = WinGetProcess($path[1]) $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $path[2], "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.ExecutablePath Then $tmp = StringSplit($objItem.ExecutablePath, "\") For $x = 1 To $tmp[0] - 1 $path[3] &= $tmp[$x] & '\' Next $path[4] = $tmp[UBound($tmp) - 1] Return $path EndIf Next EndIf SetError(1) Return "" EndFunc ;==>_WinGetPath
Edited by WTS, 01 July 2006 - 09:02 PM.
Posted 01 July 2006 - 09:20 PM
Thanks WTSThis is not your answer but you dont get an error .. or extra value after the forth
Once again, Thanks WTS (sorry ... forgot to add your name in one of the last posts, but it was also meant for you ... your efforts & others are always appreciated!)the least you can do is thank us for trying... 8)
Edited by TheSaint, 01 July 2006 - 09:25 PM.
Posted 03 July 2006 - 05:31 PM
Once again, Thanks WTS (sorry ... forgot to add your name in one of the last posts, but it was also meant for you ... your efforts & others are always appreciated!)
0 members, 0 guests, 0 anonymous users