Script to load characters

Discuss anything relevant to The World RPG! Make sure you join the official TWRPG Discord for direct contact with community!
User avatar
RockLeeNBU
Lord of Everfrost
Posts: 359
Joined: Sat Oct 19, 2013 4:18 am

Script to load characters

Post by RockLeeNBU »

Make sure to check out viewtopic.php?f=2&t=6433 before looking at mine as his is much more user friendly!



You will need to install autohotkey if you haven't already. There are instructions in the script if you open it with a notepad. You will need to make some small code changes in order for it to work for you so make sure to read the instructions. If you have further questions, you can contact me.
TIP: make the code changes and save before double clicking the .ahk file!


Edit: added new script for loading characters by class name (see bottom for download links) This one does not include ML loader.

Edit: If your Windows is installed in another language, please edit the script to use your folder path rather than finding it.
Instead of this:

Code: Select all

global twrpg_folder := "C:\Users\" . A_UserName . "\Documents\Warcraft III\CustomMapData\TWRPG"
global ml_folder    := "C:\Users\" . A_UserName . "\Documents\Warcraft III\CustomMapData\mlorpg"
Change to this:

Code: Select all

global twrpg_folder := "C:\Users\YourUserName\Documents\Warcraft III\CustomMapData\TWRPG"
global ml_folder    := "C:\Users\YourUserName\Documents\Warcraft III\CustomMapData\mlorpg"

Warcraft III 1.28.5
F8 to open loading buttons
Select a button to load said hero

Warcraft III 1.28.5 with -nativefullscr
For people with -nativefullscr, the expected behavior is to tab you out of wc3, then once you press a button on the screen, it will open wc3 back up and load your character.

Warcraft III 1.26
A few notes about the 1.26 script

There are two ways to use this script with 1.26
  1. Full-screen Mode - Just the regular wc3 with no changes to your wc3 settings. Expected result: Tabs out when you press F8, once you select a character to load, it tabs back into wc3, and then proceeds to load your character and learn skills
  2. Borderless fullscreen mode - I've included in the script a command that turns a windowed wc3 into borderless fullscreen
    (courtesy of ENT Gaming)
Personally I'd prefer using method number 2 (if i was playing on 1.26 lol)

If you'd like to use number 2 you can follow these steps: (Can skip to step e if you already know how to set your wc3 to windowed mode)
  1. Create a shortcut of your 1.26 wc3 .exe file.
  2. Right click on the new shortcut and select properties
  3. In the popup find where it says Target: and at the end of the path type this: -window
    • It should look something like this: "Your\Path\To\wc3 1.26.exe" -window
    • Note: -window needs to be outside of the quotes
  4. Press okay
  5. Launch wc3 through the shortcut
  6. with your ahk already running, Make sure you select your wc3 window and press the hotkey Alt + F11
    • You need to select wc3 before you press the hotkey since it can turn any window selected into borderless fullscreen
    • This will turn your wc3 into borderless fullscreen.
AHK Template for 1.28 and above
AHK Template for 1.28 and above WITHOUT overwriting save files (read instructions inside the script)
AHK Template for 1.28 with -nativefullscr option
AHK Template for 1.26
kazenokage
Polar Bear Giant
Posts: 45
Joined: Sun Apr 16, 2017 1:25 pm

Re: Script to load characters

Post by kazenokage »

So I followed the instruction.

;--------------- For TWRPG ---------------
Gui, Add, GroupBox, x2 y10 w360 h140 , TWRPG
;---- Column 1
Gui, Add, Button , x22 y30 w100 h30 gBtn , pd
Gui, Add, Button , x22 y70 w100 h30 gBtn , Hero4
;---- Column 2
Gui, Add, Button , x132 y30 w100 h30 gBtn , Hero2
Gui, Add, Button , x132 y70 w100 h30 gBtn , Hero5
Gui, Add, Button , x132 y110 w100 h30 gLag_tw , Lag
;---- Column 3
Gui, Add, Button , x242 y30 w100 h30 gBtn , Hero3

twrpg_folder := "D:\DOCSS\Games\Warcraft 3\Warcraft III 1.26 -IceBlitz\TWRPG"

So I opened Wc3, loaded the map, pressed F8, click "pd", but it didn't load.

so where have I gone wrong ?
"Move like a shadow, disappear like the wind"
User avatar
RockLeeNBU
Lord of Everfrost
Posts: 359
Joined: Sat Oct 19, 2013 4:18 am

Re: Script to load characters

Post by RockLeeNBU »

Things to double check:

1) are you positive your save file name is pd.txt? if not then need to change the button name to that
2) are you sure your save file is saved to that location? I would think even in 1.26 the save file is saved in a subdirectory named CustomMapData
3) did you run the AHK as admin? as stated in the script itself: "Make sure AHK is run as admin from the source (usually in C:\Program Files\AutoHotkey)"

if none of these helped, please send me your savefile and a screenshot of where that file is located so i can further help
kazenokage
Polar Bear Giant
Posts: 45
Joined: Sun Apr 16, 2017 1:25 pm

Re: Script to load characters

Post by kazenokage »

oh dang, its the version. I didn't see it, coz i have 1.27 and 1.26,
hehe !

gonna try it.

edit: i just looked at it and the directory is correct, also the pd.txt is also correct and the twrpg folder is there .

its just when i clicked the "pd" button it does not go to Warcraft (since you said it will go to wc3 after you click any buttons.)

also can you tell me what "autohotkey" program did you use.
"Move like a shadow, disappear like the wind"
User avatar
RockLeeNBU
Lord of Everfrost
Posts: 359
Joined: Sat Oct 19, 2013 4:18 am

Re: Script to load characters

Post by RockLeeNBU »

just autohotkey.com, whatever the latest one is.

It seems like I didn't account for 1.26 at all

I can't test on 1.27 since i don't have it unfortunately :/

I rewrote some stuff, but with the way 1.26 focuses on the window proved to be difficult... give this new script a try and let me know how it works

Note: after it tabs out and after you press a button, give it about 1-2 full seconds before pressing anything to tab back in. It looks like there may be some issues with selecting your skills...

https://www.dropbox.com/s/ry6p947dud6u6 ... 6.ahk?dl=0
kazenokage
Polar Bear Giant
Posts: 45
Joined: Sun Apr 16, 2017 1:25 pm

Re: Script to load characters

Post by kazenokage »

still not working.

I think its not about loading the skills coz the char does not load in the first place *or so I think*

heres the running code for the template 1.26

---------------------------------------------------------------------------------------------------------

Script lines most recently executed (oldest first). Press [F5] to refresh. The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0). The bottommost line's elapsed time is the number of seconds since it executed.

---- D:\DOCSS\Games\Warcraft 3\template 1.26.ahk
030: Gui,Add,GroupBox,x2 y10 w360 h140,TWRPG
032: Gui,Add,Button,x22 y30 w100 h30 gBtn,hero5
033: Gui,Add,Button,x22 y70 w100 h30 gBtn,pd
035: Gui,Add,Button,x132 y30 w100 h30 gBtn,Hero2
036: Gui,Add,Button,x132 y70 w100 h30 gBtn,Hero5
037: Gui,Add,Button,x132 y110 w100 h30 gLag_tw,Lag
039: Gui,Add,Button,x242 y30 w100 h30 gBtn,Hero3
042: Gui,Add,GroupBox,x2 y150 w360 h140,MLRPG
044: Gui,Add,Button,x22 y170 w100 h30 gML,Hero1
045: Gui,Add,Button,x22 y210 w100 h30 gML,Hero4
047: Gui,Add,Button,x132 y170 w100 h30 gML,Hero2
048: Gui,Add,Button,x132 y210 w100 h30 gML,Hero5
049: Gui,Add,Button,x132 y250 w100 h30 gLag_ml,Lag
051: Gui,Add,Button,x242 y170 w100 h30 gML,Hero3
053: Gui,Add,GroupBox,x2 y290 w360 h60,Misc
054: Gui,Add,Button,x132 y310 w100 h30 gHost,Host
056: Gui,Add,Button,x132 y360 w100 h30 gCancel,Cancel
059: Gui,2:Add,GroupBox,x3 y1 w220 h140,Pick
060: Gui,2:Add,DropDownList,x60 y20 w100 h150 vBot,Add|Your|Host|Bot|Names|Here
061: Gui,2:Add,Edit,x60 y60 w100 h20 vGN
062: Gui,2:Add,Button,x160 y60 w30 h20 gPlus,+1
063: Gui,2:Add,Button,x10 y100 w100 h30 gPriv,Private (0.03)
064: Gui,2:Add,Button,x120 y100 w100 h30 gPub,Public
066: clickToggle := false
067: numToggle := false
068: leftClick := true
070: SetTitleMatchMode,2
071: DetectHiddenWindows,On
072: SendMode,Input
073: SetDefaultMouseSpeed,0
074: SetMouseDelay,-1
075: SetKeyDelay,-1
076: SetWinDelay,-1
077: SetBatchLines,-1
078: SetControlDelay,-1
081: twrpg_folder := "D:\DOCSS\Games\Warcraft 3\Warcraft III 1.26 -IceBlitz\TWRPG"
082: ml_folder := "C:\Users\" . A_UserName . "\Documents\Warcraft III\CustomMapData\mlorpg"
087: Return (4.87)
088: Gui,Show,autosize,Pick Your Load Code (0.03)
089: Return (2.23)
092: Gui,Cancel
094: FileRead,code,%twrpg_folder%\%A_GuiControl%.txt
095: if not ErrorLevel
096: result := RegExMatch(code, "-load [a-zA-Z\d\?@#$%&-]*", Match)
097: char := Match
098: code =
099: }
101: if (StrLen(char) >= 115)
121: ControlSend,,{Enter},Warcraft III ahk_exe war3.exe
122: Sleep,25 (0.03)
123: ControlSend,,{Text}Loading %A_GuiControl%,Warcraft III ahk_exe war3.exe
124: Sleep,25 (0.03)
125: ControlSend,,{Enter 2},Warcraft III ahk_exe war3.exe
126: Sleep,25 (0.03)
127: ControlSend,,{Text}%char%,Warcraft III ahk_exe war3.exe
128: Sleep,25 (0.03)
129: ControlSend,,{Enter},Warcraft III ahk_exe war3.exe
130: }
131: Sleep,1500 (1.50)
132: tw_skills()
201: ControlSend,,{F1}{Ctrl down}{1}{2}{3}{Ctrl up}{Esc},Warcraft III ahk_exe war3.exe
202: Sleep,25 (0.03)
203: ControlSend,,{o}{t}{q}{w}{e}{r},Warcraft III ahk_exe war3.exe
204: }
134: Sleep,400 (0.41)
135: WinActivate,Warcraft III ahk_exe war3.exe
136: Sleep,300 (0.30)
137: WinMaximize,Warcraft III ahk_exe war3.exe
138: Return (3.31)
088: Gui,Show,autosize,Pick Your Load Code (0.01)
089: Return (4.79)
092: Gui,Cancel (0.01)
094: FileRead,code,%twrpg_folder%\%A_GuiControl%.txt
095: if not ErrorLevel
096: result := RegExMatch(code, "-load [a-zA-Z\d\?@#$%&-]*", Match)
097: char := Match
098: code =
099: }
101: if (StrLen(char) >= 115)
121: ControlSend,,{Enter},Warcraft III ahk_exe war3.exe
122: Sleep,25 (0.03)
123: ControlSend,,{Text}Loading %A_GuiControl%,Warcraft III ahk_exe war3.exe
124: Sleep,25 (0.03)
125: ControlSend,,{Enter 2},Warcraft III ahk_exe war3.exe
126: Sleep,25 (0.03)
127: ControlSend,,{Text}%char%,Warcraft III ahk_exe war3.exe
128: Sleep,25 (0.03)
129: ControlSend,,{Enter},Warcraft III ahk_exe war3.exe
130: }
131: Sleep,1500 (1.50)
132: tw_skills()
201: ControlSend,,{F1}{Ctrl down}{1}{2}{3}{Ctrl up}{Esc},Warcraft III ahk_exe war3.exe
202: Sleep,25 (0.03)
203: ControlSend,,{o}{t}{q}{w}{e}{r},Warcraft III ahk_exe war3.exe
204: }
134: Sleep,400 (0.41)
135: WinActivate,Warcraft III ahk_exe war3.exe
136: Sleep,300 (0.30)
137: WinMaximize,Warcraft III ahk_exe war3.exe
138: Return (7.52)

Press [F5] to refresh.

-----------------------------------------------------------------------------------------------------------

so i guess the WinMaximize means maximizing war3.exe, but after i pick the button it does not tab in back.
"Move like a shadow, disappear like the wind"
User avatar
RockLeeNBU
Lord of Everfrost
Posts: 359
Joined: Sat Oct 19, 2013 4:18 am

Re: Script to load characters

Post by RockLeeNBU »

I tested this on my own 1.26 and it worked on there

There must be some sort of discrepancy between my computer and yours.

Can you please send me a screenshot of ahk window spy when wc3 is selected? you can access that by first double clicking the script so that it appears in the bottom right of your taskbar, then right click it and select window spy
window spy.png
then take a screenshot like this:
opened.png
You do not have the required permissions to view the files attached to this post.
kazenokage
Polar Bear Giant
Posts: 45
Joined: Sun Apr 16, 2017 1:25 pm

Re: Script to load characters

Post by kazenokage »

Note : this is with warcraft 3 in full screen mode
Capture.PNG
Note : This one is in windowed mode.
Capture2.PNG
edit: I compared your picture and mine, the missing one for me is the war3.exe (from my version 1.26). So I tried my "main" warcraft v.1.27 and the war3.exe showed
Capture3.PNG
Hypothesis : I tried to convert to main my 1.26 (editing registry) but it seems it does not work. So maybe I can say that this script will not work with multiple copies of warcraft.
You do not have the required permissions to view the files attached to this post.
"Move like a shadow, disappear like the wind"
User avatar
RockLeeNBU
Lord of Everfrost
Posts: 359
Joined: Sat Oct 19, 2013 4:18 am

Re: Script to load characters

Post by RockLeeNBU »

Well now that i have pictures i can tell you that its probably the operating system and how wc3 interacts between them. its not impossible to make my script work for it tho...

try this: https://www.dropbox.com/s/e7ee7y4rmd4vt ... 6.ahk?dl=0
User avatar
RockLeeNBU
Lord of Everfrost
Posts: 359
Joined: Sat Oct 19, 2013 4:18 am

Re: Script to load characters

Post by RockLeeNBU »

Updated post with new script for the updated load code generator in TW
Post Reply