I Found this from another site. and will try it myself
Method 1: HDMI Connection And On The Go USB Mouse
This is probably the most effective and reliable method that you can use to unlock your phone if your screen isn’t responding and you can’t see anything on it at the same time. This isn’t an official solution to this problem, but it’s just a workaround that should work with most Android phones and tablets that support OTG and an HDMI output, including Samsung Galaxy S5, HTC One and Nexus 5.
The way this method will work is that your phone’s display will be shown on your TV using an HDMI cable and we’ll use a USB OTG mouse to unlock the phone. Even if your phone doesn’t have an HDMI port, you can still use this method as long as your phone supports an MHL to HDMI adapter. Also, make sure that you check whether your Android phone or tablet supports OTG adapters. You can also use this list to check the phones and tablets that support OTG.
Step 1
If your phone has a micro HDMI port, then this process is slightly easier and you can purchase a standard OTG adapter. Phones such as the Sony Xperia S come with micro HDMI ports. You can purchase an OTG adapter from your local phone store. You can also buy it on Amazon for about $4.47.
otg adapter
If your phone doesn’t have a micro HDMI port but supports MHL to HDMI adapters, then you’ll need to purchase a special OTG plus HDMI adapter. You might be able to find it at your local phone store. One great adapter is available on Amazon for about $19.99. This particular adapter supports five different connections and you can connect your HDMI cable and a USB mouse directly into this adapter.
otg hdmi adapter
Step 2
Get a standard USB mouse if you don’t already use one with your computer. They are widely available at computer stores.
Step 3
Connect the OTG adapter to your phone.
Step 4
Connect the USB mouse into the OTG adapter and plug in the HDMI cable into the OTG adapter as well. If you have a micro USB HDMI port on your phone, then connect the micro HDMI cable into your phone. Connect the other end of the HDMI cable to your TV. Turn on your TV and switch to HDMI mode.
hdmi otg connection
Step 5
You should now see your phone’s display on your TV. You should also see a mouse pointer on the display. Use the mouse to draw the unlock pattern on your phone or click on the keys to type in your password. That’s it! You have successfully unlocked your Android phone.