Jump to content

Recommended Posts

Posted

Hi Im new and still learning to code AutoIT. I want to create a simple bot that send a key "W". I created a simple GUI and I want after I press "Run" button on the GUI, "W" key will be sent on the loop. But i cant get it to work. I really dont know what I am missing.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $iform = GUICreate("Bot", 180, 140)
Local $_Start = GUICtrlCreateGroup("Start", 8, 8)
Local $_Run = GUICtrlCreateButton("Run", 24, 24, 129)
Local $_Exit = GUICtrlCreateGroup("Exit", 8 ,72)
Local $_Close = GUICtrlCreateButton ("Close", 24,88,129)
GuiSetState(@SW_SHOW)

HotKeySet("{ESC}", "kill")

HotKeySet("{F8}", "TogglePause")


While 1
   $iMsg = GUIGetMsg()
   Switch $iMsg
   Case $GUI_EVENT_CLOSE
      Exit

   Case $_Close
      Exit

   Case $_Run
Func _Bot()
      Send("{W}")
      Sleep(2000)
EndFunc

EndSwitch
WEnd


Func kill()
   Exit
EndFunc

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

Did you run it in SciTE4Autoit?

When run (F5) is pressed, you can see the errors in the console output

Edited by Exit

App: Au3toCmd              UDF: _SingleScript()                             

Posted (edited)

Did you run it in SciTE4Autoit?

When run (F5) is pressed, you can see the errors in the console output

Yes i run it inside Scite. I only see a blue line with this one being the indication of error "ErrorStdOut". But other than that, i dont see anything else. The problem is I cant get it to work with the GUI. If I make a simple While loop, it works normally.

Edited by NewUser01
Posted

Glad, that I could help.

BTW. Welcome to the forum.

And a little hint: Try to avoid the word 'bot'.

Read the forum rules (lower right corner in this window) and you'll understand why.

App: Au3toCmd              UDF: _SingleScript()                             

Posted (edited)

This seems a bit silly. The word itself is not specific to any particular application. The majority of example scripts could qualify. What is software automation if it isn't using some kind of robot? The forum rules are very specific about game automation, but the word bot is just a shorthand way of saying robot.

Edited by czardas

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
×
×
  • Create New...