Jump to content
Sign in to follow this  
Zohar

How to Get the FileName+FilePath of a File Opened in MSPaint.EXE?

Recommended Posts

Zohar

Hi

 

Imagine this:

You open an image file with MSPaint.EXE,

and now when Paint's window is open, ou need to get the File's Full Path.

How should I do it?

 

I am using Windows XP SP3.

The TitleBar of the window shows "Filename.png - Paint", so this gives me the Filename part,

but I also need to get the folder in which the file is located..

 

Anyone has an idea how can I do it?

 

Thank you

Edited by Zohar

Share this post


Link to post
Share on other sites
Awais

i think there is a menu item recent pic 

it holds the information of last open pics

:P  :argue:

Share this post


Link to post
Share on other sites
mLipok

Check MRU


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-09-20

Share this post


Link to post
Share on other sites
Terenz

Check this key

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Paint\Recent File List

You have File1, File2 etc. is the path of the files opened in Paint. You can delete that subkey firstly, open the file in Paint and check the File1 subkey value.


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites
sahsanu

Hello,

The problem with that method is that if you open a pic file with MsPaint and you check inside the program the list of MRU you will see the file in the list but it is not written in registry till you close the program so this method doen't work if you just have opened a file and want to check the full path.

Proof of concept ;)

Open a file with MsPaint and run below script... you will get No match found. Close MsPaint and open again the same pic file... you will get the full path.

Opt("WinTitleMatchMode", 2)
If WinExists("- Paint") Then
    $sTitle = WinGetTitle("- Paint")
    $sPicName = StringRegExpReplace($sTitle, "(.+)\s-\sPaint", "$1")

    Local $sSubKey = "", $sValKey = ""
    Local $sParenteKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Paint\Recent File List\" ;Maybe this key is different on Win XP machine
    For $i = 1 To 10
        $sSubKey = RegEnumVal($sParenteKey, $i)
        If @error Then
            ConsoleWrite("No match found" & @CRLF)
            ExitLoop
        EndIf
        $sValKey = RegRead($sParenteKey, $sSubKey)
        If StringInStr($sValKey, $sPicName) Then
            ConsoleWrite("PicName full path is: " & $sValKey & @CRLF)
            ExitLoop
        EndIf
    Next
EndIf

Note: As I comment inside the code, I don't know what is the correct RegKey for WinXP.

And sorry, I don't know any other way to get the full path of a recently file opened on MsPaint :(.

Cheers,

sahsanu

Share this post


Link to post
Share on other sites
Zohar

Thank you all

 

i think there is a menu item recent pic 

it holds the information of last open pics

 

Yes there is, when you go to the File Menu, then on the bottom you see the recently opened files.

The only problem, is that like the TitleBar, it shows only the FileName, without the Path, which is what I am missing..

 

Check this key

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Paint\Recent File List

You have File1, File2 etc. is the path of the files opened in Paint. You can delete that subkey firstly, open the file in Paint and check the File1 subkey value.

 

Thank you Terenz

As sahsanu just wrote, the list there only updates with the last file, only after I close the program.

I need the Path while the program is working..

 

Anyone has any other creative idea?

 

Technically the program holds a variable in Memory that contains the FullPath of the currently opened file.

Is there a way to find this variable, and read its content, with AutoIt?

Edited by Zohar

Share this post


Link to post
Share on other sites
jchd

I guess that there is some sequence odf system calls that will allow you to grab full pathes of open handles. For instance you can see them with Process Explorer with Lower Pane set to Handles.

Time to spend a month or more digging in MSDN mess or wait for an OS guru to pop up.

Instant googling turned up this which pointed to that. Just hints.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
jchd

The OP is after the full path.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
mLipok

Maybe this (command line feeware utility)

http://www.nirsoft.net/utils/opened_files_view.html

 

EDIT:

here is better link :

http://www.codeproject.com/Articles/18975/Listing-Used-Files

Edited by mLipok

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-09-20

Share this post


Link to post
Share on other sites
water

When you select "Save As ..." the path and filename of the last opened file is being pre-set.

Maybe you can grab it from there.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Melba23

Zohar,

A bit of a long-winded way to do it, but you could search for all files which match the name in the title bar. This works fine for me: :)

#include <StringConstants.au3>
#include <File.au3>
#include <Array.au3>

Opt("WinTitleMatchMode", 2)

$sFileName = StringSplit(WinGetTitle(WinGetHandle("Paint")), " - ", $STR_ENTIRESPLIT)[1]

$aList = _FileListToArrayRec("M:\", $sFileName, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH)

_ArrayDisplay($aList, "", Default, 8)
If you get multiple returns then _WinAPI_FileInUse might be a good way to detect which one is in use. ;)

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Zohar

I guess that there is some sequence odf system calls that will allow you to grab full pathes of open handles.

For instance you can see them with Process Explorer with Lower Pane set to Handles.

 

Thank you jhcd and mLipok

 

I actually tried that yesterday, among the many things I tried to get the Full Path.

When using SysInternal's Process Explorer, 1 out of 4 of the times, you see there a File Handle to the open file.

But it's only 1 out of 4.

the other 3 times, it's simply not htere, and I cannot understand why..

So this is not a ttrustable solution.

 

 

When you select "Save As ..." the path and filename of the last opened file is being pre-set.

Maybe you can grab it from there.

 

Thank you, this is indeed something I checkde in the past, and I have a small problem there that prevents me from taking this option further:

The FileSave CommonDialog window, does not show the full path, and only the Last SubFolder name.

You could say that we can make a trick, and iterate the TreeView in the ComboBox, and compose the full path like that,

but even that is problematic because sometimes there are folders that don't have their Parent/Ancestor folders displayed in the ComboBox

(for example known folders, like "my Pictures", etc.. and network shared folders, and more)

 

But!

I believe that the FileSave CommonDialog window, like the main program's window, holds a variable to the path that it is showing.

So if for example the FileSave CommonDialog window shows some folder - I believe there is a variable that holds the Path for that folder.

But I don't know where this variable is, and how to get it.

(it is not inside some GUI element that's for sure, since I checked well with AutoIt's Window Info tool)

 

Maybe you guys have an idea how to get it from the FileSave CommonDialog window?

 

 

Zohar,

A bit of a long-winded way to do it, but you could search for all files which match the name in the title bar. This works fine for me: :)

 

Hi Melba :)

This will work, but will make alot of hard disk noise :)

 

Amazing how the path is hidden in MSPaint.EXE!!! :)

Will there be a solution? :)

Edited by Zohar

Share this post


Link to post
Share on other sites
water

With Windows 7 "Save As ..." shows the full path.

Unfortunately I have no Windows XP to do further tests.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jchd

 

When using SysInternal's Process Explorer, 1 out of 4 of the times, you see there a File Handle to the open file.

But it's only 1 out of 4.

the other 3 times, it's simply not htere, and I cannot understand why..

I can't see an explanation either. Very strange, or does that mean that the file is open, read from and closed? Then why do you sometimes see it open is a mystery.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Zohar

With Windows 7 "Save As ..." shows the full path.

Unfortunately I have no Windows XP to do further tests.

 

I understand.

I can't see an explanation either. Very strange, or does that mean that the file is open, read from and closed? Then why do you sometimes see it open is a mystery.

 

It's probably opened, read, and closed,

and as you said, I have no idea why only sometimes it remains open.

 

Well,

Is the idea I offered, regarding the fact that there must be some variable in memory, holding the current file's Full Path, feasible?

Can AutoIt somehow get that?

Because we both know it's in memory..

Both for the program's main window,

and also for its sub-window - the Save As window..

Share this post


Link to post
Share on other sites
jchd

MRU shorthand also has the full path but I've no idea where it hides. Registry probably user hive.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Terenz

'?do=embed' frameborder='0' data-embedContent>>

'?do=embed' frameborder='0' data-embedContent>>

#include <WinAPI.au3>

Local $iPID = ProcessExists('mspaint.exe')
If Not $iPID Then Exit
Local $aFiles = _ProcessListFiles("mspaint.exe") ; Get a list of files currently opened by the process
MsgBox(64, "File opened is: ", $aFiles[UBound($aFiles) - 1] & "\" & StringTrimRight(WinGetTitle(_WinGetByPID($iPID)), 8))

Func _ProcessListFiles($vProcess, $nMaxFiles = 1000)
    Static Local $aPrivilege = DllCall("ntdll.dll", "int", "RtlAdjustPrivilege", "int", 20, "int", 1, "int", 0, "int*", 0)
    Local $nProcessId = ProcessExists($vProcess), $aRet
    Static Local $hCurrentProcess = _WinAPI_GetCurrentProcess()
    Local $aHandles = _WinAPI_EnumProcessHandles($nProcessId)
    Local $hObject, $aFiles[$nMaxFiles+1], $sPath
    Local $hProcess = _WinAPI_OpenProcess(0x0040, 0, $nProcessId, True)
    For $i = 1 To $aHandles[0][0] Step 1
        If $aHandles[$i][3] = 0x00120189 Or $aHandles[$i][3] = 0x0012019f Or $aHandles[$i][3] = 0x00100000 Then ContinueLoop
        $hObject = _WinAPI_DuplicateHandle($hProcess, $aHandles[$i][0], $hCurrentProcess, 0, False, $DUPLICATE_SAME_ACCESS)
        If Not $hObject Then ContinueLoop
        If __IsFileObject($hObject) Then
            $sPath = __FileObjectPath($hObject)
            _WinAPI_CloseHandle($hObject)
            If FileExists($sPath) Then
                For $n = 1 To $aFiles[0]
                    If $aFiles[$n] = $sPath Then
                        $sPath = 0
                        ExitLoop
                    EndIf
                Next
                If $sPath Then
                    $aFiles[0] += 1
                    $aFiles[$aFiles[0]] = $sPath
                    If $aFiles[0] >= $nMaxFiles Then ExitLoop
                EndIf
            EndIf
        EndIf
    Next
    ReDim $aFiles[$aFiles[0]+1]
    Return $aFiles
EndFunc

Func __IsFileObject(ByRef $hObject)
    Static Local $tPOTI = DllStructCreate('ushort;ushort;ptr;byte[128]'), $pData, $Length, $tString
    Local $aRet = DllCall("ntdll.dll", 'uint', 'NtQueryObject', 'ptr', $hObject, 'uint', 2, 'ptr', DllStructGetPtr($tPOTI), 'ulong', DllStructGetSize($tPOTI), 'ptr', 0)
    If @error Or $aRet[0] Then Return
    $pData = DllStructGetData($tPOTI, 3)
    If Not $pData Then Return
    $Length = DllCall("kernel32.dll", 'int', 'lstrlenW', 'ptr', $pData)
    If @error Or Not $Length[0] Then Return
    $Length = $Length[0]
    $tString = DllStructCreate('wchar[' & ($Length + 1) & ']', $pData)
    If @error Then Return
    Return (DllStructGetData($tString, 1) == "File")
EndFunc

Func __FileObjectPath($hObject)
    Static Local $tStruct = DllStructCreate("char[255];")
    Local $aDrive = DriveGetDrive("ALL"), $sPath
    Local $aDrivesInfo[UBound($aDrive) - 1][2]
    For $I = 0 To UBound($aDrivesInfo) - 1
        $aDrivesInfo[$I][0] = $aDrive[$I + 1]
        DllCall("kernel32.dll", "dword", "QueryDosDevice", "str", $aDrivesInfo[$I][0], "ptr", DllStructGetPtr($tStruct), "dword", 255)
        $aDrivesInfo[$I][1] = DllStructGetData($tStruct, 1)
    Next
    Local Static $tPOTI = DllStructCreate("ushort Length;ushort MaximumLength;ptr Buffer;wchar Reserved[260];"), $sDeviceStr, $vSolid = False
    DllCall("ntdll.dll", "ulong", "NtQueryObject", "ptr", $hObject, "int", 1, "ptr", DllStructGetPtr($tPOTI), "ulong", DllStructGetSize($tPOTI), "ulong*", "")
    $sDeviceStr = DllStructGetData(DllStructCreate("wchar[" & Ceiling(DllStructGetData($tPOTI, "Length") / 2) & "];", DllStructGetData($tPOTI, "buffer")), 1)
    For $y = 0 To UBound($aDrivesInfo) - 1
        If StringLeft($sDeviceStr, StringLen($aDrivesInfo[$y][1])) = $aDrivesInfo[$y][1] Then
            $sPath = StringUpper($aDrivesInfo[$y][0]) & StringTrimLeft($sDeviceStr, StringLen($aDrivesInfo[$y][1]))
        EndIf
    Next
    Return $sPath
EndFunc

Func _WinAPI_EnumProcessHandles($PID = 0, $iType = 0)
    If Not $PID Then $PID = @AutoItPID
    Local $tSHI, $tHandle, $pData, $Ret
    Local $Result[101][4] = [[0]]
    $tSHI = DllStructCreate('ulong;byte[4194304]')
    $Ret = DllCall('ntdll.dll', 'uint', 'ZwQuerySystemInformation', 'uint', 16, 'ptr', DllStructGetPtr($tSHI), 'ulong', DllStructGetSize($tSHI), 'ulong*', 0)
    If @error Then
        Return SetError(1, 0, 0)
    Else
        If $Ret[0] Then
            Return SetError(1, $Ret[0], 0)
        EndIf
    EndIf
    $pData = DllStructGetPtr($tSHI, 2)
    For $i = 1 To DllStructGetData($tSHI, 1)
        $tHandle = DllStructCreate('align 4;ulong;ubyte;ubyte;ushort;ptr;ulong', $pData + __Iif(@AutoItX64, 4 + ($i - 1) * 24, ($i - 1) * 16))
        If (DllStructGetData($tHandle, 1) = $PID) And ((Not $iType) Or ($iType = DllStructGetData($tHandle, 2))) Then
            __Inc($Result)
            $Result[$Result[0][0]][0] = Ptr(DllStructGetData($tHandle, 4))
            $Result[$Result[0][0]][1] = DllStructGetData($tHandle, 2)
            $Result[$Result[0][0]][2] = DllStructGetData($tHandle, 3)
            $Result[$Result[0][0]][3] = DllStructGetData($tHandle, 6)
        EndIf
    Next
    If Not $Result[0][0] Then
        Return SetError(1, 0, 0)
    EndIf
    __Inc($Result, -1)
    Return $Result
EndFunc   ;==>_WinAPI_EnumProcessHandles

Func __Inc(ByRef $aData, $iIncrement = 100)
    Select
        Case UBound($aData, 2)
            If $iIncrement < 0 Then
                ReDim $aData[$aData[0][0] + 1][UBound($aData, 2)]
            Else
                $aData[0][0] += 1
                If $aData[0][0] > UBound($aData) - 1 Then
                    ReDim $aData[$aData[0][0] + $iIncrement][UBound($aData, 2)]
                EndIf
            EndIf
        Case UBound($aData, 1)
            If $iIncrement < 0 Then
                ReDim $aData[$aData[0] + 1]
            Else
                $aData[0] += 1
                If $aData[0] > UBound($aData) - 1 Then
                    ReDim $aData[$aData[0] + $iIncrement]
                EndIf
            EndIf
        Case Else
            Return 0
    EndSelect
    Return 1
EndFunc   ;==>__Inc

Func __Iif($fTest, $iTrue, $iFalse)
    If $fTest Then
        Return $iTrue
    Else
        Return $iFalse
    EndIf
EndFunc   ;==>__Iif

Func _WinGetByPID($iPID, $iArray = 1) ; 0 Will Return 1 Base Array & 1 Will Return The First Window.
    Local $aError[1] = [0], $aWinList, $sReturn
    If IsString($iPID) Then
        $iPID = ProcessExists($iPID)
    EndIf
    $aWinList = WinList()
    For $A = 1 To $aWinList[0][0]
        If WinGetProcess($aWinList[$A][1]) = $iPID And BitAND(WinGetState($aWinList[$A][1]), 2) Then
            If $iArray Then
                Return $aWinList[$A][1]
            EndIf
            $sReturn &= $aWinList[$A][1] & Chr(1)
        EndIf
    Next
    If $sReturn Then
        Return StringSplit(StringTrimRight($sReturn, 1), Chr(1))
    EndIf
    Return SetError(1, 0, $aError)
EndFunc   ;==>_WinGetByPID

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites
Zohar

Thanks Terenz

But this works like Process Explorer - shows you the open handles.

As I wrote before, it's good only 1 out of 4 times, aprox..

 

I think the solution will be to switch to another Image Editing program.

One that hopefully has the File Name and Path accessible to be taken by AutoIt.

(for example shown in some GUI control, etc).

Too bad we don't have a way to get to the Variable that MSPaint.EXE holds the File's FullPath in.

This is different than open handles, since the file may not have an open handle right now, yet the Variable that stores the file's path must exist all the time.

 

Can anyone recommend of a Simple Image Editing program?

Simple means few MB, hopefully Portable,

and allows editing BMP, PNG, JPG, with basic graphical operations..

Edited by Zohar

Share this post


Link to post
Share on other sites
sahsanu

Can anyone recommend of a Simple Image Editing program?

Simple means few MB, hopefully Portable,

and allows editing BMP, PNG, JPG, with basic graphical operations..

 

Take a look to LazPaint, it's portable, just 9 MB and the most important thing, you will have the full path of the pic file in application title.

Cheers,

sahsanu

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×