Another way... (using mouse)
'Printer select by Euklides, 2018
GOSUB printerSelection
IF changeprint$ <> "" THEN PRINT "Active printer is now: " + changeprint$ ELSE PRINT "Printer: no change"
END
'=====================
printerSelection: 'use it as a sub-programme
GOSUB listimp: GOSUB selspecial
IF choixfait$ <> "" AND choixfait$ <> actuimp$ THEN bzz$ = choixfait$: GOSUB PRINTERMAN: changeprint$ = choixfait$
RETURN
'--- printer list---
listimp: FILETMP$ = _CWD$ + "\printy.txt": ord$ = "CMD /C" + "wmic printer get name,default > " + FILETMP$
SHELL _HIDE ord$: _DELAY .5: canal& = FREEFILE
CLOSE canal&: OPEN "i", #canal&, FILETMP$: lx = LOF(canal&): np = 0: actuprint$ = "": autreprint$ = ""
WHILE NOT EOF(canal&): LINE INPUT #canal&, apri1$
apri$ = "": FOR ypr = 1 TO LEN(apri1$): IF MID$(apri1$, ypr, 1) <> CHR$(0) THEN apri$ = apri$ + MID$(apri1$, ypr, 1)
NEXT ypr
IF INSTR(apri$ + "x", "TRUE") > 0 THEN actuprint$ = RIGHT$(apri$, LEN(apri$) - 6): impy$ = actuprint$: actuprint$ = "> " + LTRIM$(RTRIM$(actuprint$))
IF INSTR(apri$ + "x", "FALSE") > 0 THEN
apri$ = RIGHT$(apri$, LEN(apri$) - 6): apri$ = LTRIM$(RTRIM$(apri$))
autreprint$ = autreprint$ + "> " + apri$ + CHR$(10)
END IF
WEND: CLOSE canal&: KILL FILETMP$
question$ = question$ + "Choose working printer" + CHR$(10)
question$ = question$ + "*" + CHR$(10)
question$ = question$ + " Actual active printer is: " + CHR$(10) + actuprint$ + CHR$(10)
question$ = question$ + " Other printer available: " + CHR$(10) + autreprint$ + CHR$(10)
RETURN
'---printer selection----
selspecial: 'SP 'entree: question+chr$(10)...: 'sortie ChoixFait$
IF RIGHT$(question$, 1) <> CHR$(10) THEN question$ = question$ + CHR$(10)
IF NOOK = 0 THEN question$ = question$ + " CANCEL" + CHR$(10) + " OK " + CHR$(10)
COLORAS = 6: COLORBS = 1: NUMREPo = -1: RANDOMIZE TIMER
NELOX = 0: LAX = 0: ima$ = "": QWEST$ = question$: choixfait$ = ""
MSL1: j = INSTR(QWEST$, CHR$(10)): IF j = 0 THEN QWEST$ = question$: question$ = "": GOTO MSL2
NELOX = NELOX + 1: QWEST$ = RIGHT$(QWEST$, LEN(QWEST$) - j):: IF j - 1 > LAX THEN LAX = j - 1
GOTO MSL1
MSL2: j = INSTR(QWEST$, CHR$(10)): IF j = 0 THEN GOTO MSL3
KQQ$ = LEFT$(QWEST$, j - 1) + SPACE$(LAX): question$ = question$ + LEFT$(KQQ$, LAX)
QWEST$ = RIGHT$(QWEST$, LEN(QWEST$) - j): GOTO MSL2
MSL3: MSQH = INT((80 - LAX) / 2): MSQV = INT((25 - NELOX) / 2): MSQH = MSQH + 8 - INT(RND * 8)
FOR x = 0 + MSQV TO NELOX + 1 + MSQV: FOR y = MSQH TO MSQH + LAX + 2:
' LOCATE 20, 1: PRINT x; Y; " "; MSQH; "::lax=:"; LAX; " " ';question$;" ";
w = SCREEN(x, y): ima$ = ima$ + CHR$(w)
w = SCREEN(x, y, 1) AND 15: ima$ = ima$ + CHR$(w)
w = SCREEN(x, y, 1) \ 16: ima$ = ima$ + CHR$(w)
NEXT y: NEXT x
MSLV: pxq = 1: COLOR COLORAS, COLORBS: FOR x = 0 TO NELOX + 1
LOCATE MSQV + x, MSQH
IF x = 0 THEN PRINT "Ú"; STRING$(LAX, "Ä"); "¿"
COLOR COLORAS, COLORBS
IF x > 0 AND x < NELOX + 1 THEN
UQ$ = MID$(question$, pxq, LAX): PRINT "³";:
IF NUMREPo = x THEN COLOR COLORBS, COLORAS
IF LEFT$(UQ$, 1) <> ">" THEN COLOR 7, 0
PRINT UQ$;: COLOR COLORAS, COLORBS: PRINT "³";: pxq = pxq + LAX
END IF
IF x = NELOX + 1 THEN PRINT "À"; STRING$(LAX, "Ä"); "Ù";
NBEW: NEXT x
MSL4: GOSUB souriskey: IF human = 1 AND z$ = CHR$(27) THEN GOTO MSL5
IF human <> 3 THEN GOTO MSL4
IF ysouris < MSQV + 1 THEN GOTO MSL4
IF ysouris > MSQV + NELOX THEN GOTO MSL4
IF xsouris < MSQH + 1 THEN GOTO MSL4
IF xsouris > MSQH + 1 + LAX THEN GOTO MSL4
numz = ysouris - MSQV: 'LOCATE 21, 1: PRINT NUM
numz = (numz - 1) * LAX + 1: repW$ = RTRIM$(LTRIM$(MID$(question$, numz, LAX)))
IF repW$ = "OK" THEN GOTO MSL5
IF repW$ = "CANCEL" THEN choixfait$ = "": GOTO MSL5
IF LEFT$(repW$, 1) <> ">" THEN GOTO MSL4
NUMREPo = ysouris - MSQV: choixfait$ = repW$: IF NOOK = 0 THEN GOTO MSLV ELSE GOTO MSL5
MSL5: w = 1: FOR x = 0 + MSQV TO NELOX + 1 + MSQV: FOR y = MSQH TO MSQH + LAX + 2:
COLOR ASC(MID$(ima$, w + 1, 1)), ASC(MID$(ima$, w + 2, 1))
LOCATE x, y: PRINT CHR$(ASC(MID$(ima$, w, 1)));:: w = w + 3
NEXT y: NEXT x:
IF LEN(choixfait$) > 0 THEN choixfait$ = RIGHT$(choixfait$, LEN(choixfait$) - 1): choixfait$ = RTRIM$(LTRIM$(choixfait$))
RETURN
RETURN
'---printer activation
PRINTERMAN: 'entrée avec bzz$="?" pour générer la liste des imprimantes dans sortie avec question$
'avec bzz$="?", on a aussi le nom actuel dans Impy$
' bzz$ avec "nom imprimante" pour la paramétrer
IF bzz$ = "?" THEN GOTO listimp
ord$ = "CMD /C" + "wmic printer where name='" + bzz$ + "' call setdefaultprinter"
SHELL _HIDE ord$
RETURN
'---mouse management
souriskey:
human = 0: z$ = INKEY$: IF z$ <> "" THEN human = 1: RETURN
clicko = 0
IF _MOUSEINPUT THEN
human = 2: xsouris = INT(_MOUSEX + .5): ysouris = INT(_MOUSEY + .5)
MOUVSOURI$ = RIGHT$(STR$(ysouris + 100), 2) + "s" + RIGHT$(STR$(xsouris + 100), 2)
IF _MOUSEBUTTON(1) THEN clicko = 1: human = 3
END IF
RETURN
'=====================