Leaderboard
Popular Content
Showing content with the highest reputation on 05/23/2025 in all areas
-
How to modify extended style of control from another process
WildByDesign reacted to argumentum for a topic
- ..is like WTF !. - Language please ! - ..but the MF won't change ! - What I mean by language is, win32 vs .NET or other languages. Everyone knows what "Hola" mean but does not mean you speak Spanish, same with ciao ( Italian ). The point is that explorer is not win32. You'd benefit from looking at it from maybe C# or the like. Thank you for reading this excerpt from the upcoming novel "I can hear but don't understand". A book about one thing or another by renown book writer @argumentum coming to an amason near you, in PDF, later this year decade century1 point -
How to modify extended style of control from another process
KaFu reacted to pixelsearch for a topic
Glad you enjoyed the previous test I just tried your function on 2 different processes and it worked fine. 1) 1st process : please launch this 1st script and don't close its GUI : #include <GUIConstantsEx.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Local $hGUI = GUICreate("Try to make a GUI resizable from external process", 500, 250) ; do not change this title GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd 2) 2nd process : now launch this 2nd script, then click the button to add a $WS_SIZEBOX style to the GUI from 1st script : #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Local $sTitle = "Try to make a GUI resizable from external process" ; do not change this title Local $hGUI = GUICreate("The external process", 250, 220) Local $idButton = GUICtrlCreateButton("Add Resize style to external GUI", 25, 170, 200, 25) GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton If Not WinExists($sTitle) Then MsgBox($MB_TOPMOST, "External GUI not found, named...", Chr(34) & $sTitle & Chr(34)) Else Local $hWndExternal = WinGetHandle($sTitle) ; external GUI If @error Then Exit MsgBox($MB_TOPMOST, "Impossible WinGetHandle error", "@error = " & @error) __WinAPI_Set_Window_Style($hWndExternal, $WS_SIZEBOX, True) MsgBox($MB_TOPMOST, "Please check", "External GUI should be resizable by now") EndIf EndSwitch WEnd ;=========================================== Func __WinAPI_Set_Window_Style($hWnd, $i_Style, $b_Add, $b_exStyle = False) ; compacted code (from Kafu's original) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $iIndex = $b_exStyle ? $GWL_EXSTYLE : $GWL_STYLE ; $iIndex as named by msdn & help file Local $i_Style_Old = _WinAPI_GetWindowLong($hWnd, $iIndex) If $b_Add Then If BitAND($i_Style_Old, $i_Style) Then Return ; style already applied _WinAPI_SetWindowLong($hWnd, $iIndex, BitOR($i_Style_Old, $i_Style)) Else ; remove If Not BitAND($i_Style_Old, $i_Style) Then Return ; style not set _WinAPI_SetWindowLong($hWnd, $iIndex, BitXOR($i_Style_Old, $i_Style)) EndIf _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOZORDER)) ; +++ EndFunc ;==>__WinAPI_Set_Window_Style I also did this kind of test on an Explorer window (this time to remove its $WS_SIZEBOX style) and it worked. I'll try the test on the Explorer window on a Windows 11 OS in a couple of days and will report here if it worked or not1 point -
How to modify extended style of control from another process
pixelsearch reacted to KaFu for a topic
Good catch 🙂👍!1 point -
How to modify extended style of control from another process
KaFu reacted to pixelsearch for a topic
@WildByDesign thanks for your last detailed explanations ! I found a problem when using Kafu's function, let me explain it. First of all, I like his function because it allows to solve any of the 4 scenarios : add (or remove) a style (or extended style) inside a single function. Now let's say we would like to use his function, not only for top-level windows, but also for child windows (like gui controls) . Here is a runnable script that allows it : #include <GUIConstantsEx.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Local $hGUI = GUICreate("Example", 250, 220) Local $idRadio[4] GUICtrlCreateGroup(" Group ", 30, 10, 190, 130) For $i = 1 To 4 $idRadio[$i - 1] = GUICtrlCreateRadio("Radio " & $i, 40, 25 * $i, 150, 25) Next GUICtrlCreateGroup("", -99, -99, 1, 1) Local $idButton_OK = GUICtrlCreateButton("OK", 35, 170, 75, 25) Local $idButton_Cancel = GUICtrlCreateButton("Cancel", 140, 170, 75, 25) GUISetState(@SW_SHOW, $hGUI) Local $nMsg While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idRadio[0] To $idRadio[3] __WinAPI_Set_Window_Style(GUICtrlGetHandle($nMsg), $WS_TABSTOP, False) EndSwitch WEnd ;============================================== Func __WinAPI_Set_Window_Style($hWnd, $i_Style, $b_Add, $b_exStyle = False) If $b_exStyle = False Then Local $i_Style_Old = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) Else Local $i_Style_Old = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE) EndIf If $b_Add Then ; Style already applied If BitAND($i_Style_Old, $i_Style) Then Return Else ; Style not set If Not BitAND($i_Style_Old, $i_Style) Then Return EndIf If $b_exStyle = False Then If $b_Add Then _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitOR($i_Style_Old, $i_Style)) Else _WinAPI_SetWindowLong($hWnd, $GWL_STYLE, BitXOR($i_Style_Old, $i_Style)) EndIf Else If $b_Add Then _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitOR($i_Style_Old, $i_Style)) Else _WinAPI_SetWindowLong($hWnd, $GWL_EXSTYLE, BitXOR($i_Style_Old, $i_Style)) EndIf EndIf _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE)) ; Kafu's original line ; _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOZORDER)) EndFunc ;==>__WinAPI_Set_Window_Style Unfortunately, if you run this script and start clicking on the radio buttons, then you should see this the 1st time you click on them, i.e. the 4 buttons can be checked at same time ! If you run AutoIt Window Info after you checked a radio button, then you should not see this correct behavior : imho this issue comes from the fact that the Z-order of the 4 radio buttons became a mess, as indicated by a NirSoft utility named GuiPropView : ... Now let's focus on this line : _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE)) ; Kafu's original line For a start, If we comment out this line and run the script again, then everything goes back to normal. Now let's go check msdn, which stipulates what follows in its SetWindowPos link ; If you have changed certain window data using SetWindowLong, you must call SetWindowPos for the changes to take effect. Use the following combination for uFlags: SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED. See how they included SWP_NOZORDER in the arguments ? Which is described as "Retains the current Z order (ignores the hWndInsertAfter parameter)" Now if we add SWP_NOZORDER to Kafu's line and run the script again, then everything goes fine because the controls Z-order will not change after you click on them. You'll find a reworked _WinAPI_SetWindowPos line in the script (under Kafu's original line) so you can try it from there, after commenting out / uncommenting the line you'd like to test : _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE)) ; Kafu's original line ; _WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOZORDER)) Hope you'll find this test useful1 point -
SciTE AI assistant
ioa747 reacted to argumentum for a topic
My path is where SciTE is at because this is for SciTE. So I made a folder under that path and put it there ( $(SciteDefaultHome)\SciTE_AI_Assistant\SciTE_AI_Assistant.au3 ) But am (a) forgetful, (b) lazy and (c) have VMs running SciTE everywhere. And I'll have to add the new command everywhere !. Solution ?. A script to get it done for me !. main(0) Func main($iRemoveTheCommand = 0) Local $sPath_Scite = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1)) & 'SciTE' Local $iIsSciteThere = (FileGetSize($sPath_Scite & '\SciTE.exe') ? 1 : 0) ConsoleWrite('--- SciTE exists ? >' & ($iIsSciteThere ? "YES" : "NO") & '<' & @CRLF) Local $iIsScriptThere = (FileGetSize($sPath_Scite & '\SciTE_AI_Assistant\SciTE_AI_Assistant.au3') ? 1 : 0) ConsoleWrite('--- AI_Assistant script exists ? >' & ($iIsScriptThere ? "YES" : "NO") & '<' & @CRLF) If Not $iIsScriptThere Then ConsoleWriteEm('+++ Nothing to do, script is not at "' & $sPath_Scite & '\SciTE_AI_Assistant\SciTE_AI_Assistant.au3' & @CRLF) Return EndIf If Not StringInStr($CmdLineRaw, "/ErrorStdOut ") Then Local $iRet = MsgBox(262144 + 32 + 3 + 512, @ScriptName, "" & _ "Click Yes to add it" & @LF & _ "No to remove it" & @LF & _ ; in case you jusy click-click the script "Cancel to cancel it" & @LF & _ ; outside SciTE "..you have 60 seconds to decide. Tic-toc =P", 60) Switch $iRet Case 6 ; $IDYES (6) $iRemoveTheCommand = 0 Case 7 ; $IDNO (7) $iRemoveTheCommand = 1 Case Else Return EndSwitch EndIf Local $sPropertiesFilename = $sPath_Scite & "\Properties\au3.properties" Local $aProperties = FileReadToArray($sPropertiesFilename) If @error Then ConsoleWriteEm('!!! Error reading the file, bye.' & @CRLF) Return EndIf If $iRemoveTheCommand Then $sNewPropertiesFile = sciteAiAssistant_CommandSnippet_Remove($aProperties) If @error Then ConsoleWriteEm('!!! Nothing to do, the entry was not found !' & @CRLF) Return EndIf Local $hFileOpen = FileOpen($sPropertiesFilename, 2) ; $FO_OVERWRITE (2) = Write mode (erase previous contents) If $hFileOpen = -1 Then ConsoleWriteEm('!!! FAILED to open file for re-write !' & @CRLF) Return EndIf FileWrite($hFileOpen, $sNewPropertiesFile) FileClose($hFileOpen) ConsoleWriteEm('+++ Done. All good.' & @CRLF) Return EndIf Local $iLastCommand = findLastCommand($aProperties) Local $iError = @error Local $iExtended = @extended ConsoleWrite('--- LastEntryNumber , $nArrayIndex , existed >' & $iLastCommand & ' , ' & $iExtended & ' , ' & $iError & '<' & @CRLF) If $iError Then ConsoleWriteEm('+++ Nothing to do, entry already there' & @CRLF) Return EndIf $aProperties[$iExtended] &= @CRLF & sciteAiAssistant_CommandSnippet($iLastCommand + 1) If @error Then ; not gonna happen but the AI feels better with this here =D ConsoleWriteEm('+++ something went wrong, bye.' & @CRLF) Return EndIf Local $sNewPropertiesFile = "" For $n = 0 To UBound($aProperties) - 1 $sNewPropertiesFile &= $aProperties[$n] & @CRLF Next ;~ Exit ConsoleWrite($sNewPropertiesFile) Local $hFileOpen = FileOpen($sPropertiesFilename, 2) ; $FO_OVERWRITE (2) = Write mode (erase previous contents) If $hFileOpen = -1 Then ConsoleWriteEm('!!! FAILED to open file for re-write !' & @CRLF) Return EndIf FileWrite($hFileOpen, $sNewPropertiesFile) FileClose($hFileOpen) ConsoleWriteEm('+++ Done. All good.' & @CRLF) EndFunc ;==>main Func sciteAiAssistant_CommandSnippet_Remove($aProperties) Local $iError = 0, $iSkip = 0, $sRet = "" For $n = 0 To UBound($aProperties) - 1 If $iSkip = 0 And _ StringInStr($aProperties[$n], "SciTE_AI_Assistant") And _ StringInStr($aProperties[$n], "-8<-") Then ; start $iSkip = 1 $iError += 1 ContinueLoop EndIf If $iSkip = 1 And _ StringInStr($aProperties[$n], "SciTE_AI_Assistant") And _ StringInStr($aProperties[$n], "->8-") Then ; end $iSkip = 0 $iError += 1 ContinueLoop EndIf If Not $iSkip Then $sRet &= $aProperties[$n] & @CRLF Next ;~ ConsoleWrite(@CRLF & '$iError = ' & $iError & @CRLF & $sRet & @CRLF) Return SetError(($iError = 2 ? 0 : 1), 0, $sRet) EndFunc ;==>sciteAiAssistant_CommandSnippet_Remove Func findLastCommand($aProperties) Local $aTemp, $iError = 0, $iRet = -1, $iExtended = -1 For $n = 0 To UBound($aProperties) - 1 If StringInStr($aProperties[$n], "\SciTE_AI_Assistant.au3") Then $iError += 1 If Not StringInStr($aProperties[$n], "command.") = 1 Then ContinueLoop If Not StringInStr($aProperties[$n], "=") Then ContinueLoop $aTemp = StringSplit($aProperties[$n], ".$(au3)=", 1) $aTemp = StringSplit($aTemp[1], ".", 0) For $m = $aTemp[0] To 1 Step -1 If $aTemp[$m] = Int($aTemp[$m]) And $aTemp[$m] > 0 And $iRet <= $aTemp[$m] Then $iRet = Int($aTemp[$m]) $iExtended = $n ExitLoop EndIf Next Next Return SetError($iError, $iExtended, $iRet) EndFunc ;==>findLastCommand ; ( all the comments in this function aids the AI to make sense of how it work ) Func sciteAiAssistant_CommandSnippet($iCommandIndexNumber, $sFileIsAt = "$(SciteDefaultHome)\SciTE_AI_Assistant\SciTE_AI_Assistant.au3") If Int($iCommandIndexNumber) < 5 Then Return SetError(1, 0, "") Local $sRet = "" ; string to be crated andf formated to be added to a SciTE properties file $sRet &= "# ---------- SciTE_AI_Assistant ----8<---------" & @CRLF $sRet &= "# " & $iCommandIndexNumber & " SciTE_AI_Assistant" & @CRLF ; comment line entry $sRet &= "command." & $iCommandIndexNumber & ".$(au3)=""$(SciteDefaultHome)\..\AutoIt3.exe"" """ & $sFileIsAt & """" & @CRLF $sRet &= "command.subsystem." & $iCommandIndexNumber & ".$(au3)=0" & @CRLF $sRet &= "command.name." & $iCommandIndexNumber & ".$(au3)=SciTE AI Assistant" & @CRLF ; $sFileIsAt = a full filename. Can have a SciTE constant in it. $sRet &= "command.shortcut." & $iCommandIndexNumber & ".*.au3=F10" & @CRLF ; $iCommandIndexNumber = next unused integer value to use in SciTE's menu system $sRet &= "command.save.before." & $iCommandIndexNumber & ".$(au3)=2" & @CRLF $sRet &= "# command.replace.selection." & $iCommandIndexNumber & ".$(au3)=1" & @CRLF $sRet &= "command.quiet." & $iCommandIndexNumber & ".$(au3)=0" & @CRLF $sRet &= "command.input." & $iCommandIndexNumber & ".$(au3)=$(CurrentSelection)" & @CRLF $sRet &= "# ----------->8--- SciTE_AI_Assistant ---------" Return SetError(0, 0, $sRet) ; https://www.scintilla.org/SciTEDoc.html EndFunc ;==>sciteAiAssistant_CommandSnippet Func ConsoleWriteEm($sStr) If StringInStr($CmdLineRaw, "/ErrorStdOut ") Then ConsoleWrite($sStr) Else MsgBox(262144, @ScriptName, StringTrimRight($sStr, 2), 60) EndIf EndFunc ;==>ConsoleWriteEm ..close SciTE, open SciTE. and enjoy {F10} Edit: Changed the entry a bit to be able to add or remove the entry more easily.1 point -
$cv.Mat.create($image, _OpenCV_Rect($left, $top, $width, $height)).copy()1 point