Jump to content

mLipok

MVPs
  • Posts

    11,790
  • Joined

  • Last visited

  • Days Won

    66

mLipok last won the day on March 29

mLipok had the most liked content!

About mLipok

  • Birthday 07/19/1978

Profile Information

  • Member Title
    Sometimes... even usually I'm nitpicky.
  • Location
    Europe, Poland, Upper Silesia, Zabrze
  • Interests
    ¯\_(ツ)_/¯

Recent Profile Visitors

29,954 profile views

mLipok's Achievements

  1. btw. It is little funny (as I did many COM stuff in AutoIt) but .... I'm not familiar with ObjCreateInterface() and for this reason at first I also asked ChatGPT for example: #include <MsgBoxConstants.au3> ; === COM interface GUIDs (global constants) === Global Const $CLSID_SpellCheckerFactory = "{7AB36653-1796-484B-BDFA-E74F1DB7C1DC}" Global Const $IID_ISpellCheckerFactory = "{8E018A9D-2415-4677-BF08-794EA61F94BB}" Global Const $IID_ISpellChecker = "{B6FD0B71-E2BC-4653-8D05-F197E0D3B83B}" ; === Interface definitions (global tags) === Global Const $TAG_ISpellCheckerFactory = _ "CreateSpellChecker hresult(wstr;ptr*);" & _ ; Create spell checker for language "get_SupportedLanguages hresult(ptr*);" ; Get supported languages Global Const $TAG_ISpellChecker = _ "Check hresult(wstr;ptr*);" & _ ; Check text for spelling errors "Suggest hresult(wstr;ptr*);" ; Get suggestions ; === Example entry point === _EXAMPLE() Func _EXAMPLE() ; Create SpellCheckerFactory COM object Local $oFactory = ObjCreateInterface( _ $CLSID_SpellCheckerFactory, _ $IID_ISpellCheckerFactory, _ $TAG_ISpellCheckerFactory) If @error Then MsgBox($MB_ICONERROR, "Error", "Failed to create SpellCheckerFactory") Return EndIf ; Create spell checker for Polish language Local $pSpellChecker = 0 $oFactory.CreateSpellChecker("pl-PL", $pSpellChecker) If $pSpellChecker = 0 Then MsgBox($MB_ICONERROR, "Error", "Failed to create SpellChecker for pl-PL") Return EndIf ; Bind ISpellChecker interface Local $oSpell = ObjCreateInterface($pSpellChecker, $IID_ISpellChecker, $TAG_ISpellChecker) If @error Then MsgBox($MB_ICONERROR, "Error", "Failed to bind ISpellChecker interface") Return EndIf ; Word to test Local $sWord = "ksionszka" ; Perform spell check Local $pErrors = 0 $oSpell.Check($sWord, $pErrors) ; NOTE: This is simplified logic! ; Proper implementation should enumerate IEnumSpellingError If $pErrors = 0 Then MsgBox($MB_ICONINFORMATION, "Result", "Word is correct: " & $sWord) Else MsgBox($MB_ICONWARNING, "Result", "Word is INCORRECT: " & $sWord) EndIf EndFunc ;==>_EXAMPLE of course not works well.
  2. I saw here on the forum few different ways of checking spell: Spell Checker (by iCode) OpenOffice/LibreOffice Spell Checker (by GMK) v0.1.1 Scite4AutoIt SpellChecker using LibreOffice even few topics about spell checking with Word. Custom Spell Checker But I start wondering how Notepad in Windows 11 finds out that some words are written incorrectly. Then I ask ChatGPT about and he point me to Spell Checking API. https://learn.microsoft.com/en-us/windows/win32/intl/about-the-spell-checker-api So here is my question: Has anyone worked in AutoIt with MS Windows Spell Checking API ? EDIT: https://github.com/microsoft/Windows-classic-samples/blob/main/Samples/SpellCheckerClient/cpp/SampleSpellingClient.cpp
  3. I know old thread. Just needed to us this snippet so wanted to share my refactored version: ;~ https://www.autoitscript.com/forum/topic/150225-validate-if-user-entering-the-right-email-address-format/#findComment-1072558 #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <WindowsConstants.au3> mainlobby() Func mainlobby() GUICreate('', 320, 200, 500, 250) Local $recipientsenter = GUICtrlCreateInput("", 10, 5, 250, 20) Local $sendemilbutton = GUICtrlCreateButton("Send Email", 230, 128, 70, 25, 1) GUISetState() Local $msg Do $msg = GUIGetMsg() Select Case $msg = $sendemilbutton Local $sEMail = GUICtrlRead($recipientsenter) If $sEMail = "" Then MsgBox(16, "Email Not Input", "Cannot Find Any Email") Else MsgBox($MB_TOPMOST, "TEST #" & @ScriptLineNumber, "IsValidEmailAdress = " & _IsValidEmailAdress($sEMail)) EndIf EndSelect Until $msg = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>mainlobby Func _IsValidEmailAdress($sEMail) Local $aEmail = StringSplit($sEMail, ';') Local $localpart = "[[:alnum:]!#$%&'*+-/=?^_`{|}~.]+" Local $domainname = "[[:alnum:].-]+\.[[:alnum:]]+" Local $i_CountValid = 0 For $IDX = 1 To $aEmail[0] If StringRegExp($aEmail[$IDX], '(?i)^(' & $localpart & ')@(' & $domainname & ')$', $STR_REGEXPMATCH) Then $i_CountValid += 1 EndIf Next Return ($i_CountValid = $aEmail[0]) EndFunc ;==>_IsValidEmailAdress
  4. modified example: ;~ https://www.autoitscript.com/forum/topic/153782-help-filedocumentation-issues-discussion-only/page/43/#findComment-1551537 #include <MsgBoxConstants.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Example() Func Example() Local $hGUI, $hMdiChild $hGUI = GUICreate("") WinSetTitle($hGUI, "", "GUI " & $hGUI) GUICtrlCreateLabel("Label in GUI", 200, 0, 90, 20) GUICtrlSetBkColor(-1, 0xFFFF00) $hMdiChild = GUICreate("", 300, 200, 0, 0, -1, BitOR($WS_EX_WINDOWEDGE, $WS_EX_MDICHILD), $hGUI) WinSetTitle($hMdiChild, "", "MdiChild " & $hMdiChild) GUICtrlCreateLabel("Label in MdiChild", 200, 0, 90, 20) GUICtrlSetBkColor(-1, 0x00FFFF) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hMdiChild) ConsoleWrite("====" & @CRLF) ConsoleWrite( _ "> Parent/Ancestors of MdiChild window " & $hMdiChild & @CRLF & _ "Reminder : $hGUI = " & $hGUI & @CRLF & _ "Reminder : $hMdiChild = " & $hMdiChild & @CRLF & @CRLF & _ "_WinAPI_GetParent = " & _WinAPI_GetParent($hMdiChild) & " (owner, not parent +++)" & @CRLF & @CRLF & _ "_WinAPI_GetAncestor (Parent) = " & _WinAPI_GetAncestor($hMdiChild, $GA_PARENT) & " (desktop)" & @CRLF & _ "_WinAPI_GetAncestor (Root) = " & _WinAPI_GetAncestor($hMdiChild, $GA_ROOT) & " (itself / $hMdiChild)" & @CRLF & _ "_WinAPI_GetAncestor (Owner) = " & _WinAPI_GetAncestor($hMdiChild, $GA_ROOTOWNER) & " (gui / $hGUI)" & @CRLF & _ "") ConsoleWrite("====" & @CRLF) ConsoleWrite("- TEST 1 - ExStyles of $hMdiChild : 0x" & Hex(_WinAPI_GetWindowLong($hMdiChild, $GWL_EXSTYLE), 8) & @CRLF) _WinAPI_SetWindowLong($hMdiChild, $GWL_EXSTYLE, $WS_EX_MDICHILD) ConsoleWrite("- TEST 2 - ExStyles of $hMdiChild : 0x" & Hex(_WinAPI_GetWindowLong($hMdiChild, $GWL_EXSTYLE), 8) & @CRLF) ConsoleWrite("====" & @CRLF) Do Until GUIGetMsg() = -3 GUIDelete($hMdiChild) GUIDelete($hGUI) EndFunc ;==>Example results:
  5. First What I did is to change: $hMdiChild = GUICreate("", 300, 200, 0, 0, -1, $WS_EX_MDICHILD, $hGUI) to $hMdiChild = GUICreate("", 300, 200, 0, 0, -1, BitOR($WS_EX_WINDOWEDGE, $WS_EX_MDICHILD), $hGUI) but it still won't work and I have the same result as you have:
  6. my modified example: #include <MsgBoxConstants.au3> #include <WinAPISysWin.au3> #include <WindowsStylesConstants.au3> Example() Func Example() Local $hWnd_0 = GUICreate("Window 0") ConsoleWrite("$hWnd_0 = " & $hWnd_0 & @CRLF) Local $hWnd_1 = GUICreate("Window 1", Default, Default, -1, -1, -1, $WS_EX_MDICHILD, $hWnd_0) ConsoleWrite("$hWnd_1 = " & $hWnd_1 & @CRLF) Local $hWnd_2 = GUICreate("Window 2", Default, Default, -1, -1, -1, -1, $hWnd_0) ConsoleWrite("$hWnd_2 = " & $hWnd_2 & @CRLF) ConsoleWrite(@CRLF) Local $id_Label_1 = GUICtrlCreateLabel("Label 1", 0, 0) Local $h_Label_1 = GUICtrlGetHandle($id_Label_1) ConsoleWrite("$h_Label_1 = " & $h_Label_1 & @CRLF) Local $id_Label_2 = GUICtrlCreateLabel("Label_2", 0, 0) Local $h_Label_2 = GUICtrlGetHandle($id_Label_2) ConsoleWrite("$h_Label_2 = " & $h_Label_2 & @CRLF) ConsoleWrite(@CRLF) ConsoleWrite("- " & "TEST 1: Parent :: Get Parent Ancestor of " & $h_Label_2 & " > " & _WinAPI_GetAncestor($h_Label_2, $GA_PARENT) & ' TITLE=' & WinGetTitle(_WinAPI_GetAncestor($h_Label_2, $GA_PARENT)) & @CRLF) ConsoleWrite("- " & "TEST 2: Root :: Get Root Ancestor of " & $h_Label_2 & " > " & _WinAPI_GetAncestor($h_Label_2, $GA_ROOT) & ' TITLE=' & WinGetTitle(_WinAPI_GetAncestor($h_Label_2, $GA_ROOT)) & @CRLF) ConsoleWrite("- " & "TEST 3: Root Owner :: Get Root Owner Ancestor of " & $h_Label_2 & " > " & _WinAPI_GetAncestor($h_Label_2, $GA_ROOTOWNER) & ' TITLE=' & WinGetTitle(_WinAPI_GetAncestor($h_Label_2, $GA_ROOTOWNER)) & @CRLF) EndFunc ;==>Example and the question: Could somebody show example when Test 1 result is different from Test 2 ? my results:
  7. Please take a look here: https://www.autoitscript.com/autoit3/files/beta/autoit/docs/functions/AutoItSetOption.htm IMHO this bolded text should be moved/attached/described here: https://www.autoitscript.com/autoit3/docs/functions/GUISetCoord.htm And I would like to propose also changes like this What is your opinion in this regard ? Examples:
  8. small modification (Au3Check was fired): #include <File.au3> #include <WinAPIReg.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> Global Const $CLSCTX_INPROC_SERVER = 1 Global Const $CLSCTX_LOCAL_SERVER = 4 Global Const $CLSCTX_SERVER = BitOR($CLSCTX_INPROC_SERVER, $CLSCTX_LOCAL_SERVER) Global Const $sIID_IPreviewHandler = "{8895b1c6-b41f-4c1c-a562-0d564250836f}" Global Const $sTagIPreviewHandler = "SetWindow hresult(hwnd;ptr); SetRect hresult(hwnd); DoPreview hresult(); Unload hresult(); SetFocus hresult(); QueryFocus hresult(hwnd*);TranslateAccelerator hresult(ptr*);" Global Const $sIID_IInitializeWithStream = "{B824B49D-22AC-4161-AC8A-9916E8FA3F7F}" Global Const $sIID_IInitializeWithFile = "{B7D14566-0509-4CCE-A71F-0A554233BD9B}" Global Const $sTagIInitializeWithFiler = "Initialize hresult(wstr;uint);" Global Const $sTagIInitializeWithStream = "Initialize hresult(ptr;uint);" _Test() Func _Test() _WinAPI_CoInitialize() Local $sFilePath = @ScriptDir & "\Tests.odt" ;chage me for another file If Not FileExists($sFilePath) Then $sFilePath = FileOpenDialog("Select a file to be loaded", @ScriptDir, "Any File Type (*.*)", $FD_FILEMUSTEXIST) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") FileChangeDir(@ScriptDir) Exit Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) $sFilePath = StringReplace($sFilePath, "|", @CRLF) EndIf EndIf Local $sExtension = _GetFilePathExtension($sFilePath) ConsoleWrite("$sExtension: " & $sExtension & @CRLF) Local $ExtensionCLSID = _GetShellExtensionCLSIDForFileType($sExtension) ConsoleWrite("$ExtensionClsid: " & $ExtensionCLSID & @CRLF) Local $tIIDExtensionCLSID = _WinAPI_GUIDFromString($ExtensionCLSID) Local $tIIDIPreviewHandler = _WinAPI_GUIDFromString($sIID_IPreviewHandler) Local $aRet = DllCall("ole32.dll", "long", "CoCreateInstance", "ptr", DllStructGetPtr($tIIDExtensionCLSID), "ptr", 0, "dword", $CLSCTX_SERVER, "ptr", DllStructGetPtr($tIIDIPreviewHandler), "ptr*", 0) Local $pIPreviewHandler = $aRet[5] ConsoleWrite("$pIPreviewHandler: " & $pIPreviewHandler & @CRLF) Local $oPreviewHandler = ObjCreateInterface($pIPreviewHandler, $sIID_IPreviewHandler, $sTagIPreviewHandler) ConsoleWrite("$oPreviewHandler: " & IsObj($oPreviewHandler) & @CRLF) Local $pIInitializeWithStream = 0 Local $pIInitializeWithFile = 0 $oPreviewHandler.QueryInterface($sIID_IInitializeWithStream, $pIInitializeWithStream) $oPreviewHandler.QueryInterface($sIID_IInitializeWithFile, $pIInitializeWithFile) ConsoleWrite("$pIInitializeWithStream: " & $pIInitializeWithStream & @CRLF) ConsoleWrite("$pIInitializeWithFile: " & $pIInitializeWithFile & @CRLF) If $pIInitializeWithStream Then Local $pIStream = 0 $aRet = DllCall("shlwapi.dll", "long", "SHCreateStreamOnFileEx", _ "wstr", $sFilePath, _ "dword", BitOR(0x00000000, 0x00000020), _ "dword", 0, _ "boolean", False, _ "ptr", 0, _ "ptr*", 0) $pIStream = $aRet[6] ConsoleWrite("$pIStream: " & $pIStream & @CRLF) Local $oIInitializeWithStream = ObjCreateInterface($pIInitializeWithStream, $sIID_IInitializeWithStream, $sTagIInitializeWithStream) $oIInitializeWithStream.Initialize($pIStream, 0) ElseIf $pIInitializeWithFile Then Local $oIInitializeWithFile = ObjCreateInterface($pIInitializeWithFile, $sIID_IInitializeWithFile, $sTagIInitializeWithFiler) ConsoleWrite("$oIInitializeWithFile: " & IsObj($oIInitializeWithFile) & @CRLF) ConsoleWrite("$oIInitializeWithFile.Initialize: " & $oIInitializeWithFile.Initialize($sFilePath, 0x00000000) & @CRLF) ;$STGM_READ = $STGM_READ Else ConsoleWrite("-Error Interface" & @CRLF) EndIf Local $hGUI = GUICreate("IPreviewHandler", 400, 400) Local $idPic = GUICtrlCreatePic("", 10, 10, 380, 380) Local $hWnd, $tRECT $hWnd = GUICtrlGetHandle($idPic) $tRECT = _WinAPI_GetClientRect($hWnd) ConsoleWrite("oPreviewHandler.etWindow: " & $oPreviewHandler.SetWindow($hWnd, DllStructGetPtr($tRECT)) & @CRLF) ConsoleWrite("oPreviewHandler.etWindow: " & $oPreviewHandler.DoPreview() & @CRLF) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>_Test Func _GetFilePathExtension($sFilePath) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension) Return $sExtension EndFunc ;==>_GetFilePathExtension Func _GetShellExtensionCLSIDForFileType($sExtension) Local $sAssoc = _WinAPI_AssocQueryString($sExtension, $ASSOCSTR_SHELLEXTENSION, $ASSOCF_INIT_DEFAULTTOSTAR, $sIID_IPreviewHandler) Return $sAssoc EndFunc ;==>_GetShellExtensionCLSIDForFileType
  9. I'm not familiar with low level WinAPI so as so far ChatGPT results: #include <WinAPI.au3> #include <GUIConstantsEx.au3> ; GUID helper Func CLSIDFromString($sGUID) Local $tGUID = DllStructCreate("byte[16]") DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sGUID, "ptr", DllStructGetPtr($tGUID)) Return $tGUID EndFunc ;==>CLSIDFromString ; --- INIT COM --- DllCall("ole32.dll", "long", "CoInitialize", "ptr", 0) Local $file = FileOpenDialog("PDF", @ScriptDir, "PDF (*.pdf)") If @error Then Exit ; --- pobierz CLSID preview handlera dla .pdf --- Local $reg = RegRead("HKEY_CLASSES_ROOT\.pdf\shellex\{8895b1c6-b41f-4c1c-a562-0d564250836f}", "") If @error Then MsgBox(16, "Error", "Brak preview handlera") Exit EndIf Local $tCLSID = CLSIDFromString($reg) Local $tIID_IPreviewHandler = CLSIDFromString("{8895b1c6-b41f-4c1c-a562-0d564250836f}") ; CoCreateInstance Local $aCall = DllCall("ole32.dll", "long", "CoCreateInstance", _ "ptr", DllStructGetPtr($tCLSID), _ "ptr", 0, _ "dword", 1, _ ; CLSCTX_INPROC_SERVER "ptr", DllStructGetPtr($tIID_IPreviewHandler), _ "ptr*", 0) If $aCall[0] <> 0 Then MsgBox(16, "Error", "CoCreateInstance failed") Exit EndIf Local $pPreview = $aCall[5] ; --- GUI --- $hGUI = GUICreate("IPreviewHandler", 800, 600) GUISetState() ; RECT Local $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom") DllStructSetData($tRect, "Left", 0) DllStructSetData($tRect, "Top", 0) DllStructSetData($tRect, "Right", 800) DllStructSetData($tRect, "Bottom", 600) ; --- VTABLE --- Local $pVTable = DllStructGetData(DllStructCreate("ptr", $pPreview), 1) Func VTableCall($pObj, $index, $retType, $argTypes, $args) Local $pVT = DllStructGetData(DllStructCreate("ptr", $pObj), 1) Local $pFunc = DllStructGetData(DllStructCreate("ptr", $pVT + ($index * @AutoItX64 * 8)), 1) Return DllCallAddress($retType, $pFunc, "ptr", $pObj, $argTypes, $args) EndFunc ;==>VTableCall ; indeksy metod (IPreviewHandler) ; 3 = SetWindow ; 4 = SetRect ; 5 = DoPreview ; SetWindow(hwnd, rect) DllCallAddress("long", _ DllStructGetData(DllStructCreate("ptr", $pVTable + (3 * 8)), 1), _ "ptr", $pPreview, _ "hwnd", $hGUI, _ "ptr", DllStructGetPtr($tRect)) ; SetRect(rect) DllCallAddress("long", _ DllStructGetData(DllStructCreate("ptr", $pVTable + (4 * 8)), 1), _ "ptr", $pPreview, _ "ptr", DllStructGetPtr($tRect)) ; InitializeWithFile (inna interfejs!) ; GUID: IInitializeWithFile Local $tIID_Init = CLSIDFromString("{b7d14566-0509-4cce-a71f-0a554233bd9b}") Local $aQI = DllCall("ole32.dll", "long", "CoCreateInstance", _ "ptr", DllStructGetPtr($tCLSID), _ "ptr", 0, _ "dword", 1, _ "ptr", DllStructGetPtr($tIID_Init), _ "ptr*", 0) Local $pInit = $aQI[5] ; InitializeWithFile(file) Local $pVT2 = DllStructGetData(DllStructCreate("ptr", $pInit), 1) DllCallAddress("long", _ DllStructGetData(DllStructCreate("ptr", $pVT2 + (3 * 8)), 1), _ "ptr", $pInit, _ "wstr", $file, _ "dword", 0) ; DoPreview() DllCallAddress("long", _ DllStructGetData(DllStructCreate("ptr", $pVTable + (5 * 8)), 1), _ "ptr", $pPreview) ; loop While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd ; cleanup DllCall("ole32.dll", "none", "CoUninitialize") of course not working
  10. Maybe with this: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-ipreviewhandler
  11. If you have LibreOffice installed, you can preview LibreOffice documents in Windows Explorer. I wonder if it's possible to embed the document preview itself into the AutoIt window? Will the PDF preview work the same way out of the box? I know about: and: Before I focus on these threads, I'd first like to ask your opinion on whether this is possible? Or has anyone already tried it?
  12. Thank you all for your commitment to solving this problem.
×
×
  • Create New...