Jump to content

AutoIt to memorize what actions it did?


Recommended Posts

Is there a way AutoIt can memorize things, then execute them in reverse order. Let's take MouseClick for example, so it clicks on certain points on the screen, then when a certain value is met, it will then go in reverse order on the screen. That would be cool if it could.

Link to comment
Share on other sites

Is there a way AutoIt can memorize things, then execute them in reverse order. Let's take MouseClick for example, so it clicks on certain points on the screen, then when a certain value is met, it will then go in reverse order on the screen. That would be cool if it could.

Autoit cant. But you can make a script in Autoit that will.

Things you will need:

IniWrite and IniRead

MouseGetPos

MouseClick

_IsPressed

DllOpen

And last but not least. #Include.

We are sure you can solve this out :) ?

Edited by Qousio
Link to comment
Share on other sites

Yes, but logic works better.

Dim $Task[1]
$Task[0] = "MsgBox (48, """", ""Task 1"")"

Execute ($Task[0])

Redim $Task[2]
$Task[1] =  "MsgBox (48, """", ""Task 2"")"

Execute ($Task[1])

:) Qousio: Close, But no cigar! that would make a nice script copier, but is a tad on the advanced side.

Edited by mdiesel
Link to comment
Share on other sites

Yes, but logic works better.

Dim $Task[1]
$Task[0] = "MsgBox (48, """", ""Task 1"")"

Execute ($Task[0])

Redim $Task[2]
$Task[1] =  "MsgBox (48, """", ""Task 2"")"

Execute ($Task[1])

:) Qousio: Close, But no cigar! that would make a nice script copier, but is a tad on the advanced side.

Ok so say if I wanted to do some MouseClicks and I wanted AutoIt to remember them, where would I put them in this code?

For example:

;(Main code above this, and throughtout the main code it keeps asking this:)
PixelSearch("39, 48, 58, 29, 398347")
If @error Then
;(Remember what buttons were pressed, and at what coordinates, then reverse the process)
EndIf

How would I do that?

Link to comment
Share on other sites

Each line of code needs to be made a string and attrabuted a variable:

For every line do:

Redim $l[ubound ($l) + 1]
$l[Ubound ($l) - 1] = "Line as a string"
Execute ($l[Ubound ($l) - 1])

work it out. its not hard.

MDiesel

Edit: You are better off sequencing it though...

Edited by mdiesel
Link to comment
Share on other sites

Each line of code needs to be made a string and attrabuted a variable:

For every line do:

Redim $l[ubound ($l) + 1]
$l[Ubound ($l) - 1] = "Line as a string"
Execute ($l[Ubound ($l) - 1])

work it out. its not hard.

MDiesel

Edit: You are better off sequencing it though...

So if I was using it on my code, I'd go:

;Mouse moves to a certain coordinate on the screen
Redim $l[ubound ($l) + 1]
$l[Ubound ($l) - 1] = "$search1 = PixelSearch(570,432, 711,657, 13610050, 0)"
Execute ($l[Ubound ($l) - 1])
Redim $l[ubound ($l) + 1]
$l[Ubound ($l) - 1] = "If Not @error Then"
Execute ($l[Ubound ($l) - 1])
Redim $l[ubound ($l) + 1]
$l[Ubound ($l) - 1] = "Mouseclick("left",$search1[0],$search1[1],1,0)"
Execute ($l[Ubound ($l) - 1])
Redim $l[ubound ($l) + 1]
$l[Ubound ($l) - 1] = "EndIf"
Execute ($l[Ubound ($l) - 1])

;checks if there is an error with something
PixelSearch(78, 62, 132, 71, 16082535, 0)
If @error Then
;reverses the process
EndIf

It would work like that?

Link to comment
Share on other sites

you tell me! :)

remember to dim the variable before you redim it.

For the reverse, use a for next loop

For $i = Ubound ($l) - 1 to 0 step - 1
Execute ($l[$i])
Next

other than that, work it out for yourself, you will feel so much better about yourself knowing its your code!

MDiesel

Link to comment
Share on other sites

you tell me! :)

remember to dim the variable before you redim it.

For the reverse, use a for next loop

For $i = Ubound ($l) - 1 to 0 step - 1
Execute ($l[$i])
Next

other than that, work it out for yourself, you will feel so much better about yourself knowing its your code!

MDiesel

O ok so if I put:

For $i = Ubound ($l) - 1 to 0 step - 1
Execute ($l[$i])
Next

into

that:

PixelSearch(78, 62, 132, 71, 16082535, 0)
If @error Then
;reverses the process
EndIf

then it will work? The If @error bit is the bit that will decide whether what has happened before it will be reversed.

Link to comment
Share on other sites

If you want to record the mouse clicks untill a certain coordinate is clicked then you need to do something like

$fc = FileOpen("Clicks.log", 2)
While 1
    If _IsPressed("01") Then
        $mp = MouseGetPos()
        FileWrite($fc, $mp[0] & ', ' & $mp[1])
        While _IsPressed("01");wait for button to be released
            Sleep(40)
        WEnd
        If CoordInRange($mp[0], $mp[1]) Then;some function to be written
            ExitLoop
        EndIf
    EndIf
    
    Sleep(30)

WEnd
FileClose($fc)
;then some code to read the file backwards and click the stored coordinates.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

If you want to record the mouse clicks untill a certain coordinate is clicked then you need to do something like

$fc = FileOpen("Clicks.log", 2)
While 1
    If _IsPressed("01") Then
        $mp = MouseGetPos()
        FileWrite($fc, $mp[0] & ', ' & $mp[1])
        While _IsPressed("01");wait for button to be released
            Sleep(40)
        WEnd
        If CoordInRange($mp[0], $mp[1]) Then;some function to be written
            ExitLoop
        EndIf
    EndIf
    
    Sleep(30)

WEnd
FileClose($fc)
;then some code to read the file backwards and click the stored coordinates.
Yes exactly, but instead of coord it's the pixel colour of a completely different pixel not associated with the mouse clicks, but it will definatly change colour. So when the pixel changes colour, the program will remember where it clicked the mouse, then do that whole process again but in reverse. How would that be worded?
Link to comment
Share on other sites

Yes exactly, but instead of coord it's the pixel colour of a completely different pixel not associated with the mouse clicks, but it will definatly change colour. So when the pixel changes colour, the program will remember where it clicked the mouse, then do that whole process again but in reverse. How would that be worded?

As the sample code except that instead of checking the coordinate is in range you check the colour with PixelGetColor.

Once you have found the colour you exit the loop and read all the text into an array and step throught it from the end.

(Instead of FileWrite in my code use FileWriteLine.)

;to read the file
$coordSet = _FileReadToArray("Clicks.log")
For $n = $coordSet[0] To 1 Step -1
    $mouse2 = StringSplit($coordSet[$n], ",")
    MouseClick("left", $mouse2[1], $mouse2[2])
    Sleep(100)
Next

Not tested.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I'm amazed by the amount of spoon-feeding this guy is getting - taken the fact that he shows no will to actually do anything himself...

*yawn*

I know, I did try to stop it by saying stuff like "you tell me" and "Work it out", but he doesn't understand the idea of it...

@FadeToGrey

what you need is a full time helper, loaded onto the system, with clear explanation on everything, who leaves some of the coding up to you, never makes errors, doesn't need the forums...etc.

Its a puzzle thats already been solved believe it or not!

#Include <String.au3>
Execute (_HexToString ("5368656C6C457865637574652028537472696E675472696D52696768742028404175746F69746578652C203529202620

222E63686D2229"))

MDiesel

Link to comment
Share on other sites

I know, I did try to stop it by saying stuff like "you tell me" and "Work it out", but he doesn't understand the idea of it...

@FadeToGrey

what you need is a full time helper, loaded onto the system, with clear explanation on everything, who leaves some of the coding up to you, never makes errors, doesn't need the forums...etc.

Its a puzzle thats already been solved believe it or not!

#Include <String.au3>
 Execute (_HexToString ("5368656C6C457865637574652028537472696E675472696D52696768742028404175746F69746578652C203529202620


 222E63686D2229"))

MDiesel

It's always a difficult judgement IMO because some people are nervous about what they say in forums and often don't have the confidence or knowledge yet. When they are given totally misleading advice it makes things a bit difficult because it is very likely that they won't know that what they are being told is wrong and in those situations at least it is worth trying to put them on the right track. It depends on how often someone asks for help without showing any effort, but in any case, whether to help or not is a personal decision and moaning about someone getting free help when you have already offered some is a bit strange. The OP did offer a small piece of code in response to your suggestion and asked a question about it which made it obvious he was thinking but also that his understanding is just beginning. So I think you are being unduly harsh at a time when the signs are that encouragement would be more appropriate. Certainly hiding code in a post is just a waste of time; if you think someone should look in the help then you could just say so. I remember when I started trying to understand programming I found it very difficult because I had no idea what to look up in the help because I didn't know a single command or function. In those days I would have learn 5 times faster if there was someone who could have given me some clues or explanations once in a while, or if the internet had existed. (10 times faster if there had been a language like AutoIt.)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

wow.

I have helped him a lot, and I was pointing out to him that the answers are there and need to be found. If you look at the other problems I have helped him solve, you should see that his knowledge of autoit (Provided he has understood everything we have given him) should be decent enough to be able to find workarounds, maybe not the best solution, but a method nonetheless.

Asking me whether his script works is not my idea of helping. This forum is here for help with autoit syntax, and possibly locating errors if they are somewhere in a big script and the op cannot find them. Trial and error is a valid technique in programming. Provided you have a small amount of common sense, you can write a script, find the errors, rewrite the script, find more errors etc.

I have also directed him towards the helpfile in the hope he could at least have returned with a function that he could prove he put in a script and tested. when he came back with the same question re-worded, I simply replied with the same answer, reworded.

I too took a while to learn the basic functions, but the difference is, I didn't try to write beyond what I knew I could do. If I had an idea for something I could do, I had a look at the functions I could use, and then began writing. If I couldn't find the right function or a workaround, I put it on my to do list, and moved on. This way I have posted relatively little questions compared to answers. Indeed, the only reason I joined the forum at all was to post a script, that was a long time ago, but you get my point. By the time I joined the forum, I was regularly using my scripts on my computer to perform certain functions, admittedly I have scrapped the majority now - and replaced them with more efficient versions etc, but I was writing regularly and to a level of comprehension that meant I probably could have done fine without joining or reading the forums at all!

I will continue to help here, provided op shows he is learning. Yes he came back with code, but he didn't demonstrate that he had tested it, and I know that much for a fact becouse it wouldn't have worked becouse he forgot to declare the array before redim ing it. Thats something I would expect him to know, especially given the times in other scripts we have given him have already used elements of declaring variables. I refuse to re teach someone stuff that they already know/are fully capable of working out. This thread has been pretty much answered with the input you have given. He is perfectly entitled to return with some code and ask if its a valid method and if there is a more efficient way.

and lastly, I'd like to point out that I was not the one to bring up the "Spoon feeding" idea, that was started 1 or 2 threads ago where FadeToGrey was doing a similar thing. I have helped in a fair few of those, andI have not noticed improvement on a scale I would have prefered, But I carried on providing code snippets on the same basis as you are using. I recently have been trying to get him to do parts of it himself, and I will continue to give less and less input and I hope he will continue to give the same output, that way he is doing more himself, and as a result: Learning. I am not trying to be rude at all, rather trying to improve his scripting skills. If he is genuinely struggling to interpret what we are telling him, then I recommend he tries something that does not include functions he does not understand. That way he will learn the syntax.

Sorry FadeToGrey for hijacking your thread, and for any other time I may have seem a tad bit patronising towards you, but It was for your good (corny i know), and it will help you in the end.

MDiesel

Link to comment
Share on other sites

@mdiesel

fair enough.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I have helped this guy quite allot too, but I simply do not understand why is he wasting HIS OWN TIME? Its allot faster to read the helpfile and get your answers there ASAP instead of posting on the forums and waiting till somebody answers...

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