NewUser01 Posted July 7, 2014 Share Posted July 7, 2014 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. expandcollapse popup#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 Link to comment Share on other sites More sharing options...
Exit Posted July 7, 2014 Share Posted July 7, 2014 (edited) Did you run it in SciTE4Autoit? When run (F5) is pressed, you can see the errors in the console output Edited July 7, 2014 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
NewUser01 Posted July 7, 2014 Author Share Posted July 7, 2014 (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 July 7, 2014 by NewUser01 Link to comment Share on other sites More sharing options...
Exit Posted July 7, 2014 Share Posted July 7, 2014 Func _Bot() cannot be declared inside a Switch/Endswitch App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
NewUser01 Posted July 7, 2014 Author Share Posted July 7, 2014 Func _Bot() cannot be declared inside a Switch/Endswitch Thanks, I remove the Func and it works as intended. Thank you for the prompt answer. Link to comment Share on other sites More sharing options...
Exit Posted July 7, 2014 Share Posted July 7, 2014 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() Link to comment Share on other sites More sharing options...
Bert Posted July 7, 2014 Share Posted July 7, 2014 (edited) The word "bot" is like waving red in front of a bull around here.... Edited July 7, 2014 by MBALZESHARI The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
czardas Posted July 7, 2014 Share Posted July 7, 2014 (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 July 7, 2014 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now