Jabberwhacky Posted July 19, 2007 Share Posted July 19, 2007 All I'd like to do is have CTRL+Spacebar be sent every 10 seconds for as long as the script runs (anywhere from 30 minutes to 24 hours). I have no experience with AutoIt and just cobbled together this script from fishing around in the Help section. I'm putting it here so you can get a good laugh and then take pity on me and show me how it should be. $i = 0 While $i <= -1 Send("^{SPACE}") Sleep(10000) ;ten seconds $i = $i + 1 WEnd Link to comment Share on other sites More sharing options...
evilertoaster Posted July 19, 2007 Share Posted July 19, 2007 You loop fails right off- you have while $i<-1 but $i is 0 which is greater than -1. There are several ways to make an infinite loop- While 1 Send("^{SPACE}") Sleep(10000) ;ten seconds WEnd is my favorite. Which says- "while 1 is true, do the loop" since 1 is that same thing as true for logic tests, this works. Link to comment Share on other sites More sharing options...
sandman Posted July 19, 2007 Share Posted July 19, 2007 The logic seemed kind of weird to me at first... how can 1 be true, or not true? Or does it just mean While 1 is 1? [center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center] Link to comment Share on other sites More sharing options...
Jabberwhacky Posted July 19, 2007 Author Share Posted July 19, 2007 You loop fails right off- you have while $i<-1 but $i is 0 which is greater than -1. There are several ways to make an infinite loop- While 1 Send("^{SPACE}") Sleep(10000) ;ten seconds WEnd is my favorite. Which says- "while 1 is true, do the loop" since 1 is that same thing as true for logic tests, this works. Figures that I don't get past the first line before making a mistake. I just tried your script and it's not registering in my program; could it be that the commands are going too "fast" and it would work to make it hold CTRL and space for half a second or so? I swapped out ^{SPACE} for "a" and it did in fact put a in this chatbox every 10 seconds, so the script itself is sound. Link to comment Share on other sites More sharing options...
loki1982 Posted July 19, 2007 Share Posted July 19, 2007 The logic seemed kind of weird to me at first... how can 1 be true, or not true? Or does it just mean While 1 is 1?If i remember correctly there are three "states" in conditions for most programming. True, false, and nil. Any value will equate to true except 0. 0 equates to false, and in most languages you ahve to specify nil to equal nil. I might be off, but this is what I think i remember from my earlier studies ; /So "While 1" just basically says this is true keep doing the loop. Link to comment Share on other sites More sharing options...
evilertoaster Posted July 19, 2007 Share Posted July 19, 2007 I just tried your script and it's not registering in my program; could it be that the commands are going too "fast" and it would work to make it hold CTRL and space for half a second or so? I swapped out ^{SPACE} for "a" and it did in fact put a in this chatbox every 10 seconds, so the script itself is sound.well if it takes the 'a' it should send the ctrl+space ok also. What does ctrl+space do in teh chatbox? new line?The logic seemed kind of weird to me at first... how can 1 be true, or not true? Or does it just mean While 1 is 1?per help file-Conditions are evaluated as true (non-zero) or false (zero). So saying while {condition} would interally be like saying while {somthing=somthing} which evaluates to true... just like the number 1 and any other non-zero valueIf i remember correctly there are three "states" in conditions for most programming. True, false, and nil. Any value will equate to true except 0. 0 equates to false, and in most languages you ahve to specify nil to equal nil. I might be off, but this is what I think i remember from my earlier studies ; /So "While 1" just basically says this is true keep doing the loop.humm well maybe, i always only think of two states...either it's true or it's not what the language inturprits to be true can vary... Link to comment Share on other sites More sharing options...
Jabberwhacky Posted July 20, 2007 Author Share Posted July 20, 2007 CTRL+Space doesn't seem to do anything in the chat box. I added in some code to try and delay the keypresses, but it still isn't working. ^ is the right key for Control, right? While 1 Send("{^ down}") Sleep(500) Send("{SPACE down}") Sleep(300) Send("{^ up}") Send("{SPACE down}") Sleep(10000) WEnd Link to comment Share on other sites More sharing options...
enaiman Posted July 20, 2007 Share Posted July 20, 2007 (edited) CTRL+Space doesn't seem to do anything in the chat box. I added in some code to try and delay the keypresses, but it still isn't working. ^ is the right key for Control, right?Right... But ... are you sure you send something to that window?Send will send stuff to the active window - so - is you window active at the time? Maybe you should add a WinActivate("your app title here") before sending anything. Edited July 20, 2007 by enaiman SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Jabberwhacky Posted July 20, 2007 Author Share Posted July 20, 2007 Right... But ... are you sure you send something to that window?Send will send stuff to the active window - so - is you window active at the time? Maybe you should add a WinActivate("your app title here") before sending anything.Good call. I went back to my trusty "Send a" script and opened up the chat line in the game and just waited; no "a" was ever pressed. The game is already maximized, it seems to be the "active" application. Where would I find the proper name for the app? I tried using the name shown in the Application List of Windows Task Manager and it didn't do anything. 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