Yes, you are still eligible for corporate action benefits even if you sell the shares on the ex-date/record date. This is because eligibility for the benefits of corporate actions requires you to have the shares in your demat account on the ex-date/record date.
Why you remain eligible when selling on the ex-date
When you sell shares on the ex-date/record date, they will be debited from your demat account on the next day (T+1 day), not on the same day. Since you held the shares in your demat account on the ex-date/record date, you qualify for the corporate action benefits.