mIRC Home    About    Download    Register    News    Help

Print Thread
Press a key when key is mentioned in chat? #244326 16/02/14 03:21 AM
Joined: Feb 2014
Posts: 1
P
Pasukaru Offline OP
Mostly harmless
OP Offline
Mostly harmless
P
Joined: Feb 2014
Posts: 1
I want to program my mIRC bot like everytime someone
writes "F1" in the chat, the bot simulates F1 pressed on the keyboard.

So a bit like this:

Code:
on *:text:f1:#: {
  Button F1 gets pressed
}

Re: Press a key when key is mentioned in chat? [Re: Pasukaru] #244331 16/02/14 03:33 PM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Online
Hoopy frood
Online
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
This sounds like a terrible idea, but here you go:

Code:
on *:text:f1:#:sendkeys {F1}

alias sendkeys var %a = $ticks | .comopen %a WScript.Shell | if !$comerr { .comclose %a $com(%a,SendKeys,3,bstr,$1-) }


Reference: http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys(v=vs.110).aspx

Re: Press a key when key is mentioned in chat? [Re: Loki12583] #244335 17/02/14 01:51 AM
Joined: Jun 2008
Posts: 12
S
Shanatan Offline
Pikka bird
Offline
Pikka bird
S
Joined: Jun 2008
Posts: 12
Would it be possible to have it hold down the key for about 50ms?

Like the AutoHotkey function SendInput:

SendInput {Up down}
Sleep, 50
SendInput {Up up}

Re: Press a key when key is mentioned in chat? [Re: Shanatan] #244336 17/02/14 02:14 AM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Online
Hoopy frood
Online
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
Not with this method.

Re: Press a key when key is mentioned in chat? [Re: Loki12583] #244341 17/02/14 08:59 AM
Joined: Jun 2008
Posts: 12
S
Shanatan Offline
Pikka bird
Offline
Pikka bird
S
Joined: Jun 2008
Posts: 12
And with a different method?

Re: Press a key when key is mentioned in chat? [Re: Shanatan] #247544 08/08/14 01:53 AM
Joined: May 2012
Posts: 12
T
TheRandomDog Offline
Pikka bird
Offline
Pikka bird
T
Joined: May 2012
Posts: 12
Originally Posted By: Shanatan
And with a different method?


I know this is a ridiculously old thread, but I was curious myself as if there was any way to make it hold down a key, maybe with a different COM method?

Re: Press a key when key is mentioned in chat? [Re: TheRandomDog] #247545 08/08/14 06:45 AM
Joined: Sep 2005
Posts: 2,878
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,878
You can make it press a key x number of times but not hold it down for x seconds.

Change {F1} to {F1 50} to hit F1 50 times for example.