Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/15/2019 in all areas

  1. This is an old article and you may have to update the UDF scripts to make work with the latest AutoIt. Ini in Memory
    1 point
  2. If you really want to reduce redundancy, you could do something like : While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop Case $idCheckbox1 to $idCheckbox10 _buttonResponse($nMsg) EndSwitch Wend
    1 point
  3. @LarsJ Thanks for your information. I got the answer: local $oChromeAddressBar=_UIA_getFirstObjectOfElement($oChrome,"title:=Adress- und Suchleiste" , $treescope_subtree) ;works in chrome 65
    1 point
  4. @mLipok It may not be 2 cents, by I have a groszy 1. Document the ADO capabilities 2. Allows for user function extensions
    1 point
  5. Malkey

    different sort algorithm

    Last Tuesday I posted an _ArraySort() with case sensitivity in the Examples forum. The function _ArraySortc() gives the same results as notepad++ sorting - with case sensitivity. #include <ArrayMultiSortCase.au3> ; Found @ https://www.autoitscript.com/forum/topic/198148-_arraymultisort-sort-multiple-columns-with-case-sensitivity/? local $a[]= [ _ "APR_SCC_CBI","APR_SCC_CBI_DM","APR_SCC_CBI_DMIS","APR_SCC_CBI_IS","APR_SCC_CBI_NO","APR_SCC_CBI_O","APR_SCC_CBII", _ "APR_SCC_CBII_DM","APR_SCC_CBII_DMIS","APR_SCC_CBII_IS","APR_SCC_CBII_NO","APR_SCC_CBII_O","APR_SCC_CBIII","APR_SCC_CBIII_DM", _ "APR_SCC_CBIII_DMIS","APR_SCC_CBIII_IS","APR_SCC_CBIII_NO","APR_SCC_CBIII_O"] _ArraySortc($a, 0, 0, 0, 0, 0, 1) ; $iDescending = 0(ascending); $iCase = 1(Case sensitive) _ArrayDisplay($a, "First file: notepad++ sorting" ) _ArraySort($a) _ArrayDisplay($a, "Second file: _ArraySort function" )
    1 point
  6. There is really no need for code to answer such a question. The reason it doesn't work with GUICtrlCreateListViewItem is that this built-in command doesn't support item icons. Perhaps you can specify a single icon using GUICtrlSetImage but it's not worth the trouble. If you want icons in your listview then you should use the functions in the UDF. The purpose of all the built-in GUICtrlCreate-commands is to make it easy and quick to get started for a new AutoIt coder. On the other hand, they all have quite limited functionality. If you want more functionality, use the UDF functions.
    1 point
  7. Indeed not all ADO interface layers support all CursorTypes. Some support all inconditionally, some offer those the DB engine offers, some support only some (conditionally or not), etc. The variable support for CursorLocation property makes things even muddier. The same occurs with LockTypes. But all LockTypes can't be implemented only in the ADO wrapper: they can only reflect what the engine is capable of. ADO specifies a fair number of recordset properties, methods and events. Full cursor support can be counter-productive in that if the engine doesn't offer built-in efficient cursor support relying on the engine capabilities, the ADO has to implement it in its code, forcing the full recordset of a query to be stored in memory. Then it's too easy for inexperienced SQL programmer to forget that an inconspiscious (too broad) query may need yottabytes of RAM at the ADO level.
    1 point
  8. Use an UIA spy tool eg. simplespy by junkew (place the mouse over the control and press ctrl+w) or UIASpy (place the mouse over the control and press F1).
    1 point
  9. this example is very good thank you very much i hope you continue developing this program with my greetings
    1 point
  10. Clark, Looking back through the old versions of the UDF it seems that it used to use the default _GUICtrlListView_SimpleSort to do the sorting but adding colour to the mix meant that this was no longer possible and so I changed the UDF to sort its internal array and then rewrite the ListView. Hence your old script could well have worked - another mystery solved! Glad you find the UDF useful. M23
    1 point
  11. Simple solution to this problem - create a second exe that launches your rebooter at the time you want using the task scheduler. The EXE launcher will be hidden yet your rebooter won't be.
    1 point
  12. Usually its better to use software deployment using SCCM although it maybe overkill for your organisation. In which case I would recommend PDQ Deploy - https://www.pdq.com/pdq-deploy/ we use both SCCM and PDQ Deploy for third-party patching and forcing installations like anti-virus etc... as the machines come online. Just my 2cents.
    1 point
  13. Alek

    Ini in memory

    UDFs for managing Ini format in memory. They are very similar to the ini file functions (parameters and return values) I found a set of function like these on the forum (i think) that used regexp, but ran into problems when using keys/values that containd symbols (like a file dir) Bugs: -Needs more testing... #cs _IniMem_Delete(ByRef $s_ini, $s_Section, $s_key = "") _IniMem_Read($s_ini, $s_Section, $s_key, $s_default = "") _IniMem_ReadSection($s_ini, $s_Section) _IniMem_ReadSectionNames($s_ini) _IniMem_RenameSection(ByRef $s_ini, $s_Old_Sec, $s_New_Sec, $i_Flag = 0) _IniMem_Write(ByRef $s_ini, $s_Section, $s_key, $s_value) _IniMem_WriteSection(ByRef $s_ini, $s_Section, $s_data, $i_Index = 1) _IniMem_Cleanup(ByRef $s_ini) #ce ; #FUNCTION# ============================================================== ; Name...........: _IniMem_Delete ; Description ...: Deletes a value from a standard format ini string ; Syntax.........: _IniMem_Delete(ByRef $s_ini, $s_Section, [$s_key]) ; Parameters ....: $s_ini - The ini string ; $s_Section - The section you want to delete ; $s_Key - The key you want to delete (default = "") ; Return values .: Success - 1 ; Failure - 0 (cant find section or key) ; Author ........: Alek ; ========================================================================= Func _IniMem_Delete(ByRef $s_ini, $s_Section, $s_key = "") Local $s_temp_ini, $x, $i $s_temp_ini = StringSplit($s_ini, @CRLF) For $x = 1 To $s_temp_ini[0] If $s_temp_ini[$x] = "[" & $s_Section& "]" Then ExitLoop Next If $x > $s_temp_ini[0] Then Return 0 If $s_key <> "" Then For $i = $x+1 To $s_temp_ini[0] If StringLeft($s_temp_ini[$i], 1) = "[" And StringRight($s_temp_ini[$i], 1) = "]" Then ExitLoop If StringLeft($s_temp_ini[$i], StringLen($s_key)) = $s_key Then $s_temp_ini[$i] = "" ExitLoop EndIf Next Else For $i = $x To $s_temp_ini[0] If StringLeft($s_temp_ini[$i], 1) = "[" And StringRight($s_temp_ini[$i], 1) = "]" And $s_temp_ini[$i] <> "[" & $s_Section & "]" Then ExitLoop $s_temp_ini[$i] = "" Next EndIf $s_ini = "" For $x = 1 To $s_temp_ini[0] If $s_temp_ini[$x] = "" Then ContinueLoop If StringLeft($s_temp_ini[$x], 1) = "[" And StringRight($s_temp_ini[$x],1) = "]" And $x > 1 Then $s_ini &= @CRLF & $s_temp_ini[$x] & @CRLF Else $s_ini &= $s_temp_ini[$x] & @CRLF EndIf Next Return 1 EndFunc ; #FUNCTION# ============================================================== ; Name...........: _IniMem_Read ; Description ...: Reads a value from a standard format ini string ; Syntax.........: _IniMem_Read($s_ini, $s_Section, $s_key, [$s_default]) ; Parameters ....: $s_ini - The ini string ; $s_Section - The section you want to read ; $s_Key - The key you want to get ; $s_default - the return value when unable to read the key (default = "") ; Return values .: Success - value of the selected key ; Failure - $s_default ; Author ........: Alek ; ========================================================================= Func _IniMem_Read($s_ini, $s_Section, $s_key, $s_default = "") $s_ini = StringSplit($s_ini, @CRLF) For $x = 1 To $s_ini[0] If $s_ini[$x] = "[" & $s_Section & "]" Then ExitLoop Next If $x > $s_ini[0] Then Return $s_default For $i = $x+1 To $s_ini[0] If StringLeft($s_ini[$i],1) = "[" And StringRight($s_ini[$i],1) = "]" Then ExitLoop If $s_ini[$i] = "" Then ContinueLoop If StringLeft($s_ini[$i], StringLen($s_key)) = $s_key Then Return StringTrimLeft($s_ini[$i], StringLen($s_key) + 1) Next Return $s_default EndFunc ; #FUNCTION# ============================================================== ; Name...........: _IniMem_ReadSection ; Description ...: Reads all key/value pairs from a section in a standard format ini string ; Syntax.........: _IniMem_ReadSection($s_ini, $s_Section) ; Parameters ....: $s_ini - The ini string ; $s_Section - The section you want to read ; Return values .: Success - a 2 dimensional array where element[n][0] is the key and element[n][1] is the value, [0][0] is the number of elemnts ; Failure - [0][0] = 0 and sets error to 1 ; Author ........: Alek ; ========================================================================= Func _IniMem_ReadSection($s_ini, $s_Section) Local $r_Array[1][2] $s_ini = StringSplit($s_ini, @CRLF) For $x = 1 To $s_ini[0] If $s_ini[$x] = "[" & $s_Section & "]" Then ExitLoop Next If $x > $s_ini[0] Then Return SetError(1) For $i = $x+1 To $s_ini[0] If StringLeft($s_ini[$i],1) = "[" And StringRight($s_ini[$i],1) = "]" Then ExitLoop If $s_ini[$i] = "" Then ContinueLoop ReDim $r_Array[UBound($r_Array, 1) + 1][2] $r_Array[UBound($r_Array, 1) - 1][0] = StringLeft($s_ini[$i], StringInStr($s_ini[$i], "=") - 1) $r_Array[UBound($r_Array, 1) - 1][1] = StringTrimLeft($s_ini[$i], StringInStr($s_ini[$i], "=")) $r_Array[0][0] += 1 Next Return $r_Array EndFunc ; #FUNCTION# ============================================================== ; Name...........: _IniMem_ReadSectionNames ; Description ...: Reads all key/value pairs from a section in a standard format ini string ; Syntax.........: _IniMem_ReadSectionNames($s_ini) ; Parameters ....: $s_ini - The ini string ; Return values .: Success - an array of all section names in the INI string, [0] is the number of elemnts ; Failure - [0] = 0 and sets error to 1 ; Author ........: Alek ; ========================================================================= Func _IniMem_ReadSectionNames($s_ini) Local $r_Array[1] $s_ini = StringSplit($s_ini,@CRLF) For $x = 1 To $s_ini[0] If $s_ini[$x] = "" Then ContinueLoop If StringLeft($s_ini[$x],1) = "[" And StringRight($s_ini[$x],1) = "]" Then ReDim $r_Array[UBound($r_Array, 1) + 1] $r_Array[UBound($r_Array, 1) - 1] = StringTrimLeft(StringTrimRight($s_ini[$x], 1), 1) $r_Array[0] += 1 EndIf Next If $r_Array[0] = 0 Then SetError(1) Return $r_Array EndFunc ; #FUNCTION# ============================================================== ; Name...........: IniMem_RenameSection ; Description ...: Renames a section in a standard format ini string ; Syntax.........: _IniMem_RenameSection(ByRef $s_ini, $s_Old_Sec, $s_New_Sec, [$i_Flag]) ; Parameters ....: $s_ini - The ini string ; $s_old_Sec - The section you want to rename ; $s_New_Sec - The new name of the section. ; $i_Flag - 0 Fail if "new section" already exists. ; 1 Overwrite "new section". This will erase any existing keys in "new section" ; Return values .: Success - 1 ; Failure - 0 (cant find old section) ; Author ........: Alek ; ========================================================================= Func _IniMem_RenameSection(ByRef $s_ini, $s_Old_Sec, $s_New_Sec, $i_Flag = 0) Local $s_temp_ini, $x, $i If $i_Flag = 0 And StringInStr($s_ini, "[" & $s_New_Sec & "]") Then Return 0 ;$s_ini = StringReplace($s_ini,"[" & $s_Old_Sec & "]","[" & $s_New_Sec & "]", 1) $s_temp_ini = StringSplit($s_ini, @CRLF) For $x = 1 To $s_temp_ini[0] If $s_temp_ini[$x] = "[" & $s_Old_Sec & "]" Then $s_temp_ini[$x] = "[" & $s_New_Sec & "]" ExitLoop EndIf Next If $x > $s_temp_ini[0] Then Return 0 If $i_Flag = 1 Then For $i = $x + 1 To $s_temp_ini[0] If $s_temp_ini[$x] = "[" & $s_New_Sec & "]" Then ExitLoop Next If $i > $s_temp_ini[0] Then Return 0 For $x = $i+1 To $s_temp_ini[0] If StringLeft($s_temp_ini[$x], 1) = "[" And StringRight($s_temp_ini[$x], 1) = "]" Then ExitLoop $s_temp_ini[$x] = "" Next EndIf $s_ini = "" For $x = 1 To $s_temp_ini[0] If $s_temp_ini[$x] = "" Then ContinueLoop If StringLeft($s_temp_ini[$x], 1) = "[" And StringRight($s_temp_ini[$x],1) = "]" And $x > 1 Then $s_ini &= @CRLF & $s_temp_ini[$x] & @CRLF Else $s_ini &= $s_temp_ini[$x] & @CRLF EndIf Next Return 1 EndFunc ; #FUNCTION# ============================================================== ; Name...........: _IniMem_Write ; Description ...: Writes a value to a standard format ini string ; Syntax.........: _IniMem_Write(ByRef $s_ini, $s_Section, $s_key, $s_value) ; Parameters ....: $s_ini - The ini string ; $s_Section - The section name in the ini string ; $s_Key - The key name in the in the ini string ; $s_Value - The value to write/change. ; Return values .: 1 ; Author ........: Alek ; ========================================================================= Func _IniMem_Write(ByRef $s_ini, $s_Section, $s_key, $s_value) Local $s_temp_ini = StringSplit($s_ini, @CRLF) For $x = 1 To $s_temp_ini[0] If $s_temp_ini[$x] = "[" & $s_Section & "]" Then ExitLoop Next If $x > $s_temp_ini[0] Then ;$s_temp_ini[$s_temp_ini[0]] &= @CRLF & "[" & $s_Section & "]" & @CRLF & $s_key & "=" & $s_value $s_temp_ini[$s_temp_ini[0]] &= "[" & $s_Section & "]" & @CRLF & $s_key & "=" & $s_value ;looks better ;) Else For $i = $x+1 To $s_temp_ini[0] If StringLeft($s_temp_ini[$i], 1) = "[" And StringRight($s_temp_ini[$i],1) = "]" Then $x = $i-1 $i = 0 ExitLoop ElseIf StringLeft($s_temp_ini[$i], StringLen($s_key)) = $s_key Then $s_temp_ini[$i] = $s_key & "=" & $s_value ExitLoop EndIf Next If $i = 0 Then $s_temp_ini[$x] &= @CRLF & $s_key & "=" & $s_value ElseIf $i > $s_temp_ini[0] Then $s_temp_ini[$s_temp_ini[0]] &= $s_key & "=" & $s_value EndIf EndIf $s_ini = "" For $x = 1 To $s_temp_ini[0] If $s_temp_ini[$x] = "" Then ContinueLoop If StringLeft($s_temp_ini[$x], 1) = "[" And StringRight($s_temp_ini[$x],1) = "]" And $x > 1 Then $s_ini &= @CRLF & $s_temp_ini[$x] & @CRLF Else $s_ini &= $s_temp_ini[$x] & @CRLF EndIf Next Return 1 EndFunc ; #FUNCTION# ============================================================== ; Name...........: _IniMem_WriteSection ; Description ...: Writes a section to a standard format ini string ; Syntax.........: _IniMem_WriteSection(ByRef $s_ini, $s_Section, $s_data, [$i_Index]) ; Parameters ....: $s_ini - The ini string ; $s_Section - The section name in the ini string ; $s_Data - The data to write. The data can either be a string or an array. ; If the data is a string, then each key=value pair must be delimited by @LF. ; If the data is an array, the array must be 2-dimensional and the second dimension must be 2 elements. ; $i_index - If an array is passed as data, this specifies the index to start writing from. ; By default, this is 1 so that the return value of IniReadSection() can be used immediately. ; For manually created arrays, this value may need to be different depending on how the array was created. ; This parameter is ignored if a string is passed as data. ; Return values .: Success - 1 ; Failure - 0 (Invalid data format) ; Error - 1 The data array is not 2d ; Error - 2 The array is smaller then $i_Index ; Error - 3 The data array's second dimension is to small ; Author ........: Alek ; ========================================================================= Func _IniMem_WriteSection(ByRef $s_ini, $s_Section, $s_data, $i_Index = 1) Local $s_key, $s_value If IsArray($s_data) Then If UBound($s_data, 0) <> 2 Then Return SetError(1, Default, 0) If UBound($s_data, 1) - 1 > $i_Index Then Return SetError(2, Default, 0) If UBound($s_data, 2) < 2 Then Return SetError(3, Default, 0) For $x = $i_Index To UBound($s_data, 1) - 1 _IniMem_Write($s_ini, $s_Section, $s_data[$x][0], $s_data[1]) Next Else $s_data = StringSplit($s_data, @LF) If @error Then Return 0 For $x = 1 To $s_data[0] $s_key = StringLeft($s_data[$x],StringInStr($s_data[$x],"=")-1) $s_value = StringTrimLeft($s_data[$x],StringInStr($s_data[$x],"=")) If $s_key Or $s_value = "" Then ContinueLoop _IniMem_Write($s_ini, $s_Section, $s_key , $s_Value) Next EndIf Return 1 EndFunc ; #FUNCTION# ============================================================== ; Name...........: _IniMem_Cleanup ; Description ...: Cleans up a ini format string, will proberly add more features later ; Syntax.........: _IniMem_Cleanup(ByRef $s_ini) ; Parameters ....: $s_ini - The ini string ; Return values .: 1 ; Author ........: Alek ; ========================================================================= Func _IniMem_Cleanup(ByRef $s_ini) Local $s_temp_ini, $x $s_temp_ini = StringSplit($s_ini, @CRLF) $s_ini = "" For $x = 1 To $s_temp_ini[0] If $s_temp_ini[$x] = "" Then ContinueLoop If StringLeft($s_temp_ini[$x], 1) = "[" And StringRight($s_temp_ini[$x],1) = "]" And $x > 1 Then $s_ini &= @CRLF & $s_temp_ini[$x] & @CRLF Else $s_ini &= $s_temp_ini[$x] & @CRLF EndIf Next Return 1 EndFunc
    1 point
  14. ValeryVal, This could be useful if you not have too many events. By the way, all four examples in post #112 works now. Here is an example with the structure change event handler. When you download exe-files in IE9, IE10 or IE11 a notification bar shows up in the bottom of the window. This example automatically clicks the save and close buttons when the notification shows up. If a security scan notification or a download completed notification shows up the close button will be clicked. Here is the code: #include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) Global Const $S_OK = 0x00000000 Global Const $E_NOINTERFACE = 0x80004002 Global Const $sIID_IUnknown = "{00000000-0000-0000-C000-000000000046}" Global $tIUIAutomationStructureChangedEventHandler, $oIUIAutomationStructureChangedEventHandler Global $oUIAutomation MainFunc() Func MainFunc() ; Create custom event handler object for structure change events $oIUIAutomationStructureChangedEventHandler = ObjectFromTag( "oIUIAutomationStructureChangedEventHandler_", $dtagIUIAutomationStructureChangedEventHandler, $tIUIAutomationStructureChangedEventHandler, True ) If Not IsObj( $oIUIAutomationStructureChangedEventHandler ) Then Return ; Create UI Automation object $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ; Create UI element ;Local $pUIElement ;$oUIAutomation.GetRootElement( $pUIElement ) ; Desktop ;If Not $pUIElement Then Return ; Create UI element Local $hWindow, $pUIElement $hWindow = WinGetHandle( "[CLASS:IEFrame]" ) ; Internet Explorer $oUIAutomation.ElementFromHandle( $hWindow, $pUIElement ) If Not $pUIElement Then Return ; Add structure change event handler If $oUIAutomation.AddStructureChangedEventHandler( $pUIElement, $TreeScope_Subtree, 0, $oIUIAutomationStructureChangedEventHandler ) Then Exit HotKeySet( "{ESC}", "Quit" ) While Sleep(100) WEnd EndFunc Func Quit() $oIUIAutomationStructureChangedEventHandler = 0 DeleteObjectFromTag( $tIUIAutomationStructureChangedEventHandler ) Exit EndFunc ; Get property ($id) for UI element ($obj) Func _UIA_getPropertyValue( $obj, $id ) Local $tVal $obj.GetCurrentPropertyValue( $id, $tVal ) If Not IsArray( $tVal ) Then Return $tVal Local $tStr = $tVal[0] For $i = 1 To UBound( $tVal ) - 1 $tStr &= "; " & $tVal[$i] Next Return $tStr EndFunc ; List all descendants of the parent UI element ; in a hierarchical structure like a treeview. Func ListDescendants( $oParent, $iLevel, $iLevels = 0 ) If Not IsObj( $oParent ) Then Return If $iLevels And $iLevel = $iLevels Then Return Local $pRawWalker, $oRawWalker $oUIAutomation.RawViewWalker( $pRawWalker ) $oRawWalker = ObjCreateInterface( $pRawWalker, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker ) Local $pUIElement, $oUIElement $oRawWalker.GetFirstChildElement( $oParent, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) Local $sIndent = "" For $i = 0 To $iLevel - 1 $sIndent &= " " Next While IsObj( $oUIElement ) ConsoleWrite( $sIndent & "Title = " & _UIA_getPropertyValue( $oUIElement, $UIA_NamePropertyId ) & @CRLF & _ $sIndent & "Class = " & _UIA_getPropertyValue( $oUIElement, $UIA_ClassNamePropertyId ) & @CRLF & _ $sIndent & "Ctrl type = " & _UIA_getPropertyValue( $oUIElement, $UIA_ControlTypePropertyId ) & @CRLF & _ $sIndent & "Ctrl name = " & _UIA_getPropertyValue( $oUIElement, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _ $sIndent & "Value = " & _UIA_getPropertyValue( $oUIElement, $UIA_LegacyIAccessibleValuePropertyId ) & @CRLF & _ $sIndent & "Handle = " & Hex( _UIA_getPropertyValue( $oUIElement, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & @CRLF ) ListDescendants( $oUIElement, $iLevel + 1, $iLevels ) $oRawWalker.GetNextSiblingElement( $oUIElement, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) WEnd EndFunc Func oIUIAutomationStructureChangedEventHandler_HandleStructureChangedEvent( $pSelf, $pSender, $iChangeType, $pRuntimeId ) ; Ret: long Par: ptr;long;ptr ; Create sender object Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oSender.AddRef() ; Get object class Local $sClass $oSender.GetCurrentPropertyValue( $UIA_ClassNamePropertyId, $sClass ) ; Only handle objects of class "Frame Notification Bar" If $sClass = "Frame Notification Bar" Then ; Print object properties ConsoleWrite( @CRLF & _ "Title = " & _UIA_getPropertyValue( $oSender, $UIA_NamePropertyId ) & @CRLF & _ "Class = " & _UIA_getPropertyValue( $oSender, $UIA_ClassNamePropertyId ) & @CRLF & _ "Ctrl type = " & _UIA_getPropertyValue( $oSender, $UIA_ControlTypePropertyId ) & @CRLF & _ "Ctrl name = " & _UIA_getPropertyValue( $oSender, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _ "Value = " & _UIA_getPropertyValue( $oSender, $UIA_LegacyIAccessibleValuePropertyId ) & @CRLF & _ "Handle = " & Hex( _UIA_getPropertyValue( $oSender, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & @CRLF ) If $iChangeType = 0 Then ; Window open event ConsoleWrite( "Notification Bar opened" & @CRLF & @CRLF ) Else ; $iChangeType = 1 ; Window close event ConsoleWrite( "Notification Bar closed" & @CRLF & @CRLF ) Return $S_OK EndIf ; List descendants of the object ConsoleWrite( "Descendants of the Frame Notification Bar:" & @CRLF & @CRLF ) ListDescendants( $oSender, 0, 0 ) ; Condition to find Save button (split button) Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_SplitButtonControlTypeId, $pCondition ) If Not $pCondition Then Return $S_OK ; Find Save button Local $pSave, $oSave $oSender.FindFirst( $TreeScope_Descendants, $pCondition, $pSave ) If $pSave Then ; Click Save and Close buttons in the first "Frame Notification Bar" window $oSave = ObjCreateInterface( $pSave, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSave ) Then Return $S_OK ; Click (invoke) Save button Local $pInvoke, $oInvoke $oSave.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return $S_OK $oInvoke.Invoke() ConsoleWrite( "Save button clicked" & @CRLF & @CRLF ) ; Condition to find Close button Local $pCondition1, $pCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition1 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Close", $pCondition2 ) $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return $S_OK ; Find Close button Local $pClose, $oClose $oSender.FindFirst( $TreeScope_Descendants, $pCondition, $pClose ) $oClose = ObjCreateInterface( $pClose, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oClose ) Then Return $S_OK ; Click (invoke) Close button Local $pInvoke, $oInvoke $oClose.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return $S_OK $oInvoke.Invoke() ConsoleWrite( "Close button clicked" & @CRLF & @CRLF ) Else ; Click Close button in the next "Frame Notification Bar" windows ; Condition to find Close button Local $pCondition1, $pCondition2 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition1 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Close", $pCondition2 ) $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return $S_OK ; Find Close button Local $pClose, $oClose $oSender.FindFirst( $TreeScope_Descendants, $pCondition, $pClose ) $oClose = ObjCreateInterface( $pClose, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oClose ) Then Return $S_OK ; Click (invoke) Close button Local $pInvoke, $oInvoke $oClose.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return $S_OK $oInvoke.Invoke() ConsoleWrite( "Close button clicked" & @CRLF & @CRLF ) EndIf EndIf Return $S_OK EndFunc Func oIUIAutomationStructureChangedEventHandler_QueryInterface( $pSelf, $pRIID, $pObj ) ; Ret: long Par: ptr;ptr* Local $sIID = StringFromGUID( $pRIID ) If $sIID = $sIID_IUnknown Then ConsoleWrite( "oIUIAutomationStructureChangedEventHandler_QueryInterface: IUnknown" & @CRLF ) DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf ) oIUIAutomationStructureChangedEventHandler_AddRef( $pSelf ) Return $S_OK ElseIf $sIID = $sIID_IUIAutomationStructureChangedEventHandler Then ConsoleWrite( "oIUIAutomationStructureChangedEventHandler_QueryInterface: IUIAutomationStructureChangedEventHandler" & @CRLF ) DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf ) oIUIAutomationStructureChangedEventHandler_AddRef( $pSelf ) Return $S_OK Else ConsoleWrite( "oIUIAutomationStructureChangedEventHandler_QueryInterface: " & $sIID & @CRLF ) Return $E_NOINTERFACE EndIf EndFunc Func oIUIAutomationStructureChangedEventHandler_AddRef( $pSelf ) ; Ret: ulong ConsoleWrite( "oIUIAutomationStructureChangedEventHandler_AddRef" & @CRLF ) Return 1 EndFunc Func oIUIAutomationStructureChangedEventHandler_Release( $pSelf ) ; Ret: ulong ConsoleWrite( "oIUIAutomationStructureChangedEventHandler_Release" & @CRLF ) Return 1 EndFunc Func StringFromGUID( $pGUID ) Local $aResult = DllCall( "ole32.dll", "int", "StringFromGUID2", "struct*", $pGUID, "wstr", "", "int", 40 ) If @error Then Return SetError( @error, @extended, "" ) Return SetExtended( $aResult[0], $aResult[2] ) EndFunc ; Copied and slightly modified (print methods) from this post by trancexx: ; http://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/page*#entry1143566 Func ObjectFromTag($sFunctionPrefix, $tagInterface, ByRef $tInterface, $fPrint = False, $bIsUnknown = Default, $sIID = "{00000000-0000-0000-C000-000000000046}") ; last param is IID_IUnknown by default If $bIsUnknown = Default Then $bIsUnknown = True Local $sInterface = $tagInterface ; copy interface description Local $tagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _ "AddRef dword();" & _ "Release dword();" ; Adding IUnknown methods If $bIsUnknown Then $tagInterface = $tagIUnknown & $tagInterface ; Below line is really simple even though it looks super complex. It's just written weird to fit in one line, not to steal your attention Local $aMethods = StringSplit(StringReplace(StringReplace(StringReplace(StringReplace(StringTrimRight(StringReplace(StringRegExpReplace(StringRegExpReplace($tagInterface, "\w+\*", "ptr"), "\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF), 1), "object", "idispatch"), "hresult", "long"), "bstr", "ptr"), "variant", "ptr"), @LF, 3) Local $iUbound = UBound($aMethods) Local $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams, $hCallback ; Allocation $tInterface = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[" & $iUbound & "];int_ptr Callbacks[" & $iUbound & "];ulong_ptr Slots[16]") ; 16 pointer sized elements more to create space for possible private props If @error Then Return SetError(1, 0, 0) For $i = 0 To $iUbound - 1 $aSplit = StringSplit($aMethods[$i], "|", 2) If UBound($aSplit) <> 2 Then ReDim $aSplit[2] $sNamePart = $aSplit[0] $sTagPart = $aSplit[1] $sMethod = $sFunctionPrefix & $sNamePart If $fPrint Then Local $iPar = StringInStr( $sTagPart, ";", 2 ), $t If $iPar Then $t = "Ret: " & StringLeft( $sTagPart, $iPar - 1 ) & " " & _ "Par: " & StringRight( $sTagPart, StringLen( $sTagPart ) - $iPar ) Else $t = "Ret: " & $sTagPart EndIf Local $s = "Func " & $sMethod & _ "( $pSelf ) ; " & $t & @CRLF & _ "EndFunc" & @CRLF ConsoleWrite( $s ) EndIf $aTagPart = StringSplit($sTagPart, ";", 2) $sRet = $aTagPart[0] $sParams = StringReplace($sTagPart, $sRet, "", 1) $sParams = "ptr" & $sParams $hCallback = DllCallbackRegister($sMethod, $sRet, $sParams) ConsoleWrite(@error & @CRLF & @CRLF) DllStructSetData($tInterface, "Methods", DllCallbackGetPtr($hCallback), $i + 1) ; save callback pointer DllStructSetData($tInterface, "Callbacks", $hCallback, $i + 1) ; save callback handle Next DllStructSetData($tInterface, "RefCount", 1) ; initial ref count is 1 DllStructSetData($tInterface, "Size", $iUbound) ; number of interface methods DllStructSetData($tInterface, "Object", DllStructGetPtr($tInterface, "Methods")) ; Interface method pointers Return ObjCreateInterface(DllStructGetPtr($tInterface, "Object"), $sIID, $sInterface, $bIsUnknown) ; pointer that's wrapped into object EndFunc Func DeleteObjectFromTag(ByRef $tInterface) For $i = 1 To DllStructGetData($tInterface, "Size") DllCallbackFree(DllStructGetData($tInterface, "Callbacks", $i)) Next $tInterface = 0 EndFunc One issue with the code: I think the button name "Close" is localized. You should use your own button name. And here is the output in Scite console: Func oIUIAutomationStructureChangedEventHandler_QueryInterface( $pSelf ) ; Ret: long Par: ptr;ptr EndFunc 0 Func oIUIAutomationStructureChangedEventHandler_AddRef( $pSelf ) ; Ret: dword EndFunc 0 Func oIUIAutomationStructureChangedEventHandler_Release( $pSelf ) ; Ret: dword EndFunc 0 Func oIUIAutomationStructureChangedEventHandler_HandleStructureChangedEvent( $pSelf ) ; Ret: long Par: ptr;long;ptr EndFunc 0 oIUIAutomationStructureChangedEventHandler_QueryInterface: IUnknown oIUIAutomationStructureChangedEventHandler_AddRef oIUIAutomationStructureChangedEventHandler_Release oIUIAutomationStructureChangedEventHandler_AddRef oIUIAutomationStructureChangedEventHandler_QueryInterface: {0000001B-0000-0000-C000-000000000046} oIUIAutomationStructureChangedEventHandler_QueryInterface: {00000003-0000-0000-C000-000000000046} oIUIAutomationStructureChangedEventHandler_AddRef oIUIAutomationStructureChangedEventHandler_QueryInterface: {0000001B-0000-0000-C000-000000000046} oIUIAutomationStructureChangedEventHandler_QueryInterface: IUnknown oIUIAutomationStructureChangedEventHandler_AddRef oIUIAutomationStructureChangedEventHandler_AddRef oIUIAutomationStructureChangedEventHandler_QueryInterface: {00000018-0000-0000-C000-000000000046} oIUIAutomationStructureChangedEventHandler_QueryInterface: {00000019-0000-0000-C000-000000000046} oIUIAutomationStructureChangedEventHandler_QueryInterface: {4C1E39E1-E3E3-4296-AA86-EC938D896E92} oIUIAutomationStructureChangedEventHandler_Release oIUIAutomationStructureChangedEventHandler_QueryInterface: IUIAutomationStructureChangedEventHandler oIUIAutomationStructureChangedEventHandler_AddRef oIUIAutomationStructureChangedEventHandler_AddRef oIUIAutomationStructureChangedEventHandler_QueryInterface: {1C733A30-2A1C-11CE-ADE5-00AA0044773D} oIUIAutomationStructureChangedEventHandler_QueryInterface: IUIAutomationStructureChangedEventHandler oIUIAutomationStructureChangedEventHandler_AddRef Title = Class = Frame Notification Bar Ctrl type = 50033 Ctrl name = pane Value = Handle = 00010602 Notification Bar opened Descendants of the Frame Notification Bar: Title = Notification Class = DirectUIHWND Ctrl type = 50021 Ctrl name = tool bar Value = Handle = 00010604 Title = Notification bar Text Class = Ctrl type = 50020 Ctrl name = text Value = Do you want to run or save autoit-v3-setup.exe (10,9 MB) from autoitscript.com? Handle = 00000000 Title = Run Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Title = Save Class = Ctrl type = 50031 Ctrl name = split button Value = Handle = 00000000 Title = Class = Ctrl type = 50031 Ctrl name = split button Value = Handle = 00000000 Title = Cancel Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Title = Close Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Save button clicked Close button clicked Title = Class = Frame Notification Bar Ctrl type = 50033 Ctrl name = pane Value = Handle = 00010602 Notification Bar closed Title = Class = Frame Notification Bar Ctrl type = 50033 Ctrl name = pane Value = Handle = 00010602 Notification Bar opened Descendants of the Frame Notification Bar: Title = Notification Class = DirectUIHWND Ctrl type = 50021 Ctrl name = tool bar Value = Handle = 00010604 Title = Notification bar Text Class = Ctrl type = 50020 Ctrl name = text Value = Running security scan Handle = 00000000 Title = View downloads Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Title = Close Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Close button clicked Title = Class = Frame Notification Bar Ctrl type = 50033 Ctrl name = pane Value = Handle = 00010602 Notification Bar closed Title = Class = Frame Notification Bar Ctrl type = 50033 Ctrl name = pane Value = Handle = 00010602 Notification Bar opened Descendants of the Frame Notification Bar: Title = Notification Class = DirectUIHWND Ctrl type = 50021 Ctrl name = tool bar Value = Handle = 00010604 Title = Notification bar Text Class = Ctrl type = 50020 Ctrl name = text Value = The autoit-v3-setup (9).exe download has completed. Handle = 00000000 Title = Run Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Title = Open folder Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Title = View downloads Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Title = Close Class = Ctrl type = 50000 Ctrl name = button Value = Handle = 00000000 Close button clicked Title = Class = Frame Notification Bar Ctrl type = 50033 Ctrl name = pane Value = Handle = 00010602 Notification Bar closed oIUIAutomationStructureChangedEventHandler_Release Tested on Win 7 with IE 11.
    1 point
  15. ProgAndy

    FreeImage Library

    You can do this with FreeImage, but it would be easier with GDIplus. FreeImage forces you to care about Bit-depth and palettes, GDIPlus doesn't. Anyways, this code should work: $hMainImage = _FreeImage_LoadU($FIF_JPEG, "C:\TheJPEG.jpg", 0) $hMainImage32bit = _FreeImage_ConvertTo32Bits($hMainImage) _FreeImage_Unload($hMainImage) ; we have the copy in 32bits $hGIFImage = _FreeImage_LoadU($FIF_GIF, "C:\aGIF.gif", 0) $hGIFImage32bit = _FreeImage_ConvertTo32Bits($hMainImage) _FreeImage_Unload($hGIFImage) ; we have the copy in 32bits $iX = 12 $iX = 34 ; both images have to be in same format, this is why they were converted. _FreeImage_Paste($hMainImage32bit, $hGIFImage32bit, $iX, $iY, 300) ; last parameter > 255 for combiing without custom transpareny _FreeImage_Unload($hGIFImage32bit) ; now drawn, not needed anymore _FreeImage_SaveU($FIF_JPEG, $hMainImage32bit, "C:\Combined.jpg", 0) _FreeImage_Unload($hMainImage32bit) ; we saved it, not needed anymore
    1 point
×
×
  • Create New...