Generic GUI Plugin

Posted by Halig on Tue 27 Oct 2015 11:17 PM — 37 posts, 110,073 views.

Portugal #0
I'm trying to adapt the Generic GUI.

This is my current layout:

https://dl.dropboxusercontent.com/u/59281190/MushClient.jpg

Now, i've manage to remove lots of things, but how can i put my miniwindows plugins inside this one, and make the windows static in position? The only thing that i need working is the reload the windows (in order to delete all of the content) and the scroll (can be without a bar).

I still didn't manage to get that.
Portugal #1
You have entered too much data - maximum is 6000 characters.

Not even trying to split the plugin.

The plugin is here:

https://dl.dropboxusercontent.com/u/59281190/Generic_GUI.xml

Thank you.
Portugal #2
And the original Plugin:

https://dl.dropboxusercontent.com/u/59281190/Generic_GUI_org.xml
Portugal #3
Ok, so i started messing around with this. Slowly.

I have a problem. In the GUI there is a top bar, that aare macros (hotkeys), but i can't manage to change what the F1, F2, ..., F12 do.
The code that i get from the plugin is this:


-- update the hotkeys
function update_hotkeys ()

  -- To stop F1 opening the windows help dialog:
  -- File -> Global Preferences -> General, "F1, F6 are macros"

  data = msdp["HOTKEY"]

  if data ~= nil then
    hotkey = {}
    index = 0
    startpos = 1
    max = 0
    for i=1,string.len(data),1 do
      if string.byte(data,i) == 9 or i == string.len(data) then
        index = index + 1
        hotkey[index] = string.sub(data, startpos, i)
        startpos = i+1
      end -- if
    end -- for

    if index == 3 then
      hotkeys_name[tonumber(hotkey[1])] = hotkey[2]
      hotkeys_action[tonumber(hotkey[1])] = hotkey[3]
      Accelerator ("F"..hotkey[1], hotkey[3])
    end -- if
  end -- if

end -- update_hotkeys

function draw_hotkeys ()

  for i=1,12,1 do
    create_hotkey(i)
  end -- for

end -- draw_hotkeys

function create_hotkey (hotkey_number)

  win = "hotkey_window_"..hotkey_number
  hotkey = "hotkey_"..hotkey_number
  colour = ColourNameToRGB ("gold")
  offset = 115 + (67*hotkey_number)

  -- make a miniwindow under the text
  check (WindowCreate (win,   -- window ID
                offset,       -- left
                2,            -- top
                65,           -- width
                41,           -- depth
                12,           -- center it (ignored anyway) 
                2,            -- draw underneath (1) + absolute location (2)
                colour))      -- background colour

  -- load the icon background image if possible
  if hotkeys[hotkey_number] == nil or hotkeys[hotkey_number] == false then
    button = "images/layout/button_background.png"
  else -- true means the button has been pressed
    button = "images/layout/button_background2.png"
  end -- if

  if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
    check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
  end -- if

  -- draw the 'F1' to 'F12' labels on the buttons
  outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)

  -- draw the label, if any
  if hotkeys_name[hotkey_number] ~= nil then
    outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
  end -- if

  -- show the window
  WindowShow (win, true)

  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up", "hotkey_up", "F"..tostring(hotkey_number), 1, 0)

end -- create_hotkey

function update_hotkey (hotkey_number)

  if hotkeys[hotkey_number] ~= nil then
    win = "hotkey_window_"..hotkey_number
    hotkey = "hotkey_"..hotkey_number
    colour = ColourNameToRGB ("gold")

    if hotkeys[hotkey_number] == false then
      button = "images/layout/button_background.png"
    else -- true means the button has been pressed
      button = "images/layout/button_background2.png"
    end -- if

    if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
      check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
    end -- if

    -- draw the label, if any
    if hotkeys_name[hotkey_number] ~= nil then
      outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
    end -- if

    -- draw the 'F1' to 'F12' labels on the buttons
    outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)
  end -- if

end -- update_hotkey

function outlined_text (colour, window, text, size, x, y)

  outlineColour = colourBlack

  -- write the information inside
  WindowFont(window,'f','Times New Roman',size,1,0,0,0)

  -- smear black text around the location to create an outline, so that it's clearer to read
  WindowText(window,'f',text,x+1,y+1,0,0,outlineColour,0)
  WindowText(window,'f',text,x+1,y,0,0,outlineColour,0)
  WindowText(window,'f',text,x+1,y-1,0,0,outlineColour,0)
  WindowText(window,'f',text,x,y+1,y,0,outlineColour,0)
  WindowText(window,'f',text,x,y-1,y,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y+1,0,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y,0,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y-1,0,0,outlineColour,0)

  -- display the text
  WindowText(window,'f',text,x,y,0,0,colour,0)

end -- outlined_text

function get_hotkey_value (hotkey_string)
  if hotkey_string == "hs_F1" then
    return 1
  elseif hotkey_string == "hs_F2" then
    return 2
  elseif hotkey_string == "hs_F3" then
    return 3
  elseif hotkey_string == "hs_F4" then
    return 4
  elseif hotkey_string == "hs_F5" then
    return 5
  elseif hotkey_string == "hs_F6" then
    return 6
  elseif hotkey_string == "hs_F7" then
    return 7
  elseif hotkey_string == "hs_F8" then
    return 8
  elseif hotkey_string == "hs_F9" then
    return 9
  elseif hotkey_string == "hs_F10" then
    return 10
  elseif hotkey_string == "hs_F11" then
    return 11
  elseif hotkey_string == "hs_F12" then
    return 12
  else
    return 0
  end -- if
end -- get_hotkey_value

function hotkey_down (flags, hotspot_id)
  hotkey_number = get_hotkey_value (hotspot_id)
  if hotkey_number ~= 0 then
    hotkeys[hotkey_number] = true
    update_hotkey (hotkey_number)
    Redraw()
  end -- if
  return 0
end -- hotkey_down

function hotkey_up (flags, hotspot_id)
  hotkey_number = get_hotkey_value (hotspot_id)
  if hotkey_number ~= 0 then
    hotkeys[hotkey_number] = false
    update_hotkey (hotkey_number)
    if hotkeys_action[hotkey_number] ~= nil then
      Execute(hotkeys_action[hotkey_number])
      Redraw()
    else
      Note("Hotkey not defined.  Type 'hotkey' to set it.")
    end -- if
  end -- if
  return 0
end -- hotkey_up
Amended on Thu 29 Oct 2015 05:31 AM by Nick Gammon
Portugal #4
I only need to get the values from MushClient itself, or find a way to set them.
Australia Forum Administrator #5
Halig said:

And the original Plugin:

https://dl.dropboxusercontent.com/u/59281190/Generic_GUI_org.xml


It's not loading for me:


Run-time error
Plugin: Generic_GUI (called from world: smaug2)
Function/Sub: OnPluginWorldOutputResized called by Plugin Generic_GUI
Reason: Executing plugin Generic_GUI sub OnPluginWorldOutputResized
[string "Plugin"]:311: Cannot open the specified file
stack traceback:
        [C]: in function 'error'
        [string "Check function"]:1: in function 'check'
        [string "Plugin"]:311: in function 'create_layout'
        [string "Plugin"]:400: in function <[string "Plugin"]:399>
Error context in script:
 307 :                 7,          -- draw underneath (1) + absolute location (2) + transparent (4)
 308 :                 0x000000))  -- background colour
 309 : 
 310 :   -- load the titlebar image
 311*:   check (WindowLoadImage (titlebar_window, "titlebar", GetInfo (66) .. "Generic/layout/Generic_title.png"))
 312 : 
 313 :   -- draw it
 314 :   check (WindowDrawImage (titlebar_window, "titlebar", 0, -20, 0, 0, 3))  -- draw it
 315 : 



Quote:

but i can't manage to change what the F1, F2, ..., F12 do.


What do you mean?
Portugal #6
Hi Nick,

The bar has buttons F1 to F12.
I know the code is that, but i can't find out how to set what the buttons do.
For example, i have macros assined on MushClient, F2 make me invisible. With that code, the creation of a bar with buttons, is there a way to get that macro and put it on the bar?
That is my problem for now.

The full plugin, with all working except changing what the buttons do:

https://dl.dropboxusercontent.com/u/59281190/LoK_GUI2.xml

Nick, the things may not load for you cause of the images that are needed.
Amended on Thu 29 Oct 2015 11:07 AM by Halig
Australia Forum Administrator #7
You want to click the button and have it send an existing macro? You can get the macro text.


print (ExportXML (3 , "F10" ))


That prints:


<macros>

  <macro name="F10" type="send_now" >
  <send>whatever</send>

  </macro>
</macros>


With a bit of fiddling with a regular expression you could extract the macro text.


macro = ExportXML (3 , "F10" )
macrotext = string.match (macro, "<send>(.*)</send>")
print (macrotext)


That prints:


whatever
Portugal #8
Thank you Nick.
I've tried that on the MUD and everything works. Now, my problem is how to implement that on the bar, like it is! :(
It has s many functions, update_hotkeys, draw_hotkeys, etc.
Portugal #9
I figure out something:

data = msdp["HOTKEY"]

This line was missing in the plugin.
The only problem here is that the MUD that i play, doesn't support msdp. So i need to change all that to get the values of local macros, and not server hotkeys.
Still need some help please, cause i've tried endless things. Some give errors on fucntions, and some tries not even let the plugin load.
Portugal #10
Still trying and not getting the macros title or at least pressing for example F2 and send the command assigned, in this case, invis.
Don't know how to do that. I've read the posts on the icon bar (similar) but the way this is done, i can't manage to adapt.
I want to keep the backgrounds on the buttons and the 'F1' to 'F12' labels on the buttons, created in there in yellow.
Australia Forum Administrator #11
I'm not sure where your problem is. Can you put in some debugging displays to clarify? You are talking about clicking on the button, right, not just hitting (say) F5?

You have a function: hotkey_up

Is that called? If not, you need to work out why. If so, is it not sending what you want it to send?
Portugal #12
Hello Nick. Correct, getting the value stored in local F5 for example, and when i press the button F5, it sends what it's stored there.
All it is sending is:

Hotkey not defined. Type 'hotkey' to set it.

But this is a msdp command, it goes get the hotkey value on the MUD itself, not on MushClient.
That's where my problem is.

TRACE: Executing Plugin LoK_GUI script "hotkey_down"
TRACE: Executing Plugin LoK_GUI script "hotkey_up"
Hotkey not defined. Type 'hotkey' to set it.
Amended on Fri 30 Oct 2015 07:53 PM by Halig
Portugal #13

function get_hotkey_value (hotkey_string)
  if hotkey_string == "hs_F1" then
    print("teste")
  elseif hotkey_string == "hs_F2" then
    return 2
  elseif hotkey_string == "hs_F3" then
    return 3
  elseif hotkey_string == "hs_F4" then
    return 4
  elseif hotkey_string == "hs_F5" then
    return 5
  elseif hotkey_string == "hs_F6" then
    return 6
  elseif hotkey_string == "hs_F7" then
    return 7
  elseif hotkey_string == "hs_F8" then
    return 8
  elseif hotkey_string == "hs_F9" then
    return 9
  elseif hotkey_string == "hs_F10" then
    return 10
  elseif hotkey_string == "hs_F11" then
    return 11
  elseif hotkey_string == "hs_F12" then
    return 12
  else
    return 0
  end -- if
end -- get_hotkey_value
[\code]

If i change on the string hs_F1 the return 1 to print("teste") i got this:

Error number: 0
Event:        Run-time error
Description:  [string "Plugin"]:492: table index is nil

stack traceback:

	[string "Plugin"]:492: in function <[string "Plugin"]:489>
Called by:    Function/Sub: hotkey_down called by Plugin LoK_GUI

Reason: Executing plugin LoK_GUI sub hotkey_down
Australia Forum Administrator #14
Well, you are no longer returning anything. So how about:


function get_hotkey_value (hotkey_string)
  if hotkey_string == "hs_F1" then
    print("teste")
    return 1
  elseif hotkey_string == "hs_F2" then

Portugal #15
Nick, i've tried that. This is the output:

teste
teste
Hotkey not defined. Type 'hotkey' to set it.

Still don't get it.
Portugal #16
I noticed something, if i change this:


  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "hotkey_up", "F"..tostring(hotkey_number), 1, 0)


To this:


  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "F"..tostring(hotkey_number), 1, 0)


It works, but the button stays pressed, uses the pressed image, it doesn't return to the up position.
It just stays a static button.
Amended on Sat 31 Oct 2015 11:24 AM by Halig
Portugal #17
I've tried another thing:


function hotkey_down (flags, hotspot_id)
  hotkey_number = get_hotkey_value (hotspot_id)
  if hotkey_number ~= 0 then
    hotkeys[hotkey_number] = true
    update_hotkey (hotkey_number)
    Redraw()
  end -- if
  return 0
end -- hotkey_down


function hotkey_up (flags, hotspot_id)
  hotkey_number = get_hotkey_value (hotspot_id)
  if hotkey_number ~= 0 then
    hotkeys[hotkey_number] = false
    update_hotkey (hotkey_number)
      Redraw()
  end -- if
  return 0
end -- hotkey_up


This sends the output:

teste
teste

But the button changes to the up picture, so one problem is solved and i removed the message hotkey not defined.
But still getting duplicated command.
Amended on Sat 31 Oct 2015 11:24 AM by Halig
Australia Forum Administrator #18
What do you mean "duplicated command"? When the you get a mouse-down that will call get_hotkey_value and when you release the button it will call get_hotkey_value again.
Portugal #19
That's the problem. I only need it to send once, when i press the button. When i release the button, i only need the picture to change, nothing more.
Portugal #20
Ok, problem solved. Now i have another one.

If you seen the picture, it creates a bar starting on F1 till F12, and a Hotspot or those buttons.


  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "", "F"..tostring(hotkey_number), 1, 0)


Now, how can i change that to reflect what i have in those macros? I can type it myself, or make a Global Variable (it doesn't matter), and then when i'm over the F1 button it Hotspots what i said it was on F1, for example, invis.
Australia Forum Administrator #21
Drawing text and making a hotspot are two different actions.

The hotspot only is a rectangle that generates "events" if you have a mouse-down, mouse-up, mouse-over etc. event on it.

The appearance of the related area of the screen is something you can control with things like WindowText to draw words somewhere inside what you have drawn as the button.
Portugal #22
Sorry Nick for the confusion.
So i need to check and try to adapt the WindowText.


function outlined_text (colour, window, text, size, x, y)

  outlineColour = colourBlack

  -- write the information inside
  WindowFont(window,'f','Times New Roman',size,1,0,0,0)

  -- smear black text around the location to create an outline, so that it's clearer to read
  WindowText(window,'f',text,x+1,y+1,0,0,outlineColour,0)
  WindowText(window,'f',text,x+1,y,0,0,outlineColour,0)
  WindowText(window,'f',text,x+1,y-1,0,0,outlineColour,0)
  WindowText(window,'f',text,x,y+1,y,0,outlineColour,0)
  WindowText(window,'f',text,x,y-1,y,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y+1,0,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y,0,0,outlineColour,0)
  WindowText(window,'f',text,x-1,y-1,0,0,outlineColour,0)

  -- display the text
  WindowText(window,'f',text,x,y,0,0,colour,0)

end -- outlined_text


The only place where i have WindowText is in this function. So this function creates the text in the little balloon?
I've created the macros that you teached me earlier in this post, one for every F key, so i have macro1 to macro12. How can i set, lets say, keywords for everyone of those macros? I can write them manually but i want them to be displayed.
Australia Forum Administrator #23
It looks to me that you call that function to draw the text at a specified X/Y location.
Portugal #24
Correct Nick. That's my understanding of that too. But how do i change what it draws?
The function that calls this one is:


function create_hotkey (hotkey_number)

  win = "hotkey_window_"..hotkey_number
  hotkey = "hotkey_"..hotkey_number
  colour = ColourNameToRGB ("gold")
  offset = 115 + (67*hotkey_number)

  -- make a miniwindow under the text
  check (WindowCreate (win,   -- window ID
                offset,       -- left
                2,            -- top
                65,           -- width
                41,           -- depth
                12,           -- center it (ignored anyway) 
                2,            -- draw underneath (1) + absolute location (2)
                colour))      -- background colour

  -- load the icon background image if possible
  button = "images/layout/button_background.png"

  if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
    check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
  end -- if

  -- draw the 'F1' to 'F12' labels on the buttons
  outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)

  -- draw the label, if any
  if hotkeys_name[hotkey_number] ~= nil then
    outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
  end -- if

  -- show the window
  WindowShow (win, true)

  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "", "F"..tostring(hotkey_number), 1, 0)

end -- create_hotkey


function update_hotkey (hotkey_number)

  if hotkeys[hotkey_number] ~= nil then
    win = "hotkey_window_"..hotkey_number
    hotkey = "hotkey_"..hotkey_number
    colour = ColourNameToRGB ("gold")
    button = "images/layout/button_background.png"
 
    if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
      check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
    end -- if

    -- draw the label, if any
    if hotkeys_name[hotkey_number] ~= nil then
      outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
    end -- if

    -- draw the 'F1' to 'F12' labels on the buttons
    outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)
  end -- if

end -- update_hotkey


When it creates the hotkeys, it draws the F1 to F12 on the bottom of the button. That is like that, no worries.
Now, it reads what is in the hotkeys_name (i think) and that is what i want to change, so the button will show on the bottom the key (F1 to F12) and in the middle, some text that i define, let's say on the F1 - Help.
Australia Forum Administrator #25
You seem to be on the right track. How about doing a debugging print as you try to draw the name?


print (hotkeys_name[hotkey_number])


That will confirm you actually have a name there.
Portugal #26
Hi Nick, I've inserted that line, in the function create_hotkey and the function update_hotkey.
The returned print is always nil, so it is not updating anything and i can't see what to change in order to define myself what is there.
Australia Forum Administrator #27
Reply #7 covered that.
Portugal #28
Correct. I've tried that, and still nil, if i use:


print (hotkeys_name[hotkey_number])


It seems that it doesn't update. If i press the button, it sends the command correctly, so everything is good at that end.
Australia Forum Administrator #29
Halig said:

Correct. I've tried that, and still nil, if i use:



Can you post that code please?
Portugal #30

function create_hotkey (hotkey_number)

  win = "hotkey_window_"..hotkey_number
  hotkey = "hotkey_"..hotkey_number
  colour = ColourNameToRGB ("gold")
  offset = 115 + (67*hotkey_number)

  -- make a miniwindow under the text
  check (WindowCreate (win,   -- window ID
                offset,       -- left
                2,            -- top
                65,           -- width
                41,           -- depth
                12,           -- center it (ignored anyway) 
                2,            -- draw underneath (1) + absolute location (2)
                colour))      -- background colour

  -- load the icon background image if possible
  button = "images/layout/button_background.png"

  if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
    check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
  end -- if

  -- draw the 'F1' to 'F12' labels on the buttons
  outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)

  -- draw the label, if any
  if hotkeys_name[hotkey_number] ~= nil then
    outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
  end -- if

  -- show the window
  WindowShow (win, true)

  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "", "F"..tostring(hotkey_number), 1, 0)

print (hotkeys_name[hotkey_number])

end -- create_hotkey


function update_hotkey (hotkey_number)

  if hotkeys[hotkey_number] ~= nil then
    win = "hotkey_window_"..hotkey_number
    hotkey = "hotkey_"..hotkey_number
    colour = ColourNameToRGB ("gold")
    button = "images/layout/button_background.png"
 
    if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
      check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
    end -- if

    -- draw the label, if any
    if hotkeys_name[hotkey_number] ~= nil then
      outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
    end -- if

    -- draw the 'F1' to 'F12' labels on the buttons
    outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)
  end -- if

print (hotkeys_name[hotkey_number])

end -- update_hotkey


Perhaps i'm not doing the things the way i should.
Australia Forum Administrator #31
My earlier reply suggested:


macro = ExportXML (3 , "F10" )
macrotext = string.match (macro, "<send>(.*)</send>")


I'm not seeing that anywhere, or anything like it.
Portugal #32
Oh, it is as follows. I declared the macros at the top of the plugin:


macro1 = ExportXML (3 , "F1" )
macro2 = ExportXML (3 , "F2" )
macro3 = ExportXML (3 , "F3" )
macro4 = ExportXML (3 , "F4" )
macro5 = ExportXML (3 , "F5" )
macro6 = ExportXML (3 , "F6" )
macro7 = ExportXML (3 , "F7" )
macro8 = ExportXML (3 , "F8" )
macro9 = ExportXML (3 , "F9" )
macro10 = ExportXML (3 , "F10" )
macro11 = ExportXML (3 , "F11" )
macro12 = ExportXML (3 , "F12" )

function get_hotkey_value (hotkey_string)
  if hotkey_string == "hs_F1" then
    macro = string.match (macro1, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 1
  elseif hotkey_string == "hs_F2" then
    macro = string.match (macro2, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 2
  elseif hotkey_string == "hs_F3" then
    macro = string.match (macro3, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 3
  elseif hotkey_string == "hs_F4" then
    macro = string.match (macro4, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 4
  elseif hotkey_string == "hs_F5" then
    macro = string.match (macro5, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 5
  elseif hotkey_string == "hs_F6" then
    macro = string.match (macro6, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 6
  elseif hotkey_string == "hs_F7" then
    macro = string.match (macro7, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 7
  elseif hotkey_string == "hs_F8" then
    macro = string.match (macro8, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 8
  elseif hotkey_string == "hs_F9" then
    macro = string.match (macro9, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 9
  elseif hotkey_string == "hs_F10" then
    macro = string.match (macro10, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 10
  elseif hotkey_string == "hs_F11" then
    macro = string.match (macro11, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 11
  elseif hotkey_string == "hs_F12" then
    macro = string.match (macro12, "<send>(.*)</send>")
    if macro ~= nil then
     Execute (macro)
     else
     return 0
    end -- if
    return 12
  else
    return 0
  end -- if
end -- get_hotkey_value
Australia Forum Administrator #33
Yes, but I don't see where you are putting that macro stuff into the part that displays the buttons.
Portugal #34
Correct Nick. I was trying to put only the part that you told me.


print (hotkeys_name[hotkey_number])


I can't see what to do and where. Sorry about this Nick, and thank you for all your help.


function create_hotkey (hotkey_number)

  win = "hotkey_window_"..hotkey_number
  hotkey = "hotkey_"..hotkey_number
  colour = ColourNameToRGB ("gold")
  offset = 115 + (67*hotkey_number)

  -- make a miniwindow under the text
  check (WindowCreate (win,   -- window ID
                offset,       -- left
                2,            -- top
                65,           -- width
                41,           -- depth
                12,           -- center it (ignored anyway) 
                2,            -- draw underneath (1) + absolute location (2)
                colour))      -- background colour

  -- load the icon background image if possible
  button = "images/layout/button_background.png"

  if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
    check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
  end -- if

  -- draw the 'F1' to 'F12' labels on the buttons
  outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)

  -- draw the label, if any
  if hotkeys_name[hotkey_number] ~= nil then
    outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
  end -- if

  -- show the window
  WindowShow (win, true)

  -- create a hotspot over the timer
  WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up" , "", "F"..tostring(hotkey_number), 1, 0)

end -- create_hotkey


function update_hotkey (hotkey_number)

  if hotkeys[hotkey_number] ~= nil then
    win = "hotkey_window_"..hotkey_number
    hotkey = "hotkey_"..hotkey_number
    colour = ColourNameToRGB ("gold")
    button = "images/layout/button_background.png"
 
    if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
      check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2))  -- draw it
    end -- if

    -- draw the label, if any
    if hotkeys_name[hotkey_number] ~= nil then
      outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
    end -- if

    -- draw the 'F1' to 'F12' labels on the buttons
    outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)
  end -- if

end -- update_hotkey
Portugal #35
Hello to all. Been trying and no luck.
Can you guide me in one direction?
Australia Forum Administrator #36
I'd like to see you break the problem down into manageable steps.

Quote:

Been trying and no luck.


That doesn't tell me, or anyone else, anything.

What did you try? Post it, don't just talk about it.

You should be able to obtain the macro strings (I think you did that in reply #32). Now you should be able to use the code we discussed earlier to display them.