Author Topic: Adding a hotkey  (Read 3546 times)

0 Members and 1 Guest are viewing this topic.

Offline CuemifTopic starter

  • Jr. Member
  • **
  • Posts: 41
  • Activity:
    0%
  • Reputation Power: 1
  • Cuemif has no influence.
  • Respect: +5
  • Referrals: 1
    • View Profile
Adding a hotkey
« on: October 06, 2010, 05:48:47 AM »
0
I was trying to add a hot key to this here script was wondering if I could get a quick help out with it as my attempts are fail

Code: [Select]
set %bag_to_keep_open_1 VACTRMD
set %bag_to_keep_open_2 BOPVKMD


set #lobjectID %bag_to_keep_open_1
event macro 17
wait 10
set #lobjectID %bag_to_keep_open_2
event macro 17
wait 10

Thank you so much and sorry about my lame newbness

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Adding a hotkey
« Reply #1 on: October 06, 2010, 06:19:37 AM »
0
What are you trying to accomplish by hitting the hotkey?
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Adding a hotkey
« Reply #2 on: October 06, 2010, 06:24:14 AM »
0
Code: [Select]
; near the beginning of the script in the setup
set %bag_to_keep_open_1 VACTRMD
set %hotkey_to_open_bag_1 F1

set %bag_to_keep_open_2 BOPVKMD
set %hotkey_to_open_bag_2 F2

; then in the mainloop of the script
onhotkey %bag_to_keep_open_1
gosub open_bag %bag_to_keep_open_1

onhotkey %bag_to_keep_open_2
gosub open_bag %bag_to_keep_open_2

; then somewhere out of the way (end) of the script
sub open_bag
set #lobjectID %1
event macro 17
wait 10
return

Please note that onhotkey isn't an instant key press and action. You often have to hold down the key for like half a second to get it to "take".
« Last Edit: October 06, 2010, 06:25:53 AM by Cerveza »
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline CuemifTopic starter

  • Jr. Member
  • **
  • Posts: 41
  • Activity:
    0%
  • Reputation Power: 1
  • Cuemif has no influence.
  • Respect: +5
  • Referrals: 1
    • View Profile
Re: Adding a hotkey
« Reply #3 on: October 06, 2010, 10:48:55 AM »
0
Ok what I added there is my script. I do not think that there is a loop . GOD I am a newb I should just stop trying lol sorry . Please help if you can later

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Adding a hotkey
« Reply #4 on: October 06, 2010, 10:56:03 AM »
0
The script must have a main loop. Your still trying to use this with CEO's medic, right?

Look for a line with this

Mainloop:

and put this in under it...
Code: [Select]
; then in the mainloop of the script
onhotkey %bag_to_keep_open_1
gosub open_bag %bag_to_keep_open_1

onhotkey %bag_to_keep_open_2
gosub open_bag %bag_to_keep_open_2

Make sure you have the setup stuff at the beginning and the sub at the end.
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline CuemifTopic starter

  • Jr. Member
  • **
  • Posts: 41
  • Activity:
    0%
  • Reputation Power: 1
  • Cuemif has no influence.
  • Respect: +5
  • Referrals: 1
    • View Profile
Re: Adding a hotkey
« Reply #5 on: October 06, 2010, 11:36:06 AM »
0
Ok I added
Code: [Select]
set %hotkey_bag_to_keep_open_1 Mat top of script
And then right below Mainloop: I added
Code: [Select]
onhotkey %bag_to_keep_open_1
gosub open_bag %bag_to_keep_open_1

Then at bottom of script I added this
Code: [Select]
sub open_bag
set #lobjectID %1
event macro 17
wait 10
return

It still does not work I even held the M key down for about 5 secs what might I be doing wrong ?

Offline Cerveza

  • Hacksimus Maximus
  • Scripthack
  • *
  • Posts: 5857
  • Activity:
    0%
  • Reputation Power: 80
  • Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!Cerveza is awe-inspiring!
  • Gender: Male
  • So... Hows that Hopey-Changey thing working out?
  • Respect: +403
  • Referrals: 11
    • View Profile
Re: Adding a hotkey
« Reply #6 on: October 06, 2010, 11:46:54 AM »
0
You have your hotkey set to the variable

%hotkey_bag_to_keep_open_1

but when you call that hotkey you are calling a different variable

%bag_to_keep_open_1 <- notice it's different, missing "hotkey_"

You can shorten or rename this stuff to whatever makes it easier for you....

set %hotkey_1 M
set %bag_1 VACTRMD

onhotkey %hotkey_1
  gosub open_bag %bag_1

« Last Edit: October 06, 2010, 11:48:52 AM by Cerveza »
XXXXXXXXXX________________________________________] 20%
I've forgotten more about this game then most people will ever know.
Thank you for controlling your children. Their manners reflect your love for them.
Give a man a fish and you feed him for a day. Don't teach a man to fish, and you feed yourself. He's a grown man. Fishing's not that hard.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Adding a hotkey
« Reply #7 on: October 06, 2010, 12:08:59 PM »
0
Something for everyone to consider when using hotkeys.  Since onhotkey isn't latched, it's easy to miss the key.  People originally reported in the CLAw that it would take quite a bit of time for the script to react to keyboard selections.  My solution was to build a function that would just set flags and allow the script to handle a successful keypress later.  So I had a function:

Code: [Select]
;-------------------------------------------------------------------------------
sub CheckHotKey
  menu get EUOEditKey1
  onhotkey #MENURES ALT
    set %targetkey #TRUE
  menu get EUOEditKey2
  onhotkey #MENURES ALT
    set %lootarea #TRUE
return

And then I could pepper the code with "gosub CheckHotKey" to scan and capture at a higher rate.  Then you just look at the variables %targetkey and %lootarea to make the call that a key has been pressed.

To get onhotkey to be response, I'd just do this:

Code: [Select]
gosub HandleItemLoggingToHistory
gosub CheckHotKey
gosub VerifyLootCheckmarks
gosub CheckHotKey
gosub ManageIgnoreList
gosub CheckHotKey
gosub HandleExternalInterface
gosub CheckHotKey

No more hotkey lag complaints.... ;)
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline CuemifTopic starter

  • Jr. Member
  • **
  • Posts: 41
  • Activity:
    0%
  • Reputation Power: 1
  • Cuemif has no influence.
  • Respect: +5
  • Referrals: 1
    • View Profile
Re: Adding a hotkey
« Reply #8 on: October 06, 2010, 12:12:40 PM »
0
Something for everyone to consider when using hotkeys.  Since onhotkey isn't latched, it's easy to miss the key.  People originally reported in the CLAw that it would take quite a bit of time for the script to react to keyboard selections.  My solution was to build a function that would just set flags and allow the script to handle a successful keypress later.  So I had a function:

Code: [Select]
;-------------------------------------------------------------------------------
sub CheckHotKey
  menu get EUOEditKey1
  onhotkey #MENURES ALT
    set %targetkey #TRUE
  menu get EUOEditKey2
  onhotkey #MENURES ALT
    set %lootarea #TRUE
return

And then I could pepper the code with "gosub CheckHotKey" to scan and capture at a higher rate.  Then you just look at the variables %targetkey and %lootarea to make the call that a key has been pressed.

To get onhotkey to be response, I'd just do this:

Code: [Select]
gosub HandleItemLoggingToHistory
gosub CheckHotKey
gosub VerifyLootCheckmarks
gosub CheckHotKey
gosub ManageIgnoreList
gosub CheckHotKey
gosub HandleExternalInterface
gosub CheckHotKey

No more hotkey lag complaints.... ;)

Yes the lag is crazy BUT the above confuses me lol

Offline CuemifTopic starter

  • Jr. Member
  • **
  • Posts: 41
  • Activity:
    0%
  • Reputation Power: 1
  • Cuemif has no influence.
  • Respect: +5
  • Referrals: 1
    • View Profile
Re: Adding a hotkey
« Reply #9 on: October 06, 2010, 12:21:50 PM »
0
I am gonna have to figure this out

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Adding a hotkey
« Reply #10 on: October 06, 2010, 12:39:24 PM »
0
Really what I'm doing is just calling onhotkey lots more times and registering the occurrences instead of missing them.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline CuemifTopic starter

  • Jr. Member
  • **
  • Posts: 41
  • Activity:
    0%
  • Reputation Power: 1
  • Cuemif has no influence.
  • Respect: +5
  • Referrals: 1
    • View Profile
Re: Adding a hotkey
« Reply #11 on: October 06, 2010, 12:46:35 PM »
0
So... all I need to do is add
Code: [Select]
onhotkey %bag_to_keep_open_2
gosub open_bag %bag_to_keep_open_2

Here there and everywhere?

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13303
  • Activity:
    0.4%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Adding a hotkey
« Reply #12 on: October 06, 2010, 01:12:50 PM »
0
Sorry, may have confused you with a more advanced thought.  You should look at EasyUO the exact syntax of onhotkey.  It's looking for the arguments of the key.  In my case I had F1 in the menures variable so I'm looking for:

onhotkey F1 ALT

This returns true.

Other than that, pay no attention to my post; it's probably more than you need and hard to explain.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline CuemifTopic starter

  • Jr. Member
  • **
  • Posts: 41
  • Activity:
    0%
  • Reputation Power: 1
  • Cuemif has no influence.
  • Respect: +5
  • Referrals: 1
    • View Profile
Re: Adding a hotkey
« Reply #13 on: October 06, 2010, 01:14:51 PM »
0
I do want it to open faster right now it takes like 4 to 5 secs to open my bags and that is just well TO slow I am a semi fast learner so I am gonna look more into this

Tags: