What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Disable Movement from User (form Mouse/Keyboard input)

tuanha

Well-Known Member
Joined
Nov 29, 2011
Messages
6,998
Reaction score
124
Hi,

It's there anyway to ignore movement from user (using keyboard/mouse) for a short moment?

I play my mage using LazyRaider and I want he ignore my Keyboard/Mouse for 1-2 second when the CC do the facing target + cast cone of cold/dragon's breath.

CodenameG, you have the excellent mage CC (Amplify), can you please help me out on this.

I start love CC programing than actually playing wow...
 
I have never tried anything like this, but block input may be your answer.

BlockInput function

PHP:
using System.Runtime.InteropServices;

        [DllImport("user32.dll")]
        private static extern bool BlockInput(bool block);

        private void blockUserInput(TimeSpan ts)
        {
            if (Me.IsAlive)
            {
                BlockInput(true);
                Thread.Sleep(ts);
            }
            BlockInput(false);
        }

I don't know if a while loop can break itself if you are sleeping though. If not, you may want to break your sleep up into many small iterations so you can keep checking to see if you are alive.
 
Last edited:
Edited slightly. Much better now I think.

PHP:
using System.Runtime.InteropServices;

        [DllImport("user32.dll")]
        private static extern bool BlockInput(bool block);

        private void blockUserInput(int time)
        {
            int temp = 0;
            while (Me.IsAlive && temp<=time)
            {
                BlockInput(true);
                Thread.Sleep(100);
                temp+=100;
            }
            BlockInput(false);
        }
 
EDIT: bad code deleted
 
Last edited:
Thank jasf10,

I'll try on my amazing mage custome cc :P
 
Dear jasf10,

Can you please help, i import the code but it didn't work.

Your code:
Code:
        #region BlockImput
        [DllImport("user32.dll")]
        private static extern bool BlockInput(bool block);
        Stopwatch blockSW = new Stopwatch();
        bool blocking = false;

        public override void Pulse()
        {
            if (blocking)
            {
                if (!blockSW.IsRunning)
                {
                    blockSW.Reset();
                    blockSW.Start();
                }
                if (KeepBlocking(3000))
                {
                    BlockInput(true);
                    return;
                }
                else
                {
                    BlockInput(false);
                    blocking = false;
                }
            }

        }

        private bool KeepBlocking(int time)
        {
            if (blockSW.IsRunning && Me.IsAlive)
            {
                if (blockSW.Elapsed.TotalSeconds >= time)
                {
                    blockSW.Stop();
                    return false;
                }
                else
                    return true;
            }
            blockSW.Stop();
            return false;
        }
        #endregion

My Code
Code:
                #region Cone of Cold
                // [Cone of Cold]		
                if (SpellManager.Spells["Cone of Cold"].Cooldown==false)
                {
                    KeepBlocking(2);//I want to block for 2 seconds

                    if (Me.IsSafelyFacing(Y12Melee) == false)
                    {
                        Y12Melee.Face();
                    }

                    CastSpell("Cone of Cold", Y12Melee);
                }
                #endregion

I can move my mage during 2 second KeepBlocking(2)

What shout i do to fix this.

Thank you.
 
Did you ever start the block? keep blocking only continues blocking if the block has been started and ends if the time has past. the input is in milliseconds, so you would need to enter 2000.


EDIT: I could not get the timer on to stop blocking input. It was a little too overcomplicated to keep track of i guess.

I would say go with the sleep one. Sleeping is not great, but you are already blocking input so why stop there? :p

I have tested this and it works. To use, call blockUserInput(2000);

PHP:
private void blockUserInput(int time)
        {
            if (Me.IsAlive)
            {
                BlockInput(true);
                Thread.Sleep(time);
            }
            BlockInput(false);
        }
 
Last edited:
Back
Top