Try to make a script out of it. here.

This script does actually search your bag for a soul shard and delete it if it can find one, but I'm sure it can be modified.
Code:
/run i="Soul Shard"d=1 for x=0,4 do for y=1,GetContainerNumSlots(x) do  if (d>0) then l=GetContainerItemLink(x,y)  if l and GetItemInfo(l)==i then PickupContainerItem(x,y) DeleteCursorItem() d=d-1 end end end end
I made some modifications to the above script, that (hopefully) will check your bag for Soul shards, and if it finds one, it will cast Summon VoidWalker, else it will cast Summon Imp.
Code:
/run i="Soul Shard"d=1 for x=0,4 do for y=1,GetContainerNumSlots(x) do if (d>0) then l=GetContainerItemLink(x,y) if l and GetItemInfo(l)==i then CastSpellByName("Summon VoidWalker") d=d-1 else CastSpellByName("Summon Imp") end end end end
I have absolutely no idea if this will work, or if there is any bugs, but it's worth the try. Hopefully it will be helpful in some way.