Replace 1 + lines?

  • I wrote a program for the test of regular expressions. It serves as a database. When you click a button, it fills in the search and replace fields.
    I decided to make a plugin that will do the same. But the same program (exe and dll) work differently. EXE fills the fields, but the DLL can not fill.
    I tried using EnumChildWindows to find the elements of the window, as is done in the examples above. But as a result, he found only 3 elements.
    0 hwnd = 725602 Class = Button Title = Caption
    1 hwnd = 2233572 Class = Static Title =
    2 hwnd = 1707882 Class = SysTabControl32 Title = Tab1


    without seeing/understanding the actual code it is hard to say what might be the issue
    but, personally, I would not recommend using EnumChildWindows when trying to find a
    dialog control window handle, instead use GetDlgItem.

  • ; PureBasic
    hwnd = FindWindowEx_(NppData_nppHandle, 0, “#32770”, 0) ; hwnd = yes
    If Not IsWindowVisible_(hwnd)
    SendMessage_(NppData_nppHandle, #NPPM_MENUCOMMAND, 0, #IDM_SEARCH_REPLACE) ; Показать диалог поиска используя команду меню
    hwndEdit_1 = GetDlgItem_(hwnd, 1601) ; hwndEdit_1 = 0
    hwndEdit_2 = GetDlgItem_(hwnd, 1602) ; hwndEdit_2 = 0
    SendMessage_(hwndEdit_1,#WM_SETTEXT,0,GetGadgetItemText(#Combo_2 , n-1, 0))
    SendMessage_(hwndEdit_2,#WM_SETTEXT,0,GetGadgetItemText(#Combo_2 , n-1, 1))

  • @AZJIO-AZJIO said:


    be careful about searching for the ordinal only, as every dialog uses it.
    Most plugins and internal npp windows are dialogs.

  • I know it. I do not set the window class. I have no way to change this. The external program, as I said, works.


    Sorry, didn’t recognize the update.
    Windows, sometimes, treats retrieving external and internal information differently.
    Means, something you retrieved from an exe might differ from something
    you want to retrieve within its own process.

    In python, I would it do like this

    import ctypes
    user32 = ctypes.WinDLL('user32')
    hwnd = user32.FindWindowExW(None, None, u'#32770', u'Replace')
    hwndEdit_1 = user32.GetDlgItem(hwnd, 1601)
    hwndEdit_2 = user32.GetDlgItem(hwnd, 1602)

    This takes care that only the dialog with name Replace is found.

  • I have done just that. Keyword only “Extended”. But using AutoIt3

    $hWnd = WinGetHandle("[CLASS:Notepad++]")
    If Not @error Then
    If BitAND(WinGetState($hWnd), 16) Then WinActivate($hWnd)
    $hWnd = WinWait("[CLASS:#32770]", “Extended”, 2)
    If $hWnd Then
    ControlSetText($hWnd, “Extended”, “Edit1”, _GUICtrlRichEdit_GetText($hRichEdit_SPE))
    ControlSetText($hWnd, “Extended”, “Edit2”, GUICtrlRead($PtnRep))
    ControlCommand($hWnd, “Extended”, “Button18”, ‘Check’) ; 18 - regular expression (16 - normal)

    on PureBasic code is the same for exe and dll. Search window “#32770” starts at the top, so it does not cause a problem. There are either no such windows or they are below.

  • Maybe I have a wrong assumption what you are actually doing.
    When you talk about an exe I assume that this is a different standalone program, correct?
    When you talked about dll I assumed that this might be a npp plugin.
    Now I get the feeling this is incorrect. Would you mind to explain what exactly is what
    and what your ultimate goal is?

  • Thank! The previous code helped. I saw in it the absence of a handle in FindWindowExW(None
    I am intensively writing 2 plugins

  • As a result, several plugins, but there is much to strive for.

Log in to reply