A method for controlling an agricultural machine when windrowing a crop on a usable agricultural area, having: - providing an agricultural machine comprising a windrower, in the case of which a combination of raking devices (4a, 4b, 5a, 5b) is arranged on a supporting frame, said raking devices (4a, 4b, 5a, 5b) being configured to windrow a crop on a usable agricultural area; - moving the agricultural machine with the windrower on the usable agricultural area, in order to thereby windrow the crop; - repeated determination of machine position data for the agricultural machine by means of a position-determining system while the agricultural machine is being moved on the usable agricultural area, wherein the machine position data indicate a current position of the agricultural machine on the usable agricultural area; - providing electronic location information, wherein the electronic location information comprises position information, which indicates a distribution of the crop to be windrowed along a non-linear line in a partial region of the usable agricultural area; and - controlling the raking devices (4a, 4b, 5a, 5b) by means of control signals, which are generated by a control device, when during data processing of the machine position data and of the position information by means of the control device it is determined that the crop is being windrowed in the partial region of the usable agricultural area such that a working position of one or more raking devices (4a, 4b, 5a, 5b) is set and changed depending on the position in order to windrow the crop, which is distributed along the non-linear line, into a windrow, which is produced so as to run along a straight windrowing line, wherein during the position-dependent setting and changing of the working position, the one or more raking devices (4a, 4b, 5a, 5b) is/are moved between a raised non-working position and a lowered working position and/or is/are moved between a proximal as well as a distal working position with respect to the supporting frame. - providing an agricultural machine comprising a windrower, in the case of which a combination of raking devices (4a, 4b, 5a, 5b) is arranged on a supporting frame, said raking devices (4a, 4b, 5a, 5b) being configured to windrow a crop on a usable agricultural area; - moving the agricultural machine with the windrower on the usable agricultural area, in order to thereby windrow the crop; - repeated determination of machine position data for the agricultural machine by means of a position-determining system while the agricultural machine is being moved on the usable agricultural area, wherein the machine position data indicate a current position of the agricultural machine on the usable agricultural area; - providing electronic location information, wherein the electronic location information comprises position information, which indicates a distribution of the crop to be windrowed along a non-linear line in a partial region of the usable agricultural area; and - controlling the raking devices (4a, 4b, 5a, 5b) by means of control signals, which are generated by a control device, when during data processing of the machine position data and of the position information by means of the control device it is determined that the crop is being windrowed in the partial region of the usable agricultural area such that a working position of one or more raking devices (4a, 4b, 5a, 5b) is set and changed depending on the position in order to windrow the crop, which is distributed along the non-linear line, into a windrow, which is produced so as to run along a straight windrowing line, wherein during the position-dependent setting and changing of the working position, the one or more raking devices (4a, 4b, 5a, 5b) is/are moved between a raised non-working position and a lowered working position and/or is/are moved between a proximal as well as a distal working position with respect to the supporting frame.