Mount & Blade: Warband

Mount & Blade: Warband

View Stats:
AutoHotKey question (SOLVED, DO NOT PUT GAME IN ADMIN MODE)
Ok, I am testing some stuff out for a friend who is wanting to get into modding. I need a way to be able to press Ctrl + X repeatedly (since it gets old pressing it 60 times or whatever). Anyway, I have a key presser program, and it works on notepad, but I cannot get it to work in Mount and Blade. I assume it is because when I have mount and blade active, I cannot tell the program to start. I have to click out of Mount and Blade to tell the program to start (even using the hotkey to start) and then click back to Mount and Blade to make it active again. However, the program won't start working in Mount and Blade (again, I assume because Mount and Blade wasn't the active program when I told it to start). I did try using Alt+Enter to force Mount and Blade to play in a window, but that didn't help. Basically, the program is working and clicking away, but Mount and Blade isn't responding to those clicks.

Yes, I took into account it pressing too fast, it is set to only click once every second, so that isn't too fast.

Has anyone ever messed with this on Mount and Blade or have an alternate way for me to press Ctrl + X 60 times or whatever automatically?

Edit: I found an autohotkey script that supposedly works and several people online say it does, but I can't get it to work. It is located 2 posts down.
Last edited by Demon of Razgriz; Dec 20, 2017 @ 11:23am
Originally posted by Perfect Hatred:
In my experience Warband is kind of particular about how it registers keys. You need to use SendEvent and leave the key down for at least 25 milliseconds for the game to consistently register it. Also whoever gave you that code doesn't understand how loops work.

Use the following instead. Press n to start. Press n to stop.

#IfWinActive, ahk_class MB Window *$n:: if (timerActive != 1) { timerActive := 1 SendEvent, {LControl down} SetTimer, ControlXSpam, 50 } else { Gosub, TimerOff } return *$n Up:: return ControlXSpam: if WinActive("ahk_class MB Window") { SendEvent, {X down} sleep, 25 SendEvent, {X up} } else { Gosub, TimerOff } return TimerOff: SoundBeep, 523, 100 timerActive := 0 SetTimer, ControlXSpam, Off SendEvent, {LControl up} return

This is a bad way of going about things though. If you want to change troops or companions just edit them with Morghs Editor. If you want to change the player character just export, edit, and import. If you need a stack of top tier troops in your party just use a save editor and make it happen. Hell, even using CheatEngine to just edit the values in memory would be faster than this.
< >
Showing 1-7 of 7 comments
Sandvich Dec 19, 2017 @ 7:22pm 
AutoHotKey is your friend.
Demon of Razgriz Dec 19, 2017 @ 8:18pm 
Originally posted by Sandvich:
AutoHotKey is your friend.
Well, I got it and I found a script that everyone says supposedly works, but it doesn't do anything in game. Yes, I do have the script running.

#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

#IfWinActive Mount&Blade ;This script works only if Mount&Blade window is active.

$m::
Loop
{
if not GetKeyState("m", "P")
break
Click
Sleep, 10
}

$n::
Loop
{
if not GetKeyState("n", "P")
break
Send {LControl down}
Sleep, 10
Send {x down}
Sleep, 10
Send {x up}
Sleep, 10
Send {x down}
Sleep, 10
Send {x up}
Sleep, 10
Send {x down}
Sleep, 10
Send {x up}
Sleep, 10
Send {LControl up}
}
return

If I am reading this right, I just run the script, then hold "n" in game to run it right?
The author of this topic has marked a post as the answer to their question.
Perfect Hatred Dec 20, 2017 @ 12:15am 
In my experience Warband is kind of particular about how it registers keys. You need to use SendEvent and leave the key down for at least 25 milliseconds for the game to consistently register it. Also whoever gave you that code doesn't understand how loops work.

Use the following instead. Press n to start. Press n to stop.

#IfWinActive, ahk_class MB Window *$n:: if (timerActive != 1) { timerActive := 1 SendEvent, {LControl down} SetTimer, ControlXSpam, 50 } else { Gosub, TimerOff } return *$n Up:: return ControlXSpam: if WinActive("ahk_class MB Window") { SendEvent, {X down} sleep, 25 SendEvent, {X up} } else { Gosub, TimerOff } return TimerOff: SoundBeep, 523, 100 timerActive := 0 SetTimer, ControlXSpam, Off SendEvent, {LControl up} return

This is a bad way of going about things though. If you want to change troops or companions just edit them with Morghs Editor. If you want to change the player character just export, edit, and import. If you need a stack of top tier troops in your party just use a save editor and make it happen. Hell, even using CheatEngine to just edit the values in memory would be faster than this.
Last edited by Perfect Hatred; Dec 20, 2017 @ 12:28am
Demon of Razgriz Dec 20, 2017 @ 12:31am 
Originally posted by Bearded Dream:
In my experience Warband is kind of particular about how it registers keys. You need to use SendEvent and leave the key down for at least 25 milliseconds for the game to consistently register it. Also whoever gave you that code doesn't understand how loops work.

Use the following instead. Press n to start. Press n to stop.

#IfWinActive, ahk_class MB Window *$n:: if (timerActive != 1) { timerActive := 1 SendEvent, {LControl down} SetTimer, ControlXSpam, 50 } else { Gosub, TimerOff } return *$n Up:: return ControlXSpam: if WinActive("ahk_class MB Window") { SendEvent, {X down} sleep, 25 SendEvent, {X up} } else { Gosub, TimerOff } return TimerOff: SoundBeep, 523, 100 timerActive := 0 SetTimer, ControlXSpam, Off SendEvent, {LControl up} return

This is a bad way of going about things though. If you want to change troops or companions just edit them with Morghs Editor. If you want to change the player character just export, edit, and import. If you need a stack of top tier troops in your party just use a save editor and make it happen. Hell, even using CheatEngine to just edit the values in memory would be faster than this.
Morgh's Editor requires a new game though doesn't it? I am trying to edit companions in Prophecy of Pendor, I lost 10+ hours of progress due to save corruption and I am trying to get back to where I was.

Edit: I just tried to use this and it didn't work. I am assuming you used it before you posted it, so I must be doing something wrong, but I don't know what. I am making sure to run the script before I try to use it in-game, I then go to Lethaldarin's skill page and press "n" and nothing happens. I can still press Ctrl-X all day, but it gets old.

Edit2: For reference, I did make a very simple script that just types "My first script" when I press Ctrl + J in notepad or something and it works fine, so I understand that much of it at least.
Last edited by Demon of Razgriz; Dec 20, 2017 @ 12:42am
Perfect Hatred Dec 20, 2017 @ 2:43am 
Testing some stuff out for a friend who wants to get into modding and trying to recover progress after a corrupt save file are two completely different scenarios that should be approached differently.

Is the game running as admin for some reason? If it is then your AHK script also needs to be running as admin in order to interact with the game process.

As far as dealing with corrupt saves go just do what I do for all of my games. Copy your game's save folder to Dropbox. Delete the save folder from its original location. Create a symbolic link where the save folder originally was that points to its new location within your Dropbox folder. Once you've done that every time you save it will be automatically uploaded to Dropbox. Dropbox keeps a backup of file versions for 30 days. If a save file gets corrupted just revert to the most recent non-corrupt version. If you play with realistic mode you'll likely have saves made every few minutes during normal play.
Last edited by Perfect Hatred; Dec 20, 2017 @ 2:46am
Demon of Razgriz Dec 20, 2017 @ 11:08am 
Originally posted by Bearded Dream:
Testing some stuff out for a friend who wants to get into modding and trying to recover progress after a corrupt save file are two completely different scenarios that should be approached differently.

Is the game running as admin for some reason? If it is then your AHK script also needs to be running as admin in order to interact with the game process.

As far as dealing with corrupt saves go just do what I do for all of my games. Copy your game's save folder to Dropbox. Delete the save folder from its original location. Create a symbolic link where the save folder originally was that points to its new location within your Dropbox folder. Once you've done that every time you save it will be automatically uploaded to Dropbox. Dropbox keeps a backup of file versions for 30 days. If a save file gets corrupted just revert to the most recent non-corrupt version. If you play with realistic mode you'll likely have saves made every few minutes during normal play.
Ok, ill be clear on what is going on. My friend is trying to get into modding and he modded some units in Prophecy of Pendor. We both like it and I am now playing through while testing out his new units (both fighting them and using them in my army) so I can give him some feedback. However, I lost a lot of progress due to save corruption.

Edit: I am curious as to how they would be approached differently, though.

Edit2: So, apparently, the admin thing was what was wrong. I had put the game into admin mode earlier when I was using a different program because that was one of the suggested solutions (along with the program), but that didn't work. It has been in admin mode since then and I went in and took it off and now the script works, thanks a lot.

Thank you to Bearded for the script as well.
Last edited by Demon of Razgriz; Dec 20, 2017 @ 11:30am
spaceweezle Dec 20, 2023 @ 8:53pm 
Originally posted by Bearded Dream:
Is the game running as admin for some reason? If it is then your AHK script also needs to be running as admin in order to interact with the game process.

Good man. Thank you for that.

I've been using the same script for a long while now. I came back to the game recently having changed nothing and I couldn't get the script to work. Turns out it was exactly what you mentioned. Not sure why it worked before.
< >
Showing 1-7 of 7 comments
Per page: 1530 50

Date Posted: Dec 19, 2017 @ 5:27pm
Posts: 7