Maximilian Wonschik
Maximilian Wonschik

Reputation: 3

How do I change the Value of a Combobox I didn't create without getting a critical Error: (0x80131509) in AutoHotkey V2 using UIA2?

I want to make a Program which can export STEP-Files into STL-Files. (I'm pretty new to AutoHotkey V2 (AutoHotkey in general).) For this, I'm using UIA2 from Descolada. I need to change the value of a combobox so it has the value "STL-Dateien (*.stl)". However, I can't just change the Value of the combobox because it gives me a fatal error afterwards and the program shuts violently down.

Moreover, the biggest problem is that I could just hard-code it and make it so the program clicks on the List afterwards, but the elements of the List don't have any window attached to it so UIA doesn't work.

Here is a part of the script:

#Requires AutoHotkey v2.0
#include ...Lib\UIA.ahk
#SingleInstance Force

    inventSave := UIA.ElementFromHandle("Speichern unter ahk_exe Inventor.exe")

    cbx := inventSave.WaitElement({AutomationId:"1136"})
    value := cbx.GetPattern("value")
    value.SetValue("STL-Dateien (*.stl)")


I tried searching for possible answers and found out that this error-code is (I think) unique to the UIA-library because I found others who had the same issue.

However, they had created the combobox themselves, unlike me who has to change the value of an already existing one. I also watched all Videos from Descolada himself and I couldn't figure anything out how to change the value so it corresponds to the actual combobox-value and doesn't crash (it shows the correct listitem name but it still crashes). Could it be that the items in the combobox are saved as an array and I can access them like that? I have no idea how to start even finding this information out though.

I expected it to just take the value I hard-coded because it is the exact value which UIAViewer gives to me for this specific listitem. It's probably something trivial, but I already troubleshooted this script for like 6 hours today. Would appreciate any help and sorry if this question is not posted correctly I'm new here.

EDIT:

I kind of solved my question, but not my problem. I did change the value, however it still didn't invoke any changes in the options' menu how I wanted. I set cbx.SetValue("STL-Dateien (*.stl)") cbx.InvokePattern() and it changed the value but not the state of the combobox. I tried .Invoke, but it still didn't work.

Upvotes: 0

Views: 65

Answers (0)

Related Questions