Page 1 of 1

[Python] NumGumpButton, ReturnValue from ElemNum (solved)

Posted: 23.11.2018 18:45
by sauber
Hi Guys,

I'm inspecting a Gump and a Button.

The problem is that every time this Gump is opened, or I change page. The value of ReturnValue changes

I only want ElemNum 13's ReturnValue

Code: Select all

 'GumpButtons': [{'ElemNum': 1, 'Page': 0, 'PageID': 0, 'PressedID': 22153, 'Quit': 1, 'ReleasedID': 22153, 'ReturnValue': 2488, 'X': 5, 'Y': 5},
                 {'ElemNum': 2, 'Page': 0, 'PageID': 0, 'PressedID': 2435, 'Quit': 1, 'ReleasedID': 2435, 'ReturnValue': 18369, 'X': 30, 'Y': 9},
                 {'ElemNum': 3, 'Page': 0, 'PageID': 0, 'PressedID': 2437, 'Quit': 1, 'ReleasedID': 2437, 'ReturnValue': 6405, 'X': 40, 'Y': 9},
                 {'ElemNum': 4, 'Page': 0, 'PageID': 0, 'PressedID': 1896, 'Quit': 1, 'ReleasedID': 1896, 'ReturnValue': 15019, 'X': 120, 'Y': 5},
                 {'ElemNum': 6, 'Page': 0, 'PageID': 0, 'PressedID': 1896, 'Quit': 1, 'ReleasedID': 1896, 'ReturnValue': 18606, 'X': 135, 'Y': 5},
                 {'ElemNum': 8, 'Page': 0, 'PageID': 0, 'PressedID': 1896, 'Quit': 1, 'ReleasedID': 1896, 'ReturnValue': 13612, 'X': 150, 'Y': 5},
                 {'ElemNum': 10, 'Page': 0, 'PageID': 0, 'PressedID': 1896, 'Quit': 1, 'ReleasedID': 1896, 'ReturnValue': 19094, 'X': 165, 'Y': 5},
                 {'ElemNum': 12, 'Page': 0, 'PageID': 0, 'PressedID': 9701, 'Quit': 1, 'ReleasedID': 9700, 'ReturnValue': 9537, 'X': 80, 'Y': 7},
                 {'ElemNum': 13, 'Page': 0, 'PageID': 0, 'PressedID': 9705, 'Quit': 1, 'ReleasedID': 9704, 'ReturnValue': 19695, 'X': 100, 'Y': 7},

Re: [Python] NumGumpButton, ReturnValue from ElemNum

Posted: 24.11.2018 21:18
by sauber
This seems to work fine (I'm using 8.8.3 Stealth and Python2.7)

simply call the function with the Gump Index number and the Button ElemNum
even if the ReturnValue will change, this function will find it and hit the button for you

Code: Select all

def findReturnValue(gump_index, btnElemNum): 
   txt = GetGumpInfo(gump_index) 
   Wait(10)      
   for dicts in txt['GumpButtons']:
      if dicts['ElemNum'] == btnElemNum:
         NumGumpButton(gump_index,dicts['ReturnValue']) 

Re: [Python] NumGumpButton, ReturnValue from ElemNum (solved

Posted: 24.11.2018 21:46
by nah nah
why 2.7?

Re: [Python] NumGumpButton, ReturnValue from ElemNum (solved

Posted: 25.11.2018 2:32
by sauber
When I started playing around with python 4 years ago, version 2.7 was more stable.
I took a long break and I didn’t research much about its development.
It should be fine with all other versions, it’s a really simple function.
Anyway hope this will help a lot of newbies!