Sign in to follow this  
Followers 0
artego

My autotyper

9 posts in this topic

Hello everyone,

Im quite new to AutoItscript. I followed a tutorial on how to make an autotyper script and was already able to add enter to it, I would now like the option of having hotkeys too? Any idea how I start on this? This is my code:

Dim $timer, $run = False, $label[2]=['Start','Stop']
$gui = GUICreate("Artego's AutoTyper", 335, 100)
GUISetState()
GUICtrlCreateLabel("Text", 8, 10)
$key1 = GUICtrlCreateInput("", 35, 8, 120)
GUICtrlCreateLabel("Time", 8, 44)
$time1 = GUICtrlCreateInput("(in miliseconds)", 35, 40, 120)
$button = GUICtrlCreateButton($label[$run], 190, 8, 60)
HotKeySet("{F7}", "Start")
HotKeySet("{F8}", "Stop")
While 1
Switch GUIGetMsg()
Case -3
ExitLoop
Case $button
$run = Not $run
GUICtrlSetData($button, $label[$run])
$timer = 0
Case Else
If $run Then
     If TimerDiff($timer) > GUICtrlRead($time1) And Not WinActive($gui) Then
     Send(GUICtrlRead($key1))
     Send ("{ENTER}")
     $timer = TimerInit()
     EndIf
EndIf
EndSwitch
WEnd

I already thried the HotKeySet, but I think it works in a different way. Thanks if you help me, it's really appreciated :D

Share this post


Link to post
Share on other sites



Your Script seems to be incomplete

Please the full Script and Explain the code a little further


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

It is basically an autotyper application. the start and stop is to stop it. The time is how regularly it should type it. Text is the input of what is being typed. The send enter Does an Enter everytime something is typed.

$button = GUICtrlCreateButton($label[$run], 190, 8, 60) Causes it to run when and stop when the button is clicked.

This is a failed attempt to add hotkeys to start and stop:

HotKeySet("{F7}", "Start") HotKeySet("{F8}", "Stop").

Share this post


Link to post
Share on other sites

artego,

What application are you trying to spam with this "autotyper"? :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
Please the full Script...!

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

Please the full Script...!

That is my full script. Try it out :D

Share this post


Link to post
Share on other sites

artego,

What application are you trying to spam with this "autotyper"? :D

M23

It is for my own applocation/Game, a handy little tool so that players don't need to type by hand when they sell :huh:

Share this post


Link to post
Share on other sites

Dim $timer, $run = False, $label[2]=['Start','Stop']

$gui = GUICreate("Artego's AutoTyper", 335, 100)

GUISetState()

GUICtrlCreateLabel("Text", 8, 10)

$key1 = GUICtrlCreateInput("", 35, 8, 120)

GUICtrlCreateLabel("Time", 8, 44)

$time1 = GUICtrlCreateInput("(in miliseconds)", 35, 40, 120)

$button = GUICtrlCreateButton($label[$run], 190, 8, 60)

HotKeySet("{F7}", "Start")

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

While 1

Switch GUIGetMsg()

Case -3

ExitLoop

Case $button

$run = Not $run

GUICtrlSetData($button, $label[$run])

$timer = 0

Case Else

If $run Then

If TimerDiff($timer) > GUICtrlRead($time1) And Not WinActive($gui) Then

Send(GUICtrlRead($key1))

Send ("{ENTER}")

$timer = TimerInit()

EndIf

EndIf

EndSwitch

WEnd

Share this post


Link to post
Share on other sites

artego,

It is for my own applocation/Game

That is what I feared. Please read the Forum Rules - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0

  • Similar Content

    • TheDcoder
      By TheDcoder
      Hello Guys! . I have been busy with my exams... They are finished now, so summer holidays!
      I am been working very hard to bring back the reputation for AutoIt in IRC, I recently made a unofficial channel for AutoIt at freenode (freenode is a very popular IRC Network for FOSS [Free and Open Source Software]). You can check this topic if you want:
       

      Introduction
      This tutorial will guide you from start to finish covering each and every small step (no matter how small to make it more IRC newbie friendly) so that everyone can enjoy the benefits of IRC and the IRC Community. Please read the whole post for better understanding.
      Ok, lets begin our IRC adventure!
      Installing HexChat
      You might wonder why do you need HexChat, why not use the free and no installation needed online IRC client? Well, most online clients might be quick and easy to setup but don't offer much option and power, moreover they even show your IP in the public!
      For the above reason, we are using a neat desktop client called HexChat! (Its FOSS too!)
      Here are the steps you need to follow:
      1. As you might have expected, you need to download the installer first. Here is the link to the download page: http://hexchat.github.io/downloads.html. You need to select the best option for you, here are some pointers:

      2. After downloading the installer, install it... Here is a small video which I made to help you :
       
        Configuring HexChat
      This is the most important step in our journey, Configuration. After launching HexChat, it will prompt you to configure it, simply follow these steps:
      1. This is the initial window, find "freenode" in the "Networks" List:

      2. Select it and click "Favour" (optional but recommended).
      3. Change the values in the input boxes as you wish (I have set mine in the screenshot).
      4. Click edit and you will be prompted by a screen, click the "Autojoin channels" and add "##AutoIt" to it.

      5. Click "Close"
      6. Click "Connect" in the previous window and wait for it to automatically connect to ##AutoIt .
      7. Vola! You are done! You can now chat like blah blah blah.....

      Some extra optional work
      1. Type "/msg NickServ REGISTER <any password> <your email address>"
      2. Verify your email
      3. Open network manager by doing Ctrl + S
      4. Find freenode in the network list and click edit
      5. Enter your password and click "Close"
      6. Click on the "freenode" tab and enter this command: "/stats p". You will get a list of active staff members:

      7. Type "/query <nickname of the staff member> <message>"
      Replace <message> with a message asking for a "cloak", something like this would do the trick: "Hello, I want a cloak for account"
      8. Wait for the staff member to give you the cloak.
      That's it! You are done!
      End comments by the author of this tutorial
      I am glad that you are still reading until the end , You have just made a BIG contribution to freenode ##AutoIt IRC Community! Thank you very much for that
       
      IF YOU HAVE ANY PROBLEMS, FEEL FREE TO PM ME HERE OR /msg TheDcoder <message> ON IRC.
    • TheDcoder
      By TheDcoder
      Hello Guys! I wanted to share all my knowledge on arrays! Hope may enjoy the article , Lets start!
      Declaring arrays!
      Declaring arrays is a little different than other variables: 
      ; Rules to follow while declaring arrays: ; ; Rule #1: You must have a declarative keyword like Dim/Global/Local before the declaration unless the array is assigned a value from a functions return (Ex: StringSplit) ; Rule #2: You must declare the number of dimensions but not necessarily the size of the dimension if you are gonna assign the values at the time of declaration. #include <Array.au3> Local $aEmptyArray[0] ; Creates an Array with 0 elements (aka an Empty Array). Local $aArrayWithData[1] = ["Data"] _ArrayDisplay($aEmptyArray) _ArrayDisplay($aArrayWithData) That's it
      Resizing Arrays
      Its easy! Just like declaring an empty array! ReDim is our friend here:
      #include <Array.au3> Local $aArrayWithData[1] = ["Data1"] ReDim $aArrayWithData[2] ; Change the number of elements in the array, I have added an extra element! $aArrayWithData[1] = "Data2" _ArrayDisplay($aArrayWithData) Just make sure that you don't use ReDim too often (especially don't use it in loops!), it can slow down you program.
      Best practice of using "Enum"
      You might be wondering what they might be... Do you know the Const keyword which you use after Global/Local keyword? Global/Local are declarative keywords which are used to declare variables, of course, you would know that already by now , If you check the documentation for Global/Local there is a optional parameter called Const which willl allow you to "create a constant rather than a variable"... Enum is similar to Const, it declares Integers (ONLY Integers):
      Global Enum $ZERO, $ONE, $TWO, $THREE, $FOUR, $FIVE, $SIX, $SEVEN, $EIGHT, $NINE ; And so on... ; $ZERO will evaluate to 0 ; $ONE will evaluate to 1 ; You get the idea :P ; Enum is very useful to declare Constants each containing a number (starting from 0) This script will demonstrate the usefulness and neatness of Enums :
      ; We will create an array which will contain details of the OS Global Enum $ARCH, $TYPE, $LANG, $VERSION, $BUILD, $SERVICE_PACK Global $aOS[6] = [@OSArch, @OSType, @OSLang, @OSVersion, @OSBuild, @OSServicePack] ; Now, if you want to access anything related to the OS, you would do this: ConsoleWrite(@CRLF) ConsoleWrite('+>' & "Architecture: " & $aOS[$ARCH] & @CRLF) ConsoleWrite('+>' & "Type: " & $aOS[$TYPE] & @CRLF) ConsoleWrite('+>' & "Langauge: " & $aOS[$LANG] & @CRLF) ConsoleWrite('+>' & "Version: " & $aOS[$VERSION] & @CRLF) ConsoleWrite('+>' & "Build: " & $aOS[$BUILD] & @CRLF) ConsoleWrite('+>' & "Service Pack: " & $aOS[$SERVICE_PACK] & @CRLF) ConsoleWrite(@CRLF) ; Isn't it cool? XD You can use this in your UDF(s) or Program(s), it will look very neat!
      Looping through an Array
      Looping through an array is very easy! . There are 2 ways to loop an array in AutoIt!
      Simple Way:
      ; This is a very basic way to loop through an array ; In this way we use a For...In...Next Loop! Global $aArray[2] = ["Foo", "Bar"] ; Create an array ; This loop will loop 2 times because our $aArray contains 2 elements. For $vElement In $aArray ; $vElement will contain the value of the elements in the $aArray... one element at a time. ConsoleWrite($vElement & @CRLF) ; Prints the element out to the console Next ; And that's it! Advanced Way:
      ; This is an advanced way to loop through an array ; In this way we use a For...To...Next Loop! Global $aArray[2] = ["Foo", "Bar"] ; Create an array ; This loop will loop 2 times because our $aArray contains 2 elements. For $i = 0 To UBound($aArray) - 1 ; $i is automatically created and is set to zero, UBound($aArray) returns the no. of elements in the $aArray. ConsoleWrite($aArray[$i] & @CRLF) ; Prints the element out to the console. Next ; This is the advanced way, we use $i to access the elements! ; And that ends this section! For some reason, many people use the advance way more than the simple way .
      Interpreting Multi-Dimensional Arrays
      Yeah, its the most brain squeezing problem for newbies, Imagining an 3D Array... I will explain it in a very simple way for ya, so stop straining you brain now! . This way will work for any array regardless of its dimensions...
      Ok, Lets start... You can imagine an array as a (data) mine of information:

      ; Note that: ; Dimension = Level (except the ground level :P) ; Element in a Dimension = Path ; Level 2 ----------\ ; Level 1 -------\ | ; Level 0 ----\ | | ; v v v Local $aArray[2][2][2] ; \-----/ ; | ; v ; Ground Level ; As you can see that $aArray is the Ground Level ; All the elements start after the ground level, i.e from level 0 ; Level 0 Contains 2 different paths ; Level 1 Contains 4 different paths ; Level 2 Contains 8 different paths ; When you want too fill some data in the data mine, ; You can do that like this: $aArray[0][0][0] = 1 $aArray[0][0][1] = 2 $aArray[0][1][0] = 3 $aArray[0][1][1] = 4 $aArray[1][0][0] = 5 $aArray[1][0][1] = 6 $aArray[1][1][0] = 7 $aArray[1][1][1] = 8 ; Don't get confused with the 0s & 1s, Its just tracing the path! ; Try to trace the path of a number with the help of the image! Its super easy! :D I hope you might have understand how an array looks, Mapping your way through is the key in Multi-Dimensional arrays, You take the help of notepad if you want! Don't be shy!
      Frequently Asked Questions (FAQs) & Their answers
      Q #1. What are Arrays?
      A. An Array is an datatype of an variable (AutoIt has many datatypes of variables like "strings", "integers" etc. Array is one of them). An Array can store information in a orderly manner. An Array consist of elements, each element can be considered as a variable (and yes, each element has its own datatype!). AutoIt can handle 16,777,216 elements in an Array, If you have an Array with 16,777,217 elements then AutoIt crashes.
      Q #2. Help! I get an error while declaring an Array!?
      A. You tried to declare an array like this:
      $aArray[1] = ["Data"] That is not the right way, Array is a special datatype, since its elements can be considered as individual variables you must have an declarative keyword like Dim/Global/Local before the declaration, So this would work:
      Local $aArray[1] = ["Data"] Q #3. How can I calculate the no. of elements in an array?
      A. The UBound function is your answer, Its what exactly does! If you have an multi-dimensional Array you can calculate the total no. of elements in that dimension by specifying the dimension in the second parameter of UBound
      Q #4. Why is my For...Next loop throwing an error while processing an Array?
      A.  You might have done something like this:
      #include <MsgBoxConstants.au3> Local $aArray[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Local $iMyNumber = 0 For $i = 0 To UBound($aArray) ; Concentrate here! $iMyNumber += $aArray[$i] Next MsgBox($MB_OK, "Sum of all Numbers!", $iMyNumber) Did you notice the mistake? UBound returns the no. of elements in an array with the index starting from 1! That's right, you need to remove 1 from the total no. of elements in order to process the array because the index of an array starts with 0! So append a simple - 1 to the statment:
      #include <MsgBoxConstants.au3> Local $aArray[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Local $iMyNumber = 0 For $i = 0 To UBound($aArray) - 1 $iMyNumber += $aArray[$i] Next MsgBox($MB_OK, "Sum of all Numbers!", $iMyNumber) Q #5. Can an Array contain an Array? How do I access an Array within an Array?
      A. Yes! It is possible that an Array can contain another Array! Here is an example of an Array within an Array:
      ; An Array can contain another Array in one of its elements ; Let me show you an example of what I mean ;) #include <Array.au3> Global $aArray[2] $aArray[0] = "Foo" Global $aChildArray[1] = ["Bar"] $aArray[1] = $aChildArray _ArrayDisplay($aArray) ; Did you see that!? The 2nd element is an {Array} :O ; But how do we access it??? ; You almost guessed it, like this: ; Just envolope the element which contains the {Array} (as shown in _ArrayDisplay) with brackets (or parentheses)! :D ConsoleWrite(($aArray[1])[0]) ; NOTE the brackets () around $aArray[1]!!! They are required or you would get an syntax error! ; So this: $aArray[1][0] wont work!  
      More FAQs coming soon!
    • Wicked_Caty
      By Wicked_Caty
      I finally gave a look into DLLs and want to make use of them in Autoit.
      I know that a DLL is basically a library with some code, that can be used by several other programs at the same time to get some advantages.
      Yet, I need to know how they are properly used. Also it might be helpful to know what DLL is doing what task. Can you provide some resources?
      Thanks!
    • TheDcoder
      By TheDcoder
      Hello Again! I previously stumbled upon a topic asking for maps datatype's instructions... I too wasn't sure what a map is until I tried it... So I am making this topic to help other newbies (and some oldbies) better understand the Maps datatype of AutoIt! Lets start!
      A Note for Readers
      The maps datatype is still in development and is currently in Alpha Stage (More Risky than Beta) and its unstable, so AutoIt can crash indefinably while using Maps! I can't guarantee if this will be implemented in stable versions, this is a fairly new thing to AutoIt coders & in my honest opinion I don't see any use for it Maps are the best datatype in AutoIt, Very Useful ... Not hurting anyone though .  Also the maps datatype is DISABLED IN STABLE VERSIONS, So you need to install the latest beta version of AutoIt to make maps work . If you find any bugs while using a map, please report it in the Official Bug Tracker
      Introduction To Maps
      Maps are just like arrays, instead they use "keys" to access elements inside them... A key can be either a string or an integer (Other datatypes work too but they are converted to a integer [Equivalent to Int($vKey)] before assignment [Source]). Although Integers don't represent the order of elements in a map unlike in an array...
      Declaring Maps
      Its similar to declaring an Array:
      ; This is the only way to declare a map ; You must have a declarative keyword like Dim/Global/Local before the declaration unless the map is assigned a value from a functions return Local $mMap[] ; Don't insert any numbers or strings it! Simple, Isn't it?
      Using Maps
      Using maps is similar to arrays (again!):
      Local $mMap[] ; Lets declare our map first! ; Adding data to maps is easy... ; This is our key ; | ; v $mMap["Key"] = "Value" ; <--- And our value! ; A key is Case-Sensitive meaning "Key" is not same as "key"! $mMap["key"] = "value" ; Not the same as $mMap["Key"]! ; There are 2 different ways to access an element in a map $mMap["Key"] ; 1st Method $mMap.Key ; 2nd Method  Enumerating Maps
      Its quite easy to enumerate through arrays but what about maps? how can I enumerate through them!?
      #include <MsgBoxConstants.au3> ; Lets create our map first Local $mMap[] ; Lets add some information to the map, feel free to modify & add new elements $mMap["Name"] = "Damon Harris" $mMap["Alias"] = "TheDcoder" $mMap["Gender"] = "Male" $mMap["Age"] = 14 $mMap["Location"] = "India" $aMapKeys = MapKeys($mMap) ; MapKeys function returns all the keys in the format of an array Local $sProfile = "Profile of " & $mMap["Name"] & ':' & @CRLF ; We will use this string later For $vKey In $aMapKeys ; We use this to get the keys in a map :) $sProfile &= @CRLF & $vKey & ': ' & $mMap[$vKey] ; Add some details to the profile string using our map! Next MsgBox($MB_ICONINFORMATION + $MB_OK, "Profile", $sProfile) ; Finally display the profile :) It is easy as always
      Multi-Dimensional Maps
      Now now... I know that you are a little confused that how can an multi-dimensional maps exist... Although I am not 100% sure if its called that but lets continue:

      #include <MsgBoxConstants.au3> ; Multi-Dimensional maps are just maps in a map Local $mMapOfMapsvilla[] ; This map will store an other map Local $mParkMap[] ; This Park map will be inserted in the Mapsvilla's map :P $mMapOfMapsvilla["Map Item 1"] = "Town Hall" $mMapOfMapsvilla["Map Item 2"] = "Police Station" $mMapOfMapsvilla["Map Item 3"] = "Shopping Mall" $mMapOfMapsvilla["Map Item 4"] = "Residential Area" $mMapOfMapsvilla["Map Item 5"] = "Park" $mParkMap["Map Item 1"] = "Cottan Candy Stand" $mParkMap["Map Item 2"] = "Public Toilet" $mParkMap["Map Item 3"] = "Woods" $mMapOfMapsvilla.Park = $mParkMap MsgBox($MB_OK, "Map Location", $mMapOfMapsvilla["Map Item 1"]) ; Will display Town Hall MsgBox($MB_OK, "Map Location", $mMapOfMapsvilla.Park["Map Item 1"]) ; Will display Cottan Candy Stand I am sure its easy for you to understand now
      Frequently Asked Questions (FAQs) & Their answers
      Q #1. Help! My code does not respond to anything (or) I get an "Variable subscript badly formatted" error on the line of declaration...
      A. DONT USE F5 or Go, Instead use Alt + F5 or Tools -> Beta Run in SciTE (Make sure that you have Beta installed)
      Q #2. Why are you using "m" in-front of every map variable?
      A. Best coding Practices: Names of Variables 
      Q #3. What are "Elements" which you mention frequently???
      A. This is a newbie question (I have no intention of insulting you ), so I guess you are new to programming. "Elements" are data slots inside a Map (or an Array), you can imagine elements as individual variable which are stored in a Map. You can access them using "keys", Please refer to "Introduction to Maps" section at the starting of this post
      Q #4. Are Maps faster than Arrays?
      A. You need to understand that Maps have different purpose than Arrays. Maps are designed to store data dynamically (like storing information for certain controlIDs of GUI) and Arrays are designed to store data in a order (for instance, Storing every character of a string in an element for easy access). If you still want to know then if Maps are faster, then the answer is maybe... Maps are *supposed* (I am not sure ) to be faster in addition of elements (while Arrays are painfully slow while adding or removing elements). Here (Post #24) is a benchmark (Thanks kealper! )
       
      More FAQs coming soon! Feel free to ask a question in the mean while
    • Skysnake
      By Skysnake
      It seems the AutoIt community does not much venture into AutoItX and the real programmers do not need much to understand how to implement the DLLs -> is there some guidance with explanantions available?
      This part of the AutoIt site is definitely not getting as much traffic as the rest.  Obviously a lot of assumed knowledge and skill applies...  I have searched for AutoItX but can not find a single tutorial.  There are examples - but what I would really like is a ZIPped project, that explains the C layout, and the link to the AutoIT DLLs.  A bit more narrative than code  so that I can also learn how...  
      Is there maybe a static Wiki/FAQ on AutoItX that I have missed?