mIRC Homepage
Posted By: colt45 Capture a word using mouse - 09/08/06 02:17 PM
I was trying to think how to write this.

i.e. want to hold down CTRL and the mouse pointer turns to a hand pointer and when I clicked on a word (while holding down the CTRL) .. then it's echo something like - You have clicked on this word 'test'.

Can this be done? - any suggestion? (i've tried hotlink but couldn't really get it to work crazy)
Posted By: DaveC Re: Capture a word using mouse - 09/08/06 08:04 PM
Code:
on ^*:hotlink:*:*:{
  if ($mouse.key & 2) {
    ;ctrl key pressed
    if ($mouse.key & 1) {
      ;left mouse click
      echo -st You have clicked on this word $+(',$1,')
    }
    return
  }
  halt
}


* there is the chance the mouse well not have turned to a pointy finger yet, if u pushed the ctrl key without moving the mouse and then clicked the mouse on a word with no mouse movement, but i would hazzard a guess thats what you want anyway. As soon as u move the mouse with ctrl down, it well show as a pointing finger.
Posted By: colt45 Re: Capture a word using mouse - 09/08/06 09:24 PM
PERFECT!

Many thanks - yea, does works.

Now I get the idea how it's works, will tweak few things now smile

Many thanks again.
Posted By: keeker Re: Capture a word using mouse - 09/08/06 09:39 PM
this is neat daveC...but was just wondering, what would someone need to do to change it from the 'CTRL' key to an F-Key? Like F9?
Posted By: colt45 Re: Capture a word using mouse - 09/08/06 11:14 PM
Yea, or a [SHIFT] key? :P
Posted By: hixxy Re: Capture a word using mouse - 10/08/06 12:42 AM
Shift, just change:

Code:
if ($mouse.key & 2) {


To:

Code:
if ($mouse.key & 4) {


As for Fkeys, you can't see if an fkey is held down in the on hotlink event, but you can catch an fkey being pressed by using an alias:

Code:
alias F1 ; F1 is hit
alias F2 ; F2 is hit
alias CF1 ; Control+F1
alias SF6 ; Shift+F6
Posted By: DaveC Re: Capture a word using mouse - 10/08/06 07:03 AM
Quote:
this is neat daveC...but was just wondering, what would someone need to do to change it from the 'CTRL' key to an F-Key? Like F9?


/help $mouse
1 left mouse, 2 ctrl, 4 shift, 8 alt, 16 right mouse

For F keys its a little harder, if it was a custom window there would be little problem as u can detect keys down and up, but for other windows i think that might be tougher, F9 is deteted down, but I dont think theres a resource to check to see if its down.

could try this
Code:
on ^*:hotlink:*:*:{
  if ($calc($ticks - %f9@ticks) < 50) {
    ;F9 pressed less 1/20th of a second ago!
    if ($mouse.key & 1) {
      ;left mouse click
      echo -st You have clicked on this word $+(',$1,') with F9 down
    }
    return
  }
  halt
}
alias f9 { set %f9@ticks $ticks }

* the idea is F9 being held down causes the F9 alias to be called over and over, on my system its always under 50ms, it was always 31,32,47 ms between occrances, (I have my repeat rate at the max).
So I simple set what time it goes off at, then see if its under 1/20th of a second since it was last tripped, and judge that as down.

Now if it was just a F9 press and release, I would argue that no one can be accurate enough to say if the F9 was down or not at the time the mouse was clicked, if its within 1/20th of a second. AKA Close enough to correct for a human operator.
Posted By: keeker Re: Capture a word using mouse - 10/08/06 12:45 PM
this works great, thank you very much, i am using it to do a dictionary lookup on the words i clicked. i love it
grin
© mIRC Discussion Forums