What you're missing is that focus switching is a feature built into the software. Your main probably wasn't casting because you werent setting the focus on the main window.

Also i have a question about the keymaps again
i wanned to setup keys with macros that are close to W,S,A,D but didnt work cuz i couldnt put my user/pass info...is there anyway i can fix that problem?
Add a separate Key Map, and in that Key Map create a Mapped Key. This Mapped Key will toggle your other Key Map. Create 1 step, and in that step, add a Key Map State Action, to toggle your other Key Map.