Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/07/2024 in all areas

  1. thanks for your posts. I have recorded a gif-video to be opened with your browser. It's for showing how it is visible on my system. Cheers mike
    1 point
  2. I used Sciter several times. You can make interesting user interfaces but it doesn't support all modern CSS. I am interested also to find a new way to embed a web application in a GUI without installing too many third party software.
    1 point
  3. Checkbox Combo A Checkbox Combo control for multiple selections must be owner drawn to display Checkboxes. And the ListBox must remain open after an item is in/un-checked. Owner drawn Combo An owner drawn Combo control is discussed in first post. But there was one thing I forgot. For both WM_DRAWITEM and WM_MEASUREITEM messages, controlId is contained in wParam. In case of multiple Combo controls, the correct Combo can be determined by comparing controlId with wParam. Of course, it's much faster than first to create $tDIS and $tMIS structures from lParam, then extract CtlID from the structures, and finally compare controlId and CtlID. UDF and zip-file in first post updated. ListBox control An owner drawn Combo control can be implemented by subclassing the parent window. To keep the ListBox open, it's necessary to subclass the ListBox itself, and respond to WM_LBUTTONUP messages this way: Case $WM_LBUTTONUP Return 0 ; Prevents ListBox from closing This looks relatively easy in first place, but it has significant impact on the functionality of the entire Combo control. A number of smaller pieces of code must be added to make the control work normally again. Among other things AutoIt events are no longer generated for the corresponding controlID. This can be corrected by generating events for a Dummy control instead of: Case $WM_COMMAND Switch BitShift( $wParam, 16 ) ; _WinAPI_HiWord Case $CBN_CLOSEUP ; $idComboBox (Dummy control) event is generated when ListBox is closed GUICtrlSendToDummy( $aCheckboxCombo_Info[$iIdx][5] ) ; Dummy control EndSwitch Functions CheckboxCombo_Create() creates the Combo control but returns a Dummy control as mentioned above. CheckboxCombo_GetChecked() takes controlID (Dummy control) as input and returns checked items. CheckboxCombo_Delete() takes controlID (Dummy control) as input and deletes control. Example CheckboxCombo, 2D array.au3: ;#include <Array.au3> #include <GUIConstantsEx.au3> #include "..\Includes\CheckboxCombo.au3" Example() Func Example() ; Create GUI GUICreate( "Checkbox Combo", 220, 244 ) ; Combo items Local $aItems = [ [ "Item0" ], _ [ "Item1" ], _ [ "Item2", 1 ], _ ; Item2 is checked [ "Item3" ], _ [ "Item4", 1 ], _ ; Item4 is checked [ "Item5" ], _ [ "Item6", 1 ], _ ; Item6 is checked [ "Item7" ], _ [ "Item8" ], _ [ "Item9" ] ] ; Create Checkbox Combo Local $idComboBox = CheckboxCombo_Create( 10, 10, 200, 20, 10, $aItems ) ; Show GUI GUISetState() ; Message loop While 1 Switch GUIGetMsg() Case $idComboBox ConsoleWrite( "Checked items: " & CheckboxCombo_GetChecked( $idComboBox ) & @CRLF ) ;Local $aChecked = CheckboxCombo_GetChecked( $idComboBox, 1 ) ;_ArrayDisplay( $aChecked ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete() EndFunc Zip-file You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. CheckboxCombo.7z
    1 point
  4. mikell

    HTTPS Post and Request

    Ohhh Danyfirex Last gift $array = StringRegExp($response, '(\d+\.\d+)', 3) But reading the helpfile is not such a bad idea
    1 point
  5. This can be done with UI Automation 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 $tIUIAutomationPropertyChangedEventHandler, $oIUIAutomationPropertyChangedEventHandler Global $oUIAutomation Example() Func Example() $oIUIAutomationPropertyChangedEventHandler = ObjectFromTag( "oIUIAutomationPropertyChangedEventHandler_", $dtagIUIAutomationPropertyChangedEventHandler, $tIUIAutomationPropertyChangedEventHandler, True ) If Not IsObj( $oIUIAutomationPropertyChangedEventHandler ) Then Return $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return Local $pUIElement $oUIAutomation.GetRootElement( $pUIElement ) ; Desktop If Not $pUIElement Then Return Local $tPropertyArray = DllStructCreate( "int[1]" ) DllStructSetData( $tPropertyArray, 1, $UIA_WindowWindowVisualStatePropertyId, 1 ) $oUIAutomation.AddPropertyChangedEventHandlerNativeArray( $pUIElement, $TreeScope_Descendants, 0, $oIUIAutomationPropertyChangedEventHandler, $tPropertyArray, 2 ) ; Add the PropertyChangedEventHandler $oUIAutomation.AddPropertyChangedEventHandler( $pUIElement, $TreeScope_Descendants, 0, $oIUIAutomationPropertyChangedEventHandler, Ptr($tPropertyArray)) HotKeySet( "{ESC}", "Quit" ) While Sleep(100) WEnd EndFunc Func Quit() $oIUIAutomationPropertyChangedEventHandler = 0 DeleteObjectFromTag( $tIUIAutomationPropertyChangedEventHandler ) Exit EndFunc Func _UIA_getPropertyValue( $obj, $id ) Local $vVal $obj.GetCurrentPropertyValue( $id, $vVal ) Return $vVal EndFunc Func oIUIAutomationPropertyChangedEventHandler_HandlePropertyChangedEvent( $pSelf, $pSender, $iPropertyId, $newValue ) ; Ret: long Par: ptr;int;ptr ConsoleWrite( @CRLF & "oIUIAutomationPropertyChangedEventHandler_HandlePropertyChangedEvent: $iPropertyId = " & $iPropertyId & ", $newValue = " & $newValue & @CRLF ) Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oSender.AddRef() ConsoleWrite( "Handle " & _UIA_getPropertyValue( $oSender, $UIA_NativeWindowHandlePropertyId ) & @CRLF ) ConsoleWrite( "Name " & _UIA_getPropertyValue( $oSender, $UIA_NamePropertyId ) & @CRLF ) ConsoleWrite( "Class " & _UIA_getPropertyValue( $oSender, $UIA_ClassNamePropertyId ) & @CRLF ) ConsoleWrite( "Ctrl type " & _UIA_getPropertyValue( $oSender, $UIA_ControlTypePropertyId ) & @CRLF ) ConsoleWrite( "Ctrl name " & _UIA_getPropertyValue( $oSender, $UIA_LocalizedControlTypePropertyId ) & @CRLF ) ConsoleWrite( "Value " & _UIA_getPropertyValue( $oSender, $UIA_LegacyIAccessibleValuePropertyId ) & @CRLF ) ConsoleWrite( "State " & _UIA_getPropertyValue( $oSender, $UIA_WindowWindowVisualStatePropertyId ) & @CRLF ) Return $S_OK EndFunc Func oIUIAutomationPropertyChangedEventHandler_QueryInterface( $pSelf, $pRIID, $pObj ) ; Ret: long Par: ptr;ptr* Local $sIID = StringFromGUID( $pRIID ) If $sIID = $sIID_IUnknown Then ConsoleWrite( "oIUIAutomationPropertyChangedEventHandler_QueryInterface: IUnknown" & @CRLF ) DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf ) Return $S_OK ElseIf $sIID = $sIID_IUIAutomationPropertyChangedEventHandler Then ConsoleWrite( "oIUIAutomationPropertyChangedEventHandler_QueryInterface: IUIAutomationPropertyChangedEventHandler" & @CRLF ) DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf ) Return $S_OK Else ConsoleWrite( "oIUIAutomationPropertyChangedEventHandler_QueryInterface: " & $sIID & @CRLF ) Return $E_NOINTERFACE EndIf EndFunc Func oIUIAutomationPropertyChangedEventHandler_AddRef( $pSelf ) ; Ret: ulong ConsoleWrite( "oIUIAutomationPropertyChangedEventHandler_AddRef" & @CRLF ) Return 1 EndFunc Func oIUIAutomationPropertyChangedEventHandler_Release( $pSelf ) ; Ret: ulong ConsoleWrite( "oIUIAutomationPropertyChangedEventHandler_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 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 Run the code in SciTE. Press Esc to exit. Window state values: ;enum WindowVisualState Global Const $WindowVisualState_Normal=0 Global Const $WindowVisualState_Maximized=1 Global Const $WindowVisualState_Minimized=2 See also this post. CUIAutomation2.7z
    1 point
×
×
  • Create New...