ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Coragin on November 24, 2009, 03:38:44 AM

Title: Click Gump Size? Or whatever.
Post by: Coragin on November 24, 2009, 03:38:44 AM
Okay, moving gumps piss me off!

Someone mentioned to me to use the WINDOW size and not a position on the screen.  So it always targets the x/y on the gump only.  Doing this by recording the button locations on the gump while its at 0/0 x/y.

I can do that easy.  Here is my question and remember I am still a newb kinda.

How do I setup the script to click those locations on the gump window only?

Can someone explain this to me in very slow simple terms?

set %cgumpsize 100 100

and clicks would be something like

click %cgumpsiz %cgumpx %cgumpy ?

I dont know, but I dont wanna contpos 50 50 every single sub for a gump.  I could really use some help here.
Title: Re: Click Gump Size? Or whatever.
Post by: 12TimesOver on November 24, 2009, 04:39:31 AM
Actually, I would suggest the opposite. You never use screen coordinates for the gump, you want to use #gumpposx and #gumpposy - these coordinates mark the upper, lefthand corner of said gump. Your click locations should always be #gumpposx + number and #gumpposy + number. this way it doesn't matter where the gump lands. This is why you will find gump wait and gump click subs in most reputable scripter's scripts, you would typically sub the clicking like:

Code: [Select]
gosub GumpClick 50 50

sub Gumpclick
   set %clickx #contposx + %1
   set %clicky #contposy + %2
   click %clickx %clicky
return

XII
Title: Re: Click Gump Size? Or whatever.
Post by: Coragin on November 24, 2009, 05:00:14 AM
so it would basicly be if click last were at 325 400 look like this with gumpwait

Code: [Select]
gosub gumpwait
gosub gumpclick 325 400

sub Gumpclick
   set %clickx #contposx + %1
   set %clicky #contposy + %2
   click %clickx %clicky
return

And the two sets are actually gosub gumpclick 350 (set %clickx #contposx + %1) 400 (set %clicky #contposy + %2)

setclickx setting 350 click on the contain position 1% is the number I input in the call in this case 325? And %2 is the second number, in this case 400?
Title: Re: Click Gump Size? Or whatever.
Post by: Cerveza on November 24, 2009, 05:03:56 AM
I once had the ultimate tutorial on gump usage. Pictures showing a gump with measurements to show you exactly whats going on.

That was on another forum, one run by a twit who shut the doors one day and deleted a TON of useful information.

If I have some time over the holiday I'll recreate that tutorial.

Gosub a gump waiting sub, make sure you include what size the gump is that your waiting for. And some gump waits have a timeout.

Then gosub that clicker, which tells UO to click at that location relative to that particular gump
Title: Re: Click Gump Size? Or whatever.
Post by: Coragin on November 24, 2009, 05:13:21 AM
I once had the ultimate tutorial on gump usage. Pictures showing a gump with measurements to show you exactly whats going on.

That was on another forum, one run by a twit who shut the doors one day and deleted a TON of useful information.

If I have some time over the holiday I'll recreate that tutorial.

Gosub a gump waiting sub, make sure you include what size the gump is that your waiting for. And some gump waits have a timeout.

Then gosub that clicker, which tells UO to click at that location relative to that particular gump

The ultimate goal I am trying to do here is place the following subs in one file for universal use...

gumpwait
cursorwait
gumpclick

I think that would be great for scripters who are learning, such as myself and other.  Plus those are redundant subs used in a ton of scripts.
Title: Re: Click Gump Size? Or whatever.
Post by: 12TimesOver on November 24, 2009, 07:10:46 AM
so it would basicly be if click last were at 325 400 look like this with gumpwait

Code: [Select]
gosub gumpwait
gosub gumpclick 325 400

sub Gumpclick
   set %clickx #contposx + %1
   set %clicky #contposy + %2
   click %clickx %clicky
return

And the two sets are actually gosub gumpclick 350 (set %clickx #contposx + %1) 400 (set %clicky #contposy + %2)

setclickx setting 350 click on the contain position 1% is the number I input in the call in this case 325? And %2 is the second number, in this case 400?
Well I think I understand what you are driving at and, basically yes. If you are thinking of Gump basics they have a name, a size, and sometimes locations within them that you want to click something or place something.

Your basic logic would be something like:

Use item
Wait for the gump
When gump is open
   Do something

When "Do Something" is to click a button within a menu then you sometimes have to wait for the gump again or sometimes you don't.

When you are waiting for the gump you need logic to tell the code what you are waiting for - ie, a gump name or gump size. Preferably you will use both of these as there are a lot of gumps with the same gump name for example.

As for creating a set of subs, these do already exist however don't let that stop you! You want a Gump Wait and a  Click sub. Make sure your Gump Wait takes in criteria for what gump you are waiting for and the Click takes in your Click coordinates.

Hey Cerv, some of those tutorials can still be pulled out of the internet archive. Not all but some. If I remember correctly C2's old Menu tutorial is still out there. We'll have to see what else is there ;)

X
Title: Re: Click Gump Size? Or whatever.
Post by: Paulonius on November 24, 2009, 07:51:54 AM
Cor, Look in "Script Snippets" and download TM's Offset Click Finder.  It has a gump click sub posted with it and you can use it to find the correct values to send to the gump click sub.  You can go through all of your gump using scripts and replace the coordinate clicks with gump clicks that roll through the gumpclick sub. Its really easy to use and will make sense in two minutes with your experience finding click coords.
Title: Re: Click Gump Size? Or whatever.
Post by: 12TimesOver on November 24, 2009, 07:53:21 AM
Yeah that one is a nice snippet.

Alternatively, you can line up you gump using #gumpposx/y to 0/0 then look at your cursor position when you hover over your location.

X
Title: Re: Click Gump Size? Or whatever.
Post by: Paulonius on November 24, 2009, 08:05:07 AM
Here is where the snippet is located:

http://www.scriptuo.com/index.php?topic=505.0
Title: Re: Click Gump Size? Or whatever.
Post by: Coragin on November 24, 2009, 10:03:38 AM
Man you guys are great, thank you.  I am going to make a real nice script, BIG all on my own that will help a lot of people one day.  Now I just need to find something no one has done yet ;)
Title: Re: Click Gump Size? Or whatever.
Post by: cgeorgemo on December 03, 2009, 08:45:15 PM
Code: [Select]
gosub gumpclick 325 400
I did not think you could send parameters in the gosub name I thought you had to make a statement that set them...
Title: Re: Click Gump Size? Or whatever.
Post by: 12TimesOver on December 04, 2009, 02:42:41 AM
Nope.