IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Discussion :

Pb identification control dans dialogue de classe WindowsForms10.EDIT


Sujet :

Windows

  1. #1
    Membre habitué Avatar de r2d2abc
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    212
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2009
    Messages : 212
    Points : 179
    Points
    179
    Par défaut Pb identification control dans dialogue de classe WindowsForms10.EDIT
    Bonjour je cherche à automatiser le remplissage des items d'une dialogue dont je vous ai fait un extract plus bas en utilisant l'api getdlgctrlid.
    Cela marche si l'application est lancée et ne se ferme pas ce qui n'est pas acceptable en mode prod. Le pb provient du fait que l'identifiant de certaines zones change à chaque lancement de l'application donc comment faire pour le localiser d'une manière unique. Les lignes sont identifiées en rouge (id/ctrl en rouge gras)
    Merci de votre aide

    PS: dev sous codeblocks en c/c++ avec des compilateurs (gcc/cbuilder/ms/..)

    1° lancement
    WINDOW FOUND: hwnd=0x1C0BB2 title=Interface] getwindowprocessname=D:\Program Files (x86)\flux\interface\interface.exe
    1 =[(pid:tid) 0x5f8(interface.exe):0xd68] -> [0x1c0bb2:Interface] -> [0x441686:] <WindowsForms10.Window.8.app.0.1983833:WindowsForms10.Window.8.app.0.1983833> (id=4462214) coord: 3351,915 -> 3822,1060
    2 =[(pid:tid) 0x5f8(interface.exe):0xd68] -> [0x441686:] -> [0x3f16de:Auth] <WindowsForms10.STATIC.app.0.1983833:WindowsForms10.STATIC.app.0.1983833> (id=4134622) coord: 3355,915 -> 3818,952
    3 =[(pid:tid) 0x5f8(interface.exe):0xd68] -> [0x441686:] -> [0x1d1572:Code] <WindowsForms10.STATIC.app.0.1983833:WindowsForms10.STATIC.app.0.1983833> (id=1906034) coord: 3355,952 -> 3450,986
    4 =[(pid:tid) 0x5f8(interface.exe):0xd68] -> [0x441686:] -> [0x270e34sw ] <WindowsForms10.STATIC.app.0.1983833:WindowsForms10.STATIC.app.0.1983833> (id=2559540) coord: 3355,986 -> 3452,1003
    5 =[(pid:tid) 0x5f8(interface.exe):0xd68] -> [0x441686:] -> [0x170554:CANCEL] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=1508692) coord: 3355,1020 -> 3455,1048
    6 =[(pid:tid) 0x5f8(interface.exe):0xd68] -> [0x441686:] -> [0x1f0620:pipo1] <WindowsForms10.EDIT.app.0.1983833:WindowsForms10.EDIT.app.0.1983833> (id=2033184) coord: 3463,956 -> 3742,978
    7 =[(pid:tid) 0x5f8(interface.exe):0xd68] -> [0x441686:] -> [0x160740:pipo2] <WindowsForms10.EDIT.app.0.1983833:WindowsForms10.EDIT.app.0.1983833> (id=1443648) coord: 3463,990 -> 3742,1012

    8 =[(pid:tid) 0x5f8(interface.exe):0xd68] -> [0x441686:] -> [0x1607c6:OK] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=1443782) coord: 3719,1020 -> 3818,1048
    9 =[(pid:tid) 0x5f8(interface.exe):0xd68] -> [0x441686:] -> [0x630bda:Option A] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=6491098) coord: 3750,956 -> 3805,977
    10 =[(pid:tid) 0x5f8(interface.exe):0xd68] -> [0x441686:] -> [0x1d0b30:Option B] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=1903408) coord: 3750,990 -> 3805,1011

    2° lancement
    WINDOW FOUND: hwnd=0x2D126A title=Interface] getwindowprocessname=D:\Program Files (x86)\flux\interface\interface.exe
    1 =[(pid:tid) 0x2390(interface.exe):0x148c] -> [0x2d126a:Interface] -> [0x1d07f2:] <WindowsForms10.Window.8.app.0.1983833:WindowsForms10.Window.8.app.0.1983833> (id=1902578) coord: 1444,927 -> 1915,1072
    2 =[(pid:tid) 0x2390(interface.exe):0x148c] -> [0x1d07f2:] -> [0x1c0b78:Auth] <WindowsForms10.STATIC.app.0.1983833:WindowsForms10.STATIC.app.0.1983833> (id=1837944) coord: 1448,927 -> 1911,964
    3 =[(pid:tid) 0x2390(interface.exe):0x148c] -> [0x1d07f2:] -> [0x2e1578:Code] <WindowsForms10.STATIC.app.0.1983833:WindowsForms10.STATIC.app.0.1983833> (id=3020152) coord: 1448,964 -> 1543,998
    4 =[(pid:tid) 0x2390(interface.exe):0x148c] -> [0x1d07f2:] -> [0x2015e4sw ] <WindowsForms10.STATIC.app.0.1983833:WindowsForms10.STATIC.app.0.1983833> (id=2102756) coord: 1448,998 -> 1545,1015
    5 =[(pid:tid) 0x2390(interface.exe):0x148c] -> [0x1d07f2:] -> [0x1b055c:CANCEL] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=1770844) coord: 1448,1032 -> 1548,1060
    6 =[(pid:tid) 0x2390(interface.exe):0x148c] -> [0x1d07f2:] -> [0x1a0b32:] <WindowsForms10.EDIT.app.0.1983833:WindowsForms10.EDIT.app.0.1983833> (id=1706802) coord: 1556,968 -> 1835,990
    7 =[(pid:tid) 0x2390(interface.exe):0x148c] -> [0x1d07f2:] -> [0x290e34:] <WindowsForms10.EDIT.app.0.1983833:WindowsForms10.EDIT.app.0.1983833> (id=2690612) coord: 1556,1002 -> 1835,1024
    8 =[(pid:tid) 0x2390(interface.exe):0x148c] -> [0x1d07f2:] -> [0x7a1012:Ok] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=7999506) coord: 1812,1032 -> 1911,1060
    9 =[(pid:tid) 0x2390(interface.exe):0x148c] -> [0x1d07f2:] -> [0x80580:Option A] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=525696) coord: 1843,968 -> 1898,989
    10 =[(pid:tid) 0x2390(interface.exe):0x148c] -> [0x1d07f2:] -> [0x260558:Option B] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=2491736) coord: 1843,1002 -> 1898,1023

    3° lancement
    WINDOW FOUND: hwnd=0x190FFA title=Interface] getwindowprocessname=D:\Program Files (x86)\flux\interface\interface.exe
    1 =[(pid:tid) 0x1604(interface.exe):0x239c] -> [0x190ffa:Interface] -> [0x1b05c2:] <WindowsForms10.Window.8.app.0.1983833:WindowsForms10.Window.8.app.0.1983833> (id=1770946) coordwind: 1448,929 -> 1919,1074 coordcli: 1448,929 -> 1919,1074
    2 =[(pid:tid) 0x1604(interface.exe):0x239c] -> [0x1b05c2:] -> [0x111620:Auth] <WindowsForms10.STATIC.app.0.1983833:WindowsForms10.STATIC.app.0.1983833> (id=1119776) coordwind: 1452,929 -> 1915,966 coordcli: 1452,929 -> 1915,966
    3 =[(pid:tid) 0x1604(interface.exe):0x239c] -> [0x1b05c2:] -> [0x120ade:Code] <WindowsForms10.STATIC.app.0.1983833:WindowsForms10.STATIC.app.0.1983833> (id=1182430) coordwind: 1452,966 -> 1547,1000 coordcli: 1452,966 -> 1547,1000
    4 =[(pid:tid) 0x1604(interface.exe):0x239c] -> [0x1b05c2:] -> [0x41015csw] <WindowsForms10.STATIC.app.0.1983833:WindowsForms10.STATIC.app.0.1983833> (id=4260188) coordwind: 1452,1000 -> 1549,1017 coordcli: 1452,1000 -> 1549,1017
    5 =[(pid:tid) 0x1604(interface.exe):0x239c] -> [0x1b05c2:] -> [0x4416b8:CANCEL] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=4462264) coordwind: 1452,1034 -> 1552,1062 coordcli: 1452,1034 -> 1552,1062
    6 =[(pid:tid) 0x1604(interface.exe):0x239c] -> [0x1b05c2:] -> [0x1609aa:] <WindowsForms10.EDIT.app.0.1983833:WindowsForms10.EDIT.app.0.1983833> (id=1444266) coordwind: 1560,970 -> 1839,992 coordcli: 1562,972 -> 1837,990
    7 =[(pid:tid) 0x1604(interface.exe):0x239c] -> [0x1b05c2:] -> [0x24076c:] <WindowsForms10.EDIT.app.0.1983833:WindowsForms10.EDIT.app.0.1983833> (id=2361196) coordwind: 1560,1004 -> 1839,1026 coordcli: 1562,1006 -> 1837,1024
    8 =[(pid:tid) 0x1604(interface.exe):0x239c] -> [0x1b05c2:] -> [0x210554:OK] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=2164052) coordwind: 1816,1034 -> 1915,1062 coordcli: 1816,1034 -> 1915,1062
    9 =[(pid:tid) 0x1604(interface.exe):0x239c] -> [0x1b05c2:] -> [0x450688:Option A] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=4523656) coordwind: 1847,970 -> 1902,991 coordcli: 1847,970 -> 1902,991
    10 =[(pid:tid) 0x1604(interface.exe):0x239c] -> [0x1b05c2:] -> [0x350fe2:Option B] <WindowsForms10.BUTTON.app.0.1983833:WindowsForms10.BUTTON.app.0.1983833> (id=3477474) coordwind: 1847,1004 -> 1902,1025 coordcli: 1847,1004 -> 1902,1025
    [/SIZE][/SIZE]

  2. #2
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Tiens c'est vrai, les Windows Forms n'utilisent pas les Control IDs, liant directement le contrôle à un objet à la place...

    Tu peux essayer avec les APIs d'accessibilité, ça a une chance de marcher.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  3. #3
    Membre habitué Avatar de r2d2abc
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    212
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2009
    Messages : 212
    Points : 179
    Points
    179
    Par défaut
    Je vais essayer / Merci de la réponse / A plus tard

  4. #4
    Membre habitué Avatar de r2d2abc
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    212
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2009
    Messages : 212
    Points : 179
    Points
    179
    Par défaut
    Bonsoir, je vous indique la piste. Il faut trouver de manière classique le processid de l'image exécutée. Enfin allouer de la mémoire dans le process pas sur la stack ou mémoire du process appelant. Envoyer le message, récupérer la valeur par un ReadProcessMemory, enfin le changer de wide en char avant de pouvoir l'utiliser.
    Vous pouvez faire un sendmessage plutôt qu'avec un timeout, par contre le wide to byte m' a un peu ennuyé au début.
    Merci à Médinoc.
    Bien à vous


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    void GetIdCtrlName2 (HWND hwnd, DWORD processid)
    {
        const int bufsize = 1024;
        wchar_t   wctrlname [bufsize];    //wide char
        char      ctrlname[256];
        SIZE_T    nbr;
        unsigned int    GetNameMsg;
        DWORD           dwResult;
        HANDLE          hProcess;
        LPVOID          MemPid;
        LPARAM          lpMemPid;
        unsigned int    sendflags;
        LRESULT         lResult;
        BOOL            bResult;
        int             rc;
    
        //Allocate
        GetNameMsg      = RegisterWindowMessage("WM_GETCONTROLNAME");
        //dwResult        = GetWindowThreadProcessId(hwnd, &processid);
        hProcess        = OpenProcess(PROCESS_ALL_ACCESS,false,processid);
        MemPid        = VirtualAllocEx(hProcess, 0, bufsize, MEM_COMMIT,PAGE_READWRITE);
        lpMemPid      = reinterpret_cast<LPARAM>(MemPid);
        sendflags       = SMTO_ABORTIFHUNG|SMTO_BLOCK;
    
        //Execute
        lResult = SendMessageTimeout(hwnd, GetNameMsg, bufsize, lpMemPid, sendflags, 3000, &nbr);
        bResult = ReadProcessMemory(hProcess, MemPid, wctrlname, bufsize, &nbr);
        rc      = WideCharToMultiByte
                                    (
                                      CP_ACP,
                                      0,
                                      wctrlname,//(LPCWSTR)wctrlname,
                                      -1,
                                      ctrlname,
                                      256, //sizeof(ctrlname),
                                      NULL,
                                      NULL
                                    );
    
    
        //Close all allocated
        bResult = CloseHandle(hProcess);
        bResult = VirtualFreeEx(hProcess,MemPid,1024,MEM_RELEASE);
    
        cout<<endl<<"getidctrlname="<<ctrlname<<":"<<ctrlname<<" NbRead="<<nbr;
    }

    1° lancement
    ------------
    processid1=6136
    WINDOW FOUND: hwnd=0x9113A title=Interface] getwindowprocessname=e=D:\Program Files (x86)\flux\interface\interface.exe
    6 =[(pid:tid) 0x17f8(interface.exe):0x19b8] -> [0x4f10a6:] -> [0x31390:] <WindowsForms10.EDIT.app.0.1983833:WindowsForms10.EDIT.app.0.1983833> (id=201616) coordwind: 1553,977 -> 1832,999 coordcli: 1555,979 -> 1830,997
    getidctrlname=1635304:textBoxCode NumRead=1024
    7 =[(pid:tid) 0x17f8(interface.exe):0x19b8] -> [0x4f10a6:] -> [0x70e24:] <WindowsForms10.EDIT.app.0.1983833:WindowsForms10.EDIT.app.0.1983833> (id=462372) coordwind: 1553,1011 -> 1832,1033 coordcli: 1555,1013 -> 1830,1031
    getidctrlname=1635304:textBoxMdp NumRead=1024

    2° lancement
    ------------
    processid3=620
    WINDOW FOUND: hwnd=0x71196 title=Interface] getwindowprocessname=e=D:\Program Files (x86)\flux\interface\interface.exe
    6 =[(pid:tid) 0x26c(interface.exe):0xa1c] -> [0x51390:] -> [0x5138a:] <WindowsForms10.EDIT.app.0.1983833:WindowsForms10.EDIT.app.0.1983833> (id=332682) coordwind: 836,519 -> 1115,541 coordcli: 838,521 -> 1113,539
    getidctrlname=1635304:textBoxCode NumRead=1024
    7 =[(pid:tid) 0x26c(interface.exe):0xa1c] -> [0x51390:] -> [0x320b9e:] <WindowsForms10.EDIT.app.0.1983833:WindowsForms10.EDIT.app.0.1983833> (id=3279774) coordwind: 836,553 -> 1115,575 coordcli: 838,555 -> 1113,573
    getidctrlname=1635304:textBoxMdp NumRead=1024

  5. #5
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Intéressant, j'ignorait que les contrôles Windows Forms supportaient un tel message.

    Assure-toi de traiter l'échec potentiel de OpenProcess(), par contre, car cela ne marchera que sur les processus t'appartenant.
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

  6. #6
    Membre habitué Avatar de r2d2abc
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    212
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2009
    Messages : 212
    Points : 179
    Points
    179
    Par défaut
    C 'est clair. Un code plus sécurisé (petit gestion d'exception) va être mis en place.
    Kenavo

Discussions similaires

  1. Réponses: 2
    Dernier message: 24/01/2011, 14h45
  2. Réponses: 3
    Dernier message: 14/09/2010, 10h14
  3. Transparence controle dans boite de dialogue
    Par coco21 dans le forum MFC
    Réponses: 7
    Dernier message: 22/02/2008, 23h38
  4. [OpenOffice] [Macro OOBasic] controle Tree dans dialogue & DOM Parser.
    Par azerr dans le forum OpenOffice & LibreOffice
    Réponses: 0
    Dernier message: 21/11/2007, 09h13
  5. [Struts]control dans la class form
    Par jimi dans le forum Struts 1
    Réponses: 8
    Dernier message: 01/06/2005, 16h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo