Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/02/2024 in all areas

  1. Yep absolutely agree. Resource management and error handling had already gone out the window, so I decided the slap-dash approach was good enough for a demo! I'll have a proper run at putting something together soon and report back. Think I'm starting to get a handle on things too, so shouldn't need that console output. But thanks, I did appreciate the support Lastly, I finally managed to pull those descriptor blobs! Well the EDID of my screen anyway.The DisplayID block - if present - needs to be a particular version for windows to use it, so I guess it's not surprising that mine doesn't show. #AutoIt3Wrapper_UseX64=Y #Tidy_Parameters=/sf #include <winapi.au3> #include <array.au3> ; Com error code reference: ; https://learn.microsoft.com/en-us/windows/win32/com/com-error-codes-1 Global $hDLLComBase = DllOpen("Combase.dll") Global Const $PTR_LEN = @AutoItX64 ? 8 : 4 Global Const $sIUnknown = "{00000000-0000-0000-C000-000000000046}" Global Const $sIInspectable = "{AF86E2E0-B12D-4c6a-9C5A-D7AA65101E90}" Global Const $sIActivationFactory = "{00000035-0000-0000-C000-000000000046}" Global Const $sIDisplayMonitorStatics = "{6EAE698F-A228-4C05-821D-B695D667DE8E}" Global Const $sIDeviceInformationStatics = "{C17F100E-3A46-4A78-8013-769DC9B97390}" Global Const $sIAsyncInfo = "{00000036-0000-0000-C000-000000000046}" Global Const $sIDeviceInformation = "{ABA0FB95-4398-489D-8E44-E6130927011F}" Global Const $sIDisplayMonitor = "{1f6b15d4-1d01-4c51-87e2-6f954a772b59}" Global Enum $Async_Started = 0, $Async_Completed, $Async_Canceled, $Async_Error ConsoleWrite("Get AQS String" & @CRLF) ConsoleWrite('Get "Windows.Devices.Display.DisplayMonitor" Activation Factory, IDisplayMonitorStatics' & @CRLF) $pMonStatics = RoGetActivationFactory("Windows.Devices.Display.DisplayMonitor", $sIDisplayMonitorStatics) DispError() ConsoleWrite("Call IDisplayMonitorStatics::GetDeviceSelector" & @CRLF) $sDevSelector = IDisplayMonitorStatics_GetDeviceSelector($pMonStatics) DispError() ConsoleWrite($sDevSelector & @CRLF) ConsoleWrite(@CRLF) ConsoleWrite("Get Device Collection:" & @CRLF) ConsoleWrite('Get "Windows.Devices.Enumeration.DeviceInformation" Activation Factory, IDeviceInformationStatics' & @CRLF) $pDevInfoFact = RoGetActivationFactory("Windows.Devices.Enumeration.DeviceInformation", $sIDeviceInformationStatics) DispError() ConsoleWrite("Call IDeviceInformationStatics::FindAllAsyncAqsFilter with AQS string that we aquired earlier" & @CRLF) $pAsync = IDeviceInformationStatics_FindAllAsyncAqsFilter($pDevInfoFact, $sDevSelector) DispError() ConsoleWrite("Wait for Async routine..." & @CRLF) ConsoleWrite("Get AsyncInfo Interface:" & @CRLF) $pAsyncInfo = IUnknown_QueryInterface($pAsync, $sIAsyncInfo) DispError() Do Sleep(10) Until IAsyncInfo_Status($pAsyncInfo) ConsoleWrite("Async Finished. We want the status to be 1 - i.e. 'completed':" & @CRLF) ConsoleWrite("Async status=" & IAsyncInfo_Status($pAsyncInfo) & @CRLF) ConsoleWrite("GetResult of Async:" & @CRLF) $pDevInfoCol = IAsyncOperation_GetResults($pAsync) DispError() ConsoleWrite("Collection size=" & IVectorView_Size($pDevInfoCol) & @CRLF) ConsoleWrite(@CRLF) ConsoleWrite("Get First DisplayMonitor Obj" & @CRLF) ConsoleWrite("Get the fisrt item of our collection:" & @CRLF) $pDevinfo = IVectorView_GetAt($pDevInfoCol, 0) DispError() ConsoleWrite("Get the name:" & @CRLF) $sDevName = IDeviceInformation_Name($pDevinfo) DispError() ConsoleWrite("Device Name = " & $sDevName & @CRLF) ConsoleWrite("Get Device Interface ID:" & @CRLF) $sDevInterfaceId = IDeviceInformation_Id($pDevinfo) DispError() ConsoleWrite($sDevInterfaceId & @CRLF) ConsoleWrite("Get DisplayMonitor from Device Interface Id:" & @CRLF) $pAsync2 = IDisplayMonitorStatics_FromInterfaceIdAsync($pMonStatics, $sDevInterfaceId) DispError() ConsoleWrite("Kick off Async..." & @CRLF) $pAsyncInfo2 = IUnknown_QueryInterface($pAsync2, $sIAsyncInfo) DispError() Do Sleep(10) Until IAsyncInfo_Status($pAsyncInfo2) ConsoleWrite("Get the object." & @CRLF) $pMonitor = IAsyncOperation_GetResults($pAsync2) DispError() ConsoleWrite("Confirm what we have (cause we can!)" & @CRLF) ConsoleWrite(IInspectable_GetRuntimeClassName($pMonitor) & @CRLF) DispError() ConsoleWrite(@CRLF) ConsoleWrite("Get descriptors..." & @CRLF) ConsoleWrite("Display EDID:" & @CRLF) ConsoleWrite(IDisplayMonitor_GetDescriptor($pMonitor, 0) & @CRLF) ConsoleWrite("Display DisplayID:" & @CRLF) ConsoleWrite(IDisplayMonitor_GetDescriptor($pMonitor, 1) & @CRLF) ConsoleWrite(@CRLF) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func CoTaskMemFree($pBlock) DllCall("ole32.dll", "none", "CoTaskMemFree", "ptr", $pBlock) EndFunc ;==>CoTaskMemFree Func CreateGUID($sGUID) Local $tGUID = DllStructCreate($tagGUID) $aGUID = StringSplit(StringRegExpReplace($sGUID, "[{}]", ""), "-", 2) If UBound($aGUID) <> 5 Then Return False $tGUID.Data1 = Dec($aGUID[0]) $tGUID.Data2 = Dec($aGUID[1]) $tGUID.Data3 = Dec($aGUID[2]) $tGUID.Data4 = Binary("0x" & $aGUID[3] & $aGUID[4]) Return $tGUID EndFunc ;==>CreateGUID Func CreateHString($sString) Local $aCall = DllCall($hDLLComBase, "int", "WindowsCreateString", "wstr", $sString, "uint", StringLen($sString), "ptr*", 0) If Not @error Then Return $aCall[3] EndFunc ;==>CreateHString Func DeleteHString(ByRef $hString) Local $aCall = DllCall($hDLLComBase, "int", "WindowsDeleteString", "ptr", $hString) If Not @error Then $hString = 0 EndFunc ;==>DeleteHString Func DispError($iError = @error, $iScriptLineNumber = @ScriptLineNumber) Local Const $iMaxWidth = 0xFF Local $iFlags = $FORMAT_MESSAGE_FROM_SYSTEM Local $tBuff = DllStructCreate(StringFormat("wchar[%d]", $iMaxWidth)) Local $pBuff = DllStructGetPtr($tBuff) Local $iCount = _WinAPI_FormatMessage($iFlags, 0, $iError, 0, $pBuff, $iMaxWidth, 0) ConsoleWrite('(' & $iScriptLineNumber & ",0) [0x" & Hex($iError) & "] " & StringStripWS(DllStructGetData($tBuff, 1), 3) & @CRLF) EndFunc ;==>DispError Func GetPtrAt($pPtr) Local $tPtr = DllStructCreate("ptr ptr", $pPtr) Return $tPtr.ptr EndFunc ;==>GetPtrAt Func IActivationFactory_ActivateInstance($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 6 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr*", 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>IActivationFactory_ActivateInstance Func IAsyncInfo_Cancel($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 9 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis) Return SetError($aCall[0]) EndFunc ;==>IAsyncInfo_Cancel Func IAsyncInfo_Close($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 10 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis) Return SetError($aCall[0]) EndFunc ;==>IAsyncInfo_Close Func IAsyncInfo_ErrorCode($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 8 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "long*", 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>IAsyncInfo_ErrorCode Func IAsyncInfo_ID($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 6 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "uint*", 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>IAsyncInfo_ID Func IAsyncInfo_Status($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 7 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "uint*", 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>IAsyncInfo_Status Func IAsyncOperation_GetResults($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 8 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr*", 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>IAsyncOperation_GetResults Func IDeviceInformation_EnclosureLocation($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 10 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr*", 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>IDeviceInformation_EnclosureLocation Func IDeviceInformation_Id($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 6 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr*", 0) Local $sID = ReadHString($aCall[2]) DeleteHString($aCall[2]) Return SetError($aCall[0], 0, $sID) EndFunc ;==>IDeviceInformation_Id Func IDeviceInformation_IsDefault($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 9 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "bool*", 0) Return SetError($aCall[0], 0, $aCall[2] = True) EndFunc ;==>IDeviceInformation_IsDefault Func IDeviceInformation_IsEnabled($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 8 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "bool*", 0) Return SetError($aCall[0], 0, $aCall[2] = True) EndFunc ;==>IDeviceInformation_IsEnabled Func IDeviceInformation_Name($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 7 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr*", 0) Local $sName = ReadHString($aCall[2]) DeleteHString($aCall[2]) Return SetError($aCall[0], 0, $sName) EndFunc ;==>IDeviceInformation_Name Func IDeviceInformation_Properties($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 11 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr*", 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>IDeviceInformation_Properties Func IDeviceInformationStatics_FindAllAsyncAqsFilter($pThis, $sFilter) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 10 * $PTR_LEN)) Local $hsFilter = CreateHString($sFilter) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr", $hsFilter, "ptr*", 0) DeleteHString($hsFilter) Return SetError($aCall[0], 0, $aCall[3]) EndFunc ;==>IDeviceInformationStatics_FindAllAsyncAqsFilter Func IDisplayMonitor_GetDescriptor($pThis, $iKind) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 25 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "long", $iKind, "long*", 0, "ptr*", 0) Local $tData $tData = DllStructCreate(StringFormat("byte Data[%d]", $aCall[3]), $aCall[4]) Return SetError($aCall[0], 0, IsDllStruct($tData) ? $tData.Data : Binary("0x")) EndFunc ;==>IDisplayMonitor_GetDescriptor Func IDisplayMonitorStatics_FromInterfaceIdAsync($pThis, $sDevInterfaceId) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 8 * $PTR_LEN)) $hsDevIface = CreateHString($sDevInterfaceId) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr", $hsDevIface, "ptr*", 0) DeleteHString($hsDevIface) Return SetError($aCall[0], 0, $aCall[3]) EndFunc ;==>IDisplayMonitorStatics_FromInterfaceIdAsync Func IDisplayMonitorStatics_GetDeviceSelector($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 6 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr*", 0) Local $sSelector = ReadHString($aCall[2]) DeleteHString($aCall[2]) Return SetError($aCall[0], 0, $sSelector) EndFunc ;==>IDisplayMonitorStatics_GetDeviceSelector Func IInspectable_GetIids($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 3 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "long*", 0, "ptr*", 0) Local $pGUIDArray = $aCall[3], $iError = $aCall[0], $iCount = $aCall[2], $asIIDs[$iCount] For $i = 0 To $iCount - 1 $aCall = DllCall($hDLLComBase, "int", "StringFromIID", "ptr", Ptr($pGUIDArray + ($i * 16)), "wstr*", 0) $asIIDs[$i] = $aCall[2] Next CoTaskMemFree($pGUIDArray) Return SetError($aCall[0], 0, $asIIDs) EndFunc ;==>IInspectable_GetIids Func IInspectable_GetRuntimeClassName($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 4 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "handle*", 0) Local $sClassName = ReadHString($aCall[2]) DeleteHString($aCall[2]) Return SetError($aCall[0], 0, $sClassName) EndFunc ;==>IInspectable_GetRuntimeClassName Func IInspectable_GetTrustLevel($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 5 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "int*", 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>IInspectable_GetTrustLevel Func IUnknown_AddRef($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis) Return $aCall[0] EndFunc ;==>IUnknown_AddRef Func IUnknown_QueryInterface($pThis, $sIID) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt($pVTable) Local $tIID = CreateGUID($sIID) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "struct*", $tIID, "ptr*", 0) Return SetError($aCall[0], 0, $aCall[3]) EndFunc ;==>IUnknown_QueryInterface Func IUnknown_Release($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 2 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis) Return $aCall[0] EndFunc ;==>IUnknown_Release Func IVectorView_GetAt($pThis, $iIndex) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 6 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "uint", $iIndex, "ptr*", 0) Return SetError($aCall[0], 0, $aCall[3]) EndFunc ;==>IVectorView_GetAt Func IVectorView_Size($pThis) Local $pVTable = GetPtrAt($pThis) Local $pFunc = GetPtrAt(Ptr($pVTable + 7 * $PTR_LEN)) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "uint*", 0) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>IVectorView_Size Func ReadGUIDAt($pGUID) Local $tGUID = DllStructCreate($tagGUID, $pGUID) Local $sGUID = "{" $sGUID &= Hex($tGUID.Data1, 8) & "-" $sGUID &= Hex($tGUID.Data2, 4) & "-" $sGUID &= Hex($tGUID.Data3, 4) & "-" $sGUID &= StringMid($tGUID.Data4, 3, 4) & "-" $sGUID &= StringMid($tGUID.Data4, 7, 12) & "}" Return $sGUID EndFunc ;==>ReadGUIDAt Func ReadHString(ByRef $hString) Local $aCall = DllCall($hDLLComBase, "wstr", "WindowsGetStringRawBuffer", "ptr", $hString, "int*", 0) If Not @error Then Return $aCall[0] EndFunc ;==>ReadHString Func RoActivateInstance($sClassID) $hsClassID = CreateHString($sClassID) Local $aCall = DllCall($hDLLComBase, "long", "RoActivateInstance", "handle", $hsClassID, "ptr*", 0) DeleteHString($hsClassID) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>RoActivateInstance Func RoGetActivationFactory($sClassID, $sIID) Local $hsClassID = CreateHString($sClassID) Local $tIID = CreateGUID($sIID) Local $aCall = DllCall($hDLLComBase, "long", "RoGetActivationFactory", "handle", $hsClassID, "ptr", DllStructGetPtr($tIID), "ptr*", 0) DeleteHString($hsClassID) Return SetError($aCall[0], 0, $aCall[3]) EndFunc ;==>RoGetActivationFactory
    2 points
  2. Nine

    Script does not execute

    Seems to me that the WinWaitActive is waiting forever to find the window. Try a WinActivate before, and check if it is finding the right handle... Also you may want to replace your MouseClick with WinMenuSelectItem (see help file)
    1 point
  3. packing a little I removed unused consts and put them inside the function for easier portability
    1 point
  4. The SQL language is based on set theory. If you define a set of RGB colors for instance, that means {'Red', 'Green', 'Blue'} but this set has no inherent ordering. {'Blue', 'Red', 'Green'} is the exact same set. One can sometimes define an ordering on a set but this is NOT a property of the set. So in SQL, "first" and "last" row in a table (= a set) mean nothing. Hopefully in SQL you can use the ORDER BY clause to explicitely define an ordering for the resultset of a query. For instance, you can use: SELECT Product FROM Product_List WHERE category = 'Book' order by no desc limit 1; (note: 'Book' and not "Book") Your "No" column contains an identifier, which is NOT a row sequence number. Think of an identifier as a EAN or UPC barcode label which you can't read by yourself: it uniquely identifies an item but means nothing per se. You should take an SQL primer somewhere on the web.
    1 point
  5. I have done this on my PC, creating a custom weights file. Youtube has some good resources on how to start this process, look for yolo and darknet training. It will take many hours of research, possibly a weekend of learning depending how quick you can pick it up and if your PC can support the training process. I have a RTX 3070 by the way and got it all to work. I was able to install everything needed for free, and using a program called labelimg, also free, start to build a library of labeled images to use to train on. Good Luck with the process.
    1 point
  6. He hasn't log in in 4 years now, but I'll thank you in his behalf 😇 Well, that part is unrelated to the UDF ( that I've tested back in 2020 but never used ). That has to do with the project he left links for on the 1st post. Do go to those links and find out from those references. That is your best bet.
    1 point
×
×
  • Create New...