Comment introduire la possibilté de donner les cordonnée X,Y dans mon script

cs_littleGirl Messages postés 3 Date d'inscription mardi 2 juin 2009 Statut Membre Dernière intervention 6 juin 2009 - 2 juin 2009 à 02:16
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 - 2 juin 2009 à 16:01
J'ai trouver ce script écrit en vb6 qui permet de simuler un clic sur une fenêtre voulue mais le problème est qu'il clic toujours sur point (0,0), ce que je veux moi c'est de pouvoir choisir le point(X.Y)

<hr size="2" width="100%" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="ProgId" content="Word.Document" /><meta name="Generator" content="Microsoft Word 11" /><meta name="Originator" content="Microsoft Word 11" /><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CADMINI%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C02%5Cclip_filelist.xml" /><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><style><!--
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
@page Section1
{size:595.3pt 841.9pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;
mso-header-margin:35.4pt;
mso-footer-margin:35.4pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
--></style><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Tableau Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->'// purpose: do sendkey

'// input:

'//     clickMode:
{"WINDOW","EDIT","WINDOWEDIT"}

'// ex: ret = getClick("ProgramName","WINDOW")

Function getClick(ByVal applicationTitle As String, ByVal
clickMode As String) As Long

    Dim
returnValue  As Long

    Dim bHaveError As
Boolean       '// is error happen?

    Dim
strErrorMessage As String   '// error
message.

    Dim appHwnd As
Long

    Dim hWndEdit As
Long

   

    '// initial

    returnValue = 0

    bHaveError = False

    strErrorMessage =
""

   

    appHwnd =
FindWindow(0&, applicationTitle)

   

    If appHwnd <= 0
Then

        bHaveError =
True

       
strErrorMessage = "can't find the window: '" &
applicationTitle & "'."

    End If

 

    '// start to get
process handle

    If bHaveError =
False Then

        returnValue = RunDll32Add5("user32",
"PostMessageA", appHwnd, WM_LBUTTONDOWN, MK_LBUTTON, 0)

        Sleep 20

        returnValue =
RunDll32Add5("user32", "PostMessageA", appHwnd,
WM_LBUTTONUP, MK_LBUTTON, 0)

        Sleep 20

       

        If InStr(clickMode,
"EDIT") > 0 Then

            hWndEdit =
FindWindowEx(appHwnd, vbNullString, "edit", vbNullString)

           
returnValue = RunDll32Add5("user32", "PostMessageA",
hWndEdit, WM_LBUTTONDOWN, MK_LBUTTON, 0)

            Sleep 20

           
returnValue = RunDll32Add5("user32", "PostMessageA",
hWndEdit, WM_LBUTTONUP, MK_LBUTTON, 0)

            Sleep 20

        End If

       

        returnValue =
True

    Else

        MsgBox
strErrorMessage

    End If

    getClick =
returnValue

End Function

<hr size="2" width="100%" />Merci pour votre furture réponse
A voir également:

5 réponses

Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
2 juin 2009 à 07:09
envoies plutot les WM_COMMAND aec le ID des controles ou menu a activer...
tu seras au moins certain du resultat.
0
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
2 juin 2009 à 07:10
ah, et puisque tu es en VB6 et non en VBS, pourquoi faire:

RunDll32Add5("user32", "PostMessageA", appHwnd, WM_LBUTTONDOWN, MK_LBUTTON, 0)

au lieu de déclarer tes APIs ?
0
cs_littleGirl Messages postés 3 Date d'inscription mardi 2 juin 2009 Statut Membre Dernière intervention 6 juin 2009
2 juin 2009 à 13:48
Bonjour Renfield merci beaucoup pour m'avoir répondu, je ne sais pas vraiment bcp de quoi tu parle je suis novice en vb , je ne sais pas; tu pense que ce n'est pas du vb6? parce que moi j'ouvre le projet avec visual basic 6.0 en ce qui concerne le script que j'ai poser ce n'est qu'un morceau dans lequel je pense ou je doit dois apporter les changement, merc encore!
0
cs_littleGirl Messages postés 3 Date d'inscription mardi 2 juin 2009 Statut Membre Dernière intervention 6 juin 2009
2 juin 2009 à 15:07
Alors voila le le script avec les dclaratio et les commande

Option Explicit

Public Const MK_LBUTTON = &H1
Public Const MK_RBUTTON = &H2
Public Const MK_MBUTTON = &H10

Public Const WM_MOUSEMOVE = &H200
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_RBUTTONDOWN = &H204
Public Const WM_RBUTTONUP = &H205
Public Const WM_RBUTTONDBLCLK = &H206
Public Const WM_MBUTTONDOWN = &H207
Public Const WM_MBUTTONUP = &H208
Public Const WM_MBUTTONDBLCLK = &H209

'// purpose: do sendkey
'// input:
'//     clickMode: {"WINDOW","EDIT","WINDOWEDIT"}
'// ex: ret = getClick("Programe","WINDOW")
Function getClick(ByVal applicationTitle As String, ByVal clickMode As String) As Long
    Dim returnValue  As Long
    Dim bHaveError As Boolean       '// is error happen?
    Dim strErrorMessage As String   '// error message.
    Dim appHwnd As Long
    Dim hWndEdit As Long
   
    '// initial
    returnValue = 0
    bHaveError = False
    strErrorMessage = ""
   
    appHwnd = FindWindow(0&, applicationTitle)
   
    If appHwnd <= 0 Then
        bHaveError = True
        strErrorMessage = "can't find the window: '" & applicationTitle & "'."
    End If

    '// start to get process handle
    If bHaveError = False Then
        returnValue = RunDll32Add5("user32", "PostMessageA", appHwnd, WM_LBUTTONDOWN, MK_LBUTTON, 0)
        Sleep 20
        returnValue = RunDll32Add5("user32", "PostMessageA", appHwnd, WM_LBUTTONUP, MK_LBUTTON, 0)
        Sleep 20
       
        If InStr(clickMode, "EDIT") > 0 Then
            hWndEdit = FindWindowEx(appHwnd, vbNullString, "edit", vbNullString)
            returnValue = RunDll32Add5("user32", "PostMessageA", hWndEdit, WM_LBUTTONDOWN, MK_LBUTTON, 0)
            Sleep 20
            returnValue = RunDll32Add5("user32", "PostMessageA", hWndEdit, WM_LBUTTONUP, MK_LBUTTON, 0)
            Sleep 20
        End If
       
        returnValue = True
    Else
        MsgBox strErrorMessage
    End If
    getClick = returnValue
End Function
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
2 juin 2009 à 16:01
ton code est pas idéal.

dis nous ce que tu souhaites faire, exactement
0
Rejoignez-nous