Sign in to follow this  
Followers 0
AchterlijkeVleugel

Script only does 1 line then wait then terminate

23 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



you can't press the s, when it's already 'down'.

Either just send "s", or send it back 'up'.

1 person likes this

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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

Is there an alternative for send then?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Sure, so what is it you are trying to automate?

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

But i would also like to navigate in map folders, with arrow keys for example.

Edited by AchterlijkeVleugel

Share this post


Link to post
Share on other sites

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

Sure...

2 people like this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Sure...

?

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

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.

 

Share this post


Link to post
Share on other sites

It still doesnt work, does the position of the hotkeyset matter? Also i got the while loop in the function, is that bad?

Share this post


Link to post
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
Sign in to follow this  
Followers 0