Jump to content

regexptitle and regexpclass works strange


xjf
 Share

Recommended Posts

the window title and class from "AutoIt v3 Window Info" is :

title: NCRE服务器设置

class: WindowsForms10.Window.8.app.0.21373f6_r14_ad1

and then

_ArrayDisplay(WinList("[TITLE:NCRE服务器设置]"))    ; 1 window
_ArrayDisplay(WinList("[REGEXPTITLE:NCRE服务器设置]"))    ; 0 window, why ?
_ArrayDisplay(WinList("[REGEXPTITLE:服务器设置]"))    ; 1 window
_ArrayDisplay(WinList("[REGEXPTITLE:NCRE]"))    ; 0 windows, why ?
 

_ArrayDisplay(WinList("[CLASS:WindowsForms10.Window.8.app.0.21373f6_r14_ad1]"))        ; 1 window
_ArrayDisplay(WinList("[REGEXPCLASS:WindowsForms10.Window.8.app.0.21373f6_r14_ad1]"))    ; 0 window, why ?
_ArrayDisplay(WinList("[REGEXPCLASS:WindowsForms10]"))    ; 0 window, why ?

why that ? need some help. i'll be appreciate.

Link to comment
Share on other sites

@xjf

i tested your script & working fine,below script:

#include <WinAPIGdi.au3>
#include <WinAPIIcons.au3>
#include <WinAPIRes.au3>
#include <WinAPISys.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>
#include <array.au3>
Global $g_bExit = False

_Example()
Func _Example()
    Local Const $sClass = 'WindowsForms10.Window.8.app.0.21373f6_r14_ad1'
    Local Const $sName = 'NCRE服务器设置'

    ; Get module handle for the current process
    Local $hInstance = _WinAPI_GetModuleHandle(0)

    ; Create a class cursor
    Local $hCursor = _WinAPI_LoadCursor(0, 32512) ; IDC_ARROW

    ; Create a class icons (large and small)
    Local $tIcons = DllStructCreate('ptr;ptr')
    _WinAPI_ExtractIconEx(@SystemDir & '\shell32.dll', 130, DllStructGetPtr($tIcons, 1), DllStructGetPtr($tIcons, 2), 1)
    Local $hIcon = DllStructGetData($tIcons, 1)
    Local $hIconSm = DllStructGetData($tIcons, 2)

    ; Create DLL callback function (window procedure)
    Local $hProc = DllCallbackRegister('_WndProc', 'lresult', 'hwnd;uint;wparam;lparam')

    ; Create and fill $tagWNDCLASSEX structure
    Local $tWCEX = DllStructCreate($tagWNDCLASSEX & ';wchar szClassName[' & (StringLen($sClass) + 1) & ']')
    DllStructSetData($tWCEX, 'Size', DllStructGetPtr($tWCEX, 'szClassName') - DllStructGetPtr($tWCEX))
    DllStructSetData($tWCEX, 'Style', 0)
    DllStructSetData($tWCEX, 'hWndProc', DllCallbackGetPtr($hProc))
    DllStructSetData($tWCEX, 'ClsExtra', 0)
    DllStructSetData($tWCEX, 'WndExtra', 0)
    DllStructSetData($tWCEX, 'hInstance', $hInstance)
    DllStructSetData($tWCEX, 'hIcon', $hIcon)
    DllStructSetData($tWCEX, 'hCursor', $hCursor)
    DllStructSetData($tWCEX, 'hBackground', _WinAPI_CreateSolidBrush(_WinAPI_GetSysColor($COLOR_3DFACE)))
    DllStructSetData($tWCEX, 'MenuName', 0)
    DllStructSetData($tWCEX, 'ClassName', DllStructGetPtr($tWCEX, 'szClassName'))
    DllStructSetData($tWCEX, 'hIconSm', $hIconSm)
    DllStructSetData($tWCEX, 'szClassName', $sClass)

    ; Register a window class
    _WinAPI_RegisterClassEx($tWCEX)

    ; Create a window
    _WinAPI_CreateWindowEx(0, $sClass, $sName, BitOR($WS_CAPTION, $WS_POPUPWINDOW, $WS_VISIBLE), (@DesktopWidth - 400) / 2, (@DesktopHeight - 400) / 2, 400, 400, 0)
    _ArrayDisplay(WinList("[TITLE:NCRE服务器设置]")) ; 1 window
    _ArrayDisplay(WinList("[REGEXPTITLE:NCRE服务器设置]")) ; 0 window, why ?
    _ArrayDisplay(WinList("[REGEXPTITLE:服务器设置]")) ; 1 window
    _ArrayDisplay(WinList("[REGEXPTITLE:NCRE]")) ; 0 windows, why ?


    _ArrayDisplay(WinList("[CLASS:WindowsForms10.Window.8.app.0.21373f6_r14_ad1]"))    ; 1 window
    _ArrayDisplay(WinList("[REGEXPCLASS:WindowsForms10.Window.8.app.0.21373f6_r14_ad1]")) ; 0 window, why ?
    _ArrayDisplay(WinList("[REGEXPCLASS:WindowsForms10]")) ; 0 window, why ?
    While 1
        Sleep(100)
        If $g_bExit Then
            ExitLoop
        EndIf
    WEnd

    ; Unregister window class and release unnecessary resources
    _WinAPI_UnregisterClass($sClass, $hInstance)
    _WinAPI_DestroyCursor($hCursor)
    _WinAPI_DestroyIcon($hIcon)
    _WinAPI_DestroyIcon($hIconSm)

    DllCallbackFree($hProc)

EndFunc   ;==>_Example

; Func _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)
; Local $aRet = DllCall('user32.dll', 'lresult', 'DefWindowProcW', 'hwnd', $hWnd, 'uint', $iMsg, 'wparam', $wParam, 'lparam', $lParam)

; If @error Then
; Return SetError(1, 0, 0)
; EndIf
; Return $aRet[0]
; EndFunc   ;==>_WinAPI_DefWindowProcW

Func _WndProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_CLOSE
            $g_bExit = True
    EndSwitch
    Return _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WndProc

 

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

Link to comment
Share on other sites

 

17 minutes ago, xjf said:

@ad777

would your please submit a bug report this ? My English really sucks ...

i already did.

the new ver.Autoit v3.3.16.0 i think it work for substr:(below script):

#include <WinAPIGdi.au3>
#include <WinAPIIcons.au3>
#include <WinAPIRes.au3>
#include <WinAPISys.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>
#include <array.au3>
Global $g_bExit = False
_Example()
Func _Example()
    Local Const $sClass = 'WindowsForms10.Window.8.app.0.21373f6_r14_ad1'
    Local Const $sName = 'NCRE服务器设置'

    ; Get module handle for the current process
    Local $hInstance = _WinAPI_GetModuleHandle(0)

    ; Create a class cursor
    Local $hCursor = _WinAPI_LoadCursor(0, 32512) ; IDC_ARROW

    ; Create a class icons (large and small)
    Local $tIcons = DllStructCreate('ptr;ptr')
    _WinAPI_ExtractIconEx(@SystemDir & '\shell32.dll', 130, DllStructGetPtr($tIcons, 1), DllStructGetPtr($tIcons, 2), 1)
    Local $hIcon = DllStructGetData($tIcons, 1)
    Local $hIconSm = DllStructGetData($tIcons, 2)

    ; Create DLL callback function (window procedure)
    Local $hProc = DllCallbackRegister('_WndProc', 'lresult', 'hwnd;uint;wparam;lparam')

    ; Create and fill $tagWNDCLASSEX structure
    Local $tWCEX = DllStructCreate($tagWNDCLASSEX & ';wchar szClassName[' & (StringLen($sClass) + 1) & ']')
    DllStructSetData($tWCEX, 'Size', DllStructGetPtr($tWCEX, 'szClassName') - DllStructGetPtr($tWCEX))
    DllStructSetData($tWCEX, 'Style', 0)
    DllStructSetData($tWCEX, 'hWndProc', DllCallbackGetPtr($hProc))
    DllStructSetData($tWCEX, 'ClsExtra', 0)
    DllStructSetData($tWCEX, 'WndExtra', 0)
    DllStructSetData($tWCEX, 'hInstance', $hInstance)
    DllStructSetData($tWCEX, 'hIcon', $hIcon)
    DllStructSetData($tWCEX, 'hCursor', $hCursor)
    DllStructSetData($tWCEX, 'hBackground', _WinAPI_CreateSolidBrush(_WinAPI_GetSysColor($COLOR_3DFACE)))
    DllStructSetData($tWCEX, 'MenuName', 0)
    DllStructSetData($tWCEX, 'ClassName', DllStructGetPtr($tWCEX, 'szClassName'))
    DllStructSetData($tWCEX, 'hIconSm', $hIconSm)
    DllStructSetData($tWCEX, 'szClassName', $sClass)

    ; Register a window class
    _WinAPI_RegisterClassEx($tWCEX)

    ; Create a window
    _WinAPI_CreateWindowEx(0, $sClass, $sName, BitOR($WS_CAPTION, $WS_POPUPWINDOW, $WS_VISIBLE), (@DesktopWidth - 400) / 2, (@DesktopHeight - 400) / 2, 400, 400, 0)
    _ArrayDisplay(WinList("[TITLE:NCRE服务器设置]")) ; 1 window
    _ArrayDisplay(WinList("[REGEXPTITLE:服务器设置]")) ; 0 window, why ?
    _ArrayDisplay(WinList("[REGEXPTITLE:服务器设置]")) ; 1 window
    _ArrayDisplay(WinList("[REGEXPTITLE:服务器设置]")) ; 0 windows, why ?


    _ArrayDisplay(WinList("[CLASS:WindowsForms10.Window.8.app.0.21373f6_r14_ad1]"))    ; 1 window
    _ArrayDisplay(WinList("[REGEXPCLASS:21373f6_r14_ad1]")) ; 0 window, why ?
    _ArrayDisplay(WinList("[REGEXPCLASS:21373f6_r14_ad1]")) ; 0 window, why ?
    While 1
        Sleep(100)
        If $g_bExit Then
            ExitLoop
        EndIf
    WEnd

    ; Unregister window class and release unnecessary resources
    _WinAPI_UnregisterClass($sClass, $hInstance)
    _WinAPI_DestroyCursor($hCursor)
    _WinAPI_DestroyIcon($hIcon)
    _WinAPI_DestroyIcon($hIconSm)

    DllCallbackFree($hProc)

EndFunc   ;==>_Example

; Func _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)
; Local $aRet = DllCall('user32.dll', 'lresult', 'DefWindowProcW', 'hwnd', $hWnd, 'uint', $iMsg, 'wparam', $wParam, 'lparam', $lParam)

; If @error Then
; Return SetError(1, 0, 0)
; EndIf
; Return $aRet[0]
; EndFunc   ;==>_WinAPI_DefWindowProcW

Func _WndProc($hWnd, $iMsg, $wParam, $lParam)
    Switch $iMsg
        Case $WM_CLOSE
            $g_bExit = True
    EndSwitch
    Return _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_WndProc

 

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

Link to comment
Share on other sites

@jpm: concerning this thread, I just read your answer in Trac ticket #3870 (opened by @ad777 as indicated in his post just above) :

"For me, the script works the same for 3.3.14.5, 3.3.15.4, 3.3.15.5, 3.3.16.0"

If it can help, here is what I experience with a simpler script, when launched from AutoIt 3.3.14.5 then 3.3.16.0 :

#include <Array.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $sTitle = "example"
    Local $hGUI = GUICreate($sTitle, 200, 100)
    Local $idOK = GUICtrlCreateButton("OK", 60, 35, 80, 30)

    GUISetState(@SW_SHOW, $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idOK
                _ArrayDisplay(WinList("[REGEXPTITLE:example]"), @AutoItVersion)

        EndSwitch
    WEnd

    GUIDelete($hGUI)
EndFunc   ;==>Example

1305854199_issueregexptitle.png.5620859005ae618f7b21341804986d80.png

RegExp changes were made recently, as indicated in the beta's change log. Maybe there's a link, maybe not :

3.3.15.6 (Unreleased) (Beta)
AutoIt:
- Fixed #3794: StringRegExp updated to not use a string copy internally.

Hope it helps.

Link to comment
Share on other sites

Then it could be a question of AutoIt version 32bits vs 64bits, or the OS version ?
I'm using the oldest 32 bits OS version accepted by AutoIt. It won't be the 1st (or last time) that OS version shows different results, last issue in this link showed it clearly.

Edit: assuming jpm got a 64bit OS (maybe that's why it works for him with 3.3.16.0), if anyone could test with a 32bit OS (win7 for example) + AutoIt v3.3.16.0 then it could help , especially when you read above the OS's & AutoIt versions used by OP & ad777 during their tests.

@Musashi or @ad777 : could you please try this on your computers win 7 32bit ?
* download AutoIt zip file 3.3.16.0 (the one without installer +++), it's name is "autoit-v3.3.16.zip" (17M)
* unpack it in any new folder you like, then enter Scite folder, click SciTE.exe and run the script (from my last post) directly from Scite 3.3.16.0 (i.e. no double click on a .au3 file or it will open in your usual AutoIt version)

This is how I tried it and It won't do any harm to your present AutoIt installation.
It could help to make sure the issue appears with a win7 32bits OS + 3.3.16.0

Thanks

Edited by pixelsearch
1 edit comment added
Link to comment
Share on other sites

1 hour ago, pixelsearch said:

 

@Musashi or @ad777 : could you please try this on your computers win 7 32bit ?
* download AutoIt zip file 3.3.16.0 (the one without installer +++), it's name is "autoit-v3.3.16.zip" (17M)
* unpack it in any new folder you like, then enter Scite folder, click SciTE.exe and run the script (from my last post) directly from Scite 3.3.16.0 (i.e. no double click on a .au3 file or it will open in your usual AutoIt version)

This is how I tried it and It won't do any harm to your present AutoIt installation.
It could help to make sure the issue appears with a win7 32bits OS + 3.3.16.0

Thanks

snip.png

Edited by ad777

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

Link to comment
Share on other sites

@ad777 & @argumentum :
Thank you guys for the test, your results will certainly be useful to jpm & jon. If I understand well :

1) It always works when AutoIt < 3.3.16.0, no matter the OS (32/64bits)

2) If AutoIt 3.3.16.0, then :
* win XP 32 bits => issue
* Win 7  32 bits => issue
* Win 7  64 bits => ok
* Other OS's (could be same : ok for 64 bits, not ok for 32 bits)

Link to comment
Share on other sites

is this related to:
https://www.autoitscript.com/trac/autoit/ticket/3870
?

regexptitle and regexpclass should be somehow fixed in the comming Au3.3.16.1 (Hope soon).
It is quite possible that it is fixed but waitng for realease:   https://www.autoitscript.com/trac/autoit/ticket/3866

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...