An electronic system for locking doors or windows, comprising: - a counter-plate installable on a fixed frame of the door or window; - an electronic lock installable on a wing of the door or window and provided with closing means mobile between a release configuration, in which the closing means engages the counter-plate when the counter-plate is proximal to the electronic lock , and a retained configuration, in which the closing means is maintained inside the electronic lock and does not engage the counter-plate , wherein said electronic lock comprises an opening device configured to activate a switching of the closing means at least between the retained configuration and the release configuration, characterised in that it comprises a control system for controlling the opening of the door or window comprising: - a first infrared device arranged in the counter-plate and configured to transmit at least a first optical signal (S1) or activating optical signal containing an activating message and to receive at least a second optical signal (S2), - a second infrared device arranged in the electronic lock and configured to receive said first optical signal (S1) and to transmit said second optical signal (S2), said second optical signal (S2) comprising a message relating to the status of the wing and/or an authentication message suitable for being used by the first infrared device for authenticating the activating message previously sent via the first optical signal (S1), said first and second infrared device being positioned in a condition of reciprocal visibility at least when the counter-plate is proximal to the electronic lock . - a counter-plate installable on a fixed frame of the door or window; - an electronic lock installable on a wing of the door or window and provided with closing means mobile between a release configuration, in which the closing means engages the counter-plate when the counter-plate is proximal to the electronic lock , and a retained configuration, in which the closing means is maintained inside the electronic lock and does not engage the counter-plate , wherein said electronic lock comprises an opening device configured to activate a switching of the closing means at least between the retained configuration and the release configuration, characterised in that it comprises a control system for controlling the opening of the door or window comprising: - a first infrared device arranged in the counter-plate and configured to transmit at least a first optical signal (S1) or activating optical signal containing an activating message and to receive at least a second optical signal (S2), - a second infrared device arranged in the electronic lock and configured to receive said first optical signal (S1) and to transmit said second optical signal (S2), said second optical signal (S2) comprising a message relating to the status of the wing and/or an authentication message suitable for being used by the first infrared device for authenticating the activating message previously sent via the first optical signal (S1), - a first infrared device arranged in the counter-plate and configured to transmit at least a first optical signal (S1) or activating optical signal containing an activating message and to receive at least a second optical signal (S2), - a second infrared device arranged in the electronic lock and configured to receive said first optical signal (S1) and to transmit said second optical signal (S2), said second optical signal (S2) comprising a message relating to the status of the wing and/or an authentication message suitable for being used by the first infrared device for authenticating the activating message previously sent via the first optical signal (S1), <EOS>