I found a solution – not sure if it’s the best, but it works!
target = thisComp.layer("Colors Screen");
colorpicker = thisComp.layer("ColorPicker");
sampledColor_8bpc = 255* target.sampleImage(target.fromWorld(colorpicker.position), [0.5,0.5], true, time);
R = Math.round(sampledColor_8bpc[0]);
G = Math.round(sampledColor_8bpc[1]);
B = Math.round(sampledColor_8bpc[2]);
outputString = "#" +R.toString(16) + G.toString(16) + B.toString(16);
outputString;