AntiGuide: LoupeVista4moitiees



PagePrincipale :: DerniersChangements :: ParametresUtilisateur :: Vous êtes 216.73.217.5 :: Signaler un abus :: le: 20250729 07:26:06
loupe, lire les bases: LoupeWindows
gaffe: pas jeune, date de 2009
ATTENTION: pour VISTA seulement ( Voir Seven dans pas longtemps ); PORTAGE SOUS XP impossible; à suivre: LoupeXp4moitiees
(pour les historiens, voir solution obsolète: LoupeWindows4MoitieesBat )
Cette page présente un usage de la loupe intégrée de Windows Vista permettant de voir et travailler n'importe quelle partie de l'écran.
(rappel: la loupe ne permet pas d'action à la souris sous la "lentille")
l'outil s'appuie sur:
Notes

INSTALLATION
- ATTENTION: vérifiez que vous n'avez pas déjà une affectation pour les raccourci proposés.
- copier/coller le fichier .vbs ci dessous par exemple dans le dossier "mes documents" ou le télécharger à: http://antiguide.free.fr/divers/loupewindows4moitiees/loupe.zip et le décompresser.
- l'ouvrir UNE FOIS pour installer les raccourcis, choisir la combinaison de touches de commande


Soluce
' po flavigny 
Const DATEMAJ="20091220-07:30"
' appel de la loupe windows par raccourcis clavier
' lire: http://antiguide.free.fr/wiki/wakka.php?wiki=LoupeVista4Moitiees
Const ESPERE="Windows Vista"
Const pasapas=false
Const prefixe="Z_"
Const MSAVANTRELANCE=1000
Const CACHERTOUJOURS=false
Const CACHERSIBATCH=true
' selon: http://msdn.microsoft.com/en-us/library/0ea7b5xe%28VS.85%29.aspx
' pour partager les raccourcis, les mettre dans: "AllUsersDesktop"
TARGETDESKTOP="desktop"

titre="Jongleur de loupe pour " & espere & vbcrlf & _
  " (version du: " & DATEMAJ & ")."
batch=false ' passera a true si installés par ligne de commande
Effacer=false
nbraccourciVus=0
masque="" ' global!
' to do:
' rien a redire!
' end todo!
' wscript.echo "appel"
Set wshshell=CreateObject("wscript.Shell") 
Set fso = Wscript.CreateObject("Scripting.FileSystemObject")
totale 
' c'est fini!
' ----------------------------------
sub totale
' loupe tout par registre
' il faudra fermer/ouvir la sessions pour disposer des raccourcis

' ---- Obtenir Version de Windows.
strComputer = "."
Set objWMIService = GetObject(_
    "winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery(_
    "Select * from Win32_OperatingSystem")
For Each objItem in colItems
 version= objItem.caption
Next

if instr(version,espere)=0 then
   wscript.echo titre & vbcrlf & _
    "Conçu pour: " & espere & "." & vbcrlf & _
   "Actuellement: "  & _
    version & vbcrlf & _
    "Pour forcer l'exécution, corriger la ligne ""Const ESPERE=..."" "
   exit sub
end if

set args = WScript.Arguments
rep=""
demandermasque=false
init=false
if args.count=0 then 
     demandermasque=true
     init=true
   else
    c=args(0)
'    wscript.echo "c=" & c' 
    if len(c)=0 then demandermasque=true:init=true
    if instr("0367",c)>0 then rep=c:init=true:batch=true
'    wscript.echo "rep=" & rep ' 
     
  end if ' args.count=0

' wscript.echo demandermasque & init
           '   "lire: http://antiguide.free.fr/wiki/wakka.php?wiki=LoupeVista4Moitiees" & vbcrlf & _
if init then 
if demandermasque then rep=inputbox (titre & vbcrlf & _
              "Choix des touches de commande:" & vbcrlf & _
              "3:<CTRL>+<MAJUSCULE> (conseillé), " & vbcrlf & _
              "6:<ctrl>+<alt>, " & vbcrlf & _
              "7:<ctrl>+<alt>+<majuscule>" & vbcrlf & _ 
              "0: désinstaller," &vbcrlf & _
              "pour abandonner: clic sur le bouton 'Annuler'.")
     permis="0367"
     c=""
   if (rep="") then exit sub
' wscript.echo "rep=" & rep
    if  (instr(permis,rep)=0) or (len(rep)<>1) then 
     wscript.echo  titre & vbcrlf & _
     "ERREUR le masque doit être 3, 6, 7."
     exit sub
     end if
' effacer
if rep="0" then effacer=true
' wscript.echo "kill rep=" & rep
  WshShell.Run "taskkill.exe /im magnify.exe" ,0  
' choix des touches maintenues
if instr("7",rep)>0  then masque="CTRL+ALT+SHIFT+"
if instr("6",rep)>0  then masque="CTRL+ALT+"
if instr("3",rep)>0  then masque="CTRL+SHIFT+"
'
' verifier vista avant d'installer

' ----- essai de créer les raccourcis
' parametres: libellé, Hotkey, paramètre de commande
' pour l'instant pas super....
' sub raccourci (caption,key,param)
 raccourci "Init","HOME",""
 raccourci "Haut","UP","N"
 raccourci "Bas","DOWN","S"
 raccourci "Gauche","LEFT","O"
 raccourci "Droite","RIGHT","E"
 raccourci "Plus","PRIOR","+"
 raccourci "Moins","NEXT","-"
 raccourci "Fin","END","."
if not batch then 
if rep="0" then 
if nbraccourciVus=0 then 
 wscript.echo  titre & vbcrlf & _
  "aucun raccourci trouvé."
else
 wscript.echo  titre & vbcrlf & _
  nbraccourciVus & " raccourcis d'accès à la loupe ont été supprimés."
end if ' nb=0

else ' rep 0
 wscript.echo  titre & vbcrlf & _
  nbraccourciVus & " raccourcis ont été ajoutés et sont utilisables."
end if 'rep 0
end if ' not batch
 exit sub
end if

' autres vérifications:
if args.count>1 then 
        wscript.echo  titre & vbcrlf & _
     "loupe n'accepte qu'un argument: +-NSEO."
   exit sub
end if

if instr("+-.NSEO",c)=0 then
   wscript.echo titre & vbcrlf & _
   "loupe l'argument doit être: +-.NSEO."
   exit sub
  end if

' ------- tuer la loupe avant de modifier le registre
if instr("NSOE.+-",c)>0 then 
  ' on pourrait trester si elle est là!
  WshShell.Run "taskkill.exe /im magnify.exe" ,0  
end if

' ----- si fermer, tout est fait
if c="." then exit sub

' --------------------------------------------
' obtenir le zoom
ruche="HKEY_CURRENT_USER\Software\Microsoft\ScreenMagnifier\"
numzoom= WshShell.RegRead (ruche & "ClassicMagnification") 
' ----------------------------------

' ---- Obtenir dimensions de l'écran.
strComputer = "."
px=0
py=0
maxx=0
maxy=0
Set objWMIService = GetObject(_
    "winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery(_
    "Select * from Win32_DesktopMonitor")
For Each objItem in colItems
    py= objItem.ScreenHeight
    px= objItem.ScreenWidth
if px>maxx then maxx=px
if py>maxy then maxy=py
Next


' construire dimensions
LargeurLoupeHorizontale=maxx-32
HauteurLoupeHorizontale=maxy/2 -32
LargeurLoupeVerticale=maxx/2 -32
HauteurLoupeVerticale=maxy -70
' WScript.Echo maxx & "*" & maxy 




'  WScript.Echo "exec pour " & c & " oldzoom=" & numzoom
' -----  calcul du ZOOM -- 
newzoom=0
if (c="-")  then 
   if numzoom<=2 then numzoom=4
   newzoom=numzoom\2
'   wscript.echo numzoom & "-" & newzoom & c
   end if

if (c="+") then
   if (numzoom<2)  then numzoom=2 
   if (numzoom>8)  then numzoom=8
       newzoom=numzoom*2
'   wscript.echo numzoom & "+" & newzoom & c
  end if 
' dimensions & Position -------------------------------
lLoupe=0
hLoupe=0

if (c="N") or (c="S") then  lLoupe=LargeurLoupeHorizontale : hLoupe=HauteurLoupeHorizontale
   
if (c="O") or (c="E") then lLoupe=LargeurLoupeVerticale: hLoupe=HauteurLoupeVerticale

Lx=-1
ly=-1

if c="N" then   Lx=10  :  Ly=maxy\2

if C="S" then  Lx=10 :  Ly=38

if C="E" then   lx=10:   ly=38
'wscript.echo lx & c & ly & " H:" & hLoupe & " L: " & lLoupe

if C="O" then Lx=maxx\2  :  ly=38

' mise à jour des paramètres dans le registre
if newzoom>0 then   WshShell.RegWrite ruche & "ClassicMagnification", newzoom, "REG_DWORD"
if lx>-1 then   WshShell.RegWrite ruche & "ClassicWindowX", lx, "REG_DWORD"
if ly>-1 then   WshShell.RegWrite ruche & "ClassicWindowY", ly, "REG_DWORD"
if lLoupe>0 then   WshShell.RegWrite ruche & "ClassicWindowCX", lLoupe, "REG_DWORD"
if hLoupe>0 then   WshShell.RegWrite ruche & "ClassicWindowCY", hLoupe, "REG_DWORD"
   
' écrire zoom augmenté
if newzoom>0 then  WshShell.RegWrite ruche & "ClassicMagnification", newzoom, "REG_DWORD"

' forcer loupe flotante et suivi
' ancré: 0: non, 1: oui
 WshShell.RegWrite ruche & "ClassicDocked",0, "REG_DWORD"
' rem O en haut, 1: gauche, 2: droite, 3: bas
' WshShell.RegWrite ruche & "ClassicDockPosition",0, "REG_DWORD"
 WshShell.RegWrite ruche & "ClassicFollowFocus",1, "REG_DWORD"
 WshShell.RegWrite ruche & "ClassicFollowCaret",1, "REG_DWORD"
 WshShell.RegWrite ruche & "ClassicFollowMouse",1, "REG_DWORD"
 WshShell.RegWrite ruche & "MinimizeOptions",1, "REG_DWORD"
' -------------------------------------------------------------------------

' ---- lancer la loupe (sauf pour .!)

' forcer attente sleep 1/2 seconde
    wscript.sleep (MSAVANTRELANCE)
    WshShell.Run "magnify.exe" ,7
 
'   wscript.echo "fait"

end sub ' totale


sub raccourci (caption,key,param)
'
' wscript.echo "ajouter " & caption & " " & key & " " & param & vbcrlf & strDesktop & caption & ".lnk"

' ----- construire le nom du fichier raccourci (sur bureau utilisateur)
  strDesktop = WshShell.SpecialFolders(TARGETDESKTOP)
  filename=strDesktop & "\" & prefixe & caption & ".lnk"
' s'il existe détruire ancien raccourci
' wscript.echo filename
   
 if fso.fileexists(filename) then   
    fso.deleteFile  filename
    if effacer then    nbraccourciVus=nbraccourciVus+1
    end if

' ----- si appel pour effacer, c'est fini
if effacer  then        exit sub 

' ----- créer raccourci
    nbraccourciVus=nbraccourciVus+1
'       wscript.echo "creer " & filename & " m=" & m
   set oShellLink = WshShell.CreateShortcut(filename)
   oShellLink.TargetPath = WScript.ScriptFullName
   oShellLink.WindowStyle = 1
   if key<>"" then 
on error resume next
     oShellLink.Hotkey = masque & key
if err<>0 then wscript.echo key & vbcrlf & err.description
on error goto 0
     oShellLink.Arguments = """" & param & """"
   else
      oShellLink.Arguments = ""
   end if
   oShellLink.IconLocation = "magnify.exe, 0"
   oShellLink.Description = prefixe & caption
   oShellLink.WorkingDirectory = strDesktop
   oShellLink.Save 
set oShellLink=nothing
' ici on pourrait cacher les raccourcis si batch
if (batch and CACHERSIBATCH) or CACHERTOUJOURS then
   set f= fso.getfile(filename)
   f.attributes=2
   set f=nothing
end if

if pasapas then wscript.echo masque & key 
end sub


(1) il est aussi possible lors de l'installation de choisir d'autres combinaisons: <CTRL>+<ALT> ou <CTRL>+<ALT>+<MAJUSCULE> mais elles entrent en conflit avec d'autres commandes et sont à proscrire.

(2) pour ne pas encombrer le bureau, placez dans le groupe démarrage un raccourci vers loupe.vbs avec le code du masque souhaité.

(3) pour partager entre tous les utilisateurs, http://msdn.microsoft.com/en-us/library/0ea7b5xe%28VS.85%29.aspx

(4) A EVALUER: http://www.donationcoder.com/Forums/bb/index.php?topic=18189.msg163170#top