1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| Option Explicit
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long
Private Sub CommandButton1_Click()
Dim cible As Range, ppx As Double, i As Integer, ou As Single, titix As Long, titiy As Long, c As Long, r As Long
Dim nbtests As Integer, attente As Integer
nbtests = 10 ' ----->> choisir le nombre de tests à faire
attente = 2 ' ------>> choisir le temps d'affichage en secondes qui vous sied
Randomize
With CreateObject("WScript.Shell")
ppx = .RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\AppliedDPI") / 72
End With
For i = 1 To nbtests
Range("A1:A20").RowHeight = Int((50 * Rnd) + 10)
Range("A1:AA20").ColumnWidth = Int((50 * Rnd) + 10)
ou = Int((40 * Rnd) + 10)
Rows(ou).RowHeight = Int((111 * Rnd) + 50) / 10
ou = Int((4 * Rnd) + 1)
Rows(ou).RowHeight = Int((40 * Rnd) + 40) / 10
ou = Int((20 * Rnd) + 1)
Rows(ou).RowHeight = Int((50 * Rnd) + 50) / 10
ou = Int((4 * Rnd) + 1)
Rows(ou).RowHeight = Int((40 * Rnd) + 40) / 10
ou = Int((6 * Rnd) + 1)
Rows(ou).RowHeight = Int((33 * Rnd) + 40) / 10
ou = Int((20 * Rnd) + 1)
Columns(ou).ColumnWidth = Int((50 * Rnd) + 50) / 10
ou = Int((20 * Rnd) + 1)
Columns(ou).ColumnWidth = Int((50 * Rnd) + 50) / 10
ou = Int((20 * Rnd) + 1)
Columns(ou).ColumnWidth = Int((10 * Rnd) + 40) / 10
ou = Int((20 * Rnd) + 1)
Columns(ou).ColumnWidth = Int((1# * Rnd) + 13) / 10
DoEvents
ou = Int((20 * Rnd) + 1)
Columns(ou).ColumnWidth = Int((50 * Rnd) + 50) / 10
r = Int((10 * Rnd) + 1)
c = Int((10 * Rnd) + 1)
Set cible = Cells(r, c)
Label1.Caption = " " & Replace(cible.Address, "$", "")
DoEvents
With ActiveWindow
BlockInput True ' ---->> inhibition du clavier et de la souris
cible.Show
DoEvents
With Label1
.Font.Size = 14
.Top = cible.Top
.Left = cible.Left
.BackColor = RGB(255, 200, 200)
.Width = 400
End With
With ActiveWindow.ActivePane
titiy = Int(cible.Top)
titix = Int(cible.Left)
SetCursorPos .PointsToScreenPixelsX(titix), .PointsToScreenPixelsY(titiy)
End With
Application.Wait Now + TimeValue("0:00:" & attente) ' attente pour donner le temps de voir
BlockInput False ' --->> je réhabilité souris et clavier
End With
Next
End Sub |
Partager