Jump to content

Script only does 1 line then wait then terminate


Recommended Posts

sleep(random(350,500,1))
send ("{s down}")
sleep(random(350,500,1))
send ("{s down}")
sleep(random(350,500,1))
send ("{s down}")
sleep(random(350,500,1))
send ("{s down}")
sleep(random(350,500,1))
send ("{s down}")
sleep(random(350,500,1))
send ("{s down}")
sleep(random(350,500,1))
send ("{s down}")
sleep(random(350,500,1))
send ("{s down}")
sleep(random(350,500,1))
send ("{s down}")
So im trying to get this script done, but it only sends s one time.
Also how do i terminate a script with a hotkey?
Edited by AchterlijkeVleugel
Link to comment
Share on other sites

Who knows what the app accepting the sends is doing...send is one of the most unreliable functions you can use, but your script is certainly sending s 3 times to some application, or whatever.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

  • Developers

Honestly im just trying to understand the au3 language better, im sending to a word document atm. 

Sure...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Note: this won't work on game automation, so don't even waste your time:

Run("notepad.exe")
$w = WinWait("[CLASS:Notepad]","",10)
$c = ControlGetHandle($w,"",15)
ControlSetText($w,"",$c,ControlGetText($w,"",$c) & "s")
ControlSetText($w,"",$c,ControlGetText($w,"",$c) & "s")
ControlSetText($w,"",$c,ControlGetText($w,"",$c) & "s")



Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Note: this won't work on game automation, so don't even waste your time:

Run("notepad.exe")
$w = WinWait("[CLASS:Notepad]","",10)
$c = ControlGetHandle($w,"",15)
ControlSetText($w,"",$c,ControlGetText($w,"",$c) & "s")
ControlSetText($w,"",$c,ControlGetText($w,"",$c) & "s")
ControlSetText($w,"",$c,ControlGetText($w,"",$c) & "s")



Oh you guys think im trying to bot, haha now Jos' comment makes sense to me.

Well im really not trying to bot a game.

What is the difference between winwait/winactive/winwaitactive

Also doesnt the repeating of winwait cause the script to be slower?

Why didnt u make a variable for controlgettext?

Link to comment
Share on other sites

Oh you guys think im trying to bot, haha now Jos' comment makes sense to me.

Well im really not trying to bot a game.

What is the difference between winwait/winactive/winwaitactive

Also doesnt the repeating of winwait cause the script to be slower?

Why didnt u make a variable for controlgettext?

 

Answering in order:

1) Well, given your other questions on the forum (waiting for a pixel to disappear, stressing on repeating the "s" key, etc.), I kind of understand the apprehension :)

2) Difference between winwait and winwaitactive is that the former waits till a window exists, and the latter waits till a window is active. (You can read that in the first sentences in the respective help files.) WinActive is a function that checks whether a window is active (and WinExists checks if a window exists). So you could say winwait is to winexists as winwaitactive is to winactive.

3) So where is that code repeating winwait?

4) Laziness leading to copypaste, I guess, but I'll leave that to jdelaney :D

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Hi

I would simply use send ("{s}")

(for the first question) and see how that works out

I personally had some problem with ControlSetText, more so then with Send. ControlSend is a third option and ControlCommand with "EditPaste" option is yet another.

I dont yet have the experience to say which is better and where, I would leave that to, well anyone else in this thread to tell :) 

I personaly usually just go through the possibilities, and while I work on it, it turns out which one is the most reliable in said envierment.

PS.: If he wants to automate a game or something, and he is doing it since 2013 october, I say help him with it, just because his willpower to stick with it should be rewarded :D

Link to comment
Share on other sites

Answering in order:

1) Well, given your other questions on the forum (waiting for a pixel to disappear, stressing on repeating the "s" key, etc.), I kind of understand the apprehension :)

3) So where is that code repeating winwait?

 

Lol, if u look at it that way i understand it too. 

Well the code has 3 excuting lines right? all of them got the variable for winwait in them.

 

 

PS.: If he wants to automate a game or something, and he is doing it since 2013 october, I say help him with it, just because his willpower to stick with it should be rewarded :D

Lmfao

Link to comment
Share on other sites

Well the code has 3 excuting lines right? all of them got the variable for winwait in them.

 

Ah, that's what you mean. No, that's not how it works. Referring to the variable does not re-execute the WinWait. The WinWait is executed 1 time and 1 time only, in that second line. The script halts there until the window in question exists, meaning potentially forever if the window never comes to life. The only other way that function can stop is if the timeout expires, but that's optional, so by default the function will sit there waiting forever until the window exists.

Now then, when the WinWait function is done, it returns a value (see the helpfile: in case of success, it's the handle to the window, the only other option is that the timeout expired and then it returns 0). That result value, returned from the function, is then stored in that variable. So when you refer to the variable, you're not re-executing the WinWait, you're merely looking up the result value ("remembered" in that variable) of that earlier execution.

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Okay so i got these hotkeys atm

HotKeySet("z", "Main")
HotKeySet("PAUSE", "TogglePause")
HotKeySet("ESC", "Terminate")

But only z works, Main is the function for the script.

But only z works, Main is the function for the script.

Nothing happens when i press pause or esc

Edited by AchterlijkeVleugel
Link to comment
Share on other sites

its
HotKeySet("{ESC}", "Terminate")
if its not with {} =  youl need to press E on keyboard (3 button combination dont know it itl work)
for second question just add if your looking for a loop
 

While 1
Sleep(10)
Wend

as how to pause i'm pretty sure autoit help file have it nicely explained on HotKeySet example together with {} so open that help file :)

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

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