TehWhale Posted August 13, 2008 Share Posted August 13, 2008 (edited) I wanted your opinions on this. ;=============================================================================== ; ; Function Name: _FileDisplayProperties ; Description:: Uses a DLL to call the properties window of a file ; Parameter(s): $a_CallFile = The file to display the properties of ; $a_Wait = 1, wait until the user closes the dialog ; 0, automatically return when it opens ; Requirement(s): Shell32.dll ; Return Value(s): Returns the DLL call value, 1 if it was a success ; Author(s): Alienware (Swift) and LarryDalooza ; Examples(s): ; #Include <File.au3> ; $FilePropReturnValue = _FileDisplayProperties(@ScriptFullPath) ; MsgBox(0, "_FileDisplayProperties return value", "The return value of _FileDisplayProperties is: " & $FilePropReturnValue) ; ;=============================================================================== Func _FileDisplayProperties($sCallFile, $iWait = 1) If Not FileExists($sCallFile) Then Return SetError(1, 0, 0) Local $iReturn = DllCall("shell32.dll", "int", _ "SHObjectProperties", "hwnd", 0, "dword", 0x00000002, _ "wstr", $sCallFile, "wstr", 0) If $iWait = 1 Then $bOriginalOpt = Opt("WinTitleMatchMode", 2) WinWaitActive("Properties", "Cancel") WinWaitClose("Properties", "Cancel") Opt("WinTitleMatchMode", $bOriginalOpt) EndIf Return $iReturn[0] EndFunc ;==>_FileDisplayProperties I think that it should be included in the File.au3 file, included with the AutoIt3 Install set. What do you think? Edited August 13, 2008 by Alienware Link to comment Share on other sites More sharing options...
TehWhale Posted August 13, 2008 Author Share Posted August 13, 2008 (edited) Hmm, that works, when you have 1 as the $iWait. If you have anything else, it just goes into a infinity loop? And never returns? Edited August 13, 2008 by Alienware Link to comment Share on other sites More sharing options...
TehWhale Posted August 13, 2008 Author Share Posted August 13, 2008 And never returns? even before I modify...My version works fine? Link to comment Share on other sites More sharing options...
TehWhale Posted August 13, 2008 Author Share Posted August 13, 2008 Well, when I use your original code and set $iWait = 0, nothing appears...That's because it returns super-fast, and exits before it has a chance to display. Put a small loop or something below it. Link to comment Share on other sites More sharing options...
ResNullius Posted August 14, 2008 Share Posted August 14, 2008 (edited) Hmm, that works, when you have 1 as the $iWait. If you have anything else, it just goes into a infinity loop? And never returns?I tried JScript's version and worked great with 0 or 1. I'm on XP w/ SP3. Edit: Think I found the problem with JScript's version: The WinWaitActive() is actually case sensitive. If I call the fuction with _FileDisplayProperties("c:\ test.txt",0) The properties window title starts with Test.text and the WinWaitActive never returns true. Fix the function by changing $bOriginalOpt = Opt("WinTitleMatchMode",2) to $bOriginalOpt = Opt("WinTitleMatchMode",-2) Changed the Match mode to -2. Edited August 14, 2008 by ResNullius Link to comment Share on other sites More sharing options...
rasim Posted August 14, 2008 Share Posted August 14, 2008 (edited) Another solution: expandcollapse popup_ShowFileProperties("c:\boot.ini") Func _ShowFileProperties($sFile, $sVerb = "properties", $hWnd = 0) If Not FileExists($sFile) Then Return SetError(1, 0, 0) Local Const $SEE_MASK_INVOKEIDLIST = 0xC Local Const $SEE_MASK_NOCLOSEPROCESS = 0x40 Local Const $SEE_MASK_FLAG_NO_UI = 0x400 Local $PropBuff, $FileBuff, $SHELLEXECUTEINFO $PropBuff = DllStructCreate("char[256]") DllStructSetData($PropBuff, 1, $sVerb) $FileBuff = DllStructCreate("char[256]") DllStructSetData($FileBuff, 1, $sFile) $SHELLEXECUTEINFO = DllStructCreate("int cbSize;long fMask;hwnd hWnd;ptr lpVerb;ptr lpFile;ptr lpParameters;ptr lpDirectory;" & _ "int nShow;int hInstApp;ptr lpIDList;ptr lpClass;hwnd hkeyClass;int dwHotKey;hwnd hIcon;" & _ "hwnd hProcess") DllStructSetData($SHELLEXECUTEINFO, "cbSize", DllStructGetSize($SHELLEXECUTEINFO)) DllStructSetData($SHELLEXECUTEINFO, "fMask", BitOR($SEE_MASK_NOCLOSEPROCESS, $SEE_MASK_INVOKEIDLIST, $SEE_MASK_FLAG_NO_UI)) DllStructSetData($SHELLEXECUTEINFO, "hwnd", $hWnd) DllStructSetData($SHELLEXECUTEINFO, "lpVerb", DllStructGetPtr($PropBuff, 1)) DllStructSetData($SHELLEXECUTEINFO, "lpFile", DllStructGetPtr($FileBuff, 1)) $aRet = DllCall("shell32.dll", "int", "ShellExecuteEx", "ptr", DllStructGetPtr($SHELLEXECUTEINFO)) If $aRet[0] = 0 Then Return SetError(2, 0, 0) Local $iPrevMode = Opt("WinTitleMatchMode", 2) Local $iTitle = StringRegExpReplace($sFile, "^.*\\(.*)\..*", "\1") WinWait($iTitle) Do Sleep(10) Until WinExists($iTitle) = 0 Opt("WinTitleMatchMode", $iPrevMode) Return $aRet[0] EndFunc Edited August 14, 2008 by rasim Link to comment Share on other sites More sharing options...
TehWhale Posted August 15, 2008 Author Share Posted August 15, 2008 Another solution: expandcollapse popup_ShowFileProperties("c:\boot.ini") Func _ShowFileProperties($sFile, $sVerb = "properties", $hWnd = 0) If Not FileExists($sFile) Then Return SetError(1, 0, 0) Local Const $SEE_MASK_INVOKEIDLIST = 0xC Local Const $SEE_MASK_NOCLOSEPROCESS = 0x40 Local Const $SEE_MASK_FLAG_NO_UI = 0x400 Local $PropBuff, $FileBuff, $SHELLEXECUTEINFO $PropBuff = DllStructCreate("char[256]") DllStructSetData($PropBuff, 1, $sVerb) $FileBuff = DllStructCreate("char[256]") DllStructSetData($FileBuff, 1, $sFile) $SHELLEXECUTEINFO = DllStructCreate("int cbSize;long fMask;hwnd hWnd;ptr lpVerb;ptr lpFile;ptr lpParameters;ptr lpDirectory;" & _ "int nShow;int hInstApp;ptr lpIDList;ptr lpClass;hwnd hkeyClass;int dwHotKey;hwnd hIcon;" & _ "hwnd hProcess") DllStructSetData($SHELLEXECUTEINFO, "cbSize", DllStructGetSize($SHELLEXECUTEINFO)) DllStructSetData($SHELLEXECUTEINFO, "fMask", BitOR($SEE_MASK_NOCLOSEPROCESS, $SEE_MASK_INVOKEIDLIST, $SEE_MASK_FLAG_NO_UI)) DllStructSetData($SHELLEXECUTEINFO, "hwnd", $hWnd) DllStructSetData($SHELLEXECUTEINFO, "lpVerb", DllStructGetPtr($PropBuff, 1)) DllStructSetData($SHELLEXECUTEINFO, "lpFile", DllStructGetPtr($FileBuff, 1)) $aRet = DllCall("shell32.dll", "int", "ShellExecuteEx", "ptr", DllStructGetPtr($SHELLEXECUTEINFO)) If $aRet[0] = 0 Then Return SetError(2, 0, 0) Local $iPrevMode = Opt("WinTitleMatchMode", 2) Local $iTitle = StringRegExpReplace($sFile, "^.*\\(.*)\..*", "\1") WinWait($iTitle) Do Sleep(10) Until WinExists($iTitle) = 0 Opt("WinTitleMatchMode", $iPrevMode) Return $aRet[0] EndFunc That one must of took some work! Thanks for your help guys. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now