The invention relates to a method for controlling an agricultural machine when windrowing a crop on a usable agricultural area, comprising: making available an agricultural machine with a windrowing rake (1), in which a combination of raking devices (4, 5) is arranged on a supporting frame (3), said raking devices (4, 5) being configured to windrow a crop on a usable agricultural area: moving the agricultural machine with the windrowing rake (1) on the usable agricultural area, in order to windrow the crop: and controlling the raking devices (4, 5) during the windrowing operation by means of control signals generated by a control device of the agricultural machine, wherein in this context the raking devices (4, 5) are controlled in accordance with a first operating mode to windrow a first section of a windrow of the crop with a first windrow width if the agricultural machine with the windrowing rake (1) is moving along an essentially straight driving section; and the raking devices (4, 5) are controlled in ac