Jump to content

(Help) Keyboard error problem


McG
 Share

Recommended Posts

I created a BOT (using AutoIT) for online game that can run as an inactive window.

Commands that i use is: ControlSend, WinGetHandle, WinGetTitle, and also pixelgetcolour.

Situation when running BOT:

1. Active window is a program like corel, photoshop or a text editing program such as OfficeXP.

2. Inactive Window is active online game supported by my BOT program.

The problem that I experienced:

When I work with shortcut keys such as SHIFT/CTRL/ALT along with the BOT program, the keyboard becomes error. CAPS LOCK key is automatically on and off continuously. Worse, the keyboard does not work at all. I've tried using another keyboard.

My question:

How do I get BOT program does not consider as an input or a command when I was pressing the SHIFT/CTRL/ALT which is often I use at work?

Hopefully someone will be able to help me

Warm regards

DK

Link to comment
Share on other sites

  • Moderators

McG,

First, welcome to the AutoIt forums. :)

Please note that forum etiquette is that you do not bump your own thread within 24 hrs. You must bear in mind that this is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually. Or if not - tough! ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I suggest you post your code and highlight the spots that are not working for you.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Sorry, i forgot that one.

Dim $title
Dim $handle
Dim $Paused

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

AutoItSetOption("WinTitleMatchMode", 4)
$title = WinGetTitle("my game name", "")
MsgBox(0, "Full title read was:", $title)
$handle = WinGetHandle("my game name", "")

while 1 = 1
If @error Then
MsgBox(4096, "Error", "Could not find the correct window")
Else
target()
checkTarget()
do_some_Skill()
my_health()
pick()
EndIf
Wend

Func Terminate()
Exit 0
EndFunc

Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',0,0)
WEnd
ToolTip("")
EndFunc

Func target();function to find the target
ControlSend($handle, "", "", "E")
sleep (1000)
Endfunc

Func checkTarget();function to check the target, avoided or not
while ((PixelGetColor(60,64) > 10000000) _
and (PixelGetColor(110,64) > 10000000) _
and (PixelGetColor(91,58) > 10000000) _
and (PixelGetColor(92,58) < 10000000))
ControlSend($handle, "", "", "E")
sleep(1000)
my_health()
pick()
while ((PixelGetColor(67,58) > 16500000) _
and (PixelGetColor(67,61) > 16500000) _
and (PixelGetColor(73,58) > 16500000) _
and (PixelGetColor(73,64) > 16500000) _
and (PixelGetColor(75,60) > 16500000) _
and (PixelGetColor(84,58) > 16500000) _
and (PixelGetColor(93,64) > 16500000) _
and (PixelGetColor(96,61) > 16500000))
ControlSend($handle, "", "", "E")
sleep(1000)
my_health()
pick()
WEnd
WEnd
EndFunc

Func do_some_Skill(); function to do some skill
ControlSend($handle, "", "", "R")
sleep (500)
ControlSend($handle, "", "", "1")
sleep (500)
ControlSend($handle, "", "", "2")
sleep (500)
ControlSend($handle, "", "", "3")
sleep (500)
ControlSend($handle, "", "", "4")
sleep (500)
ControlSend($handle, "", "", "5")
sleep (500)
my_health()
pick()
EndFunc

Func my_health();function to check hp/mp
if (pixelgetcolor(140,28) < 1000000) then
ControlSend($handle, "", "", "0")
sleep (500)
EndIf
EndFunc

Func pick();function to pick up items dropped from monsters
ControlSend($handle, "", "", "FFF")
sleep (500)
EndFunc

Overall this bot goes well.

But when I work with shortcut keys such as SHIFT/CTRL/ALT along with the BOT program, the keyboard becomes error. CAPS LOCK key is automatically on and off continuously. Worse, the keyboard does not work at all. I've tried using another keyboard.

How do I get BOT doesn't consider as an input or a command when I was pressing the SHIFT/CTRL/ALT which is often I use at work?

Edited by McG
Link to comment
Share on other sites

Firstly, learn and use Tidy so your code looks more like below

Secondly, I cannot see where you have tried to use SHIFT/CTRL/ALT so i can't tell if you have done it correctly.

Thirdly, have you looked closely at the SendKeyList in the help file

Fourthly, caps lock would only go on and off if instructed and I have no idea why it would do that or why your keyboard would stop working, sorry. What game is it?

Opt("MustDeclareVars", 1)

Dim $title
Dim $handle
Dim $Paused

HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

AutoItSetOption("WinTitleMatchMode", 4)
$title = WinGetTitle("my game name", "")
MsgBox(0, "Full title read was:", $title)
$handle = WinGetHandle("my game name", "")

While 1 = 1
    If @error Then
        MsgBox(4096, "Error", "Could not find the correct window")
    Else
        target()
        checkTarget()
        do_some_Skill()
        my_health()
        pick()
    EndIf
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func target();function to find the target
    ControlSend($handle, "", "", "E")
    Sleep(1000)
EndFunc   ;==>target

Func checkTarget();function to check the target, avoided or not
    While ((PixelGetColor(60, 64) > 10000000) _
            And (PixelGetColor(110, 64) > 10000000) _
            And (PixelGetColor(91, 58) > 10000000) _
            And (PixelGetColor(92, 58) < 10000000))
        ControlSend($handle, "", "", "E")
        Sleep(1000)
        my_health()
        pick()
        While ((PixelGetColor(67, 58) > 16500000) _
                And (PixelGetColor(67, 61) > 16500000) _
                And (PixelGetColor(73, 58) > 16500000) _
                And (PixelGetColor(73, 64) > 16500000) _
                And (PixelGetColor(75, 60) > 16500000) _
                And (PixelGetColor(84, 58) > 16500000) _
                And (PixelGetColor(93, 64) > 16500000) _
                And (PixelGetColor(96, 61) > 16500000))
            ControlSend($handle, "", "", "E")
            Sleep(1000)
            my_health()
            pick()
        WEnd
    WEnd
EndFunc   ;==>checkTarget

Func do_some_Skill(); function to do some skill
    ControlSend($handle, "", "", "R")
    Sleep(500)
    ControlSend($handle, "", "", "1")
    Sleep(500)
    ControlSend($handle, "", "", "2")
    Sleep(500)
    ControlSend($handle, "", "", "3")
    Sleep(500)
    ControlSend($handle, "", "", "4")
    Sleep(500)
    ControlSend($handle, "", "", "5")
    Sleep(500)
    my_health()
    pick()
EndFunc   ;==>do_some_Skill

Func my_health();function to check hp/mp
    If (PixelGetColor(140, 28) < 1000000) Then
        ControlSend($handle, "", "", "0")
        Sleep(500)
    EndIf
EndFunc   ;==>my_health

Func pick();function to pick up items dropped from monsters
    ControlSend($handle, "", "", "FFF")
    Sleep(500)
EndFunc   ;==>pick

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

@Mass Spammer, thanks for your reply

:) Firstly, what is 'Tidy' ? Sorry for that, cause i'm newbie in AutoIT

Online game I played was "Tantra Online"

I use SHIFT/CTRL/ALT as a shortcut to the program that I use for work (coreldraw, photoshop or OfficeXp) and not the bot or the game.

So I wonder, every time i press the (SHIFT +1) or (CTRL +2) as a shortcut key or press {SHIFT} to write big letters when working with coreldraw/officeXP/photoshop, keyboard gradually become errors.

Cases I often come across is, the keyboard to write all the letters in uppercase form without having to hit 'SHIFT' or 'Capslock', and when that happens automatically Capslock lights on and off continuously.

Effect on my game: when the error happen, the bot can not stop. When it's stop, I can't press the "E" button temporarily to find the target in the manual mode (without the bot running)

Is it possible that bot program assume the SHIFT/CTRL/ALT button as one of the executed commands as if I will stop the bot

HotKeySet("(PAUSE)", "TogglePause");for stop script
Edited by McG
Link to comment
Share on other sites

@Mass Spammer, thanks for your reply

:) Firstly, what is 'Tidy' ? Sorry for that, cause i'm newbie in AutoIT

Tidy is a program that comes with the full version of Scite. You can learn more here - http://www.autoitscript.com/autoit3/scite/. CTRL+T is the shortcut for it.

Online game I played was "Tantra Online"

I use SHIFT/CTRL/ALT as a shortcut to the program that I use for work (coreldraw, photoshop or OfficeXp) and not the bot or the game.

So I wonder, every time i press the (SHIFT +1) or (CTRL +2) as a shortcut key or press {SHIFT} to write big letters when working with coreldraw/officeXP/photoshop, keyboard gradually become errors.

Cases I often come across is, the keyboard to write all the letters in uppercase form without having to hit 'SHIFT' or 'Capslock', and when that happens automatically Capslock lights on and off continuously.

Effect on my game: when the error happen, the bot can not stop. When it's stop, I can't press the "E" button temporarily to find the target in the manual mode (without the bot running)

That is quite strange. I know some programs like Word can lock in uppercase via program settings. I assume the issue your having happens everywhere once you get it, not just in the program? What happens if that program is closed? Sorry, I have more questions then answers - I can't even guess what is happening there.

Is it possible that bot program assume the SHIFT/CTRL/ALT button as one of the executed commands as if I will stop the bot

HotKeySet("(PAUSE)", "TogglePause");for stop script

Yes. You might want to rename the function TogglePause to End or something like that. Use "Exit" in that function to end the script.

I use

HotKeySet("^!x", "MyExit") ; Press Ctrl+Alt+x to stop the script
; ... the rest of the code
Func MyExit()
    ConsoleWrite("Script Stoppted by user")
    Exit
EndFunc   ;==>MyExit

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

@Mass Spammer!, I think you have too many questions than answers because you do not understand my problems. :)

Apparently not only corel, photoshop, or OfficeXp errors, but when I try to write a sentence in notepad also occurred the same problem. I also have tried to write a sentence in notepad, while the programs I worked with are off. Game and BOT active in background mode.

I write the sentence

Most battles need support eventually

but it is written to be like this B)

MoSt baTtles neED sUpPOrt eveNtualLy

Know the difference?

from the example case, there are some characters that should not have written in capital letters but somehow the writing could be like that.

Worse yet, if I write a capital letter by pressing shift for too long as like

recommend that you PREPARE YOUR HARD DRIVE FOR INSTALLATION BY RUNNING SCANDISK AND DISK DEFRAGMENTER prior
What happens if I press the SHIFT key too long and BOT is running, the notepad become errors. When i press the button nothing happens.

Could there be a lack of command on my Bot resulting keys (Capslock) or (shift) became error as I experience?

What was missing when I use the command "controlsend ()"?

Or is it a bug?

Please understand and apologize if this newbie spoil too much of your time to answer this silly problems ;)

Link to comment
Share on other sites

I understand your issue, your keyboard goes spastic when you run Autoit scripts. How many are you running at one time?

Your "controlsend()" call is fine, your are sending 'E' to your game. Seems to be there is more going on there that I can see. You many have something else running in the background. You could try using send when the game/program in focus?

Either way I can't see anything wrong in your script to cause you the errors you explained. Sorry I can't give you a solution.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

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...