HighlyUnlikely Posted June 17, 2008 Share Posted June 17, 2008 Hi all!!! My name is Kaylee and I need to write a script to basically do this 1. do something, wait 25 seconds and repeat unless a. a window pops up, i need it to shut and go back to step 1 b. a different window pops up, i need it to shut and go back to step 1 c. a different window pops up, i need it to shut and go back to step 1 d. a diferent window pops up, i need to go to step 2 how can i do this? I am having immense trouble figuring out how to make autoit recognize the different pop up windows. I dont know where to begin thanks!!! lol that looks like me now that Ive had no sleep Link to comment Share on other sites More sharing options...
Clipper34 Posted June 17, 2008 Share Posted June 17, 2008 You can try this: ;loop the entire program While 1 = 1 ;Varible for the while loop $i = 0 ;Start the loop While $i < 30 ;Make your function to do step 1. Func Name() EndFunc ;if its not working, it exits While @error Exit ;End the @error loop WEnd ;End the $i loop $i = $i + 1 ;Function for step a. Func Kill() ;Kills the window, put the window title in there WinKill("Name of Window Here") Name() EndFunc ;Same as Kill(), but calling the function name at line 8 after the WinKill Func Kill2() WinKill("Name of Window Here") Name() EndFunc ;Do the samething again Func Kill3() Kill2() EndFunc WEnd hope that helps, Clipper34. Link to comment Share on other sites More sharing options...
HighlyUnlikely Posted June 17, 2008 Author Share Posted June 17, 2008 Hi there Clipper, thanks so much for your help Do you think the kill window command will work even though they are 'in program' windows regulated by the program and not a 'windows' window (LOL)? You can try this: ;loop the entire program While 1 = 1 ;Varible for the while loop $i = 0 ;Start the loop While $i < 30 ;Make your function to do step 1. Func Name() EndFunc ;if its not working, it exits While @error Exit ;End the @error loop WEnd ;End the $i loop $i = $i + 1 ;Function for step a. Func Kill() ;Kills the window, put the window title in there WinKill("Name of Window Here") Name() EndFunc ;Same as Kill(), but calling the function name at line 8 after the WinKill Func Kill2() WinKill("Name of Window Here") Name() EndFunc ;Do the samething again Func Kill3() Kill2() EndFunc WEnd hope that helps, Clipper34. Link to comment Share on other sites More sharing options...
Clipper34 Posted June 17, 2008 Share Posted June 17, 2008 (edited) Yep, if you spell the window name correctly it will work. But this may help the program: WinWaitActive("Name of program goes here") because the code will wait until you've clicked on that certain window you defined, then the script will start. Hope that helps. Edited June 17, 2008 by Clipper34 Link to comment Share on other sites More sharing options...
HighlyUnlikely Posted June 18, 2008 Author Share Posted June 18, 2008 Hi there again What if the window doesn't have a title? Can I ask it to just look for text in the window? Thanks! Yep, if you spell the window name correctly it will work. But this may help the program: WinWaitActive("Name of program goes here") because the code will wait until you've clicked on that certain window you defined, then the script will start. Hope that helps. Link to comment Share on other sites More sharing options...
Richard Robertson Posted June 18, 2008 Share Posted June 18, 2008 WinWaitActive("", "some text on the window") Link to comment Share on other sites More sharing options...
HighlyUnlikely Posted June 18, 2008 Author Share Posted June 18, 2008 Thankyou Richard, I wish I wasnt so technically dumb but this is my first real stint and Im only 18 WinWaitActive("", "some text on the window") Link to comment Share on other sites More sharing options...
Richard Robertson Posted June 18, 2008 Share Posted June 18, 2008 I'm only 19. Age has nothing to do with it. Link to comment Share on other sites More sharing options...
HighlyUnlikely Posted June 18, 2008 Author Share Posted June 18, 2008 (edited) Ripping my hair out here! Heres what I have Func Cast(20) MouseClickDrag ( "Left", 641, 572, 639, 694 , 10 ) Sleep 25000 WinWaitActive("", "Value:") Func Close Window(1) MouseClick ( "Left", 771, 348, 1, 10 ) EndFunc WinWaitActive("", "old boot") Func Close Window(1) MouseClick ( "Left", 852, 264, 1, 10 ) EndFunc WinWaitActive("", "150") Func Close Window (1) MouseClick ( "Left", 851, 275, 1, 10 ) EndFunc WinWaitActive("", "and come back.") Func Close Window (1) MouseClick ( "Left", 639, 500, 1, 10 ) EndFunc Im getting errors galore!! I know its not done but heres the latest error: Line 6, "Func Close Window (1)" Error: "Func statement has no matching "EndFunc" also I put the 1 in there because I think it means close the window only once? Edited June 18, 2008 by HighlyUnlikely Link to comment Share on other sites More sharing options...
Clipper34 Posted June 18, 2008 Share Posted June 18, 2008 err, no but if your starting a function you use Func Name() Hope that helps. Link to comment Share on other sites More sharing options...
Richard Robertson Posted June 18, 2008 Share Posted June 18, 2008 (edited) You aren't allowed to put spaces in function names. I've never seen a language that allows that. Remove the space and it will work.Edit: Wait, what in the world are you trying to do? I just looked closer and I can't, for the life of me, figure out what that means or where it came from. Edited June 18, 2008 by Richard Robertson Link to comment Share on other sites More sharing options...
cartman380 Posted June 18, 2008 Share Posted June 18, 2008 (edited) When you use functions you don't use them inside of themselves. ..some code here.. Cast() ..some more code here.. Close_Window() ..some more code here.. *End of code* Func Cast() ..code that does cast.. EndFunc Func Close_Window() ..code that does close window.. EndFunc Btw are you trying to write an auto fishing script for a game? that's my best guess at what you're trying to do. Edit: fixed typo Edited June 18, 2008 by cartman380 Link to comment Share on other sites More sharing options...
James Posted June 18, 2008 Share Posted June 18, 2008 When you use functions you don't use them inside of themselves.Actually, you can. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Richard Robertson Posted June 18, 2008 Share Posted June 18, 2008 You don't declare them inside themselves. Link to comment Share on other sites More sharing options...
HighlyUnlikely Posted June 19, 2008 Author Share Posted June 19, 2008 Yes I am making a fishing program for a game my family plays and so, the different popups I outlined at different things that might happen if they catch something ie: 1. they could catch a fish, and need to close the popup and cast again 2. they could catch a boot, need to close the popup and cast again 3. they could catch a jar of bait, need to close the popup and cast again 4. they could not catch anything and need to cast again 5. they could run out of bait and need to go sell their fish 6. they might catch their max amount of fish and need to go sell their fish Link to comment Share on other sites More sharing options...
HighlyUnlikely Posted June 19, 2008 Author Share Posted June 19, 2008 (edited) So this looks about right ? Cast () Close Value () Close_boot () Close_150 () Close_comeback () Func Cast () MouseClickDrag ( "Left", 641, 572, 639, 694 , 10 ) Sleep (25000) EndFunc Func Close_Value () WinWaitActive("", "Value:") MouseClick ( "Left", 771, 348, 1, 10 ) EndFunc Func Close_boot () WinWaitActive("", "old boot") MouseClick ( "Left", 852, 264, 1, 10 ) EndFunc Func Close_150 () WinWaitActive("", "150") MouseClick ( "Left", 851, 275, 1, 10 ) EndFunc Func Close_comeback () WinWaitActive("", "and come back.") MouseClick ( "Left", 639, 500, 1, 10 ) Endfunc Again, thanks for all your help! My family loves you guys lol Edited June 19, 2008 by HighlyUnlikely Link to comment Share on other sites More sharing options...
cartman380 Posted June 19, 2008 Share Posted June 19, 2008 (edited) Ok so you want the program to just keep on running until you have to go get more bait? Or do you want it to go get the bait, I'm not exactly sure how it works but this code just keeps on running, I don't know what you have to do when the screen and come back comes up. Btw you don't have to put 1 and 10 in the mouse click function those are the default parameters, but just in case you do want to change them I left the code in there to handle that. You'll have to decide when to stop the program for now I have a Hotkey that will exit the program when you hit the Escape key. I also put a pause after the window is closed to give it enough time to close. I'd really have to see the game to be able to tell what needs to happen at each event, but this is what I came up with based on your code. HotKeySet("{ESC}", "Exit_Game") While 1 Cast() If WinExists("", "Value:") Then Close_Window("", "Value:", "Left", 771, 348) ElseIf WinExists("", "old boot") Then Close_Window("", "old boot", "Left", 852, 264) ElseIf WinExists("", "150") Then Close_Window("", "150", "Left", 851, 275) ElseIf WinExists("", "and come back.") Then Close_Window("", "and come back.", "Left", 639, 500) EndIf Sleep(1000) WEnd Func Cast () MouseClickDrag ( "Left", 641, 572, 639, 694 , 10 ) Sleep (25000) EndFunc Func Close_Window($title, $text, $button, $x, $y, $clicks = 1, $speed = 10) _WinWaitActive($title, $text) MouseClick($button, $x, $y, $clicks, $speed) EndFunc Func _WinWaitActive($title, $text = "") WinWait($title, $text) WinActivate($title, $text) WinWaitActive($title, $text) EndFunc Func Exit_Game() Exit EndFunc Edited June 19, 2008 by cartman380 Link to comment Share on other sites More sharing options...
HighlyUnlikely Posted August 9, 2008 Author Share Posted August 9, 2008 (edited) hey there sorry its been so long since i came on, ive been getting ready for university and i went away on a trip okay so pretty much, I have a certain amount of 'bait' and I can run out.. however I am making the macro assuming that Im not. But when I do, I want to be able to sell my fish (I need to sell the fish if either 1. my bucket is full [i have caught 20 fish ] or 2. I run outta bait) like I said, the code would have to determine which window pops up (ie: out of bait, therefore, must sell fish. bucket full, therefore must sell fish. didnt catch anything and time is running out therefore must re cast. caught an old boot, therefore, must recast.) i dont know if this helps EDIT: also it is hard because the windows that pop up indicating whether Ive run out of bait etc are in game windows so i dont know how autoit would recognize them? Ok so you want the program to just keep on running until you have to go get more bait? Or do you want it to go get the bait, I'm not exactly sure how it works but this code just keeps on running, I don't know what you have to do when the screen and come back comes up. Btw you don't have to put 1 and 10 in the mouse click function those are the default parameters, but just in case you do want to change them I left the code in there to handle that. You'll have to decide when to stop the program for now I have a Hotkey that will exit the program when you hit the Escape key. I also put a pause after the window is closed to give it enough time to close. I'd really have to see the game to be able to tell what needs to happen at each event, but this is what I came up with based on your code. HotKeySet("{ESC}", "Exit_Game") While 1 Cast() If WinExists("", "Value:") Then Close_Window("", "Value:", "Left", 771, 348) ElseIf WinExists("", "old boot") Then Close_Window("", "old boot", "Left", 852, 264) ElseIf WinExists("", "150") Then Close_Window("", "150", "Left", 851, 275) ElseIf WinExists("", "and come back.") Then Close_Window("", "and come back.", "Left", 639, 500) EndIf Sleep(1000) WEnd Func Cast () MouseClickDrag ( "Left", 641, 572, 639, 694 , 10 ) Sleep (25000) EndFunc Func Close_Window($title, $text, $button, $x, $y, $clicks = 1, $speed = 10) _WinWaitActive($title, $text) MouseClick($button, $x, $y, $clicks, $speed) EndFunc Func _WinWaitActive($title, $text = "") WinWait($title, $text) WinActivate($title, $text) WinWaitActive($title, $text) EndFunc Func Exit_Game() Exit EndFunc Edited August 9, 2008 by HighlyUnlikely Link to comment Share on other sites More sharing options...
HighlyUnlikely Posted August 13, 2008 Author Share Posted August 13, 2008 bump? you guys were so helpful 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