[Ex] Handle scrolling = Hscroll

Partagez vos scripts, et vos applications AutoIt.
Règles du forum
.
Répondre
ani
Niveau 11
Niveau 11
Messages : 1826
Enregistré le : lun. 23 juil. 2007 12:31
Localisation : Bureau
Status : Hors ligne

[Ex] Handle scrolling = Hscroll

#1

Message par ani »

Ce bout de code n'est pas de moi, je l'ai juste adapté pour autoit :)
Celui-ci fait une copie de votre écran et fait un mouvement de gauche à droite, graçe à la fonction _winapi_BitBlt (voir aide pour de plus amples information)

Faut que vous testiez, car j'explique très mal :p

Code : Tout sélectionner

#include <winapi.au3>
#include <WindowsConstants.au3>
Global $swid = _winapi_GetSystemMetrics($SM_CXSCREEN)
Global $shgt = _winapi_GetSystemMetrics($SM_CYSCREEN)
Global $dwid = $swid * 2

Global $hDC, $cDC, $hScr = 0, $hBmp, $hOld

$hDC= _winapi_GetDC($hScr)
$hBmp = _winapi_CreateCompatibleBitmap($hDC,$dwid,$shgt)
$cDC = _winapi_CreateCompatibleDC($hDC)
$hOld = _winapi_SelectObject($cDC,$hBmp)

_winapi_BitBlt($cDC,0,0,$swid,$shgt,$hDC,0,0,$SRCCOPY)
_winapi_BitBlt($cDC,$swid,0,$swid,$shgt,$hDC,0,0,$SRCCOPY)

For $i = $swid to 0 step - 8
    _winapi_BitBlt($hDC,0,0,$swid,$shgt,$cDC,$i,0,$SRCCOPY)
    Sleep(20)
next

_SendMessage(0,$WM_PAINT,$hDC,0)
_winapi_DeleteObject($hBmp)
_winapi_SelectObject($cDC,$hOld)
_winapi_DeleteDC($cDC)
_winapi_ReleaseDC($hScr,$hDC)
exit
on peut remplacer le systemMetric par des macro, ce qui permet de raccourcir de quelque ligne le code, merci a siao

Code : Tout sélectionner

#include <WindowsConstants.au3>
#include <WinAPI.au3>

$hScreenDC = _WinAPI_GetWindowDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScreenDC)
$hMemBMP = _WinAPI_CreateCompatibleBitmap($hScreenDC, @DesktopWidth*2, @DesktopHeight)
_WinAPI_DeleteObject(_WinAPI_SelectObject($hMemDC, $hMemBMP))
_WinAPI_BitBlt($hMemDC, 0, 0, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)
_WinAPI_BitBlt($hMemDC, @DesktopWidth, 0, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)

For $i = @DesktopWidth To 0 Step -8
    _WinAPI_BitBlt($hScreenDC, 0, 0, @DesktopWidth, @DesktopHeight, $hMemDC, $i, 0, $SRCCOPY)
    Sleep(20)
Next

_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN)
_WinAPI_ReleaseDC(0, $hScreenDC)
_WinAPI_DeleteObject($hMemBMP)
_WinAPI_DeleteDC($hMemDC)

Exit
tolf
Niveau 7
Niveau 7
Messages : 318
Enregistré le : ven. 15 févr. 2008 12:25
Localisation : Paris
Status : Hors ligne

Re: [Ex] Handle scrolling = Hscroll

#2

Message par tolf »

Trop fort le script !!

J'ai essayé de l'adapter pour faire un mouvement vertical au lieu d'un mouvement horizontal en remplaçant :

Code : Tout sélectionner

For $i = @DesktopWidth To 0 Step -8
    _WinAPI_BitBlt($hScreenDC, 0, 0, @DesktopWidth, @DesktopHeight, $hMemDC, $i, 0, $SRCCOPY)
    Sleep(20)
Next
par :

Code : Tout sélectionner

For $i = @DesktopHeight To 0 Step -8
    _WinAPI_BitBlt($hScreenDC, 0, 0, @DesktopWidth, @DesktopHeight, $hMemDC, 0, $i, $SRCCOPY)
    Sleep(20)
Next
mais l'image de l'écran se superpose à celle d'origine au lieu de la "bousculer". Quelqu'un a-t-il une explication ?
Lisez la documentation d'AutoIt en français (et participez svp :mrgreen:) !

Mes UDF :
[/i][/b]
ani
Niveau 11
Niveau 11
Messages : 1826
Enregistré le : lun. 23 juil. 2007 12:31
Localisation : Bureau
Status : Hors ligne

Re: [Ex] Handle scrolling = Hscroll

#3

Message par ani »

merci tolf, moi aussi j'ai bien aimé :)

Je prend le deuxieme code comme exemple :
Alors j'explique, si tu désire faire de haut vers le bas faut multiplier la valeur $height (DesktopHeight) par deux .

les changement à effectuer sont

Code : Tout sélectionner

$hMemBMP = _WinAPI_CreateCompatibleBitmap($hScreenDC, @DesktopWidth*2, @DesktopHeight)
par

Code : Tout sélectionner

$hMemBMP = _WinAPI_CreateCompatibleBitmap($hScreenDC, @DesktopWidth, @DesktopHeight*2)
ensuite

Code : Tout sélectionner

_WinAPI_BitBlt($hMemDC,@DesktopWidth, 0, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)
par

Code : Tout sélectionner

_WinAPI_BitBlt($hMemDC,0, @DesktopHeight, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)
Code complet

Code : Tout sélectionner

#include <WindowsConstants.au3>
#include <WinAPI.au3>

$hScreenDC = _WinAPI_GetWindowDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScreenDC)
$hMemBMP = _WinAPI_CreateCompatibleBitmap($hScreenDC, @DesktopWidth, @DesktopHeight*2)
_WinAPI_DeleteObject(_WinAPI_SelectObject($hMemDC, $hMemBMP))
_WinAPI_BitBlt($hMemDC, 0, 0, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)
_WinAPI_BitBlt($hMemDC,0, @DesktopHeight, @DesktopWidth, @DesktopHeight, $hScreenDC, 0, 0, $SRCCOPY)

For $i = @DesktopHeight To 0 Step -8
    _WinAPI_BitBlt($hScreenDC, 0, 0, @DesktopWidth, @DesktopHeight, $hMemDC, 0, $i, $SRCCOPY)
    Sleep(20)
Next

_WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN)
_WinAPI_ReleaseDC(0, $hScreenDC)
_WinAPI_DeleteObject($hMemBMP)
_WinAPI_DeleteDC($hMemDC)

Exit
Pour l'exemple 1

Code : Tout sélectionner

#include <winapi.au3>
#include <WindowsConstants.au3>
Global $swid = _winapi_GetSystemMetrics($SM_CXSCREEN)
Global $shgt = _winapi_GetSystemMetrics($SM_CYSCREEN)
Global $dhgt = $shgt * 2

Global $hDC, $cDC, $hScr = 0, $hBmp, $hOld

$hDC= _winapi_GetDC($hScr)
$hBmp = _winapi_CreateCompatibleBitmap($hDC,$swid,$dhgt)
$cDC = _winapi_CreateCompatibleDC($hDC)
$hOld = _winapi_SelectObject($cDC,$hBmp)

_winapi_BitBlt($cDC,0,0,$swid,$shgt,$hDC,0,0,$SRCCOPY)
_winapi_BitBlt($cDC,0,$shgt,$swid,$shgt,$hDC,0,0,$SRCCOPY)

For $i = $shgt to 0 step - 8
    _winapi_BitBlt($hDC,0,0,$swid,$shgt,$cDC,0,$i,$SRCCOPY)
    Sleep(20)
next

_SendMessage(0,$WM_PAINT,$hDC,0)
_winapi_DeleteObject($hBmp)
_winapi_SelectObject($cDC,$hOld)
_winapi_DeleteDC($cDC)
_winapi_ReleaseDC($hScr,$hDC)
exit
Il est aussi possible de le faire en diagonal ;)
tolf
Niveau 7
Niveau 7
Messages : 318
Enregistré le : ven. 15 févr. 2008 12:25
Localisation : Paris
Status : Hors ligne

Re: [Ex] Handle scrolling = Hscroll

#4

Message par tolf »

merci ani pour les précisions :D
Lisez la documentation d'AutoIt en français (et participez svp :mrgreen:) !

Mes UDF :
[/i][/b]
ani
Niveau 11
Niveau 11
Messages : 1826
Enregistré le : lun. 23 juil. 2007 12:31
Localisation : Bureau
Status : Hors ligne

Re: [Ex] Handle scrolling = Hscroll

#5

Message par ani »

Petite exercice :o
horizontal inverser = de droite à gauche
vertical inverser = de bas en haut
Avatar du membre
arrkhan
Niveau 8
Niveau 8
Messages : 528
Enregistré le : sam. 17 nov. 2007 03:30
Status : Hors ligne

Re: [Ex] Handle scrolling = Hscroll

#6

Message par arrkhan »

Ouch !!!
C'est dans ces moments que je me dit que j'ai encore un sale niveau en code... vu comment j ai du mal a le digerer (j'ai eu la flemme de lire les includes, j'aurais p'têt pas dus), mais sinon c est clair c'est bien sympa ^^ meme si j en voit pas trop l interet hihi, peut etre pour un systeme de bureau multiple mais je suis quasi sur de dire une co**erie
ani
Niveau 11
Niveau 11
Messages : 1826
Enregistré le : lun. 23 juil. 2007 12:31
Localisation : Bureau
Status : Hors ligne

Re: [Ex] Handle scrolling = Hscroll

#7

Message par ani »

:)

Faut pas lire l'include, on obtiend aucune information ^^'
Moi aussi j'ai eu un peu de mal, même pour faire un effet inverse :(

vlà la solution (c'était tout simple :p)

Code : Tout sélectionner

#include <winapi.au3>
#include <WindowsConstants.au3>
Global $swid = _winapi_GetSystemMetrics($SM_CXSCREEN)
Global $shgt = _winapi_GetSystemMetrics($SM_CYSCREEN)
Global $dwid = $swid * 2

Global $hDC, $cDC, $hScr = 0, $hBmp, $hOld

$hDC= _winapi_GetDC($hScr)
$hBmp = _winapi_CreateCompatibleBitmap($hDC,$dwid,$shgt)
$cDC = _winapi_CreateCompatibleDC($hDC)
$hOld = _winapi_SelectObject($cDC,$hBmp)

_winapi_BitBlt($cDC,0,0,$swid,$shgt,$hDC,0,0,$SRCCOPY)
_winapi_BitBlt($cDC,$swid,0,$swid,$shgt,$hDC,0,0,$SRCCOPY)

; au lieu de for $i = $swid to 0 step -8
For $i = 0 to $swid step 8 ; c'est simple :o 
    _winapi_BitBlt($hDC,0,0,$swid,$shgt,$cDC,$i,0,$SRCCOPY)
    Sleep(20)
next

_SendMessage(0,$WM_PAINT,$hDC,0)
_winapi_DeleteObject($hBmp)
_winapi_SelectObject($cDC,$hOld)
_winapi_DeleteDC($cDC)
_winapi_ReleaseDC($hScr,$hDC)
exit
ps: ce post se verra modifier (si vous êtes d'accord) :)
tolf
Niveau 7
Niveau 7
Messages : 318
Enregistré le : ven. 15 févr. 2008 12:25
Localisation : Paris
Status : Hors ligne

Re: [Ex] Handle scrolling = Hscroll

#8

Message par tolf »

J'ai modifié ces lignes :

Code : Tout sélectionner

For $i = 0 to $swid step 8
    _winapi_BitBlt($hDC,0,0,$swid,$shgt,$cDC,$i,0,$SRCCOPY)
    Sleep(20)
next
par cela :

Code : Tout sélectionner

For $i = 0 to $swid step 3 
    _winapi_BitBlt($hDC,0,0,$swid,$shgt,$cDC,$i,0,$SRCCOPY)
next
... et l'effet est plus fluide
Lisez la documentation d'AutoIt en français (et participez svp :mrgreen:) !

Mes UDF :
[/i][/b]
Avatar du membre
chandragon
Niveau 1
Niveau 1
Messages : 7
Enregistré le : mer. 16 avr. 2008 01:10
Status : Hors ligne

Re: [Ex] Handle scrolling = Hscroll

#9

Message par chandragon »

Waaaaa balaise xD
Mais il y a des trucs que je saisit pas ... genre le _WinAPI_BitBlt
Tu dit d'aller voir dans l'aide mais quelle aide ? pasque dans l'aide de Autoit il y a juste ça:
Performs a bit-block transfer of color data
Et je comprend pas bien à quoi ça sert ....
Répondre