Jump to content

Keyboard and mouse goes crazy after running scrip


sithz
 Share

Recommended Posts

Hello guys.

Need some help here :D

I have a simple script compiled to an .exe file.

The script is as follows:

AutoItSetOption( "TrayIconHide", 1)
AutoItSetOption( "SendKeyDownDelay", 10)
Send("CP")
Exit

Sometimes after the script has been run, my mouse looses the left click function when you double click files or folders

and you have to right click to open a file/folder.

Also the keyboard goes crazy and you can not type, seems like keys are shifted around.

Anyone got an idea how to fix this? It's happening on several computers, all running win xp sp2.

Thank you in advance.

/Sithz

Edited by sithz
Link to comment
Share on other sites

AutoItSetOption( "TrayIconHide", 1)<BR>AutoItSetOption( "SendKeyDownDelay", 10)<BR>Send("CP")<BR>Exit

Sometimes after the script has been run, my mouse looses the left click function when you double click files or folders

and you have to right click to open a file/folder.

Also the keyboard goes crazy and you can not type, seems like keys are shifted around.

No way to tell what may be, please what is the context in which you run this?

How do you run the script?

As it just "presses" C and P nothing is wrong with the script but it has to be something that is triggered by those keys.

For example if you run this with a hot key "Ctrl+Shift+S" the ctrl and shift keys get stuck. Kind of Windows bug that sometimes happen: the computer starts to work as if sticky keys (accesibility) was activated, this, of course happens when not running scripts too.

Always, when the first line is Send() add a Sleep(500) before to let the user release the keys (He has to release them). Other possible work around: I think there is a function that disables keyboard and mouse input but I never used it, be careful, if the script ends with a MsgBox() and you don't re enable user input... The user will have to reboot.

Tips: the exit command is redundant, AutoItSetOption() can be changed by Opt() see help file (F1 in SciTE).

The only line that can be 'problematic' is Send("CP"), the rest just work inside AutoIt.

When your computer starts behaving this way press and release alternatively all your Alt, Control, Shift, Win, and ContMenu keys.

AutoIt is a blessing, I don't know how I was able to use my computer before [Auto]It :-S

Link to comment
Share on other sites

several computers with XP SP2...

I don't have that OS, so it makes sense that I wouldn't experience the problem...

is this the only thing you're running when this error occurs?

is that the entire code?

does anyone else experience the problem?

Edited by crzftx
Link to comment
Share on other sites

Thanks all for your replys.

Yes thats the whole code and it's triggered by an external program starting the .exe

But can't see that should be a problem, since I get these problems when manually running the .exe by myself.

I will try and see if changing to lower letters instead of capital will help.

I can not add a Sleep(500), cause the program needs to send the keys ASAP when it's run.

Also there might be other keys pressed by user at this time, since the user dont know when the script runs

(it's for a game and the script runs based on actions that happens in game).

Thank you

Link to comment
Share on other sites

Manually running the exe, you mean: click the file, then enter or just double click? Executing it from your desktop without the game running :D ?

I didn't thought about lower case but yes, FreeFry has a point there, unless you really need uppercase always use lower with Send and ControlSend.

Just for testing, at least, add Sleep(250). Come on it's just 1/4 of a second :P . And make it simpler:

Sleep(250)
Send("cp")

If that still gives you errors I don't know what else could it be.

Do you have a KVM? (It's a device that let's you use a keyboard, a mouse and a monitor with 2 or more PCs, you change the target PC with a button).

Do you have a mouse with extra buttons or a Keyboard with extra buttons that uses a program to set actions for those buttons?

When you get this behavior, do CapsLock and NumLock still work?

The keys that can be more trouble are the ones that toggle things: Alt, Shift, Win and the weird behavior ends when you press the one that got "stuck". If this happens when you're playing press them all and see what happens.

AutoIt is a blessing, I don't know how I was able to use my computer before [Auto]It :-S

Link to comment
Share on other sites

Manually running the exe, you mean: click the file, then enter or just double click? Executing it from your desktop without the game running :D ?

I didn't thought about lower case but yes, FreeFry has a point there, unless you really need uppercase always use lower with Send and ControlSend.

Just for testing, at least, add Sleep(250). Come on it's just 1/4 of a second ;) . And make it simpler:

Sleep(250)
Send("cp")

If that still gives you errors I don't know what else could it be.

Do you have a KVM? (It's a device that let's you use a keyboard, a mouse and a monitor with 2 or more PCs, you change the target PC with a button).

Do you have a mouse with extra buttons or a Keyboard with extra buttons that uses a program to set actions for those buttons?

When you get this behavior, do CapsLock and NumLock still work?

The keys that can be more trouble are the ones that toggle things: Alt, Shift, Win and the weird behavior ends when you press the one that got "stuck". If this happens when you're playing press them all and see what happens.

Hello and thank you for your input.

The file is normally triggered by an c# application and thats when I get the problem.

By double clicking the .exe file the problem did not seem to show (strange enough)

Anyhow, it seems I have solved it now. After the keyboard and mouse starts going weird, I just press ALT and it's back to normal.

So I have now included ALTDOWN and ALTUP in the script and that seemed to solve the problem :P

Also the "cp" is now sendt in lowercase.

AutoItSetOption( "TrayIconHide", 1)
AutoItSetOption( "SendKeyDownDelay", 10)
Send("cp")
Sleep(250)
Send("{ALTDOWN}")
Send("{ALTUP}")

Thank you all for your input guys!

Link to comment
Share on other sites

I'm just curious, is there any key held down(ingame or wherever) when the script "triggers" ?

The script is triggered by another application that I have made in C# for the game.

I could not get the SendKeys to work from C# (game uses directx and normal SendKeys from C# would not work), so thats why I'm using Autoit script to do the SendKeys.

The C# application monitors data in the game and trigger the function CP by triggering the Autoit script.

Edited by sithz
Link to comment
Share on other sites

The script is triggered by another application that I have made in C# for the game.

I could not get the SendKeys to work from C# (game uses directx and normal SendKeys from C# would not work), so thats why I'm using Autoit script to do the SendKeys.

The C# application monitors data in the game and trigger the function CP by triggering the Autoit script.

Well if I read this right then CP is an actual Function and/or you don't want the actual "cp" characters sent, correct? If that's right then your script won't work as you intended.

Is this what you really wanted or am I off base here?

AutoItSetOption( "TrayIconHide", 1)
AutoItSetOption( "SendKeyDownDelay", 10)
Func CP()
  ;Send("cp")
  ;Sleep(250)
   Send("{ALTDOWN}")
   Send("{ALTUP}")
EndFunc

But what are you doing with the {ALTDOWN} and {ALTUP}? Remember that Send() simulates keystrokes. Generally just pressing the Alt key by itself does nothing except open menus.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

The script is triggered by another application that I have made in C# for the game.

I could not get the SendKeys to work from C# (game uses directx and normal SendKeys from C# would not work), so thats why I'm using Autoit script to do the SendKeys.

The C# application monitors data in the game and trigger the function CP by triggering the Autoit script.

ok ok, but what I was thinking is just if that there's any key's pressed ingame(like a button that needs to be held down to open an in-game menu or something), while the script triggers, it might somehow conflict(especially if it's a modifier key like alt/shift/etc.).

What game is it btw.?

Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...