Leaderboard
Popular Content
Showing content with the highest reputation on 02/02/2014 in all areas
-
Question about using const.
jaberwacky and one other reacted to guinness for a topic
The errors are correct. Const doesn't define/re-define scope.2 points -
Learning To Script with AutoIt V3 Document was last updated 17 February 2010 This document is for you if you are interested in learning to script with AutoIt. Where possible, I will try to assume that you have no prior coding experience and I aim to teach you some good general coding habits, which will be beneficial should you decide to move on to other languages. Download here Learning to Script with AutoIt V3 (Last Updated 17 Feb 2010).zip(Previous Versions = 10152) The download contains the tutorial, example AU3 files contained in the text, printable exercise question/answer sheet and more. If you encounter any issues, with the text, please post them, but this is not a thread for requsting help or requesting scripts. Please do not PM me either. We have this wonderful support forum, so use it! Original Document: Alex Peters (LxP) http://yallara.cs.rmit.edu.au/~apeters/ Updated By: Brett Francis (BrettF) http://signa5.com1 point
-
Given a URL, you could use the WinHTTP UDF to read the web page and then extract the title from the returned data.1 point
-
Can you help me convert this to AutoHotKey?
Palestinian reacted to Jos for a topic
Why ask here... It a pretty inappropriate to say the least. On top of that check our forumrules before you post again. Jos1 point -
So many ways to shake a stick!1 point
-
How Do I Release Memory of a Static Variable?
DatMCEyeBall reacted to czardas for a topic
Yes it's perfect trancexx! Why am I making it sound so complicated - I don't know.1 point -
Why do you need global variable? Doesn't this do what you want: Func Test($bDeleteStaticVal = False) Local Static $vStatic If $bDeleteStaticVal Then ConsoleWrite("-> freeing static" & @CRLF & @CRLF) $vStatic = "" ElseIf Not $vStatic Then ConsoleWrite("+> allocating and retrieving static" & @CRLF) $vStatic = "Some static value that occupies memory" & @CRLF Else ConsoleWrite("> retrieving static" & @CRLF) EndIf Return $vStatic EndFunc ConsoleWrite(Test() & @CRLF) ConsoleWrite(Test() & @CRLF) ConsoleWrite(Test() & @CRLF) ; memory is freed Test(True) ; and here we go again... ConsoleWrite(Test() & @CRLF) ConsoleWrite(Test() & @CRLF) ConsoleWrite(Test() & @CRLF)1 point
-
Nope. 300KB is actually nothing, which leads me to believe you're using upx compression.1 point
-
(?is)forme juridique.*?class="tableResult">([^(]*)1 point
-
guestscripter, Add region_indent=1 to your Tidy.ini or add the /Region_Indent (or /ri) parameter to a #Tidy_Parameters directive in the script. I use it all the time. Sometimes I wonder why I bothered to completely rewrite the SciTE4Autoit3 Help file last year - you can find all this via the <Help - SciTE Help - Extra Utilities - Tidy> menu option. M231 point
-
_StringBetween function returns an array. So, in your script you are storing an array in $array[$n][1] - an array in an array. If you are using The latest AutoIt release version 3.3.10.2, or the latest beta version then this should work. Note the trailing "[0]". $array[$n][1] = _StringBetween(FileReadLine($sFileName, 87), '<td>', '</td>')[0]1 point
-
SciTE indentation settings - how to make it indent within #Region..#EndRegion
guestscripter reacted to jaberwacky for a topic
::Shameless Plug:: If you download SciTE Customization GUI found in my signature then you'll have all of the Tidy options that I know about available in one easy to use GUI. I do agree with water, but you should try it for yourself before you make a judgement call.1 point -
You have it. Freeing allocated memory can be done from within the other thread just before it's terminated. And with MessageBoxIndirect you get working x64 version for free, that's the main difference.1 point
-
SafeArrays. Some of the methods take safe arrays as parameters. According to documentation safe arrays are zero-based, one-dimensional arrays (zero-based vectors). For UI Automation client methods apparently only three data types are used in safe arrays: integers, pointers and strings (BSTR). In case of pointers it seems to be only IUIAutomationCondition interface pointers. This UDF implements five functions under these conditions: SafeArrayCreateVector, SafeArrayGetElement, SafeArrayPutElement, SafeArrayGetUBound and SafeArrayDestroy. #include-once #cs Global Const $tagSAFEARRAY = _ "ushort cDims;" & _ ; The number of dimensions. "ushort fFeatures;" & _ ; Flags, see below. "ulong cbElements;" & _ ; The size of an array element. "ulong cLocks;" & _ ; The number of times the array has been locked without a corresponding unlock. "ptr pvData;" & _ ; The data. "ulong cElements;" & _ ; The number of elements in the dimension. "long lLbound" ; The lower bound of the dimension. ; fFeatures flags Global Const $FADF_AUTO = 0x0001 ; An array that is allocated on the stack. Global Const $FADF_STATIC = 0x0002 ; An array that is statically allocated. Global Const $FADF_EMBEDDED = 0x0004 ; An array that is embedded in a structure. Global Const $FADF_FIXEDSIZE = 0x0010 ; An array that may not be resized or reallocated. Global Const $FADF_RECORD = 0x0020 ; An array that contains records. When set, there will be a pointer to the IRecordInfo interface at negative offset 4 in the array descriptor. Global Const $FADF_HAVEIID = 0x0040 ; An array that has an IID identifying interface. When set, there will be a GUID at negative offset 16 in the safe array descriptor. Flag is set only when FADF_DISPATCH or FADF_UNKNOWN is also set. Global Const $FADF_HAVEVARTYPE = 0x0080 ; An array that has a variant type. The variant type can be retrieved with SafeArrayGetVartype. Global Const $FADF_BSTR = 0x0100 ; An array of BSTRs. Global Const $FADF_UNKNOWN = 0x0200 ; An array of IUnknown*. Global Const $FADF_DISPATCH = 0x0400 ; An array of IDispatch*. Global Const $FADF_VARIANT = 0x0800 ; An array of VARIANTs. Global Const $FADF_RESERVED = 0xF008 ; Bits reserved for future use. #ce Func SafeArrayCreateVector( $sType, $iRows ) Local Const $tagSAFEARRAY = "ushort cDims; ushort fFeatures; ulong cbElements; ulong cLocks; ptr pvData; ulong cElements; long lLbound" Local Const $FADF_HAVEIID = 0x0040, $FADF_HAVEVARTYPE = 0x0080, $FADF_BSTR = 0x0100, $FADF_UNKNOWN = 0x0200 Local Const $VT_INT = 22, $VT_INT_PTR = 37 Local $iVarType, $iFeatures Switch $sType Case "int" $iVarType = $VT_INT Case "ptr" ; IUIAutomationCondition interface pointer $iVarType = $VT_INT_PTR $iFeatures = $FADF_UNKNOWN ; $FADF_UNKNOWN must be included in fFeatures in the SafeArray structure. ; Otherwise an E_INVALIDARG error will occur when the condition is created. If @OSVersion <> "WIN_XP" Then $iFeatures = BitOR( $iFeatures, $FADF_HAVEIID ) ; On Windows later than XP $FADF_HAVEIID is used instead of $FADF_HAVEVARTYPE. Case "str" ; BSTR (binary string) $iVarType = $VT_INT_PTR $iFeatures = $FADF_BSTR Case Else Return SetError(1, 0, 0) EndSwitch Local $aRet = DllCall( "oleaut32.dll", "ptr", "SafeArrayCreateVector", "int", $iVarType, "long", 0, "ulong", $iRows ) If @error Then Return SetError(2, 0, 0) Local $pSafeArray = $aRet[0] Switch $sType Case "ptr" Local $tSAFEARRAY = DllStructCreate( $tagSAFEARRAY, $pSafeArray ) Local $fFeatures = DllStructGetData( $tSAFEARRAY, "fFeatures" ) $fFeatures = BitOR( $fFeatures, $iFeatures ) If @OSVersion <> "WIN_XP" Then $fFeatures = BitXOR( $fFeatures, $FADF_HAVEVARTYPE ) ; On Windows later than XP $FADF_HAVEIID is used instead of $FADF_HAVEVARTYPE. DllStructSetData( $tSAFEARRAY, "fFeatures", $fFeatures ) Case "str" Local $tSAFEARRAY = DllStructCreate( $tagSAFEARRAY, $pSafeArray ) Local $fFeatures = DllStructGetData( $tSAFEARRAY, "fFeatures" ) $fFeatures = BitOR( $fFeatures, $iFeatures ) DllStructSetData( $tSAFEARRAY, "fFeatures", $fFeatures ) EndSwitch Return $pSafeArray EndFunc Func SafeArrayGetElement( $pSafeArray, $iIndex, ByRef $vValue ) Local Const $tagSAFEARRAY = "ushort cDims; ushort fFeatures; ulong cbElements; ulong cLocks; ptr pvData; ulong cElements; long lLbound" Local Const $FADF_BSTR = 0x0100, $FADF_UNKNOWN = 0x0200 Local $fFeatures = DllStructGetData( DllStructCreate( $tagSAFEARRAY, $pSafeArray ), "fFeatures" ) Local $sType Select Case BitAND( $fFeatures, $FADF_BSTR ) OR BitAND( $fFeatures, $FADF_UNKNOWN ) $sType = "ptr*" Case Else $sType = "int*" EndSelect Local $aRet = DllCall( "oleaut32.dll", "int", "SafeArrayGetElement", "ptr", $pSafeArray, "long*", $iIndex, $sType, 0 ) If @error Then Return SetError(1, 0, 1) $vValue = $aRet[3] If BitAND( $fFeatures, $FADF_BSTR ) Then $vValue = SysReadString( $vValue ) If @error Then Return SetError(2, 0, 1) EndIf Return $aRet[0] EndFunc Func SafeArrayPutElement( $pSafeArray, $iIndex, $vValue ) Local Const $tagSAFEARRAY = "ushort cDims; ushort fFeatures; ulong cbElements; ulong cLocks; ptr pvData; ulong cElements; long lLbound" Local Const $FADF_BSTR = 0x0100, $FADF_UNKNOWN = 0x0200 Local $tSAFEARRAY = DllStructCreate( $tagSAFEARRAY, $pSafeArray ) Local $fFeatures = DllStructGetData( $tSAFEARRAY, "fFeatures" ) Local $sType Select Case BitAND( $fFeatures, $FADF_BSTR ) $sType = "ptr*" DllStructSetData( $tSAFEARRAY, "fFeatures", $fFeatures - $FADF_BSTR ) ; This is a workaround. String is not inserted if $fFeatures includes $FADF_BSTR. $vValue = SysAllocString( $vValue ) If @error Then Return SetError(1, 0, 1) Case BitAND( $fFeatures, $FADF_UNKNOWN ) $sType = "ptr*" DllStructSetData( $tSAFEARRAY, "fFeatures", $fFeatures - $FADF_UNKNOWN ) ; This is a workaround. The DllCall crashes if $fFeatures includes $FADF_UNKNOWN. Case Else $sType = "int*" EndSelect Local $aRet = DllCall( "oleaut32.dll", "int", "SafeArrayPutElement", "ptr", $pSafeArray, "long*", $iIndex, $sType, $vValue ) If @error Then Return SetError(2, 0, 1) Select Case BitAND( $fFeatures, $FADF_BSTR ) OR BitAND( $fFeatures, $FADF_UNKNOWN ) DllStructSetData( $tSAFEARRAY, "fFeatures", $fFeatures ) ; This will undo the workaround. EndSelect Return $aRet[0] EndFunc Func SafeArrayGetUBound( $pSafeArray, ByRef $iUBound ) Local $aRet = DllCall( "oleaut32.dll", "int", "SafeArrayGetUBound", "ptr", $pSafeArray, "uint", 1, "long*", 0 ) If @error Then Return SetError(1, 0, 1) $iUBound = $aRet[3] Return $aRet[0] EndFunc Func SafeArrayDestroy( $pSafeArray ) Local $aRet = DllCall( "oleaut32.dll", "int", "SafeArrayDestroy", "ptr", $pSafeArray ) If @error Then Return SetError(1, 0, 1) Return $aRet[0] EndFunc ; BSTR functions ; Copied and slightly modified from AutoItObject.au3 by the AutoItObject-Team Func SysAllocString( $str ) Local $aRet = DllCall( "oleaut32.dll", "ptr", "SysAllocString", "wstr", $str ) If @error Then Return SetError(1, 0, 0) Return $aRet[0] EndFunc Func SysFreeString( $pBSTR ) If Not $pBSTR Then Return SetError(1, 0, 0) DllCall( "oleaut32.dll", "none", "SysFreeString", "ptr", $pBSTR ) If @error Then Return SetError(2, 0, 0) EndFunc Func SysReadString( $pBSTR, $iLen = -1 ) If Not $pBSTR Then Return SetError(1, 0, "") If $iLen < 1 Then $iLen = SysStringLen( $pBSTR ) If $iLen < 1 Then Return SetError(2, 0, "") Return DllStructGetData( DllStructCreate( "wchar[" & $iLen & "]", $pBSTR ), 1 ) EndFunc Func SysStringLen( $pBSTR ) If Not $pBSTR Then Return SetError(1, 0, 0) Local $aRet = DllCall( "oleaut32.dll", "uint", "SysStringLen", "ptr", $pBSTR ) If @error Then Return SetError(2, 0, 0) Return $aRet[0] EndFunc SafeArray.au3 This Windows Explorer example demonstrates reading of integer and BSTR safe arrays with PollForPotentialSupportedPatterns and PollForPotentialSupportedProperties methods of the IUIAutomation interface: #include "CUIAutomation2.au3" #include "SafeArray.au3" Opt( "MustDeclareVars", 1 ) MainFunc() Func MainFunc() ; Get window handle for Windows Explorer Local $hExplorer = WinGetHandle( "[CLASS:CabinetWClass]", "" ) ; Vista, 7, 8 ;Local $hExplorer = WinGetHandle( "[CLASS:ExploreWClass]", "" ) ; Windows XP If Not $hExplorer Then Return ; Create UI Automation object Local $oUIAutomation $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ; Get UI Automation element from window handle Local $pExplorer, $oExplorer $oUIAutomation.ElementFromHandle( $hExplorer, $pExplorer ) $oExplorer = ObjCreateInterface( $pExplorer, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oExplorer ) Then Return ; Potential supported patterns for Windows Explorer top window Local $pPatternIds, $pPatternNames, $iUBound, $id, $name $oUIAutomation.PollForPotentialSupportedPatterns( $oExplorer, $pPatternIds, $pPatternNames ) SafeArrayGetUBound( $pPatternIds, $iUBound ) ConsoleWrite( @CRLF & "Potential supported patterns for Windows Explorer top window" & @CRLF ) For $i = 0 To $iUBound SafeArrayGetElement( $pPatternIds, $i, $id ) SafeArrayGetElement( $pPatternNames, $i, $name ) ConsoleWrite( " $i, $id, $name = " & $i & ", " & $id & ", " & $name & @CRLF ) Next SafeArrayDestroy( $pPatternIds ) SafeArrayDestroy( $pPatternNames ) ; Potential supported properties for Windows Explorer top window Local $pPropertyIds, $pPropertyNames, $iUBound, $id, $name $oUIAutomation.PollForPotentialSupportedProperties( $oExplorer, $pPropertyIds, $pPropertyNames ) SafeArrayGetUBound( $pPropertyIds, $iUBound ) ConsoleWrite( @CRLF & "Potential supported properties for Windows Explorer top window" & @CRLF ) For $i = 0 To $iUBound SafeArrayGetElement( $pPropertyIds, $i, $id ) SafeArrayGetElement( $pPropertyNames, $i, $name ) ConsoleWrite( " $i, $id, $name = " & $i & ", " & $id & ", " & $name & @CRLF ) Next SafeArrayDestroy( $pPropertyIds ) SafeArrayDestroy( $pPropertyNames ) EndFunc Tested on XP 32 bit and Win 7 64 bit. Should work on Vista and Win 8 too. This Windows Explorer example demonstrates creation of a safe array with pointers. The code creates a CreateAndConditionFromArray condition to search for a file named Test.txt in the current folder (virtual items on Win 7, 8 are not taken into account: Test.txt must be visible in the listview). Note that the search is case sensitive. #include "CUIAutomation2.au3" #include "SafeArray.au3" Opt( "MustDeclareVars", 1 ) MainFunc() Func MainFunc() ; Get window handle for Windows Explorer Local $hExplorer = WinGetHandle( "[CLASS:CabinetWClass]", "" ) ; Vista, 7, 8 ;Local $hExplorer = WinGetHandle( "[CLASS:ExploreWClass]", "" ) ; Windows XP If Not $hExplorer Then Return ; Create UI Automation object Local $oUIAutomation $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ; Get UI Automation element from window handle Local $pExplorer, $oExplorer $oUIAutomation.ElementFromHandle( $hExplorer, $pExplorer ) $oExplorer = ObjCreateInterface( $pExplorer, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oExplorer ) Then Return ; Conditions to find "Test.txt" item in listview Local $pCondition1, $pCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListItemControlTypeId, $pCondition1 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Test.txt", $pCondition2 ) If Not $pCondition1 Or Not $pCondition2 Then Return ConsoleWrite( @CRLF & "Conditions to find ""Test.txt"" item in listview" & @CRLF ) ConsoleWrite( "$pCondition1 (item) = " & Ptr( $pCondition1 ) & @CRLF ) ConsoleWrite( "$pCondition2 (name) = " & Ptr( $pCondition2 ) & @CRLF ) ; Create pointer SafeArray with 2 rows Local $ptrSafeArray = SafeArrayCreateVector( "ptr", 2 ) ConsoleWrite( @CRLF & "Create pointer SafeArray with 2 rows" & @CRLF ) ConsoleWrite( "$ptrSafeArray = " & $ptrSafeArray & @CRLF ) ; Write SafeArray structure Local Const $tagSAFEARRAY = "ushort cDims; ushort fFeatures; ulong cbElements; ulong cLocks; ptr pvData; ulong cElements; long lLbound" Local $tSAFEARRAY = DllStructCreate( $tagSAFEARRAY, $ptrSafeArray ) ConsoleWrite( @CRLF & "SafeArray structure" & @CRLF ) ConsoleWrite( "$tSAFEARRAY size = " & DllStructGetSize( $tSAFEARRAY ) & @CRLF ) ConsoleWrite( "$tSAFEARRAY cDims = " & DllStructGetData( $tSAFEARRAY, "cDims" ) & @CRLF ) ConsoleWrite( "$tSAFEARRAY fFeatures = " & "0x" & Hex( DllStructGetData( $tSAFEARRAY, "fFeatures" ) ) & @CRLF ) ConsoleWrite( "$tSAFEARRAY cbElements = " & DllStructGetData( $tSAFEARRAY, "cbElements" ) & @CRLF ) ConsoleWrite( "$tSAFEARRAY cLocks = " & DllStructGetData( $tSAFEARRAY, "cLocks" ) & @CRLF ) ConsoleWrite( "$tSAFEARRAY pvData = " & DllStructGetData( $tSAFEARRAY, "pvData" ) & @CRLF ) ConsoleWrite( "$tSAFEARRAY cElements = " & DllStructGetData( $tSAFEARRAY, "cElements" ) & @CRLF ) ConsoleWrite( "$tSAFEARRAY lLbound = " & DllStructGetData( $tSAFEARRAY, "lLbound" ) & @CRLF ) ; Put the two conditions into SafeArray SafeArrayPutElement( $ptrSafeArray, 0, $pCondition1 ) SafeArrayPutElement( $ptrSafeArray, 1, $pCondition2 ) ConsoleWrite( @CRLF & "The two conditions put into SafeArray" & @CRLF ) ; Get and write the two conditions Local $pValue ConsoleWrite( @CRLF & "Get the two conditions" & @CRLF ) SafeArrayGetElement( $ptrSafeArray, 0, $pValue ) ConsoleWrite( "$pCondition1 (item) = " & Ptr( $pValue ) & @CRLF ) SafeArrayGetElement( $ptrSafeArray, 1, $pValue ) ConsoleWrite( "$pCondition2 (name) = " & Ptr( $pValue ) & @CRLF ) Local $pAndCondition $oUIAutomation.CreateAndConditionFromArray( $ptrSafeArray, $pAndCondition ) ConsoleWrite( @CRLF & "Create condition from SafeArray" & @CRLF ) ConsoleWrite( "$pAndCondition = " & Ptr( $pAndCondition ) & @CRLF ) ; Find item Local $pItem $oExplorer.FindFirst( $TreeScope_Descendants, $pAndCondition, $pItem ) If $pItem Then ConsoleWrite( @CRLF & """Test.txt"" found" & @CRLF ) Else ConsoleWrite( @CRLF & """Test.txt"" not found" & @CRLF ) EndIf SafeArrayDestroy( $ptrSafeArray ) ConsoleWrite( @CRLF & "Destroy SafeArray" & @CRLF & @CRLF ) EndFunc Tested on XP 32 bit and Win 7 64 bit. Should work on Vista and Win 8 too.1 point
-
Under Options, Open Global Options File: 1. save.session=1 --> save.session=0 2. #wrap=1 --> wrap=1 Save, close SciTE and reopen it.1 point