This AutoHotkey script should theoreticaly fix the problem but it doesn't work for me. If there is someone who can write AutoHotkey scripts, please make it work.
#Persistent
; Get the current position of the mouse cursor.
MouseGetPos, x, y
; Check if the mouse cursor is at the right edge of the screen.
if x >= A_ScreenWidth Send {D}
; Check if the mouse cursor is at the left edge of the screen.
if x <= 0 Send {A}
; Check if the mouse cursor is at the top edge of the screen.
if y <= 0 Send {W}
; Check if the mouse cursor is at the bottom edge of the screen.
if y >= A_ScreenHeight Send {S}