Guest BL@(K-R34P3R Posted October 2, 2004 Share Posted October 2, 2004 I'm writing a sneak trainer bot for Morrowind. I'm trying to make it so that F1 will start the script, and F2 will stop it. For some reason, when I start the script, it will automatically start going, even without the hotkey press... Also, It won't stop when I press F2. Can someone please tell me what's wrong? I have looked over helpfile many times. Thanks. ;Raises the sneak skill in Morrowind. ;Use: ;Start Morrowind game save, go to a shop where people are, and face the corner, then start the script. ;F1 - starts script, F2 - stops script $i = 1 HotKeySet("{F1}", "SneakFunc") HotKeySet("{F2}", "FuncStop") SneakFunc() Func SneakFunc() WinActivate("Morrowind") WinSetState("Morrowind", "", @SW_MAXIMIZE) While $i > 0 Send("{CTRLDOWN}") Send("{w down}") $i = $i + 1 Wend EndFunc FuncStop() Func FuncStop() Exit 0 EndFunc Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 2, 2004 Share Posted October 2, 2004 (edited) I was just thinking... In my while loop... Do I even need to do the: $i = $i + 1 ? Or will the $i = 1 part at top be enough? Edited October 2, 2004 by BL@(K-R34P3R Link to comment Share on other sites More sharing options...
Valik Posted October 2, 2004 Share Posted October 2, 2004 You know that While 1 you keep asking about? Think about it for a moment. Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 2, 2004 Share Posted October 2, 2004 To create an infinite loop, you can use a non-zero number as the expression.Thanks. Edited:;Raises the sneak skill in Morrowind. ;Use: ;Start Morrowind game save, go to a shop where people are, and face the corner, then start the script. ;F1 - starts script, F2 - stops script HotKeySet("{F1}", "SneakFunc") HotKeySet("{F2}", "FuncStop") SneakFunc() Func SneakFunc() WinActivate("Morrowind") WinSetState("Morrowind", "", @SW_MAXIMIZE) While 1 Send("{CTRLDOWN}") Send("{w down}") Wend EndFunc FuncStop() Func FuncStop() Exit 0 EndFuncQuestion still stands... Any ideas Valik? Are my hotkeys messed up or something? Link to comment Share on other sites More sharing options...
KnowledgeSponge Posted October 2, 2004 Share Posted October 2, 2004 (edited) I'm writing a sneak trainer bot for Morrowind. I'm trying to make it so that F1 will start the script, and F2 will stop it. For some reason, when I start the script, it will automatically start going, even without the hotkey press... Also, It won't stop when I press F2. Can someone please tell me what's wrong? I have looked over helpfile many times. Thanks.;Raises the sneak skill in Morrowind. ;Use: ;Start Morrowind game save, go to a shop where people are, and face the corner, then start the script. ;F1 - starts script, F2 - stops script HotKeySet("{F1}", "SneakFunc") HotKeySet("{F2}", "FuncStop") While 1 Sleep(2147483647); WEnd ;SneakFunc() <=== you are calling sneakfunc to be run, that is why it is starting Func SneakFunc() WinActivate("Morrowind") WinSetState("Morrowind", "", @SW_MAXIMIZE) While 1 Send("{CTRLDOWN}") Send("{w down}") Wend EndFunc Func FuncStop() Exit EndFunc<{POST_SNAPBACK}>You cannot use hotkeys with some games. I editted your code. Edited October 2, 2004 by KnowledgeSponge Link to comment Share on other sites More sharing options...
Valik Posted October 2, 2004 Share Posted October 2, 2004 (edited) Theres a huge logic error. You call SneakFunc() right off to get to the While loop so your script doesn't die, correct? But obviously, this also starts your other code as well. The helpfile example for HotKeySet does exactly what you want.Edit: And F1/F2 are probably bound by the game. Try something more arbitrary. Edited October 2, 2004 by Valik Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 2, 2004 Share Posted October 2, 2004 Woa, I just learned a lot... I was under the impression, that to make a function in AutoIt, you need to declare it like this: FuncName() ; I THOUGHT I NEEDED THIS!!!! Func FuncName() EndFunc Well, I'm really stupid. I will edit and try again, thanks for help Valik, and KnowledgeSponge. Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 2, 2004 Share Posted October 2, 2004 While 1 Sleep(2147483647); WEnd Just curious, but why would I sleep it for forever? ... I'm not sure why that is in there? Link to comment Share on other sites More sharing options...
KnowledgeSponge Posted October 2, 2004 Share Posted October 2, 2004 (edited) While 1 Sleep(2147483647); WEndJust curious, but why would I sleep it for forever? ... I'm not sure why that is in there?<{POST_SNAPBACK}>Just to keep the script running with least possible cpu cycles used. If you took this out the script would just run and exit immediately. You gotta direct it to run some code or it goes bye bye. Edited October 2, 2004 by KnowledgeSponge Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 2, 2004 Share Posted October 2, 2004 Question: Doesn't the sleep command pause the script??? I never knew that a script could run with sleep on. Link to comment Share on other sites More sharing options...
KnowledgeSponge Posted October 2, 2004 Share Posted October 2, 2004 Question:Doesn't the sleep command pause the script??? I never knew that a script could run with sleep on.<{POST_SNAPBACK}>Hotkey pulls it out of sleep and sends it to the function called by the hotkey. Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 2, 2004 Share Posted October 2, 2004 Thanks. I just edited the script a little: ;Raises the sneak skill in Morrowind. ;Use: ;Start Morrowind game save, go to a shop where people are, and face the corner, then start the script. ;F1 - starts script, F2 - stops script HotKeySet("{F2}", "SneakFunc") HotKeySet("{F3}", "FuncStop") StartFunc() Func StartFunc() WinActivate("Morrowind") WinSetState("Morrowind", "", @SW_MAXIMIZE) EndFunc Func SneakFunc() While 1 Send("{CTRLDOWN}") Send("{w down}") Wend EndFunc Func FuncStop() Exit 0 EndFunc Problem is, even after assigning the script to unused hotkeys, it still won't work. Now, it won't start the script at F2 press, and I have no idea if F3 works because it wont start in the first place! So do you think this is because the game doesn't allow hotkeys? Link to comment Share on other sites More sharing options...
KnowledgeSponge Posted October 2, 2004 Share Posted October 2, 2004 Dude, that looks to me like it is gonna execute the startup func and then exit. If that script is staying open after you run morrowind, then I'm missing something. Once it sets the windows state, it's leaving the function. What are you telling it to do at that point? Nothing, so it's gonna exit. Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 2, 2004 Share Posted October 2, 2004 Oh... I thought it would keep running... Would this work? ;Raises the sneak skill in Morrowind. ;Use: ;Start Morrowind game save, go to a shop where people are, and face the corner, then start the script. ;F1 - starts script, F2 - stops script HotKeySet("{F2}", "SneakFunc") HotKeySet("{F3}", "FuncStop") WinActivate("Morrowind") WinSetState("Morrowind", "", @SW_MAXIMIZE) Func SneakFunc() While 1 Send("{CTRLDOWN}") Send("{w down}") Wend EndFunc Func FuncStop() Exit 0 EndFunc Without the StartFunc() Function? I thought that in order for it to run commands like WaitWinActive and whatever, it needed to be in a function, or am I wrong? Link to comment Share on other sites More sharing options...
KnowledgeSponge Posted October 2, 2004 Share Posted October 2, 2004 Oh... I thought it would keep running... Would this work?;Raises the sneak skill in Morrowind. ;Use: ;Start Morrowind game save, go to a shop where people are, and face the corner, then start the script. ;F1 - starts script, F2 - stops script HotKeySet("{F2}", "SneakFunc") HotKeySet("{F3}", "FuncStop") WinActivate("Morrowind") WinSetState("Morrowind", "", @SW_MAXIMIZE) Func SneakFunc() While 1 Send("{CTRLDOWN}") Send("{w down}") Wend EndFunc Func FuncStop() Exit 0 EndFuncWithout the StartFunc() Function? I thought that in order for it to run commands like WaitWinActive and whatever, it needed to be in a function, or am I wrong?<{POST_SNAPBACK}>No that will do the same thing. What code is going to be executed after WinSetState? It's not running those functions unless you call them with either a hotkey or say func(). I posted code already that would work. If it didn't work it's due to the fact the autoit is not reading the hotkey presses. Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 2, 2004 Share Posted October 2, 2004 Ahh.. That's probably why then =(. I want hotkeys to work! Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 2, 2004 Share Posted October 2, 2004 New, working script: ;Raises the sneak skill in Morrowind. ;Use: ;Start Morrowind game save, go to a shop where people are, and face the corner, then start the script. ;To exit the script, exit Morrowind. Then Right click the system tray icon and click "Exit". StartFunc() Func StartFunc() WinActivate("Morrowind") WinSetState("Morrowind", "", @SW_MAXIMIZE) EndFunc SneakFunc() Func SneakFunc() While 1 Send("{CTRLDOWN}") Send("{w down}") Wend EndFunc Any suggestions on how to improve it? Link to comment Share on other sites More sharing options...
Valik Posted October 2, 2004 Share Posted October 2, 2004 I said once that the example in the helpfile for HotKeySet does exactly what you want. (By exactly, I mean that you have to insert your code for Morrowind, but other than that, the code is what you want). Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 2, 2004 Share Posted October 2, 2004 Valik, I am looking at the Helpfile right now... Can you PLEASE be more specific, if it is possible, I would like to assign it to a hotkey, or hotkeys. If you can help, please don't hold back! I just looked at it again, and I am still not seeing anything different.. Link to comment Share on other sites More sharing options...
Valik Posted October 2, 2004 Share Posted October 2, 2004 (edited) Similar to the helpfile example:;Raises the sneak skill in Morrowind. ;Use: ;Start Morrowind game save, go to a shop where people are, and face the corner, then start the script. ;To exit the script, exit Morrowind. Then Right click the system tray icon and click "Exit". Global $bPaused = 1, $alive = 1 ; Redefine these to whatever you want Global $hkToggle = "!t" Global $hkEnd = "!s" HotKeySet($hkToggle, "Toggle") HotKeySet($hkEnd, "Stop") WinActivate("Morrowind") WinSetState("Morrowind", "", @SW_MAXIMIZE) While $alive If $bPaused Then Sleep(100) Else Send("{CTRLDOWN}") Send("{w down}") EndIf WEnd ; You can place any cleanup code after the While loop ; Function definitions Func Toggle() $bPaused = Not $bPaused; If 0, becomes 1, if 1, becomes 0 EndFunc; Toggle() Func Stop() $alive = 0 EndFunc; Stop()If the hotkeys don't work, change them to something else. If you can't find any keys that work, then it means Morrowind is doing something to prevent them from working.Edit: Fixed typo in code. Edited October 2, 2004 by Valik 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