Provide a negative argument with C-u - (“Control+U” then “minus”), or even more simply C-- (“Control minus”).
- Move to previous window: C-- C-x o
- Move to previous frame: C-- C-x 5 o
From code, (other-window -1)
or (other-frame -1)
will do the same thing.
Check out the help for the key you want to reverse (e.g. C-h k C-x o to show help for C-x o) and if it says “A negative argument…” you know you can use C--.