What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Press an AddOn Button

Inrego

New Member
Joined
Feb 7, 2010
Messages
2,765
Reaction score
71
Hey I'm fiddling around with getting HB to click a button of an AddOn. It's some auctioning addon where I need it to press the button to post the auction. The AddOn dev has given some macros to press said button, but when I have HB click it, the button just turns grey and nothing more happens. If I click the macro manually, there are no problems.
I've tried

Code:
Lua.DoString(string.Format("RunMacroText(\"{0}\")", "/click ButtonName"), 0);
I've also tried making a macro with /click ButtonName and then doing
Code:
Lua.DoString("RunMacro('post')");
I've even tried running the buttons action directly through HB with the lua, and still, the button just turns grey.

Any ideas how to make it work?
 
Hey I'm fiddling around with getting HB to click a button of an AddOn. It's some auctioning addon where I need it to press the button to post the auction. The AddOn dev has given some macros to press said button, but when I have HB click it, the button just turns grey and nothing more happens. If I click the macro manually, there are no problems.
I've tried

Code:
Lua.DoString(string.Format("RunMacroText(\"{0}\")", "/click ButtonName"), 0);
I've also tried making a macro with /click ButtonName and then doing
Code:
Lua.DoString("RunMacro('post')");
I've even tried running the buttons action directly through HB with the lua, and still, the button just turns grey.

Any ideas how to make it work?
The button is executing lua that requires a hardware event. Clicking the button in game or pressing a macro key in game will trigger this event. Lua.DoString() can execute lua that requires hardware event if executed directly. Calling buttons click() function will not work since it's indirect.

2 options exist.
1) look at the lua source for the button and place the code directly in Lua.DoString()
You'll run into issues if code in button's click function uses addon local variable.
This option is harder as it requires knowing lua (easy to learn language btw)
2) Use of HB's KeyboardManager class. For example KeyboardManager.PressKey('1') will press the number 1 button. This should work though I've never bothered trying.

one more thing. Calling KeyboardManager.AntiAfk() just before you call
Code:
Lua.DoString("ButtonName:Click()");
will sometimes work but not allways. Thats why I didn't list it as an option.
There is one thing you can try though that might work always.
Code:
            using (new FrameLock())
            {
                KeyboardManager.AntiAfk();
                Lua.DoString("ButtonName:Click()");
            }
FrameLock cause everything inside its block to run in one frame tick.
 
Last edited:
Thanks highvoltz. This gave a little more information than I had already. I've already tried running the lua as you suggest, but that didn't work either, the button still just turned grey since there was no hardware event. I also tried KeyboardManager.PressKey('1') which did nothing at all (was kinda fuzzed about this).
So last thing I can try is the ButtonName:Click
How would I go about adding that framelock with those 2 in a PB Custom Code? :P
 
Back
Top