SoonToBe Posted July 2, 2007 Share Posted July 2, 2007 Okay this may be somewhat difficult to understand. I will do my best to explain what it is I'm trying to do, if you don't understand something let me know and I will think of an alternative way of explaining it. So I play this game where you have to attack with the a key quite often manually with your finger in the game. So I'm making a "macro" that will repeatedly press the a key for me. But I would like it to pause the repeating a key when 2 things happen. When if: One. I press the "End" key. Or when If Two. I press the Enter key. The way I have it right now, it currently will pause if I press the end key, and resume if I re-press the End key. (Just how I want it) But to "Chat" in the game you must press the Enter key to activate the chat box where you type your message in, and then you must re-press the Enter key to send what you have typed to other players. But if I have my macro on while I try to type, it just types a lot a's. Example of what it looks like. "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa". The only way to stop this, is if I actually press the End key first, which actually takes a lot of time in this fast paced game. I would like it so when I press Enter it will stop the "aaaaaaaaaaaaa" and when I press Enter again (to send the typed message) it will continue to repeatedly press a after the message has been sent. (Unless I have told it to pause with the End key, in which case when I press Enter the 2nd time I would like for it to continue to stay paused) Now I have it so when you press Enter, it does in fact stop the "aaaaaaa" But it doesn't pop up the chat box to type a message in, and when I re press enter it goes back to the "aaaaaaaaaaaaa" I think I know why it's doing this, but I don't know how to correct it, I have spent a few days trying to solve this myself looking at many, many sites and problems other people have had with things (including many examples on this site) but have not found a solution for my particular problem. Here is my code, this is my first Autoit program so if the structure looks way off or if stuff looks extreamly weird or not how it should be I apologize. Opt("WinTitleMatchMode", 3);Exact Title Match Global $Paused Global $Chat HotKeySet("{End}", "TogglePause");Toggle Pause HotkeySet("{Insert}", "About");The About HotkeySet("{Enter}", "Chat");Enter Chat WinWaitActive ("gamegoeshere");Find game is active While @error = 1 Send("a");Repeat the a key (attack) Sleep(20) WEnd Func TogglePause() $Paused = NOT $Paused While $Paused if $Paused then;If hotkey "End" is pressed Pause the attack repeat (a key), else un pause. Sleep(100) Else Sleep(100) EndIf WEnd ToolTip("") EndFunc Func Chat() $Chat = $Paused If $Chat = $Chat then Call("TogglePause");If enter is pressed pause attack repeat (a key) EndFunc Func About() msgbox(0,"About" ,"stuff");About popup EndFunc I think the problem is the Chat function, because all I'm telling it to do is call the pause function...which it does, but when I do that not only does the chat box not pop up, but I can't type anything at all as well. (even if im not in the game the program still runs like I am, which if someone could show me how to make it how to make it so it won't run unless the game is up, I would also really appresheate that.) I thought the "WinWaitActive" made it so it would only run if that window was active, but I guess not. so I can't type anything outside the game either unless I hit the End key. Any help in resolving this frustrating problem will make my day. I look forward to your responses. Link to comment Share on other sites More sharing options...
martin Posted July 2, 2007 Share Posted July 2, 2007 I haven't read what you wrote, it's too much for me, I've only looked at the script. Opt("WinTitleMatchMode", 3);Exact Title Match Global $Paused=false;<--best to know what it is to start with Global $Chat = false HotKeySet("{End}", "TogglePause");Toggle Pause HotkeySet("{Insert}", "About");The About HotkeySet("{Enter}", "Chat");Enter Chat WinWaitActive ("gamegoeshere");Find game is active While @error = 1 if not $paused and not $chat then Send("a");Repeat the a key (attack) Sleep(20);this is 50 keys each second- maybe a few too many WEnd Func TogglePause() $Paused = NOT $Paused While $Paused ;----------what's the if else bit for? it sleeps(100) paused or not so just put sleep(100) if $Paused then;If hotkey "End" is pressed Pause the attack repeat (a key), else un pause. Sleep(100) Else Sleep(100) EndIf WEnd ToolTip("") EndFunc Func Chat() ; $Chat = $Paused $Chat = true :??????$chat always equals $chat ; If $Chat = $Chat then Call("TogglePause");If enter is pressed pause attack repeat (a key) ;I think you mean If not $paused then TogglePause() but more simple would be just $paused = true ;then do chat bit $chat = false EndFunc Func About() msgbox(0,"About" ,"stuff");About popup EndFunc To stop the Hotkeys working while you're in chat mode, disable them with Hotkeyset("{ENTER}) etc, then when you're finished set them back. Might be better to have different hot keys like Alt+F7 say. 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 More sharing options...
SoonToBe Posted July 2, 2007 Author Share Posted July 2, 2007 Thank You. However I'm not exactly sure what other changes I'm suppose to make along with yours. I now have. Opt("WinTitleMatchMode", 3);Exact Title Match Global $Paused=false;<--best to know what it is to start with Global $Chat = false HotKeySet("{End}", "TogglePause");Toggle Pause HotkeySet("{Insert}", "About");The About HotkeySet("{Enter}", "Chat");Enter Chat WinWaitActive ("gamegoeshere");Find game is active While @error = 1 if not $paused and not $chat then Send("a");Repeat the a key (attack) Sleep(20) WEnd Func TogglePause() $Paused = NOT $Paused While $Paused Sleep(100) WEnd ToolTip("") EndFunc Func Chat() $Chat = true $paused = true $chat = false EndFunc Func About() msgbox(0,"About" ,"stuff");About popup EndFunc But like I said i'm not sure what I'm suppose to change from there, because now the script just closes when I enter the game (basically it does nothing) and I purposely didn't change the "WinWaitActive ("gamegoeshere")" bit for the forum, just in case you may think I'm not changing it. Thank you however for your help. Link to comment Share on other sites More sharing options...
martin Posted July 2, 2007 Share Posted July 2, 2007 Thank You. However I'm not exactly sure what other changes I'm suppose to make along with yours. I now have. Opt("WinTitleMatchMode", 3);Exact Title Match Global $Paused=false;<--best to know what it is to start with Global $Chat = false HotKeySet("{End}", "TogglePause");Toggle Pause HotkeySet("{Insert}", "About");The About HotkeySet("{Enter}", "Chat");Enter Chat WinWaitActive ("gamegoeshere");Find game is active While @error = 1 if not $paused and not $chat then Send("a");Repeat the a key (attack) Sleep(20) WEnd Func TogglePause() $Paused = NOT $Paused While $Paused Sleep(100) WEnd ToolTip("") EndFunc Func Chat() $Chat = true $paused = true $chat = false EndFunc Func About() msgbox(0,"About" ,"stuff");About popup EndFunc But like I said i'm not sure what I'm suppose to change from there, because now the script just closes when I enter the game (basically it does nothing) and I purposely didn't change the "WinWaitActive ("gamegoeshere")" bit for the forum, just in case you may think I'm not changing it. Thank you however for your help. if @error is not 1 then the script terminates. So either winwaitactive is not returning because it doesn'r detect your game, or @error is not 1. I suggest you use if winwaitactive("gametitle","",20) then msgbox(0,"error","The game was not found after waiting 20 sec!") exit endif 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 More sharing options...
SoonToBe Posted July 2, 2007 Author Share Posted July 2, 2007 (edited) I did that, and the message pops up instantly after going into the game. So it seems like it's not even waiting 20 seconds, because it shows it like instantly. So it must be detecting the game if it does in fact wait until I get into it before showing the message. I don't get it, I've never had a problem detecting whether or game was active or not. Edited July 2, 2007 by SoonToBe Link to comment Share on other sites More sharing options...
SoonToBe Posted July 3, 2007 Author Share Posted July 3, 2007 I've been messing with it for a really long time now, and still not working. Link to comment Share on other sites More sharing options...
Siao Posted July 3, 2007 Share Posted July 3, 2007 (edited) expandcollapse popupOpt("WinTitleMatchMode", 3);Exact Title Match Global $Paused = True, $Chat = False Global $WinTitle = "Untitled - Notepad";Game window title HotKeySet("{End}", "TogglePause");Toggle Pause HotkeySet("{Insert}", "About");The About HotkeySet("{Enter}", "Chat");Enter Chat While 1 ;main program loop While WinActive($WinTitle) If Not $Paused And Not $Chat Then Send("a") WEnd Sleep(500) WEnd Func TogglePause() If WinActive($WinTitle) Then $Paused = Not $Paused Else HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "TogglePause") EndIf EndFunc Func Chat() If WinActive($WinTitle) Then $Chat = Not $Chat Else HotkeySet(@HotKeyPressed) Send(@HotKeyPressed) HotkeySet(@HotKeyPressed, "Chat") EndIf EndFunc Func About() If WinActive($WinTitle) Then MsgBox(0,"About", "Cheating is lame.") Else HotkeySet(@HotKeyPressed) Send(@HotKeyPressed) HotkeySet(@HotKeyPressed, "About") EndIf EndFunc Edited July 3, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
SoonToBe Posted July 3, 2007 Author Share Posted July 3, 2007 (edited) This program just doesn't want to cooperate Your code does in fact "work" to a degree. If end is pressed it does what I want, if it is repressed it does pause it like I want. If its attacking, and enter is pressed it pauses the attack like I want as well....But the chat window doesnt pop up...I had this exact problem before by writing the code a different way. I wonder if maybe this can't be achieved because it seems like if you set enter as a hotkey to pause, that takes priority over the game, and it ignores the fact that I want to type something, I really don't know. When I had this problem myself I was never able to get around the fact that if it paused the code it wouldn't put the chat box up. I'm not sure if there is a way "around" that. As always thanks for your help. I really do appreciate it. By the way, I like your sig haha Edited July 3, 2007 by SoonToBe Link to comment Share on other sites More sharing options...
Siao Posted July 3, 2007 Share Posted July 3, 2007 (edited) Replace Chat() function with this one: Func Chat() If WinActive($WinTitle) Then $Chat = Not $Chat EndIf HotkeySet(@HotKeyPressed) Send(@HotKeyPressed) HotkeySet(@HotKeyPressed, "Chat") EndFunc Edited July 3, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
SoonToBe Posted July 3, 2007 Author Share Posted July 3, 2007 Wow...It works. I didn't think it ever would haha. Thank You Siao! I don't know if there is a +rep on this forum, but if Admins do things for members that solve issues someone please give Siao something. I really appreciate your time. Link to comment Share on other sites More sharing options...
SoonToBe Posted July 3, 2007 Author Share Posted July 3, 2007 (edited) Edit: Sorry for the double post, the board froze up, so I clicked back and reposted without looking. Edited July 3, 2007 by SoonToBe 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