Close
Page 2 of 2 FirstFirst 1 2
Showing results 11 to 18 of 18
  1. #11

    Default

    I had zero knowledge about scripts when I started. I really wanted some of the more advanced stuff that keyclone couldn't handle. So I sat down and figured it out by trial and error. There's still a lot I don't know (like templates) but just by keeping at it I learned it.

    That's my best advice to ya. Just keep trying different things and eventually you get better at it. It actually even starts to make sense lol. I can't actually "read' a script yet without a little bit of reference but I'm pretty close to being able to! Also whenever I found something that really gave me trouble Freddie was always great about helping or pointing in the right direction.

  2. #12

    Default

    I can't actually "read' a script yet...
    Here's a really useful trick. (At least I think so.) After you load the script, click "Show loaded hotkeys." The program will show you the hotkeys that it makes from your templates. The hotkeys are what really count -- they are the things that actually get loaded -- and they are much easier to read than templates.

    Question also is the " " need to signify whats in the %%
    Quotation marks are only needed if they enclose text that contains spaces and you want HotkeyNet to think of the enclosed text as a single thing.

    You need them here for the arguments that contain spaces. If you had written things slightly differently you wouldn't have needed them.

    For example, you could have written this:

    Code:
    <Template If>
      <If MouseIsOverWindowRect %1% %2% %3% %4% %5%>
          <SendLabel %6%>
             <Key %7%>
    <EndTemplate>
    See the difference? I wrote seven %% symbols instead of three like you did. This allows me to apply the template without quotes like this:

    Code:
       <ApplyTemplate If WoW5 88 299 125 58 w3 Numpad1>
    Also is this script language like that of like C++ or is this all in its own?
    I should have made the language like C for exactly this reason. It would be easier for people to learn. (C is a subset of C++.)

    However I was in an experimental mood when I designed HotkeyNet 1's language and as a result, the script language is bizarre and unlike anything I've ever heard of.

    I've learned my lesson and designed the new script language in HotkeyNet 2 so it resembles C as closely as possible.

    But we're stuck with the old script language for now, until HKN2 is ready.
    Last edited by Freddie : 09-10-2009 at 04:02 AM
    �Author of HotkeyNet and Mojo

  3. #13

    Default

    Edit: sry, mine and freedies post crossed, so sry, if the following is alittlebit redundant

    Jeah, to get into HotkeyNet is not as simply as installing KC or ISBoxer, but for the first steps, I recommend looking at the sample-scripts on hotkeynet.com and reading the HKN-Guide in this forum (ok, this is a little self promoting, but I think its quite helpfull).

    You are right, some more advanced thinks like Templates (and Virtual Buttons) aren'T covered in it, but I wrote it more as a beginner guide to get a 'normal' setup.

    The best thing to look for informations on the more advanced stuff is the HKN-Command-Reference (to get an Ideawhat commands are available) and the HKN-Forum. Normaly if you have a specific problem and ask there for help, you will find some nice people who are willing to give it to you...

    But back to Templates:

    The general idea of templates in HKN is, to give a way to simplify some definitions, that occure quite often, and have a very similar structure.

    One relay simple example:

    -Lets say you want to define multiple keys (1,2) which sends the key to w1 and always 'w' to w2 (and you don't know about keylists ).

    This could be done by defining a Template like:
    Code:
    <Template blubb>
            <Sendlabel w1>
            <Key %trigger%>
        <Sendlabel w2>
             <Key w>
    <EndTemplate>
    and calling it like:
    Code:
    <Hotkey 1>
        <ApplyTemplate blubb>
    
    <Hotkey 2>
        <ApplyTemplate blubb>
    What HotkeyNet now does, is simply when finding the '<ApplyTemplate blubb>' look if there a definition for the template with the name 'blubb' specified by <Template blubb> and if it finds such a definition, it substitutes the <ApplyTemplate blubb> with the text defined between <Template blubb> and <EndTemplate>.

    So on runtime, the tow Hotkey definitions would look like:
    Code:
    <Hotkey 1>
            <Sendlabel w1>
            <Key %trigger%>
        <Sendlabel w2>
             <Key w>
    
    <Hotkey 2>
            <Sendlabel w1>
            <Key %trigger%>
        <Sendlabel w2>
             <Key w>
    This is a real simple working example, but if this would be all templates could do, it wouldn't be so usefull.

    The next component of templates are parameters. With parameters you can, when calling a template with <ApplyTemplate> give the call some specific values, which then are used in the template.

    For this the calling syntax is:
    <ApplyTemplate name parameter1 parameter2 parameter3 ..>

    in the Template itself every occurence of %PARAMETER_NUMBER% is than replaced with the text for the parameter.

    Short example:
    <ApplyTemplate test This is a test>

    in the Template specified by <Template test> every occurence of:
    - %1% is replaced with This
    - %2% is replaced with is
    - %3% is replaced with a
    - %4% is replaced with test

    so the following
    Code:
    <Template sendkey>
       <Hotkey %1%>
           <SendLabel %2%>
                 <Key %3%>
    <EndTemplate>
    
    <ApplyTemplate 1 w1 u>
    would create the following Hotkey:
    Code:
    <Hotkey 1>
       <Sendlabel w1>
           <Key u>
    Now, one last important thing:
    Normaly HKN seperates parameters by a space.
    If you want to use a phrase as an Parameter which containes spaces (like f.e. a path) you have to capsulate it in "" like "This is a test".


    So to come back to the original code:
    <Template If>
    <If MouseIsOverWindowRect %1% %2%>
    <SendLabel %3%>
    <Key %4%>
    <EndTemplate>
    <Template Else>
    <If MouseIsOverWindowRect %1% %2%>
    <SendLabel %3%>
    <Key %4%>
    <EndTemplate>

    <Hotkey ScrollLockOn LButton>
    <ApplyTemplate If "WoW5" "88 299 125 58" "w3" "Numpad1">
    <ApplyTemplate ElseIf "WoW5" "88 367 125 58" "w3" "Numpad2">
    <ApplyTemplate ElseIf "WoW5" "88 433 125 58" "w3" "Numpad3">
    <Else>
    <SendFocusWin>
    <ClickMouse down %Trigger%>
    Lets have a look at what <ApplyTemplate If "WoW5" "88 299 125 58" "w3" "Numpad1"> does:

    it replaces the <ApplayTemplate If ...> with the block between <Template If> and <EndTemplate> and substitutes:
    - %1% with WoW5
    - %2% with 88 299 125 58
    - %3% with w3
    - %4% with Numpad1

    So the code in HKN would look like:
    <Hotkey ScrollLockOn LButton>
    <If MouseIsOverWinRect WoW5 88 299 125 58>
    <Sendlabel
    w3>
    <Key
    Numpad1>
    <ApplyTemplate ElseIf "WoW5" "88 367 125 58" "w3" "Numpad2">
    <ApplyTemplate ElseIf "WoW5" "88 433 125 58" "w3" "Numpad3">
    <Else>
    <SendFocusWin>
    <ClickMouse down %Trigger%>

    ( And of course
    <ApplyTemplate ElseIf ..> would then be replaced with the text of <Template ElseIf> )

    I hope I could bring some light in defining/using templates and some of the 'fog' went away
    Last edited by olipcs : 09-10-2009 at 04:28 AM
    OLIPCS - ordinary life is pretty complex stuff
    ----------------------------------------------------------------
    Pala, Priest, Druid, Hunter, Mage
    Focusless Targetless Leaderless - Wiki
    HotKeyNet - Guide

  4. #14

    Default

    That's a great explanation of templates, Olipcs. It would be nice to reprint that in a reference section somewhere, either here or on HKN's site.
    �Author of HotkeyNet and Mojo

  5. #15

    Default

    Thanks, that you like it.
    How about I add it to the HKN-Guide here, and if you want you add it to the reference/whatever-section on HKN.com ?
    OLIPCS - ordinary life is pretty complex stuff
    ----------------------------------------------------------------
    Pala, Priest, Druid, Hunter, Mage
    Focusless Targetless Leaderless - Wiki
    HotKeyNet - Guide

  6. #16

    Default

    Sounds good!
    �Author of HotkeyNet and Mojo

  7. #17

    Default

    Yeah that helped a lot and will for others I know because first looking at the template instructions I couldn't seem to grasp that %#% was what you wanted sent. but thanks again guys.

  8. #18

    Default

    When HotkeyNet sees "ApplyTemplate" it copies the template.

    As it copies the template, it replaces %#% with the piece of text that you specified.

    The piece of text can be anything. It doesn't have to be something that gets sent.

    http://hotkeynet.com/p/templates.html
    Last edited by Freddie : 09-10-2009 at 07:59 PM Reason: Tried to make the idea more clear.
    �Author of HotkeyNet and Mojo

Posting Rules

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •