If you’re on Windows 10, you can use the XBox Bar:
- Press Win+G to call it.
- Press the Record button (full circle).
- Click on your game’s window; the recording will start.
- When done, either close the game’s window or press Stop recording.
- You should now have a.mp4 file. You can use it as is, or find an online converter to gif.