Leaderboard
Popular Content
Showing content with the highest reputation on 10/15/2022 in all areas
-
Read Date
Danp2 reacted to pixelsearch for a topic
Hello. What I quickly notice is this : * _GUICtrlDTP_Create() returns a handle * GUICtrlRead() requires a control identifier (controlID) as returned by a GUICtrlCreate...() function.1 point -
When you dispose the image, then set the handle in variable to 0.1 point
-
Problem with Edit Control (Long Time User)
ahha reacted to pixelsearch for a topic
Maybe because you placed the statement before GUISetState ? It works for me, only when placed after GUISetState : #include <GUIConstants.au3> #include <GuiEdit.au3> Local $GUIWidth = 800 Local $LogWindowHeight = 326 Local $hMainGUI = GUICreate("Test", $GUIWidth, 50 + $LogWindowHeight, -1, -1, $WS_SIZEBOX) Local $EditText = "This is Line 1" & @CRLF & "This is Line 2" Local $LogWindowID = GUICtrlCreateEdit($EditText, 20, 25, $GUIWidth - 40, $LogWindowHeight - 20, _ $ES_MULTILINE + $ES_WANTRETURN + $WS_HSCROLL + $ES_READONLY) GUISetState() _GUICtrlEdit_SetSel($LogWindowID, -1, 0) ; ok when placed after GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete()1 point -
You can use this script to query/set microphone by going thru systray options. You need to provide all 3 strings that defines your systray sound button (button, device type, and device). I gave you french version. The speaker button needs to be visible. Tested on win7. #NoTrayIcon #include "Includes\CUIAutomation2.au3" #include <Constants.au3> #include <Array.au3> Opt("MustDeclareVars", 1) Local $aMenu = _Systray_SelectOption("Haut-parleurs", "Périphériques d’enregistrement", "Microphone") If IsArray ($aMenu) Then _ArrayDisplay ($aMenu) Func _Systray_SelectOption($sButton, $sDeviceType, $sDevice) Local $hWnd = WinGetHandle('[Class:Shell_TrayWnd]') If Not $hWnd Then Return SetError(1) Local $hCtrl = ControlGetHandle($hWnd, '', "ToolbarWindow321") ; must be visible If Not $hCtrl Then Return SetError(2) ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If Not IsObj($oUIAutomation) Then Return ConsoleWrite("$oUIAutomation ERR" & @CRLF) ConsoleWrite("$oUIAutomation OK" & @CRLF) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement($pDesktop) $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oDesktop) Then Return ConsoleWrite("$oDesktop ERR" & @CRLF) ConsoleWrite("$oDesktop OK" & @CRLF) ; Get element by handle Local $pElement, $oElement $oUIAutomation.ElementFromHandle($hCtrl, $pElement) $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oElement) Then Return ConsoleWrite("$oElement ERR" & @CRLF) ConsoleWrite("$oElement OK" & @CRLF) ; Get condition (ControlType = Button) Local $pCondition, $oCondition $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition) $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition) If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF) ConsoleWrite("$oCondition OK" & @CRLF) ; Find all buttons Local $pElementArray, $oElementArray, $iElements $oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray) $oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) $oElementArray.Length($iElements) If Not IsObj($oElementArray) Then Return ConsoleWrite("$oElementArray ERR" & @CRLF) ConsoleWrite("$oElementArray OK" & @CRLF) ; Get array of buttons Local $aElements[$iElements] For $i = 0 To $iElements - 1 $oElementArray.GetElement($i, $pElement) $aElements[$i] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) Next ; Get name and position for each button Local $vValue, $aPos, $bFound = False Local $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom") Local $tPoint = DllStructCreate("long X;long Y"), $bBool, $oSound For $i = 0 To UBound($aElements) - 1 $aElements[$i].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue) ConsoleWrite("Name:" & $vValue) $aElements[$i].CurrentBoundingRectangle($tRect) ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF) $aElements[$i].GetClickablePoint($tPoint, $bBool) If StringInStr($vValue, $sButton) Then MouseClick("Right", $tPoint.X, $tPoint.Y, 1, 1) $bFound = True $oSound = $aElements[$i] ExitLoop EndIf Next Sleep(1500) $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "#32768", $pCondition) If Not $pCondition Then Return ConsoleWrite("$pCondition ERR" & @CRLF) ConsoleWrite("$pCondition OK" & @CRLF) Local $pSound, $oObject $oDesktop.FindFirst($TreeScope_Descendants, $pCondition, $pSound) $oObject = ObjCreateInterface($pSound, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oObject) Then Return ConsoleWrite("$oObject ERR" & @CRLF) ConsoleWrite("$oObject OK" & @CRLF) $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, $sDeviceType, $pCondition) $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition) If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF) ConsoleWrite("$oCondition OK" & @CRLF) $oObject.FindFirst($TreeScope_Descendants, $pCondition, $pSound) $oSound = ObjCreateInterface($pSound, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oSound) Then Return ConsoleWrite("$oSound ERR" & @CRLF) ConsoleWrite("$oSound OK" & @CRLF) $oSound.GetCurrentPropertyValue($UIA_NamePropertyId, $vValue) ConsoleWrite("Name:" & $vValue) $oSound.CurrentBoundingRectangle($tRect) ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF) $oSound.GetClickablePoint($tPoint, $bBool) MouseClick("left", $tPoint.X, $tPoint.Y, 1, 1) Sleep (1500) $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "#32770", $pCondition) $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition) If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF) ConsoleWrite("$oCondition OK" & @CRLF) $oDesktop.FindFirst($TreeScope_Children, $oCondition, $pElement) $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oElement) Then Return ConsoleWrite("$oElement ERR" & @CRLF) ConsoleWrite("$oElement OK" & @CRLF) $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "SysListView32", $pCondition) $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition) If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF) ConsoleWrite("$oCondition OK" & @CRLF) $oElement.FindFirst($TreeScope_Children, $oCondition, $pElement) $oObject = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oObject) Then Return ConsoleWrite("$oObject ERR" & @CRLF) ConsoleWrite("$oObject OK" & @CRLF) $oUIAutomation.CreatePropertyCondition($UIA_NamePropertyId, $sDevice, $pCondition) $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition) If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF) ConsoleWrite("$oCondition OK" & @CRLF) $oObject.FindFirst($TreeScope_Children, $oCondition, $pElement) $oSound = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oSound) Then Return ConsoleWrite("$oSound ERR" & @CRLF) ConsoleWrite("$oSound OK" & @CRLF) $oSound.GetCurrentPropertyValue($UIA_NamePropertyId, $vValue) ConsoleWrite("Name:" & $vValue) $oSound.CurrentBoundingRectangle($tRect) ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF) $oSound.GetClickablePoint($tPoint, $bBool) MouseClick ("Right", $tPoint.X, $tPoint.Y+10, 1, 1) Sleep (1000) $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "#32768", $pCondition) If Not $pCondition Then Return ConsoleWrite("$pCondition ERR" & @CRLF) ConsoleWrite("$pCondition OK" & @CRLF) $oDesktop.FindFirst($TreeScope_Descendants, $pCondition, $pSound) $oObject = ObjCreateInterface($pSound, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oObject) Then Return ConsoleWrite("$oObject ERR" & @CRLF) ConsoleWrite("$oObject OK" & @CRLF) ; Get condition (ControlType = Menu Items) $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_MenuItemControlTypeId, $pCondition) $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition) If Not IsObj($oCondition) Then Return ConsoleWrite("$oCondition ERR" & @CRLF) ConsoleWrite("$oCondition OK" & @CRLF) ; Find all menu items $oObject.FindAll($TreeScope_Children, $oCondition, $pElementArray) $oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) $oElementArray.Length($iElements) If Not IsObj($oElementArray) Then Return ConsoleWrite("$oElementArray ERR" & @CRLF) ConsoleWrite("$oElementArray OK" & @CRLF) ; Get array of menu items Local $aElements[$iElements][4] For $i = 0 To $iElements - 1 $oElementArray.GetElement($i, $pElement) $aElements[$i][0] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) Next ; Get name and position for each menu items For $i = 0 To $iElements - 1 $aElements[$i][0].GetCurrentPropertyValue($UIA_NamePropertyId, $vValue) ConsoleWrite("Name:" & $vValue) $aElements[$i][1] = $vValue $aElements[$i][0].CurrentBoundingRectangle($tRect) ConsoleWrite(" L:" & $tRect.Left & " T:" & $tRect.Top & " R:" & $tRect.Right & " B:" & $tRect.Bottom & @CRLF) $aElements[$i][0].GetClickablePoint($tPoint, $bBool) $aElements[$i][2] = $tPoint.X $aElements[$i][3] = $tPoint.Y Next Return $aElements EndFunc ;==>_Systray_SelectOption1 point