Yeah, that's a tricky one and it needs either a cheat or the not so new but usually overlooked iTaSC solver.
So, in the settings of your armature, enable iTaSC:
I made the blue part the boss and the green will follow. If I'm not mistaken, this special solver doesn't like unparented targets, so I made a main bone. The hierarchy is as follows (u = upper):
bluebone, mainlever1-u, target-u and height-u are children of main
mainlever2-u is a child of mainlever1-u
follow-u is a child of mainlever2-u, not connected
greenbone is a child of follow-u, but does not inherit rotation.
mainlever2-u has an IK-constraint, chain length 2 to target-u with the following settings:
This is straightforward. Would be exactly the same with an ordinary constraint. Simplest leg rig possible.
But the settings of follow-u are where the magic happens:
It points to height-u and it's axis reference is set to target, lock X. That means, its tip tries to get on the X-axis of height-u. In effect that means its tip stays the same height if it can since height-u's X axis is parallel to the ground.
You could do without the lower armature, if you equip the meshes with Mirror Modifiers with a Mirror Object on the center line of your mechanism.
And for old time's sake, the cheat:
Simply add a very long cheat bone and turn follow-u and cheaty into another IK chain, 2 bones long. Since cheaty is so long, the up/down motion of the joint is minimal. Then you'd move greenbone with a simple copylocation constraint in one axis and it won't bob up or down. There's ways to make the bobbing even smaller, but it will already be invisible if cheaty is long enough.
It's not entirely obsolete since iTaSC sometimes gets hickups if you re-arrange stuff after it's been set up. It likes your workflow to be linear. Then again, it could just be me being clumsy.