Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 03/13/2024 in Posts

  1. We have changed the login to require your Email address and disabled the option to use your member name to make the hacking of accounts harder, as that was happening regularly lately. We can assist in case you don't remember the Email address used at signup. Just use the "Contact us" link at the bottom of the page.
    11 points
  2. All, I see that there are multiple efforts to create/maintain an AutoIt3 Visual Studio Code extension, and I would like to open a discussion to see how that can be streamlined/merged/done more effectively so we can come up with the one that's preferred. I have been toying with the idea to stop the development of all the LUA extra's used by SciTE and start using VSCode for the more advanced way of developing AutoIt3 scripts, as many things a way after when the extension supports it, like running au3check on save so you just click the problems tab to see the warnings/errors of the currently opened scripts. So I have been working on making the utilities packaged with SciTE4AutoIt3 suitable to run stand-alone without the need for wrapping them with AutoIt3Wrapper, with the plan to be able to make them all more generic usable for any editor. They need to support UTF8 & ANSI encoded files, even when through includes the encoding is mixed. I have modified AutoIt3Wrapper to stop renaming and changing encoding of script/include files, and updated Tidy/Au3check/Au3stripper to support special characters in filenames and mixed ANSI/UTF8 file encoding and the generated console output is UTF8. I have been toying a bit with the VSCODE extension maintained by Damian (just picked one without looking at any others) and made some modifications locally for testing. Run au3check (Ctrl+F5), Tidy (Ctrl+t), Au3Stripper (Ctrl+Shift+o) without using AutoIt3Wrapper. Other already standardly available option (Run/Compile) still run via AutoIt3Wrapper as there is an added value doing it that way. I really like what I see and think this is a good way forward. So... I like to hear how you all think about this and possibly your preferred VSCode autoIt3 extension with reasons why. Also feels as a waste of effort when so many are making their own version of an extension instead of bundling the effort making one really nice one with all required features. Thoughts/Opinions?
    10 points
  3. Hi everybody With the help of this thread, @AspirinJunkie @Nine and @Musashi , I was able to add a GUI to Google translation with AutoIt. Please note the 3 colors possible (green / yellow / red) found in these 3 pics, we'll discuss them later (need some sleep now) The maximum number of characters allowed for the original text is 65535, but imho it's too much. If you experience some slowness with 65535, then you can modify this variable at the very beginning of the script and indicate a lower value : Local $iMaxInputLength = 65535 There are different ways to import the text to translate : * Paste it directly from the clipboard (Ctrl+V) inside the upper edit control * Click the "Paste ClipBoard" button in the GUI * Drag a text file inside the upper edit control * Click the "Open File" button in the GUI (only .txt files for the moment) Then choose in each combo box the language you want ("Detect language" is useful for the Original) and click Translate. After the translation is done, if you want to copy the translated text, then a click on the "Copy Translated" button is possible. During the translation process, you have the possibility to press the "Escape" key if you want to stop the translation. ; Version 11 (June 30, 2024) ; This script requires AutoIt 3.3.16.1 (which includes Maps, as Json.au3 requires Maps for some translations) ; It also requires the file "Google Translate (languages list #3).txt" to be placed in same folder as the script ; To translate pdf files, it requests "pdftotext.exe" (a free command line tool from Xpdf downloadable at https://www.xpdfreader.com) #include "Json.au3" ; by @AspirinJunkie, download from https://github.com/Sylvan86/autoit-json-udf #include <Array.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <FileConstants.au3> #include <GUIConstantsEx.au3> #include <GUIEdit.au3> #Include <GUIMenu.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <StringConstants.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Opt("GUICloseOnESC", 0) ;1=ESC closes (default), 0=ESC won't close Global $iMaxInputLength = 65535 ; In theory, 65535 is the maximum length of the original encoded string, when it is only composed of ; letters, digits, etc... which have an ascii code < 128 and coded on 1 byte only. ; But in practice, this variable should probably be lower (5000 as Google Translate site ?) or 10000, 15000 ... ; to avoid the warning message that will appear when the original encoded string becomes > 65535 bytes length. ; Also _JSON_Parse() may take some time on slow computers with "big" original encoded strings, we'll see... ; Global $iMaxInputLength = 5460 ; this value allows any encoded string to be < 65536 length, even if each character is a Unicode character ; requiring 4 bytes. In this case, each character will be coded on 12 bytes in the string "%..%..%..%.." ; 5460 * 12 = 65520 bytes (which is < 65536) ; user can choose amongst 39 GUI languages (this has nothing to do with 133 translatable languages) Global $aLangGui = _FillArrayLangGui("Google Translate (languages list #3).txt") Global $sIniFile = StringTrimRight(@ScriptFullPath, 4) & ".ini" ; ".au3" | ".a3x" | ".exe" => ".ini" Global $aLang, $aLink, $sLang = "", $iLangGui = -1, $bRTL Global $aIni = _ReadIniFile($sIniFile, $aLang, $aLink, $sLang) ; _ArrayDisplay($aLang, Ubound($aLang) & " codes & languages", Default, $ARRAYDISPLAY_NOROW, Default, "Code|Language|In Combo ?") #Region ### START Koda GUI section ### Form=C:\Temp\koda_1.7.3.0\Forms\google translate #4.kxf Global $sGUI_Title, $hGUI, $idPasteClip, $idOpenFile, $idLabelFrom, $idLangFrom, $idFontSizeFrom, $idWordWrapFrom, $idLanguageFilter Global $idLabelTo, $idLangTo, $idFontSizeTo, $idWordWrapTo, $idTranslate, $idCopyTrans, $idTextFrom, $idTextTo, $idCharStatus Global $idMsg, $sFileName, $sFileExt, $sEmpty = "" ; variable $sEmpty created only because ByRef doesn't accept literals _CreateGui() GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $idMsg = GUIGetMsg() Switch $idMsg Case $GUI_EVENT_CLOSE _WriteIniFile($sIniFile, $aLink) ExitLoop Case $idPasteClip ; in edit control containing the original text _UpdateGUI(StringLeft(ClipGet(), $iMaxInputLength)) Case $idOpenFile, $GUI_EVENT_DROPPED ; in edit control containing the original text $sFileName = ($idMsg = $idOpenFile) ? _OpenFile() : @GUI_DragFile If $sFileName Then $sFileExt = StringMid($sFileName, 1 + StringInStr($sFileName, ".", 0, -1)) ; -1 to start search from the right If StringLen($sFileExt) = StringLen($sFileName) Then $sFileExt = "no dot found" ; no "." found in $sFileName If StringInStr(FileGetAttrib($sFileName), "D") Then $sFileExt = "this is a folder" Select Case $sFileExt = "txt" ; no problem with txt extension Case $sFileExt = "pdf" ; extract pdf content to txt file using pdftotext.exe $sFileName = _PdfToText($sFileName) ; $sFileName (xxx.pdf) => $sFileName (TextExtractedFromPDF.txt) if success. If Not $sFileName Then ContinueLoop ; ... if extraction of txt fails, then $sFileName becomes "" (0 in fact) Case Else MsgBox($MB_TOPMOST, "File extension error ", _ "File extension '" & $sFileExt & "' can't be processed" & @crlf & _ "Only .txt or .pdf file can be processed", 0, $hGUI) _UpdateGUI($sEmpty) ContinueLoop EndSelect _UpdateGUI(StringLeft(FileRead($sFileName), $iMaxInputLength)) EndIf Case $idFontSizeFrom GUICtrlSetFont($idTextFrom, Int(GUICtrlRead($idFontSizeFrom))) GUICtrlSetState($idTextFrom, $GUI_FOCUS) ; keep showing an eventual selection Case $idWordWrapFrom $idTextFrom = _EditRecreate_From(Int(GUICtrlRead($idFontSizeFrom)), GUICtrlRead($idWordWrapFrom)) ; Font size, WordWrap GUICtrlSetState($idTextFrom, $GUI_FOCUS) Case $idFontSizeTo GUICtrlSetFont($idTextTo, Int(GUICtrlRead($idFontSizeTo))) GUICtrlSetState($idTextTo, $GUI_FOCUS) Case $idWordWrapTo $idTextTo = _EditRecreate_To(Int(GUICtrlRead($idFontSizeTo)), GUICtrlRead($idWordWrapTo)) ; Font size, WordWrap GUICtrlSetState($idTextTo, $GUI_FOCUS) Case $idTranslate GUICtrlSetState($idTranslate, $GUI_DISABLE) ; prevent accidental double click on the button GUICtrlSetData($idTextTo, "") WinSetTitle($hGUI, "", _GuiTitle()) HotKeySet("{ESC}", "_Wanna_Quit") ; in case user keys Esc during the translation process _Translate() HotKeySet("{ESC}") GUICtrlSetState($idTranslate, $GUI_ENABLE) Case $idCopyTrans ClipPut(GUICtrlRead($idTextTo)) MsgBox($MB_TOPMOST, "Copy", "Done", 1, $hGUI) ; timeout 1s Case $idLanguageFilter GUIRegisterMsg($WM_COMMAND, "") GUISetState(@SW_DISABLE, $hGUI) _LanguageFilter($aLang, $aLink, $sLang) ; in a new temporary GUI ($hGUI2) GUISetState(@SW_RESTORE, $hGUI) ; only flag that seems to do the job correctly, even on a non-minimized window !? GUISetState(@SW_ENABLE, $hGUI) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Case $idLabelFrom ; clickable label to decrease both combobox font size (some GUI languages appear much smaller than others) If $aIni[8] - 1 < 8.3 Then ContinueLoop $aIni[8] -= 1 GUICtrlSetFont($idLangFrom, $aIni[8]) GUICtrlSetFont($idLangTo, $aIni[8]) ; if a language is displayed as squares in the combobox, try instead the 2 following lines ; GUICtrlSetFont($idLangFrom, $aIni[8], 400, 0, "Ms Shell Dlg", 2) ; GUICtrlSetFont($idLangTo, $aIni[8], 400, 0, "Ms Shell Dlg", 2) Case $idLabelTo ; clickable label to increase both combobox font size (some GUI languages appear much smaller than others) If $aIni[8] + 1 > 16.3 Then ContinueLoop $aIni[8] += 1 GUICtrlSetFont($idLangFrom, $aIni[8]) GUICtrlSetFont($idLangTo, $aIni[8]) ; if a language is displayed as squares in the combobox, try instead the 2 following lines ; GUICtrlSetFont($idLangFrom, $aIni[8], 400, 0, "Ms Shell Dlg", 2) ; GUICtrlSetFont($idLangTo, $aIni[8], 400, 0, "Ms Shell Dlg", 2) EndSwitch WEnd GUIDelete($hGUI) ;============================================== Func _UpdateGUI(ByRef $sText) GUICtrlSetData($idTextFrom, $sText) _UpdateCharStatus() GUICtrlSetData($idTextTo, "") WinSetTitle($hGUI, "", _GuiTitle()) EndFunc ;==>_UpdateGUI ;============================================== Func _CreateGui() $sGUI_Title = "Google Translation (v11)" $hGUI = GUICreate(_GuiTitle(), 900, 700, -1, -1, $WS_OVERLAPPEDWINDOW, $WS_EX_ACCEPTFILES) $idPasteClip = GUICtrlCreateButton("Paste Clipboard", 10, 10, 100, 30) $idOpenFile = GUICtrlCreateButton("Open File", 10, 50, 100, 30) GUICtrlCreateGroup(" Original text options ", 120, 10, 310, 70) $idLabelFrom = GUICtrlCreateLabel("Language From", 133, 32, 110, 17) GUICtrlSetTip(-1, "click to decrease both combobox font size", "", 0, 1) $idLangFrom = GUICtrlCreateCombo("", 128, 50, 140, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL), _ ; $CBS_HASSTRINGS always forced ? $bRTL _ ? BitOr($WS_EX_LEFTSCROLLBAR, $WS_EX_RTLREADING, $WS_EX_RIGHT) _ : -1) GUICtrlSetFont(-1, $aIni[8]) ; if a language is displayed as squares in the combobox, try instead the following line ; GUICtrlSetFont(-1, $aIni[8], 400, 0, "Ms Shell Dlg", 2) GUICtrlSetData(-1, $aLangGui[$iLangGui + 2] & "|" & $sLang) ; ex. item 0 is "Detect language" or "Sprache erkennen" or etc... GUICtrlSendMsg($idLangFrom, $CB_SETCURSEL, $aIni[0], 0) GUICtrlCreateLabel("Font size", 290, 32, 54, 17) $idFontSizeFrom = GUICtrlCreateInput($aIni[1], 288, 50, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_NUMBER)) GUICtrlSetLimit(-1, 2) GUICtrlCreateUpdown($idFontSizeFrom) GUICtrlSetLimit(-1, 72, 8) GUICtrlCreateLabel("Word wrap", 364, 32, 64, 17) $idWordWrapFrom = GUICtrlCreateCheckbox("", 382, 46, 17, 25) GUICtrlSetState(-1, $aIni[2]) ; $GUI_CHECKED = 1 , $GUI_UNCHECKED = 4 GUICtrlCreateGroup("", -99, -99, 1, 1) $idLanguageFilter = GUICtrlCreateButton("?", 437, 48, 25, 25) GUICtrlCreateGroup(" Translated text options ", 470, 10, 310, 70) $idLabelTo = GUICtrlCreateLabel("Language To", 483, 32, 110, 17) GUICtrlSetTip(-1, "click to increase both combobox font size", "", 0, 1) $idLangTo = GUICtrlCreateCombo("", 478, 50, 140, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL), _ ; $CBS_HASSTRINGS always forced ? $bRTL _ ? BitOr($WS_EX_LEFTSCROLLBAR, $WS_EX_RTLREADING, $WS_EX_RIGHT) _ : -1) GUICtrlSetFont(-1, $aIni[8]) ; if a language is displayed as squares in the combobox, try instead the following line ; GUICtrlSetFont(-1, $aIni[8], 400, 0, "Ms Shell Dlg", 2) GUICtrlSetData(-1, $sLang) GUICtrlSendMsg(-1, $CB_SETCURSEL, $aIni[3], 0) GUICtrlCreateLabel("Font size", 640, 32, 54, 17) $idFontSizeTo = GUICtrlCreateInput($aIni[4], 638, 50, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_NUMBER)) GUICtrlSetLimit(-1, 2) GUICtrlCreateUpdown($idFontSizeTo) GUICtrlSetLimit(-1, 72, 8) GUICtrlCreateLabel("Word wrap", 714, 32, 64, 17) $idWordWrapTo = GUICtrlCreateCheckbox("", 732, 46, 17, 25) GUICtrlSetState(-1, $aIni[5]) ; $GUI_CHECKED = 1 , $GUI_UNCHECKED = 4 GUICtrlCreateGroup("", -99, -99, 1, 1) $idTranslate = GUICtrlCreateButton("Translate", 790, 10, 100, 30) $idCopyTrans = GUICtrlCreateButton("Copy Translated", 790, 50, 100, 30) $idTextFrom = _EditRecreate_From($aIni[1], $aIni[2]) ; Font size, WordWrap (for edit control containing the original text) $idTextTo = _EditRecreate_To ($aIni[4], $aIni[5]) ; same, for edit control containing the translated text. $idCharStatus = GUICtrlCreateLabel("", 790, 380, 80, 25, BitOR($SS_CENTER,$SS_CENTERIMAGE)) _UpdateCharStatus() EndFunc ;==>_CreateGui ;============================================== Func _Translate() Local $iItemTo = GUICtrlSendMsg($idLangTo, $CB_GETCURSEL, 0, 0) If $iItemTo = - 1 Then ; no "Language To" selected WinSetTitle($hGUI, "", _GuiTitle()) MsgBox($MB_TOPMOST, "'Language To' is undefined", "Please choose a target language from the list", 0, $hGUI) Return EndIf Local $sEncoded = _URIEncode(GUICtrlRead($idTextFrom)) If StringLen($sEncoded) = 0 Then WinSetTitle($hGUI, "", _GuiTitle()) MsgBox($MB_TOPMOST, "No original text", "Nothing to translate", 0, $hGUI) Return EndIf ; ConsoleWrite(BinaryToString(StringToBinary("$sEncoded: " & $sEncoded, $SB_UTF8), $SB_ANSI) & @crlf) Local $iBytes = StringLen($sEncoded) ; ConsoleWrite("Length of $sEncoded : " & $iBytes & @crlf & @crlf) If $iBytes > 65535 Then ; tested (not 65536 !) Local $iYesNo = MsgBox(BitOr($MB_TOPMOST, $MB_YESNO, $MB_DEFBUTTON2, $MB_ICONWARNING), _ "Warning : Encoded text is too big", _ "Encoded text size: " & @Tab & $iBytes & @crlf & _ "Max. allowed:" & @Tab & " 65535" & @crlf & _ "" & @crlf & _ "Do you want to truncate the original text ?", 0, $hGUI) If $iYesNo = $IDNO Then Return $sEncoded = _URIEncode_Truncate(GUICtrlRead($idTextFrom)) EndIf Local $iItemFrom = GUICtrlSendMsg($idLangFrom, $CB_GETCURSEL, 0, 0) Local $sLangFrom = ($iItemFrom = 0) ? "auto" : $aLang[$aLink[$iItemFrom - 1]][0] ; ex. "auto", "en", de", ... ; Local $iItemTo = GUICtrlSendMsg($idLangTo, $CB_GETCURSEL, 0, 0) ; moved at beginning of function, to test if a "Language To" is selected Local $sLangTo = $aLang[$aLink[$iItemTo]][0] ; ex. "en", "de", ... Local $sLangUsed, $sTranslated = _GoogleAPITranslate($sEncoded, $sLangFrom, $sLangTo, $sLangUsed) If $sLangUsed Then ; translation has succeeded and $sLangUsed always contains the code that Google used for its last translation ; ConsoleWrite("$sLangUsed: >>>" & $sLangUsed & "<<<" & @crlf) _GUICtrlEdit_SetText($idTextTo, $sTranslated) If $sLangFrom = "auto" Then Local $sLangUsedFull For $i = 0 To Ubound($aLang) - 1 If $sLangUsed = $aLang[$i][0] Then $sLangUsedFull = $aLang[$i][1] ; ex. "English", "German" , ... ExitLoop EndIf Next WinSetTitle($hGUI, "", "Translated From " & _ ($sLangUsedFull ? $sLangUsedFull : $sLangUsed & " (???)") & _ " To " & $aLang[$aLink[$iItemTo]][1]) Else WinSetTitle($hGUI, "", "Translated From " & $aLang[$aLink[$iItemFrom - 1]][1] & " To " & $aLang[$aLink[$iItemTo]][1]) EndIf Else ; translation failed as $sLangUsed is still empty WinSetTitle($hGUI, "", _GuiTitle()) MsgBox($MB_TOPMOST, "Error", _ "Something went wrong during translation" & @crlf & _ "(Internet connection ok ?)", 0, $hGUI) EndIf EndFunc ;==>_Translate ;============================================== Func _GoogleAPITranslate(Const ByRef $sEncoded, $sFrom, $sTo, ByRef $sLangUsed) Local $oLocalCOMErrorHandler = ObjEvent("AutoIt.Error", "_ErrFuncLocal") ; format and send request With ObjCreate("WinHttp.WinHttpRequest.5.1") ; thanks AspirinJunkie for correct syntax of the Object methods below. .Open("POST", "https://translate.googleapis.com/translate_a/single", False) .SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") .Send(StringFormat("client=gtx&sl=%s&tl=%s&dt=t&q=%s", $sFrom, $sTo, $sEncoded)) Local $sResponse = .ResponseText EndWith ; ConsoleWrite(BinaryToString(StringToBinary("$sResponse: " & $sResponse, $SB_UTF8), $SB_ANSI) & @crlf) Local $vResponse = _JSON_Parse($sResponse) ; process return Local $sOutput = "" If VarGetType($vResponse) = 'Array' Then ; _ArrayDisplay($vResponse, "$vResponse") Local $aData = $vResponse[0] If VarGetType($aData) = 'Array' Then For $i = 0 To UBound($aData) -1 $sOutput &= ($aData[$i])[0] Next EndIf $sLangUsed = $vResponse[2] ; ex. "en" , "de" , ... to display which language Google used for translation, in case user choosed "Detect language" EndIf Return $sOutput EndFunc ;==>_GoogleAPITranslate ;============================================== Func _URIEncode(Const ByRef $sData) ; code below from Prog@ndy (minor changes) : https://www.autoitscript.com/forum/topic/95850-url-encoding/?do=findComment&comment=689060 ; maybe Chr(32) should always be encoded as "%20" and not "+" to be compatible with all browsers (?) we'll see... Local $aData = StringSplit(BinaryToString(StringToBinary($sData, $SB_UTF8), $SB_ANSI), "") ; "" => each character returns as an element Local $nChar, $sEncoded = "" For $i = 1 To $aData[0] $nChar = Asc($aData[$i]) Switch $nChar Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126 $sEncoded &= $aData[$i] Case 32 $sEncoded &= "+" Case Else $sEncoded &= "%" & Hex($nChar, 2) EndSwitch Next Return $sEncoded EndFunc ;==>_URIEncode ;============================================== Func _URIEncode_Truncate(Const ByRef $sData) Local $dBinary, $nChar, $sEncoded = "", $iGoodLen = 0 For $j = 1 To StringLen($sData) $iGoodLen = StringLen($sEncoded) ; from the previous loop $dBinary = StringToBinary(StringMid($sData, $j, 1), $SB_UTF8) ; for example л (russian) becomes 0xD0BB For $i = 1 To BinaryLen($dBinary) $nChar = Number(BinaryMid($dBinary, $i, 1)) Switch $nChar Case 45, 46, 48 To 57, 65 To 90, 95, 97 To 122, 126 $sEncoded &= Chr($nChar) Case 32 $sEncoded &= "+" Case Else $sEncoded &= "%" & Hex($nChar, 2) EndSwitch Next If StringLen($sEncoded) > 65535 Then ; stop encoding... GUICtrlSetData($idTextFrom, StringLeft($sData, $j - 1)) ; ...truncate original text... $sEncoded = StringLeft($sEncoded, $iGoodLen) ;...delete the very last byte(s) in $sEncoded... ExitLoop ; ...return the corresponding encoded string (which will never exceed 65535 bytes) EndIf Next Return $sEncoded EndFunc ;==>_URIEncode_Truncate ;============================================== Func _LanguageFilter(ByRef $aLang, ByRef $aLink, ByRef $sLang) ; Backup 3 arrays (quick), $iLangGui, $bRTL : in case user makes changes in GUI2 then presses Cancel button in GUI2 => revert Local $aLang_backup = $aLang, $aLink_backup = $aLink, $sLang_backup = $sLang, $iLangGui_backup = $iLangGui, $bRTL_backup = $bRTL ; Keep status of combo "Language From" (to select it again, even with another GUI language... if user keeps the language checked) Local $iOld_ItemFrom = GUICtrlSendMsg($idLangFrom, $CB_GETCURSEL, 0, 0) ; always 0+ (0 <=> "Detect language" or "Sprache erkennen" or etc...) Local $sOld_CodeFrom = ($iOld_ItemFrom = 0) ? "auto" : $aLang[$aLink[$iOld_ItemFrom - 1]][0] ; ex. "en" , "de" , ... Local $bCheck_ItemFrom = ($iOld_ItemFrom = 0) ? False : True ; Keep status of combo "Language To" (to select it again, even with another GUI language... if user keeps the language checked) Local $iOld_ItemTo = GUICtrlSendMsg($idLangTo, $CB_GETCURSEL, 0, 0) ; may be -1 if no selected "Language To" . 0+ if selected Local $sOld_CodeTo = ($iOld_ItemTo = -1) ? "" : $aLang[$aLink[$iOld_ItemTo]][0] ; ex. "en" , "de" , ... Local $bCheck_ItemTo = ($iOld_ItemTo = -1) ? False : True Local $iNumLi = -1, $iLeft = 15, $iTop = 49, $iMaxLanguages = Ubound($aLang), $idCheckbox[$iMaxLanguages] Local $iCountGui_Lang = Ubound($aLangGui) / 4, $idMenuItem[$iCountGui_Lang] Local $hGUI2 = GUICreate(_GuiTitle(2), 900, 700, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX)) Local $hMenu = _GUICtrlMenu_GetSystemMenu($hGUI2) _GUICtrlMenu_EnableMenuItem($hMenu, $SC_CLOSE, $MF_GRAYED, False) ; "disable red [X] and System Menu 'Close' item" (Melba23, Dec 14 2009) Local $idMenu_Lang = GUICtrlCreateMenu("GUI language") For $i = 0 To Ubound($aLangGui) - 1 Step 4 ; 0, 4, 8, 12, ... , 152 when 39 Gui languages $idMenuItem[$i / 4] = GUICtrlCreateMenuItem($aLangGui[$i + 1], $idMenu_Lang, -1, 1) ; 1 = menuradioitem If $i = $iLangGui Then GUICtrlSetState(-1, $GUI_CHECKED) Next GUICtrlCreateGroup("", 5, 39, 890, 639) ; just to display a thin rectangle around all Checkbox controls For $i = 0 To $iMaxLanguages - 1 $iNumLi += 1 ; 0+ If $iNumLi > 24 Then ; 0 to 24 = 25 checkbox controls per column (x 7 columns => 175 languages max. with these coords. Actually 133) $iLeft += 125 $iNumLi = 0 EndIf $idCheckbox[$i] = GUICtrlCreateCheckbox($aLang[$i][1], $iLeft, $iTop + $iNumLi * 25, 115, 25, _ $bRTL _ ? BitOr($BS_RIGHTBUTTON, $BS_RIGHT) _ : -1) If $aLang[$i][2] = 1 Then ; display this language in combobox GUICtrlSetState($idCheckbox[$i], $GUI_CHECKED) GUICtrlSetBkColor($idCheckbox[$i], 0xC0FFFF) ; light blue when checked EndIf Next GUICtrlCreateGroup("", -99, -99, 1, 1) Local $idCheckAll = GUICtrlCreateButton("Check All", 150, 7, 100, 30) Local $idUncheckAll = GUICtrlCreateButton("Uncheck All", 270, 7, 100, 30) Local $idOk = GUICtrlCreateButton("Ok", 520, 7, 100, 30) Local $idCancel = GUICtrlCreateButton("Cancel", 640, 7, 100, 30) GUISetState(@SW_SHOW) Local $idMsg, $iLangGuiNew While 1 $idMsg = GUIGetMsg() Switch $idMsg Case $idCancel ; no $GUI_EVENT_CLOSE here, as GUI close button disabled just after GUI creation. Also Opt("GUICloseOnESC", 0) $aLang = $aLang_backup $aLink = $aLink_backup $sLang = $sLang_backup $iLangGui = $iLangGui_backup $bRTL = $bRTL_backup ExitLoop Case $idMenuItem[0] To $idMenuItem[$iCountGui_Lang - 1] ; ex. 30 To 68 when 39 GUI languages $iLangGuiNew = 4 * ($idMsg - $idMenuItem[0]) ; 0, 4, 8, 12, ... , 152 (when 39 GUI languages) If $iLangGuiNew <> $iLangGui Then _ChangeGuiLang($hGUI2, $iLangGuiNew, $idCheckbox) Case $idCheckbox[0] To $idCheckbox[$iMaxLanguages - 1] ; ex. 70 To 202 when 133 translatable languages... ; ...surrounded by 2 GUICtrlCreateGroup("") i.e. controls #69 & #203 If GUICtrlRead($idMsg) = $GUI_CHECKED Then GUICtrlSetBkColor($idMsg, 0xC0FFFF) ; light blue when checked $aLang[$idMsg - $idCheckbox[0]][2] = 1 ; display this language in combobox Else GUICtrlSetBkColor($idMsg, $GUI_BKCOLOR_DEFAULT) $aLang[$idMsg - $idCheckbox[0]][2] = "" ; do not display this language in combobox EndIf Case $idCheckAll GUISetState(@SW_LOCK, $hGui2) ; "Lock the window to avoid repainting" For $i = 0 To $iMaxLanguages - 1 GUICtrlSetState($idCheckbox[$i], $GUI_CHECKED) GUICtrlSetBkColor($idCheckbox[$i], 0xC0FFFF) ; light blue when checked $aLang[$i][2] = 1 ; display this language in combobox Next GUISetState(@SW_UNLOCK, $hGui2) ; "Unlock the window to allow repainting" Case $idUncheckAll GUISetState(@SW_LOCK, $hGui2) For $i = 0 To $iMaxLanguages - 1 GUICtrlSetState($idCheckbox[$i], $GUI_UNCHECKED) GUICtrlSetBkColor($idCheckbox[$i], $GUI_BKCOLOR_DEFAULT) $aLang[$i][2] = "" ; do not display this language in combobox Next GUISetState(@SW_UNLOCK, $hGui2) Case $idOk For $i = 0 To $iMaxLanguages - 1 ; test if one language (at least) is checked If GUICtrlRead($idCheckbox[$i]) = $GUI_CHECKED Then ExitLoop Next If $i = $iMaxLanguages Then ; no language checked MsgBox(BitOr($MB_TOPMOST, $MB_ICONWARNING), "Warning", "Please check at least 1 language", 0, $hGUI2) ContinueLoop EndIf ; at this stage $aLang[][2] Col 2 is fully up to date (1 = display this language in combobox, or "" = do not display) Local $iCountChecked = 0, $iNew_ItemFrom = -1, $iNew_ItemTo = -1 Dim $aLink[$iMaxLanguages] $sLang = "" For $i = 0 To $iMaxLanguages - 1 If GUICtrlRead($idCheckbox[$i]) = $GUI_CHECKED Then $iCountChecked += 1 ; 1+ $aLink[$iCountChecked - 1] = $i ; ex. $aLink[0] = 10 (1st combobox item links to row 10 in $aLang) , $aLink[1] = 27 etc... $sLang &= $aLang[$i][1] & "|" If $bCheck_ItemFrom And $aLang[$i][0] = $sOld_CodeFrom Then $iNew_ItemFrom = $iCountChecked ; 1+ (remember item 0 <=> "Detect language" or "Sprache erkennen" or etc...) $bCheck_ItemFrom = False EndIf If $bCheck_ItemTo And $aLang[$i][0] = $sOld_CodeTo Then $iNew_ItemTo = $iCountChecked - 1 ; 0+ $bCheck_ItemTo = False EndIf EndIf Next Redim $aLink[$iCountChecked] ; delete all superfluous empty rows (quick) GUICtrlSetData($idLangFrom, "|" & $aLangGui[$iLangGui + 2] & "|" & $sLang) ; "|" at beginning destroys the previous list (help file) GUICtrlSetData($idLangTo, "|" & $sLang) If $bRTL <> $bRTL_backup Then ; redraw both combo (RTL or LTR) If $bRTL Then _WinAPI_SetWindowLong(GUICtrlGetHandle($idLangFrom), $GWL_EXSTYLE, _ BitOr($WS_EX_LEFTSCROLLBAR, $WS_EX_RTLREADING, $WS_EX_RIGHT)) _WinAPI_SetWindowLong(GUICtrlGetHandle($idLangTo), $GWL_EXSTYLE, _ BitOr($WS_EX_LEFTSCROLLBAR, $WS_EX_RTLREADING, $WS_EX_RIGHT)) Else _WinAPI_SetWindowLong(GUICtrlGetHandle($idLangFrom), $GWL_EXSTYLE, 0) ; combobox don't have default exstyles (help file error) _WinAPI_SetWindowLong(GUICtrlGetHandle($idLangTo) , $GWL_EXSTYLE, 0) EndIf EndIf If $iNew_ItemFrom = - 1 Then ; old language From has been unchecked OR $iOld_ItemFrom = 0 GUICtrlSendMsg($idLangFrom, $CB_SETCURSEL, 0, 0) ; ex. "Detect language" or "Sprache erkennen" or etc... _WinAPI_SetWindowLong(GUICtrlGetHandle($idTextFrom), $GWL_EXSTYLE, $WS_EX_CLIENTEDGE) ; default extended style value in Edit field Else ; 1+ GUICtrlSendMsg($idLangFrom, $CB_SETCURSEL, $iNew_ItemFrom, 0) EndIf If $iNew_ItemTo = - 1 Then ; old language To has been unchecked OR $iOld_ItemTo = -1 GUICtrlSendMsg($idLangTo, $CB_SETCURSEL, -1, 0) ; blank the "Language To" selection GUICtrlSetData($idTextTo, "") ; clear the eventual translated text _WinAPI_SetWindowLong(GUICtrlGetHandle($idTextTo), $GWL_EXSTYLE, $WS_EX_CLIENTEDGE) ; default extended style value in Edit field Else ; 0+ GUICtrlSendMsg($idLangTo, $CB_SETCURSEL, $iNew_ItemTo, 0) EndIf If $iNew_ItemFrom > 0 And $iNew_ItemTo > -1 Then WinSetTitle($hGUI, "", "Translated From " & _ $aLang[$aLink[$iNew_ItemFrom - 1]][1] & " To " & $aLang[$aLink[$iNew_ItemTo]][1]) Else WinSetTitle($hGUI, "", _GuiTitle()) ; display the generic GUI title (which doesn't mention any translation language) EndIf ExitLoop EndSwitch WEnd GUIDelete($hGUI2) EndFunc ;==>_LanguageFilter ;============================================== Func _ChangeGuiLang(Const $hGUI2, Const $iLangGuiNew, Const ByRef $idCheckbox) ; ConsoleWrite($iLangGui & " " & $iLangGuiNew & @crlf) ; both can be 0, 4, 8, 12, ..., 152 (when 39 Gui languages) Local $bRTL_old = $bRTL ; define this variable before _FillArrayLang() ; Remap the links between the 2 language arrays (before redrawing all checkbox) Local $iIndex, $aLangNew = _FillArrayLang($aLangGui[$iLangGuiNew]) ; 3rd column of $aLangNew is empty at this stage ; $iLangGui & $bRTL redefined during _FillArrayLang() ... ; ... which means, from now on, $iLangGui = $iLangGuiNew For $i = 0 To Ubound($aLang) - 1 If Not $aLang[$i][2] Then ContinueLoop $iIndex = _ArraySearch($aLangNew, $aLang[$i][0], 0, 0, 1, 2, 1, 0) ; 2 = exact match, last 0 = search in col 0 of a 2D array If $iIndex > -1 Then $aLangNew[$iIndex][2] = 1 ; same language code (displayed in combobox) will very often have a different index in the new array. Else MsgBox(BitOr($MB_TOPMOST, $MB_ICONWARNING), "Serious warning", _ "Code language '" & $aLang[$i][0] & "' not found in " & $aLangGui[$iLangGui + 1] & @crlf & _ "Language text file is corrupted", 0, $hGUI2) EndIf Next ; redraw all checkbox with their captions reflecting the new language, tick the ones that need to be ticked, take care of LTR / RTL GUISetState(@SW_LOCK, $hGui2) ; Lock the window to avoid repainting Local $iStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($idCheckbox[0]), $GWL_STYLE) ; all 133 checkbox got the same style, pick any one. For $i = 0 To Ubound($aLang) - 1 If $bRTL <> $bRTL_old Then _WinAPI_SetWindowLong(GUICtrlGetHandle($idCheckbox[$i]), $GWL_STYLE, _ $bRTL _ ? BitOr ($iStyle, $BS_RIGHTBUTTON, $BS_RIGHT) _ : BitXOr($iStyle, $BS_RIGHTBUTTON, $BS_RIGHT)) EndIf GUICtrlSetData($idCheckbox[$i], $aLangNew[$i][1]) If $aLangNew[$i][2] = 1 Then ; display this language in combobox GUICtrlSetState($idCheckbox[$i], $GUI_CHECKED) GUICtrlSetBkColor($idCheckbox[$i], 0xC0FFFF) ; light blue when checked Else GUICtrlSetState($idCheckbox[$i], $GUI_UNCHECKED) GUICtrlSetBkColor($idCheckbox[$i], $GUI_BKCOLOR_DEFAULT) EndIf Next WinSetTitle($hGUI2, "", _GuiTitle(2)) GUISetState(@SW_UNLOCK, $hGui2) ; Unlock the window to allow repainting $aLang = $aLangNew ; note that $iLangGui and $bRTL have been updated during _FillArrayLang() EndFunc ;==>_ChangeGuiLang ;============================================== Func _ReadIniFile($sIniFile, ByRef $aLang, ByRef $aLink, ByRef $sLang) If FileExists($sIniFile) Then Local $aIni = FileReadToArray($sIniFile) If @extended <> 9 Then MsgBox($MB_TOPMOST, "_FileReadToArray: extended = " & @extended, _ "Ini file should have exactly 9 lines, not " & @extended & @crlf & _ "(this message is normal if you just upgraded the script to a new version.)" & @crlf & _ "" & @crlf & _ "Incompatible .ini file will be deleted now, please run the script again.") FileDelete($sIniFile) Exit EndIf For $i = 0 To 5 $aIni[$i] = Number($aIni[$i]) ; Number, or serious issues later with GUICtrlSendMsg() Next $aLink = StringSplit($aIni[6], ",", $STR_NOCOUNT) $aLang = _FillArrayLang(StringStripWS($aIni[7], $STR_STRIPLEADING + $STR_STRIPTRAILING)) ; ex. $aIni[7] = "en" or "de" or etc... ; (GUI interface for the language names) For $i = 0 To Ubound($aLink) - 1 $aLang[$aLink[$i]][2] = 1 ; display this language in ComboBox $sLang &= $aLang[$aLink[$i]][1] & "|" ; "a trailing GUIDataSeparatorChar is ignored" (help file, topic GUICtrlSetData for combo & list control) Next $aIni[8] = Number($aIni[8]) ; _ArrayDisplay($aIni, "Existing ini file") $aIni[6] = "" ; string not needed anymore (no big deal, just to match same behavior when ini file doesn't exist) Else ; ini file doesn't exist Local $aIni[9] $aIni[0] = 0 ; Language From (combobox) (force 'Detect Language' when .ini file doesn't exist) $aIni[1] = 11 ; Font Size for edit control original text $aIni[2] = 1 ; Word wrap for edit control original text (1 = checked, 4 = unchecked) $aIni[3] = -1 ; Language To (combobox) (forced to -1 [unselected] when .ini file doesn't exist) $aIni[4] = 11 ; Font Size for edit control translated text $aIni[5] = 1 ; Word wrap for edit control translated text (1 = checked, 4 = unchecked) ; $aIni[6] : nothing special about $aIni[6] when ini file doesn't exist. $aIni[7] = "en" ; Suggest english GUI interface when no ini file (i.e. language names in english) though it's changeable here $aIni[8] = 9.3 ; Font Size for both combobox (decrease by clicking LABEL $idLabelFrom, increase by clicking LABEL $idLabelTo) $aLang = _FillArrayLang($aIni[7]) Dim $aLink[Ubound($aLang)] For $i = 0 To Ubound($aLang) - 1 ; add all languages in $sLang when ini file doesn't exist (user will keep those he needs, later) $aLang[$i][2] = 1 ; 1 = display this language in ComboBox ("" = don't display it) $aLink[$i] = $i ; link between combobox item # and row in $aLang . This will be useful if user unchecks some languages he doesn't need $sLang &= $aLang[$i][1] & "|" ; "a trailing GUIDataSeparatorChar is ignored" (help file, topic GUICtrlSetData for combo & list control) Next ; _ArrayDisplay($aIni, "New ini file") EndIf Return $aIni EndFunc ;==>_ReadIniFile ;============================================== Func _WriteIniFile($sIniFile, Const ByRef $aLink) Local $hIni = FileOpen($sIniFile, $FO_OVERWRITE) If $hIni = -1 Then MsgBox($MB_TOPMOST, "FileOpen error", $sIniFile, 0, $hGUI) ; 5th param prevents clicking inside the GUI Else FileWrite($hIni, _ GUICtrlSendMsg($idLangFrom, $CB_GETCURSEL, 0, 0) & @crlf & _ Int(GUICtrlRead($idFontSizeFrom)) & @crlf & _ GUICtrlRead($idWordWrapFrom) & @crlf & _ GUICtrlSendMsg($idLangTo, $CB_GETCURSEL, 0, 0) & @crlf & _ Int(GUICtrlRead($idFontSizeTo)) & @crlf & _ GUICtrlRead($idWordWrapTo) & @crlf & _ _ArrayToString($aLink, ",") & @crlf & _ $aLangGui[$iLangGui] & @crlf & _ ; ex. "en" or "de" etc... (it will be the GUI interface for the language names, on next launch) $aIni[8]) ; So there are 9 lines in ini file (no need of a last @crlf , though it is allowed but not mandatory) FileClose($hIni) EndIf EndFunc ;==>_WriteIniFile ;============================================== Func _EditRecreate_From($iFontSize, $iWordWrap) Local $idEdit_Old = $idTextFrom ; 0 at first passage Local $iExStyle If $idEdit_Old Then Local $aPos = ControlGetPos($hGUI, "", $idEdit_Old) Local $sText = GUICtrlRead($idEdit_Old) Local $aSel = _GUICtrlEdit_GetSel($idEdit_Old) $iExStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($idEdit_Old), $GWL_EXSTYLE) GUICtrlDelete($idEdit_Old) Else ; 1st passage Local $aPos[4] = [10, 100, 880, 275] Local $iItemFrom = GUICtrlSendMsg($idLangFrom, $CB_GETCURSEL, 0, 0) Local $sLangFrom = ($iItemFrom = 0) ? "auto" : $aLang[$aLink[$iItemFrom - 1]][0] ; ex. "auto", "en", de", ... $iExStyle = _IsRTL($sLangFrom) _ ? BitOR($WS_EX_LEFTSCROLLBAR, $WS_EX_RTLREADING, $WS_EX_RIGHT, $WS_EX_CLIENTEDGE) _ : -1 ; -1 is the default value ($WS_EX_CLIENTEDGE) used by GUICtrlCreateEdit below EndIf Local $idTextFrom = GUICtrlCreateEdit("", $aPos[0], $aPos[1], $aPos[2], $aPos[3], _ (($iWordWrap = 1) _ ; Word wrap (1 = unchecked, 4 = checked) ? BitOr($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL) _ : -1), _ $iExStyle) ; new control ID (1st passage) or same control ID as the deleted edit control (2nd+ passage) => no gap in id's controls list GUICtrlSetFont(-1, $iFontSize) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlSendMsg(-1, $EM_LIMITTEXT, $iMaxInputLength, 0) If $idEdit_Old Then _GUICtrlEdit_SetText($idTextFrom, $sText) If $aSel[0] <> $aSel[1] Then _GUICtrlEdit_SetSel($idTextFrom, $aSel[0], $aSel[1]) EndIf Return $idTextFrom EndFunc ;==>_EditRecreate_From ;============================================== Func _EditRecreate_To($iFontSize, $iWordWrap) Local $idEdit_Old = $idTextTo ; 0 at first passage Local $iExStyle If $idEdit_Old Then Local $aPos = ControlGetPos($hGUI, "", $idEdit_Old) Local $sText = GUICtrlRead($idEdit_Old) Local $aSel = _GUICtrlEdit_GetSel($idEdit_Old) $iExStyle = _WinAPI_GetWindowLong(GUICtrlGetHandle($idEdit_Old), $GWL_EXSTYLE) GUICtrlDelete($idEdit_Old) Else ; 1st passage Local $aPos[4] = [10, 410, 880, 275] Local $iItemTo = GUICtrlSendMsg($idLangTo, $CB_GETCURSEL, 0, 0) If $iItemTo = -1 Then ; no "Language To" selected $iExStyle = -1 ; -1 is the default value ($WS_EX_CLIENTEDGE) used by GUICtrlCreateEdit below Else Local $sLangTo = $aLang[$aLink[$iItemTo]][0] ; ex. "en", "de", ... $iExStyle = _IsRTL($sLangTo) _ ? BitOR($WS_EX_LEFTSCROLLBAR, $WS_EX_RTLREADING, $WS_EX_RIGHT, $WS_EX_CLIENTEDGE) _ : -1 ; -1 is the default value ($WS_EX_CLIENTEDGE) EndIf EndIf Local $idTextTo = GUICtrlCreateEdit("", $aPos[0], $aPos[1], $aPos[2], $aPos[3], _ (($iWordWrap = 1) _ ; Word wrap (1 = unchecked, 4 = checked) ? BitOr($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL) _ : -1), _ $iExStyle) ; new control ID (1st passage) or same control ID as the deleted edit control (2nd+ passage) => no gap in id's controls list GUICtrlSetFont(-1, $iFontSize) GUICtrlSendMsg(-1, $EM_LIMITTEXT, -1, 0) ; allow unlimited text size in edit control (translated text) If $idEdit_Old Then _GUICtrlEdit_SetText($idTextTo, $sText) If $aSel[0] <> $aSel[1] Then _GUICtrlEdit_SetSel($idTextTo, $aSel[0], $aSel[1]) EndIf Return $idTextTo EndFunc ;==>_EditRecreate_To ;============================================== Func _OpenFile() Local $sFileName = FileOpenDialog( _ "Open Text or PDF file", _ @ScriptDir, _ "Text or PDF (*.txt;*.pdf)", _ BitOR($FD_FILEMUSTEXIST, $FD_PATHMUSTEXIST), _ "", _ $hGUI) If @error Then ;~ MsgBox($MB_TOPMOST, "Open File", _ ;~ "No file selected ", 0, $hGUI) ; FileOpenDialog() was exited by Cancel/Red X button, or by Esc key Return ; 0 EndIf ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder (on successful return) ; FileChangeDir(@ScriptDir) Return $sFileName EndFunc ;==>_OpenFile ;============================================== Func _PdfToText(Const $sInputFileName) Local Static $sPdfToText = @ScriptDir & ((@OSVersion <> "WIN_XP") ? "\pdftotext.exe" : "\pdftotext40.exe") Local Static $sOutputFileName = @ScriptDir & "\TextExtractedFromPDF.txt" If Not FileExists($sPdfToText) Then MsgBox($MB_TOPMOST, "PDF : missing extractor file", _ "To translate a pdf, you need the file 'pdftotext.exe'" & @crlf & _ "" & @crlf & _ "It can be downloaded at https://www.xpdfreader.com" & @crlf & _ "then place it in same folder as the script", 0, $hGUI) _UpdateGUI($sEmpty) Return ; 0 EndIf Local $sCommand = " /c" & " " & _ chr(34) & chr(34) & $sPdfToText & chr(34) & " " & _ "-enc UTF-8" & " " & _ chr(34) & $sInputFileName & chr(34) & " " & _ chr(34) & $sOutputFileName & chr(34) & chr(34) Local $iRet = RunWait(@ComSpec & $sCommand, @ScriptDir, @SW_HIDE) Select Case @error MsgBox($MB_TOPMOST, "RunWait: error " & @error, _ "AutoIt error, please check AutoIt code", 0, $hGUI) Return ; 0 Case $iRet Local $sErr = "" ; following exit codes (from 0 To 99) are found in PdfToText documentation, except the personal "Case Else" Switch $iRet ;~ Case 0 ;~ $sErr = "No error." Case 1 $sErr = "Error opening a PDF file." Case 2 $sErr = "Error opening an output file." Case 3 $sErr = "Error related to PDF permissions." Case 98 $sErr = "Out of memory." ; this exit code 98 was added in last version 4.05 of pdftotxt.exe (released on Feb 8, 2024) Case 99 $sErr = "Other error." Case Else ; should never happen $sErr = "This error isn't found in PdfToText documentation !" EndSwitch MsgBox($MB_TOPMOST, "PdfToText exit code: error " & $iRet, _ $sErr, 0, $hGUI) _UpdateGUI($sEmpty) Return ; 0 EndSelect ; all is good from now on ($iRet = 0, which means no error returned from pdftotext.exe) Return $sOutputFileName EndFunc ;==>_PdfToText ;============================================== Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) ; Local $hWndFrom = $lParam ; Local $iIDFrom = _WinAPI_LoWord($wParam) Local $iIDFrom = BitAND($wParam, 0xFFFF) ; same (cf WinAPIConv.au3) ; Local $iCode = _WinAPI_HiWord($wParam) Local $iCode = BitShift($wParam, 16) ; same (cf WinAPIConv.au3) Switch $iIDFrom Case $idTextFrom If $iCode = $EN_UPDATE Then ; Sent when an edit control is about to redraw itself _UpdateCharStatus() EndIf Case $idLangFrom If $iCode = $CBN_CLOSEUP Or $iCode = $CBN_KILLFOCUS Then Local $iExStyle_Old = _WinAPI_GetWindowLong(GUICtrlGetHandle($idTextFrom), $GWL_EXSTYLE) ; Edit field From Local $iItemFrom = GUICtrlSendMsg($idLangFrom, $CB_GETCURSEL, 0, 0) Local $sLangFrom = ($iItemFrom = 0) ? "auto" : $aLang[$aLink[$iItemFrom - 1]][0] ; ex. "auto", "en", de", ... Local $iExStyle_New = _IsRTL($sLangFrom) _ ? BitOR($WS_EX_LEFTSCROLLBAR, $WS_EX_RTLREADING, $WS_EX_RIGHT, $WS_EX_CLIENTEDGE) _ : $WS_EX_CLIENTEDGE ; $WS_EX_CLIENTEDGE is the default extended style value in Edit field If $iExStyle_New <> $iExStyle_Old Then _WinAPI_SetWindowLong(GUICtrlGetHandle($idTextFrom), $GWL_EXSTYLE, $iExStyle_New) EndIf EndIf Case $idLangTo If $iCode = $CBN_CLOSEUP Or $iCode = $CBN_KILLFOCUS Then Local $iExStyle_Old = _WinAPI_GetWindowLong(GUICtrlGetHandle($idTextTo), $GWL_EXSTYLE) ; Edit field To Local $iItemTo = GUICtrlSendMsg($idLangTo, $CB_GETCURSEL, 0, 0) If $iItemTo = -1 Then ; no "Language To" selected Local $iExStyle_New = $WS_EX_CLIENTEDGE ; $WS_EX_CLIENTEDGE is the default extended style value in Edit field Else Local $sLangTo = $aLang[$aLink[$iItemTo]][0] ; ex. "en", "de", ... Local $iExStyle_New = _IsRTL($sLangTo) _ ? BitOR($WS_EX_LEFTSCROLLBAR, $WS_EX_RTLREADING, $WS_EX_RIGHT, $WS_EX_CLIENTEDGE) _ : $WS_EX_CLIENTEDGE ; $WS_EX_CLIENTEDGE is the default extended style value in Edit field EndIf If $iExStyle_New <> $iExStyle_Old Then _WinAPI_SetWindowLong(GUICtrlGetHandle($idTextTo), $GWL_EXSTYLE, $iExStyle_New) EndIf EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND ;============================================== Func _UpdateCharStatus() Local $iChars = GUICtrlSendMsg($idTextFrom, $WM_GETTEXTLENGTH, 0, 0) ; same as _GUICtrlEdit_GetTextLen($idTextFrom) ? Select Case $iChars > $iMaxInputLength GUICtrlSetData($idTextFrom, StringLeft(GUICtrlRead($idTextFrom), $iMaxInputLength)) ContinueCase Case $iChars = $iMaxInputLength GUICtrlSetData($idCharStatus, $iMaxInputLength & " / " & $iMaxInputLength) GUICtrlSetBkColor($idCharStatus, 0xFF4040) ; reddish Case Else ; i.e. $iChars < $iMaxInputLength GUICtrlSetData($idCharStatus, $iChars & " / " & $iMaxInputLength) GUICtrlSetBkColor($idCharStatus, ($iChars <= 5460) ? 0x80FF80 : 0xFFFF00) ; greenish => ok, yellow => encoded string may become too long. EndSelect EndFunc ;==>_UpdateCharStatus ;============================================== Func _ErrFuncLocal($oError) ; https://www.autoitscript.com/forum/topic/191401-com-error-handling-in-a-udf-best-practice/?do=findComment&comment=1373102 MsgBox($MB_TOPMOST, @ScriptName & " (" & $oError.scriptline & ") : ==> Local COM error handler - COM Error intercepted !", _ @Tab & "err.number is: " & @Tab & @Tab & "0x" & Hex($oError.number) & @crlf & _ @Tab & "err.windescription:" & @Tab & @Tab & StringStripWS($oError.windescription, 2) & @crlf & _ @Tab & "err.description is: " & @Tab & @Tab & StringStripWS($oError.description, 2) & @crlf & _ @Tab & "err.source is: " & @Tab & @Tab & $oError.source & @crlf & _ @Tab & "err.helpfile is: " & @Tab & @Tab & $oError.helpfile & @crlf & _ @Tab & "err.helpcontext is: " & @Tab & @Tab & $oError.helpcontext & @crlf & _ @Tab & "err.lastdllerror is: " & @Tab & @Tab & $oError.lastdllerror & @crlf & _ @Tab & "err.scriptline is: " & @Tab & @Tab & $oError.scriptline & @crlf & _ @Tab & "err.retcode is: " & @Tab & @Tab & "0x" & Hex($oError.retcode), 0, $hGUI) EndFunc ;==>_ErrFuncLocal ;============================================== Func _Wanna_Quit() ; in case user keys Esc during the translation process HotKeySet("{ESC}") If WinActive($hGUI) Then MouseMove(@DesktopWidth / 2, @DesktopHeight / 2, 0) ; 0 = fastest move If MsgBox(BitOr($MB_TOPMOST, $MB_OKCANCEL, $MB_DEFBUTTON2), _ "Esc was keyed", "Quit translation script ?", 0, $hGUI) = $IDOK Then GUIDelete($hGUI) Exit EndIf Else ; Esc was keyed when another application was on top Send("{ESC}") EndIf HotKeySet("{ESC}", "_Wanna_Quit") EndFunc ;_Wanna_Quit ;============================================== Func _FillArrayLangGUI($sFileName) ; Text file containing a list of 39 languages & codes (for GUI) found patiently on Google translate web site, one by one... Local $sFilePath = @ScriptDir & "\" & $sFileName If Not FileExists($sFilePath) Then Exit MsgBox($MB_TOPMOST, "File not found", $sFilePath) Local $s_String = FileRead($sFilePath) If @error Then Exit MsgBox($MB_TOPMOST, "FileRead : error " & @error, $sFilePath) ; this shouldn't happen, but who knows ? Local $sPattern = '(?i)Language code\h*:?\h*(.+?)\h*\R+\h*Language name\h*:?\h*(.+?)\h*\R+\h*\["auto","(.+?)"],(\[".+"])\h*(?:\R+|$)' Local $aArray = StringRegExp($s_String, $sPattern, 3) If @error Then Exit MsgBox($MB_TOPMOST, "StringRegExp", _ "error = " & @error & (@error = 1 ? " (no matches)" : " (bad pattern)") & @crlf & _ "" & @crlf & _ $sFilePath) If Mod(Ubound($aArray), 4) Then _ArrayDisplay($aArray, "Malformed txt file : number of rows should be a multiple of 4") Exit MsgBox($MB_TOPMOST, "error", _ "Please install a correct language text file" & @crlf & _ "" & @crlf & _ $sFilePath) EndIf ; _ArrayDisplay($aArray, (Ubound($aArray) / 4) & " GUI languages codes & names") Return $aArray EndFunc ;==>_FillArrayLangGUI ;============================================== Func _FillArrayLang($sCode) For $i = 0 To Ubound($aLangGui) - 1 Step 4 ; 4 consecutive rows (in $aLangGui) contain the characteristics of each GUI language If $aLangGui[$i] = $sCode Then ExitLoop ; ex. "en" or "de" etc... Next If $i > Ubound($aLangGui) - 1 Then Exit MsgBox($MB_TOPMOST, 'error', _ 'Language code "' & $sCode & '" not retrieved in language text file' & @crlf & _ 'Please install a correct language text file (and delete your eventual ini file)') $iLangGui = $i ; important global variable indicating the row where starts the characteristics of the actual Gui language. ; its value is 0, 4, 8, 12...152 (when 39 Gui languages) Local $s_String = $aLangGui[$iLangGui + 3] ; string of 133 languages, for ex. ["af","Afrikaans"],["sq","Albanian"],[...],["zu","Zulu"] ; suppress eventual leading & trailing whitespaces ; Regexp Pattern in _FillArrayLangGUI() has already checked this => comment out the test below ; $s_String = StringStripWS($s_String, $STR_STRIPLEADING + $STR_STRIPTRAILING) ; check the string starts with an opening bracket followed by a double quote, then ends with a double quote followed by a closing bracket ; Regexp Pattern in _FillArrayLangGUI() has already checked this => comment out the test below ; If StringLeft($s_String, 2) <> '["' Or StringRight($s_String, 2) <> '"]' Then Exit MsgBox($MB_TOPMOST, _ ; 'Language code "' & $sCode & '" : bracket and double quote error inside language text file', _ ; 'The first 2 characters of the string must be ["' & @crlf & _ ; 'The last 2 characters of the string must be "]') ; beginning of string : suppress leading opening bracket and first double quote ; end of string : suppress last double quote and trailing closing bracket $s_String = StringMid($s_String, 3, StringLen($s_String) - 4) ; Split the string in a 2D array (2 columns) with a 3rd empty column added for further usage (5th param. of _StringSplit2D_EX) Local $aArray = _StringSplit2D_EX($s_String, '","', '"],["', False, 1) If @error Then Exit MsgBox($MB_TOPMOST, "_StringSplit2D_EX : error " & @error, _ "All rows don't have the same number of fields" & @crlf & _ "Please install a correct language text file") If Ubound($aArray, $UBOUND_COLUMNS) <> 3 Then Exit MsgBox($MB_TOPMOST, _ "error : number of columns = " & Ubound($aArray, $UBOUND_COLUMNS), _ "It should be 3 (last column being empty for further usage)" & @crlf & _ "Please install a correct language text file") $bRTL = _IsRTL($sCode) ; True if language is RTL, False if not Return $aArray EndFunc ;==>_FillArrayLang ;============================================== Func _IsRTL($sCode) ; June 2024 : 10 languages are RTL amongst the 133 traductable languages (tested) ; Place them all in the string below, though only 3 of them are accessible from the 39 GUI languages (Arabic, Hebrew, Persian) ; Arabic (ar) , Dhivehi (dv), Hebrew (iw), Kurdish (Sorani) (ckb), Pashto (ps) ; Persian (fa), Sindhi (sd), Urdu (ur), Uyghur (ug), Yiddish (yi) ; Note : in version 10+ the whole list (10 RTL languages) is checked in case of 1 or 2 edit fields are RTL (in edit creation & WM_COMMAND) Local Static $sRTL = "ar,dv,iw,ckb,ps,fa,sd,ur,ug,yi," ; end the string with a comma (to make the search easy on next line) Return (StringInStr($sRTL, $sCode & ",") > 0) ? True : False EndFunc ;==>_IsRTL ;============================================== Func _GuiTitle($iGui = 0) Local $sTitle Switch $iGui Case 0 ; add GUI language code (which may change during the script) to the string, so user knows what GUI language is actually set. ; ex. "Google Translation (v10 - en)" $sTitle = StringTrimRight($sGUI_Title, 1) & " - " & $aLangGui[$iLangGui] & ")" Case 2 ; add GUI language name to the string ; ex. "GUI language (English) & Languages filter" $sTitle = "GUI language (" & $aLangGui[$iLangGui + 1] & ") & Languages filter" Case Else $sTitle = "Scripter, where are you ?" EndSwitch Return $sTitle EndFunc ;==>_GuiTitle ;============================================== Func _StringSplit2D_EX(ByRef $sString, $sDelim_Col = "|", $sDelim_Row = @CRLF, $bExpand = False, $iAdd_EmptyCol = 0) ; based on AspirinJunkie's function _StringSplit2D found at https://autoit.de/thread/85380-1d-array-in-2d-array-splitten/ ; Thanks Nine for suggesting the 4th parameter $bExpand, to allow or not the same number of fields per row (as in _FileReadToArray) Local $a_FirstDim = StringSplit($sString, $sDelim_Row, $STR_ENTIRESPLIT + $STR_NOCOUNT) Local $iKeep_NbCol = Ubound(StringSplit($a_FirstDim[0], $sDelim_Col, $STR_ENTIRESPLIT + $STR_NOCOUNT)) ; keep nb cols row 0 Local $a_Out[UBound($a_FirstDim)][1 + $iAdd_EmptyCol], $a_Line, $i_2DMax = 1 For $i = 0 To UBound($a_FirstDim) - 1 $a_Line = StringSplit($a_FirstDim[$i], $sDelim_Col, $STR_ENTIRESPLIT + $STR_NOCOUNT) If (Not $bExpand) And (Ubound($a_Line) <> $iKeep_NbCol) Then Return SetError(3, 0, 0) ; same error # as _FileReadToArray If UBound($a_Line) > $i_2DMax Then ; when $bExpand = False, this test will be True maximum 1 time, never more. $i_2DMax = UBound($a_Line) ReDim $a_Out[UBound($a_Out)][$i_2DMax + $iAdd_EmptyCol] EndIf For $j = 0 To UBound($a_Line) - 1 $a_Out[$i][$j] = $a_Line[$j] Next Next Return $a_Out EndFunc ;==>_StringSplit2D_EX Please indicate if something doesn't work correctly as I just finished the script a few minutes ago. Have a great day * Update June 7, 2024 (version 7) If you don't need all 133 language names (in both combobox) and prefer to display less names for a better visibility, then it's easily doable as explained in my post just below * Update June 23, 2024 (version 9) list of changes below in this thread, here * Update June 27, 2024 (version 10) this will be probably my final update (unless a bug is discovered in the script) + Added code to take care of possible RTL edit fields (10 languages amongst 133) during Edit controls creation, or during the registered WM_COMMAND function (test on $CBN_CLOSEUP, $CBN_KILLFOCUS etc...) + Minor cosmetic changes * Update June 30, 2024 (version 11) Pdf files can now be opened for translation. Instructions to download the free utility "pdftotext" are found in the post below Google Translate (languages list #3).zip
    10 points
  4. I need from from time to time to run small processes to perform task that would otherwise clog the main process. Yes, there is a number of other UDF that could have done it very well, but I felt they were an over-kill for what I wanted. Don't throw me stones, I know it's not really multi-threading, but it is as close as I could get with simple AutoIt. If someone wonders why I called it PMT, the P stands for Pretending. And I'm also not pretending it is an elaborate UDF. Just small and simple to use... Version 2025-01-03 * changed how temporary files are deleted * changed location of temporary files to use standard folder * added support to unusual location of AutoIt Version 2025-01-02 * corrected bug when temporary files has space within their name. Version 2024-03-24 * corrected bug when 8 parameters (max) is passed to the function Example : #AutoIt3Wrapper_Res_SaveSource=y #include "PMT-UDF.AU3" #include <Constants.au3> _PMT_Init() Local $hProc1 = _PMT_Start("Test1", Default, "Test 1") _PMT_Start("Test2") _PMT_Start("Test3", 5) Local $sResponse While Sleep(50) $sResponse = _PMT_GetResponse($hProc1) If @error Then Exit MsgBox($MB_OK, "Error", "Process has dropped") If $sResponse <> "" Then MsgBox($MB_OK, "Success", $sResponse & @CRLF) ExitLoop EndIf WEnd Func Test1($sTitle, $sMessage) Local $iResp = MsgBox($MB_OK, $sTitle, $sMessage) Return "Done with value " & $iResp EndFunc Func Test2() MsgBox($MB_OK, "2", "Test 2") EndFunc Func Test3($iTimeout) MsgBox($MB_OK, "3", "Test 3", $iTimeout) EndFunc You can pass up to 8 parameters to _PMT_Start. It is up to you to manage the right number. You cannot pass structures, maps or arrays as parameter (only bool, ptr, hWnd, int, float, string, and the keyword Default). You could use my WCD-IPC if need be to exchange large amount of data. If you want to run it compiled, you need to have add #AutoIt3Wrapper_Res_SaveSource=y at the start of your script. In the case you decide to compile your script, _PMT_Init allows you to identity where AutoIt3 is located (in the situation where AutoIt is not installed in the usual directory) to get the right includes in your "threads". Let me know if you have any question, or suggestion, I will be glad to hear them. Enjoy. PMT-UDF.au3
    8 points
  5. I ported half of the Cairo functions to Autoit. You can read more about the functions here: https://www.cairographics.org/documentation/ The probability is high that errors have crept in and I have only tested a fraction of the functions. Anyone who wants to can contribute examples. All needed files (DLLs, UDF and examples) can be download from my OneDrive: Cairo for Autoit If you find a mistake, I am sure you will, then please report it.
    8 points
  6. I shamelessly used (copied and pasted) a very nice @eukalyptus's script to underline and send you some auspicious messages ... sorry for the laziness... ; source ; https://autoit.de/thread/17855-led-laufschrift/ ; ; reference for this script (by Eukalyptus): ; https://autoit.de/thread/17855-led-laufschrift/?postID=140164#post140164 #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GDIPlusConstants.au3> ; #include "LEDTXT.au3" ; (by Eukalyptus) already embedded here below Local $sText1 = "Hello friends! ☺ best wishes for a happy holiday and a happy new year (me)" Local $sText2 = "Let us greet together this new year that ages our friendship without aging our hearts. (Victor Hugo)" Local $sText3 = "The best time to plant a tree was 20 years ago. The second best time is now. (Chinese proverb)" Local $sText4 = "The future belongs to those who believe in the beauty of their dreams. (Eleanor Roosevelt)" Local $sText5 = "In the end, what matters is not the years of your life, but the life you put into those years. (Abraham Lincoln)" HotKeySet("{ESC}", "_Exit") _GDIPlus_Startup() $hGuiTrans = GUICreate("", @DesktopWidth, 300, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hGuiTrans, 0xABCDEF) GUISetState() $hGui = GUICreate("", @DesktopWidth, 400, 0, 300, Default, $WS_EX_TOPMOST) ; WinSetTrans($hGui, "", 100) GUISetState() #cs parameters info: $hGui: Handle to the window $sText: The text $iX: X position of the scrolling text $iY: Y position $iW: Length $iH: Height $iType: Appearance of the LEDs 0=Round with 3D effect, 1=Square with 3D, 2=Round, 3=Square; (the last two are filled and/or outlined, depending on which colors are <>0) $iLedW = X-size of an LED $iLedH = Y-size of an LED $nLedOnCol1 = Color 1 of the ON LEDs (foreground for 3D, fill color for $iType 2 and 3) $nLedOnCol2 = Color 2 of the ON LEDs (background for 3D, color of the outline for $iType 2 and 3) $nLedOffCol1 = Color 1 of the OFF LEDs $nLedOffCol2 = Color 2 of the OFF LEDs $nBkColor = Background color $iDistW = X-distance of the LEDs $iDistH = Y-distance of the LEDs $sFont = Font $iTextSize = Font size $iTextOpt = Font options (see _GDIPlus_FontCreate ) $iTextOffY = Y offset of the font #ce $aLed1 = _LEDTXT_Create_Gdi($hGuiTrans, $sText1, 0, 0, @DesktopWidth, 50, 0, 2, 2, 0xFFFFAA00, 0xFF000000, 0xAA111122, 0xAA000000, 0, 0, 0, "Courier New", 40, 1) $aLed2 = _LEDTXT_Create_Gdi($hGuiTrans, $sText2, 0, 50, @DesktopWidth, 50, 3, 2, 2, 0, 0xFF0088FF, 0, 0xFF000000, 0, 0, 0, "Arial", 40, 1) $aLed3 = _LEDTXT_Create_Gdi($hGuiTrans, $sText3, 0, 100, @DesktopWidth, 100, 1, 4, 4, 0xFFFF0000, 0xFF000000, 0, 0, 0xFFABCDEF, 1, 1, "Times New Roman", 80, 1) $aLed4 = _LEDTXT_Create_Gdi($hGuiTrans, $sText4, 0, 200, @DesktopWidth, 100, 1, 4, 4, 0xFF00FF00, 0xFF000000, 0xFFABCDEF, 0xFFABCDEF, 0xFFABCDEF, 0, 0, "Arial", 80, 1) $aLed5 = _LEDTXT_Create_Gdi($hGui, $sText5, 0, 0, @DesktopWidth, 350, 0, 14, 14, 0xFF00FF00, 0xFF00AA00, 0x44111119, 0x4400EE00, 0x44000000, 0, 0, "Arial", 410, 1, -60) GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND") While 1 _LEDTXT_Step($aLed1, 1) _LEDTXT_Step($aLed2, -1) _LEDTXT_Step($aLed3, 1) _LEDTXT_Step($aLed4, -1) _LEDTXT_Step($aLed5, 1) _WinAPI_RedrawWindow($hGuiTrans, 0, 0, 5) _WinAPI_RedrawWindow($hGui, 0, 0, 5) Sleep(10) WEnd Func _WM_ERASEBKGND($hWnd, $Msg, $wParam, $lParam) Switch $hWnd Case $hGuiTrans _LEDTXT_Draw($aLed1) _LEDTXT_Draw($aLed2) _LEDTXT_Draw($aLed3) _LEDTXT_Draw($aLed4) Case $hGui _LEDTXT_Draw($aLed5) EndSwitch Return True EndFunc ;==>_WM_ERASEBKGND Func _Exit() _LEDTXT_Destroy($aLed1) _LEDTXT_Destroy($aLed2) _LEDTXT_Destroy($aLed3) _LEDTXT_Destroy($aLed4) _LEDTXT_Destroy($aLed5) _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit ; =============================== ; LEDTXT.au3 (by Eukalyptus) ; =============================== Func _LEDTXT_Step(ByRef $aLed, $iDir = 1) $aLed[6] -= $aLed[8] * $iDir Select Case $aLed[6] + $aLed[7] < 0 $aLed[6] = 0 Case $aLed[6] > 0 $aLed[6] = -$aLed[7] EndSelect EndFunc ;==>_LEDTXT_Step Func _LEDTXT_Draw($aLed) Local $iPos = Round($aLed[6]) - Mod(Round($aLed[6]), $aLed[8]) Switch $aLed[10] Case True Switch $iPos Case -$aLed[7] To -$aLed[7] + $aLed[4] _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], -$iPos, 0, $iPos + $aLed[7], $aLed[5], $aLed[2], $aLed[3], $iPos + $aLed[7], $aLed[5]) If $aLed[6] + $aLed[7] < $aLed[4] Then _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], 0, 0, $aLed[4] - ($iPos + $aLed[7]), $aLed[5], $aLed[2] + $iPos + $aLed[7], $aLed[3], $aLed[4] - ($iPos + $aLed[7]), $aLed[5]) Case Else _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], -$iPos, 0, $aLed[4], $aLed[5], $aLed[2], $aLed[3], $aLed[4], $aLed[5]) EndSwitch Case Else Switch $iPos Case -$aLed[7] To -$aLed[7] + $aLed[4] _WinAPI_BitBlt($aLed[0], $aLed[2], $aLed[3], $aLed[2] + $iPos + $aLed[7], $aLed[5], $aLed[1], -$iPos, 0, $MERGECOPY) If $aLed[6] + $aLed[7] < $aLed[4] Then _WinAPI_BitBlt($aLed[0], $aLed[2] + $iPos + $aLed[7], $aLed[3], $aLed[4] - ($iPos + $aLed[7]), $aLed[5], $aLed[1], 0, 0, $MERGECOPY) Case Else _WinAPI_BitBlt($aLed[0], $aLed[2], $aLed[3], $aLed[4], $aLed[5], $aLed[1], -$iPos, 0, $MERGECOPY) EndSwitch EndSwitch EndFunc ;==>_LEDTXT_Draw Func _LEDTXT_Create_GdiPlus($hGui, $sText, $iX, $iY, $iW, $iH, $iType, $iLedW = 8, $iLedH = 8, $nLedOnCol1 = 0xFFFFAA00, $nLedOnCol2 = 0xFF000000, $nLedOffCol1 = 0xAA111122, $nLedOffCol2 = 0xAA000000, $nBkColor = 0xFF000000, $iDistW = 0, $iDistH = 0, $sFont = "Arial", $iTextSize = 0, $iTextOpt = 1, $iTextOffY = 0) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) Local $hLedOn = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOnCol1, $nLedOnCol2) Local $hLedOff = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOffCol1, $nLedOffCol2) Local $hLed, $iWidth $hLed = _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, $iWidth) Local $aReturn[11] $aReturn[0] = $hGraphics $aReturn[1] = $hLed $aReturn[2] = $iX $aReturn[3] = $iY $aReturn[4] = $iW $aReturn[5] = $iH $aReturn[6] = 0 $aReturn[7] = $iWidth $aReturn[8] = $iLedW + $iDistW $aReturn[9] = 0 $aReturn[10] = True ; True = _GdiPlus, False=_WinApi Return $aReturn EndFunc ;==>_LEDTXT_Create_GdiPlus Func _LEDTXT_Create_Gdi($hGui, $sText, $iX, $iY, $iW, $iH, $iType, $iLedW = 8, $iLedH = 8, $nLedOnCol1 = 0xFFFFAA00, $nLedOnCol2 = 0xFF000000, $nLedOffCol1 = 0xAA111122, $nLedOffCol2 = 0xAA000000, $nBkColor = 0xFF000000, $iDistW = 0, $iDistH = 0, $sFont = "Arial", $iTextSize = 0, $iTextOpt = 1, $iTextOffY = 0) Local $bGdiStarted = True If Not $__g_hGDIPDll Then $bGdiStarted = False _GDIPlus_Startup() EndIf Local $hDC = _WinAPI_GetDC($hGui) Local $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC) Local $hLedOn = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOnCol1, $nLedOnCol2) Local $hLedOff = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOffCol1, $nLedOffCol2) Local $hLed, $iWidth $hLed = _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, $iWidth) Local $hBmpDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hLed) _WinAPI_SelectObject($hBmpDC, $hBmp) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hLed) Local $aReturn[11] $aReturn[0] = $hDC $aReturn[1] = $hBmpDC $aReturn[2] = $iX $aReturn[3] = $iY $aReturn[4] = $iW $aReturn[5] = $iH $aReturn[6] = 0 $aReturn[7] = $iWidth $aReturn[8] = $iLedW + $iDistW $aReturn[9] = $hBmp ; zum späteren destroy?! $aReturn[10] = False ; True = _GdiPlus, False=_WinApi _GDIPlus_GraphicsDispose($hGraphics) If Not $bGdiStarted Then _GDIPlus_Shutdown() Return $aReturn EndFunc ;==>_LEDTXT_Create_Gdi Func _LEDTXT_Destroy($aLed) Switch $aLed[10] Case True _GDIPlus_BitmapDispose($aLed[1]) _GDIPlus_GraphicsDispose($aLed[0]) Case Else _WinAPI_DeleteObject($aLed[9]) _WinAPI_ReleaseDC(0, $aLed[1]) _WinAPI_DeleteDC($aLed[0]) EndSwitch EndFunc ;==>_LEDTXT_Destroy Func _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, ByRef $iReturnW) $sText = StringReplace($sText, @LF, "") $iW -= Mod($iW, $iLedW + $iDistW) If Not $iTextSize Then $iTextSize = $iH Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFont = _GDIPlus_FontCreate($hFamily, $iTextSize, $iTextOpt, 2) Local $tLayout = _GDIPlus_RectFCreate($iW, 0, 0, 0) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sText, $hFont, $tLayout, $hFormat) Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width")) + $iW $iWidth -= Mod($iWidth, $iLedW + $iDistW) Local $iHeight = $iH ;Ceiling(DllStructGetData($aInfo[0], "Height")) DllStructSetData($aInfo[0], "Y", $iTextOffY) Local $hBmpTxt = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Local $hBmpLed = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Local $hBmpTmp = _GDIPlus_BitmapCreateFromGraphics($iLedW, $iHeight, $hGraphics) Local $hGfxTxt = _GDIPlus_ImageGetGraphicsContext($hBmpTxt) Local $hGfxLed = _GDIPlus_ImageGetGraphicsContext($hBmpLed) Local $hGfxTmp = _GDIPlus_ImageGetGraphicsContext($hBmpTmp) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) _GDIPlus_GraphicsClear($hGfxTxt, 0xFF000000) If $nBkColor Then _GDIPlus_GraphicsClear($hGfxLed, $nBkColor) _GDIPlus_GraphicsDrawStringEx($hGfxTxt, $sText, $hFont, $aInfo[0], $hFormat, $hBrush) Local $BitmapData = _GDIPlus_BitmapLockBits($hBmpTxt, $iW, 0, $iWidth - $iW, $iHeight, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $Stride = DllStructGetData($BitmapData, "Stride") Local $Width = DllStructGetData($BitmapData, "Width") Local $Height = DllStructGetData($BitmapData, "Height") Local $Scan0 = DllStructGetData($BitmapData, "Scan0") Local $PixelData = DllStructCreate("ubyte lData[" & (Abs($Stride) * $Height - 1) & "]", $Scan0) If $hLedOff Then For $i = 0 To $Height - 1 Step $iLedH + $iDistH _GDIPlus_GraphicsDrawImage($hGfxTmp, $hLedOff, 0, $i) Next For $i = 0 To $iW - 1 Step $iLedW + $iDistW _GDIPlus_GraphicsDrawImage($hGfxLed, $hBmpTmp, $i, 0) Next EndIf For $col = 0 To $Width - 1 Step $iLedW + $iDistW If $hLedOff Then _GDIPlus_GraphicsDrawImage($hGfxLed, $hBmpTmp, $col + $iW, 0) For $row = 0 To $Height - 1 Step $iLedH + $iDistH If DllStructGetData($PixelData, 1, $row * $Stride + ($col * 4) + 1) Then _GDIPlus_GraphicsDrawImage($hGfxLed, $hLedOn, $col + $iW, $row) Next Next _GDIPlus_BitmapUnlockBits($hBmpTxt, $BitmapData) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hBmpTxt) _GDIPlus_GraphicsDispose($hGfxTxt) _GDIPlus_BitmapDispose($hBmpTmp) _GDIPlus_GraphicsDispose($hGfxTmp) _GDIPlus_GraphicsDispose($hGfxLed) $iReturnW = $iWidth Return $hBmpLed EndFunc ;==>_LEDTXT_Create_Bmp Func _LEDTXT_Create_Led($hGraphics, $iType, $iWidth, $iHeight, $nColor1, $nColor2) If Not $nColor1 And Not $nColor2 Then Return 0 Local $hBmp = _GDIPlus_BitmapCreateFromGraphics($iWidth + 1, $iHeight + 1, $hGraphics) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp) Switch $iType Case 0 Local $hPen = _GDIPlus_PenCreate() Local $hPath = _GDIPlus_CreatePath() _GDIPlus_AddPathEllipse($hPath, 0, 0, $iWidth, $iHeight) Local $hBrushGrad = _GDIPlus_CreatePathGradientFromPath($hPath) _GDIPlus_SetLineGammaCorrection($hBrushGrad, True) _GDIPlus_SetPathGradientSurroundColorsWithCount($hBrushGrad, $nColor2) _GDIPlus_SetPathGradientCenterColor($hBrushGrad, $nColor1) _GDIPlus_FillPath($hGfx, $hBrushGrad, $hPath) _GDIPlus_ClosePathFigure($hPath) _GDIPlus_GraphicsDrawEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrushGrad) _GDIPlus_PathDispose($hPath) Case 1 Local $hPen = _GDIPlus_PenCreate() Local $hPath = _GDIPlus_CreatePath() _GDIPlus_AddPathRectangle($hPath, 0, 0, $iWidth, $iHeight) Local $hBrushGrad = _GDIPlus_CreatePathGradientFromPath($hPath) _GDIPlus_SetLineGammaCorrection($hBrushGrad, True) _GDIPlus_SetPathGradientSurroundColorsWithCount($hBrushGrad, $nColor2) _GDIPlus_SetPathGradientCenterColor($hBrushGrad, $nColor1) _GDIPlus_FillPath($hGfx, $hBrushGrad, $hPath) _GDIPlus_ClosePathFigure($hPath) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrushGrad) _GDIPlus_PathDispose($hPath) Case 2 If $nColor1 Then Local $hBrush = _GDIPlus_BrushCreateSolid($nColor1) _GDIPlus_GraphicsFillEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_BrushDispose($hBrush) EndIf If $nColor2 Then Local $hPen = _GDIPlus_PenCreate($nColor2) _GDIPlus_GraphicsDrawEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) EndIf Case 3 If $nColor1 Then Local $hBrush = _GDIPlus_BrushCreateSolid($nColor1) _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_BrushDispose($hBrush) EndIf If $nColor2 Then Local $hPen = _GDIPlus_PenCreate($nColor2) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) EndIf EndSwitch _GDIPlus_GraphicsDispose($hGfx) Return $hBmp EndFunc ;==>_LEDTXT_Create_Led Func _GDIPlus_CreatePath($brushMode = 0) Local $hPath $hPath = DllCall($__g_hGDIPDll, "int", "GdipCreatePath", "int", $brushMode, "handle*", 0) If @error Then Return SetError(1, @error, 0) Return SetError($hPath[0], 0, $hPath[2]) EndFunc ;==>_GDIPlus_CreatePath Func _GDIPlus_AddPathEllipse($hPath, $iX, $iY, $iWidth, $iHeight) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathEllipse", "handle", $hPath, "float", $iX, "float", $iY, "float", $iWidth, "float", $iHeight) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_AddPathEllipse Func _GDIPlus_AddPathRectangle($hPath, $iX, $iY, $iWidth, $iHeight) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipAddPathRectangle", "handle", $hPath, "float", $iX, "float", $iY, "float", $iWidth, "float", $iHeight) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_AddPathRectangle Func _GDIPlus_CreatePathGradientFromPath($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipCreatePathGradientFromPath", "handle", $hPath, "int*", 0) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[2]) EndFunc ;==>_GDIPlus_CreatePathGradientFromPath Func _GDIPlus_SetLineGammaCorrection($hBrush, $useGammaCorrection = True) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetLineGammaCorrection", "handle", $hBrush, "int", $useGammaCorrection) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_SetLineGammaCorrection Func _GDIPlus_SetPathGradientCenterColor($hBrush, $iARGB) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientCenterColor", "handle", $hBrush, "int", $iARGB) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_SetPathGradientCenterColor Func _GDIPlus_FillPath($hGraphic, $hBrushGrad, $hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipFillPath", "handle", $hGraphic, "handle", $hBrushGrad, "handle", $hPath) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_FillPath Func _GDIPlus_SetPathGradientSurroundColorsWithCount($hBrush, $aArgb) Local $iI, $iCount, $aResult, $res, $x, $pArgb If IsArray($aArgb) Then $iCount = UBound($aArgb) $tArgb = DllStructCreate("int[" & $iCount & "]") $pArgb = DllStructGetPtr($tArgb) For $iI = 0 To $iCount - 1 DllStructSetData($tArgb, 1, $aArgb[$iI], $iI + 1) Next Else $iCount = 1 $tArgb = DllStructCreate("int") $pArgb = DllStructGetPtr($tArgb) DllStructSetData($tArgb, 1, $aArgb, 1) EndIf $aResult = DllCall($__g_hGDIPDll, "int", "GdipSetPathGradientSurroundColorsWithCount", "handle", $hBrush, "int", $pArgb, "int*", $iCount) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], $aResult[3], $aResult[0] = 0) EndFunc ;==>_GDIPlus_SetPathGradientSurroundColorsWithCount Func _GDIPlus_ClosePathFigure($hPath) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipClosePathFigure", "handle", $hPath) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>_GDIPlus_ClosePathFigure Func __GDIPlus_PathDispose($hPath) Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipDeletePath", "handle", $hPath) If @error Then Return SetError(1, @error, 0) Return SetError($aResult[0], 0, $aResult[0] = 0) EndFunc ;==>__GDIPlus_PathDispose
    7 points
  7. Just a bit of fun because evidently I have too much time on my hands! I'm doing all sorts of bad things to in order to handle note on/off events from the stream - so I wouldn't recommend using that part for any real project. A few days early, but happy new year folks!🎉 HappyNewYear.zip
    7 points
  8. Unsure if this is intended, but as some of you noticed chromedriver now tries to use a random port on opening. You can override that by supplying the desired port number as a parameter -- _WD_Option('DriverParams', '--port=9515 --verbose --log-path="' & @ScriptDir & '\chrome.log"')
    7 points
  9. Hi @TheSaint Here a fast hack how to rotate the image by drawing a line on the edge of the CD cover to give you more flexibility. ;Coded by UEZ 2024-03-16 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $sFile = "cover.jpg" ;FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.gif;*.bmp)") If @error Then Exit Const $fPI = ACos(-1) _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile($sFile), $hImage_rotated Global $aDim = _GDIPlus_ImageGetDimension($hImage) Global Const $hGUI = GUICreate("Image Rotate", $aDim[0], $aDim[1]) Global Const $hDC = _WinAPI_GetDC($hGUI) Global Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $aDim[0], $aDim[1]) Global Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Global Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Global Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) Global Const $hPen = _GDIPlus_PenCreate(0xFFFFFFFF) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, 4) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) GUISetCursor(3, 0, $hGUI) GUISetState() Global $aCI, $c = 0, $x1, $y1, $x2, $y2 Do _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) $aCI = GUIGetCursorInfo($hGUI) If $aCI[2] Then While GUIGetCursorInfo($hGUI)[2] Sleep(1) WEnd $c += 1 Switch $c Case 1 $x1 = $aCI[0] $y1 = $aCI[1] Case 2 $x2 = $aCI[0] $y2 = $aCI[1] EndSwitch EndIf Switch $c Case 1 _GDIPlus_GraphicsDrawLine($hCanvas, $x1, $y1, $aCI[0], $aCI[1], $hPen) Case 2 _GDIPlus_GraphicsDrawLine($hCanvas, $x1, $y1, $x2, $y2, $hPen) EndSwitch _WinAPI_BitBlt($hDC, 0, 0, $aDim[0], $aDim[1], $hDC_backbuffer, 0, 0, $SRCCOPY) If $aCI[3] Then ExitLoop Sleep(10) Until False _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) _GDIPlus_ImageRotate($hImage, 360 - CalculateAngle($x1, $y1, $x2, $y2)) $hImage_rotated = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) ;save result _GDIPlus_GraphicsClear($hCanvas) Do _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage_rotated, 0, 0, $aDim[0], $aDim[1]) _WinAPI_BitBlt($hDC, 0, 0, $aDim[0], $aDim[1], $hDC_backbuffer, 0, 0, $SRCCOPY) Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_ReleaseDC($hGUI, $hDC) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_PenDispose($hPen) _GDIPlus_ImageDispose($hImage) _GDIPlus_ImageDispose($hImage_rotated) _GDIPlus_Shutdown() Func CalculateAngle($x1, $y1, $x2, $y2) Return ATan(($y2 - $y1) / ($x2 - $x1)) * (180 / $fPi) + ($x1 > $x2 ? 180 : ($y1 > $y2 ? 360 : 0)) EndFunc Func _GDIPlus_ImageRotate($hImage, $fDegree) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fDegree = ' & $fDegree & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console Local $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $aDim[0] / 2, $aDim[1] / 2) _GDIPlus_MatrixRotate($hMatrix, $fDegree) _GDIPlus_MatrixTranslate($hMatrix, -$aDim[0] / 2, -$aDim[1] / 2) _GDIPlus_GraphicsSetTransform($hCanvas, $hMatrix) _GDIPlus_MatrixDispose($hMatrix) EndFunc After you have started the script and the image is displayed click (lmb) on the left upper corner of the CD cover move the move the mouse to the right upper corner of the CD cover and press click the lmb again press the right mouse button The image should be rotated according to the angle of x1, y1 and x2, y2. You may add a crop function to get only a desired area of the image. 😉
    7 points
  10. Hi all, I've just been playing with window messages that are sent to win32 controls themselves (rather than to the parent GUI), and it looks like you can do some cool stuff. So I thought I'd share some things that I found interesting. And yeah I know the code probably needs a cleanup - but I figure its good enough to get the point across... Anyway what I have is: while the "lock" checkbox is selected, the buttons behave normally. Otherwise you can drag them around and/or resize them. Because you're essentially dragging the buttons by their "Caption" bar, double clicking will also maximise them. #include <guiConstants.au3> #include <winapi.au3> Global Const $DLGC_BUTTON = 0x2000 Global Const $DLGC_WANTTAB = 0x0002 Global $hGui = GUICreate("", 300, 200) Global $idBtn = GUICtrlCreateButton("Button 1", 4, 4, 80, 80) Global $idBtn2 = GUICtrlCreateButton("Button 2", 90, 4, 80, 80) Global $idLockButtons = GUICtrlCreateCheckbox("Lock Buttons", 200, 20, 80, 20) Global $hCursor = _WinAPI_CopyCursor(_WinAPI_LoadCursor(0, $OCR_CROSS)) Global $hBtnMoveProc = DllCallbackRegister("ButtonMoveProc", "long", "hwnd;uint;wparam;lparam") Global $pBtnMoveProc = DllCallbackGetPtr($hBtnMoveProc) Global $hBtn = GUICtrlGetHandle($idBtn) Global $hBtn2 = GUICtrlGetHandle($idBtn2) Global $pOrigBtnProc = _WinAPI_SetWindowLong($hBtn, $GWL_WNDPROC, $pBtnMoveProc) _WinAPI_SetWindowLong($hBtn2, $GWL_WNDPROC, $pBtnMoveProc) GUISetState() While 1 Local $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $idLockButtons _WinAPI_SetWindowLong($hBtn, $GWL_WNDPROC, (GUICtrlRead($iMsg) = $GUI_CHECKED) ? $pOrigBtnProc : $pBtnMoveProc) _WinAPI_SetWindowLong($hBtn2, $GWL_WNDPROC, (GUICtrlRead($iMsg) = $GUI_CHECKED) ? $pOrigBtnProc : $pBtnMoveProc) Case $idBtn, $idBtn2 ConsoleWrite("Click " & GUICtrlRead($iMsg) & @CRLF) EndSwitch WEnd Func ButtonMoveProc($hWnd, $uMsg, $wParam, $lParam) Local $aPos, $iRet, $aPoint[2], $iSrc, $iEvent Local $aRes = DllCallAddress("long", $pOrigBtnProc, "hwnd", $hWnd, "uint", $uMsg, "wparam", $wParam, "lparam", $lParam) Switch $uMsg Case $WM_NCHITTEST $aPos = WinGetPos($hWnd) $aPoint[0] = BitAND($lParam, 0xFFFF) $aPoint[1] = BitShift($lParam, 16) $iRet = $HTCAPTION If $aPoint[0] - $aPos[0] < 10 Then $iRet = $HTLEFT If $aPoint[0] - $aPos[0] > ($aPos[2] - 10) Then $iRet = $HTRIGHT If $aPoint[1] - $aPos[1] < 10 Then Switch $iRet Case $HTLEFT $iRet = $HTTOPLEFT Case $HTRIGHT $iRet = $HTTOPRIGHT Case Else $iRet = $HTTOP EndSwitch ElseIf $aPoint[1] - $aPos[1] > ($aPos[3] - 10) Then Switch $iRet Case $HTLEFT $iRet = $HTBOTTOMLEFT Case $HTRIGHT $iRet = $HTBOTTOMRIGHT Case Else $iRet = $HTBOTTOM EndSwitch EndIf Return $iRet Case $WM_SETCURSOR $iSrc = BitAND($lParam, 0xFFFF) $iEvent = BitShift($lParam, 16) If $iSrc = $HTCAPTION And $iEvent = $WM_LBUTTONDOWN Then _WinAPI_SetCursor($hCursor) Return True EndIf Case Else EndSwitch Return $aRes[0] ;~ Return _WinAPI_DefWindowProcW($hWnd, $uMsg, $wParam, $lParam) EndFunc ;==>ButtonProc
    6 points
  11. Nine

    x64 bitwise operations

    I needed a very fast x64 unsigned shift right, and doing it through an AutoIt array was way too slow. So I decided to make a .dll to perform such a task. While I was there, why not include all the bitwise operators that I know of. And then why not make a UDF. This is a bit like my wife does, she buys some draperies and then I end up repainting the whole room because the colors do not match anymore. Anyway, hope it can be useful for you too. Let me know if you have enhancements or comments, I will be glad to incorporate them (if possible). Version 2024-12-07 ASM * Code optimization (elimination of redundancy) Version 2024-12-06 ASM Func BitAND64 Func BitOR64 Func BitXOR64 Func BitSHIFT64 Func BitROTATE64 Func BitNOT64 Version 2020-04-27 DLL Func _BitAND64 Func _BitOR64 Func _BitXOR64 Func _BitEQV64 Func _BitIMP64 Func _BitSHIFT64 Func _BitROTATE64 Func _BitNOT64 Func _x64CloseDLL Version 2020-04-27 Util Func _Hex2Dec x64_Ops.zip
    6 points
  12. Hello guys. I just did another OCR wrapper for this nice library. What's AU3-RapidOCR? RapidOCR UDF is a simple wrapper for RapidOCR library. Features. Get Text From Image File. Easy to use. Usage: #include "RapidOCR.au3" _Example() Func _Example() MsgBox(0, "", _RapidOCR_ImageToText(@ScriptDir & "\images\Image1.png")) EndFunc Check RapidOCR UDF on GitHub. Saludos
    6 points
  13. MattyD

    WinRT Object Libraries

    Hi folks, Attached below is one way of attacking WinRT Objects. These are essentially COM objects, however they don't have an IDispatch interface so ObjCreate() cannot be used. It is possible to expose them using ObjCreateInterface though. Alternately, DllCallAddress() may be used to access an object's functions directly from memory. I'm using the latter mainly because that's the path I started down first! To make sense of whats in the attachment... WinRT.au3 - Core high level functions that sit on top of interface libraries Includes Async and Collection implementations etc. So basic high level functionality. WinRTCore.au3 - Internal helper functions for interface libraries Interface Folder - Interface libraries (there are over 850 of these!). Essentially these wrap the functions in an interface's vtable Includes tags which may be used with ObjCreateInterface Enums Folder - Contains map datatypes that can be used to convert enumeration strings to their numeric type, or vice versa Classes Folder - doesn't actually contain code - A class file includes interface and enum files that belong to a class. Namespaces Folder - doesn't actually contain code - A namespace file includes classes that are related. Bonus: I've also uploaded a rudimentary WinRT Class Explorer if it happens to be useful to anyone. Bonus2: I've added a tool that installs/removes calltips for interface libraries. Original post: WinRT Libraries - Latest ClassExplorer.zip
    6 points
  14. Nine

    AutoIt Snippets

    Wonder how to have a progress in your window task bar, here you go : #include <GUIConstantsEx.au3> Global Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}" Global Const $sIID_ITaskbarList3 = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}" Global Const $tagITaskbarList3 = _ "HrInit hresult();" & _ "AddTab hresult(hwnd);" & _ "DeleteTab hresult(hwnd);" & _ "ActivateTab hresult(hwnd);" & _ "SetActiveAlt hresult(hwnd);" & _ "MarkFullscreenWindow hresult(hwnd;boolean);" & _ "SetProgressValue hresult(hwnd;uint64;uint64);" & _ "SetProgressState hresult(hwnd;int);" & _ "RegisterTab hresult(hwnd;hwnd);" & _ "UnregisterTab hresult(hwnd);" & _ "SetTabOrder hresult(hwnd;hwnd);" & _ "SetTabActive hresult(hwnd;hwnd;dword);" & _ "ThumbBarAddButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarUpdateButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarSetImageList hresult(hwnd;ptr);" & _ "SetOverlayIcon hresult(hwnd;ptr;wstr);" & _ "SetThumbnailTooltip hresult(hwnd;wstr);" & _ "SetThumbnailClip hresult(hwnd;ptr);" Example() Func Example() Local $hGUI = GUICreate("AutoIt v3", 400, 100) GUISetState() Local $oTaskBar = TB_Init() For $i = 1 To 100 TB_SetProgress($oTaskBar, $hGUI, $i, 100) Sleep(25) Next TB_Flash($oTaskBar, $hGUI, 4, 300) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example Func TB_Init() Local $oTB = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList3, $tagITaskbarList3) $oTB.HrInit() Return $oTB EndFunc ;==>TB_Init Func TB_SetProgress(ByRef $oTB, $hWnd, $iCurrent, $iCompleted) $oTB.SetProgressValue($hWnd, $iCurrent, $iCompleted) EndFunc ;==>TB_SetProgress Func TB_Flash(ByRef $oTB, $hWnd, $iTimes, $iDelay) For $i = 1 To $iTimes $oTB.SetProgressState($hWnd, 0) Sleep($iDelay) $oTB.SetProgressValue($hWnd, 100, 100) Sleep($iDelay) Next $oTB.SetProgressState($hWnd, 0) EndFunc ;==>TB_Flash
    6 points
  15. jpm

    Struct Notation

    Hi, already fix for next beta/release
    6 points
  16. BIG THANKS to @UEZ for his code, which I adapted, plus adding some of my own. See his post here. I spent quite a while trying to come up with something simple to include in a program of mine. The examples in the Help file didn't quite do it for me, some very complex. Here's an image I needed to rotate by 1 degree right, and then trim and resize, for embedding into my FLAC and MP3 files for that album. The image was sourced from eBay, as alas Discogs let me down. Admittedly the album title wasn't very helpful, and there are two other volumes, though I only have the first one. Anyway, I have provided the image, so you can test and play around with it. #include <GDIPlus.au3> ; BIG THANKS to UEZ ; I modified his example from - https://www.autoitscript.com/forum/topic/155932-gdiplus-need-help-with-rotating-an-image/?do=findComment&comment=1127106 Global $hBackbuffer, $hBitmap, $hBitmap_Scaled, $hClone, $hCoverBitmap, $hCoverGC, $hCoverMatrix, $hCoverTexture, $hGraphic, $iH, $inifile, $iW, $newfile, $sCLSID $inifile = @ScriptDir & "\Settings.ini" $newfile = @ScriptDir & "\rotated.jpg" If FileExists($newfile) Then FileDelete($newfile) _GDIPlus_Startup() $hCoverTexture = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\cover.jpg") $iW = _GDIPlus_ImageGetWidth($hCoverTexture) $iH = _GDIPlus_ImageGetHeight($hCoverTexture) $iW = $iW / 2 $iH = $iH / 2 $hBitmap_Scaled = _GDIPlus_ImageResize($hCoverTexture, $iW, $iH, 5) Global $hGUI = GUICreate("", $iW, $iH) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hGraphic) $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) $hCoverBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $hBackbuffer) $hCoverGC = _GDIPlus_ImageGetGraphicsContext($hCoverBitmap) $hCoverMatrix = _GDIPlus_MatrixCreate() Rotate() Sleep(1000) Local $crop = 1, $resize = 1, $trim If $crop = 1 Then Local $lft = IniRead($inifile, "Image Crop", "left", 0) Local $tp = IniRead($inifile, "Image Crop", "top", 0) Local $wd = IniRead($inifile, "Image Crop", "width", $iW) Local $ht = IniRead($inifile, "Image Crop", "height", $iH) Local $size = $lft & "_" & $tp & "_" & $wd & "_" & $ht ; $trim = InputBox("Crop Query", "Please set the desired values." & @LF & @LF & "Left_Top_Width_Height", $size, "", 200, 160, Default, Default) If @error = 0 Then $trim = StringSplit($trim, "_", 1) If $trim[0] = 4 Then $lft = $trim[1] $tp = $trim[2] $wd = $trim[3] $ht = $trim[4] IniWrite($inifile, "Image Crop", "left", $lft) IniWrite($inifile, "Image Crop", "top", $tp) IniWrite($inifile, "Image Crop", "width", $wd) IniWrite($inifile, "Image Crop", "height", $ht) If $wd < 1 Then $wd = $iW EndIf If $ht < 1 Then $ht = $iH EndIf If $lft < 1 Then $lft = 0 EndIf If $tp < 1 Then $tp = 0 EndIf $wd = $wd - $lft $ht = $ht - $tp ; 188_55_630_496 $hClone = _GDIPlus_BitmapCloneArea($hBitmap, $lft, $tp, $wd, $ht, $GDIP_PXF24RGB) Else MsgBox(262192, "Crop Error", "Wrong number of values specified. 4 required.", 0, $DropboxGUI) EndIf EndIf Else $hClone = "none" EndIf If $resize = 1 Then If $hClone = "none" Then $hClone_Scaled = _GDIPlus_ImageResize($hBitmap, 600, 600, 5) Else $hClone_Scaled = _GDIPlus_ImageResize($hClone, 600, 600, 5) EndIf Else $hClone_Scaled = $hBitmap EndIf $sCLSID = _GDIPlus_EncodersGetCLSID("JPG") _GDIPlus_ImageSaveToFileEx($hClone_Scaled, $newfile, $sCLSID) If FileExists($newfile) Then ShellExecute($newfile) GUIDelete($hGUI) _GDIPlus_BitmapDispose($hBitmap_Scaled) _GDIPlus_BitmapDispose($hClone_Scaled) If $hClone <> "none" Then _GDIPlus_ImageDispose($hClone) _GDIPlus_MatrixDispose($hCoverMatrix) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_GraphicsDispose($hCoverGC) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_BitmapDispose($hCoverBitmap) _GDIPlus_BitmapDispose($hCoverTexture) _GDIPlus_ImageDispose($hBackbuffer) _GDIPlus_Shutdown() Exit Func Rotate() _GDIPlus_GraphicsClear($hBackbuffer, 0xFF6495ED) _GDIPlus_MatrixTranslate($hCoverMatrix, 0, 0) ; move it back to 0, 0 since (112 / 2) and (37 / 2) are it's middle origin point _GDIPlus_MatrixRotate($hCoverMatrix, 1) ; rotate it around it's middle origin point (minus to rotate left) _GDIPlus_GraphicsSetTransform($hCoverGC, $hCoverMatrix) _GDIPlus_MatrixTranslate($hCoverMatrix, 0, 0) _GDIPlus_GraphicsClear($hCoverGC, 0xFFFFFFFF) ; show the GC _GDIPlus_GraphicsDrawImageRect($hCoverGC, $hCoverTexture, 0, 0, $iW, $iH) ; place the arrow at the center of it's GC _GDIPlus_GraphicsDrawImage($hBackbuffer, $hCoverBitmap, 0, 0) ; move it's GC by an offset so the image is at the correct XY using it's origin _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $iW, $iH) EndFunc Resulting image. Enjoy! P.S. I should have probably removed the comments by UEZ in the Rotate function, especially as I changed it to not rotate around the center. Some of the code in that function is likely redundant too, because of that change.
    6 points
  17. So another vscode extension for the AutoIt language emerges! I've tried the existing ones, and found small problems that i felt i could improve on, but it would require an entire new approach to the inner working of the existing extensions. Also working on a complete AutoIt3 parser a vscode extension just made sense Any feedback is appreciated, and i hope this project will benefit more than just me 🤡 Visual Studio Code Marketplace GitHub repo Some of the current features: Basic AutoIt2 syntax highlighting, for fun 🤡 AutoIt3 syntax highlighting Variable/Function hover gives declaration information if available. Goto declaration #include links Syntax checking, as you type Function signature help Function and variable list in a file via the outline tab. Works on desktop (any OS) and web version ⚠️ The parser used is not yet 100% complete (see issues for know problems), and the last thing to be implemented is the With code block. Hope you like 😃
    5 points
  18. Version 1.8.2 has just been released! I should have been 1.8.0, but issues with deployment pipeline after bigger changes to how the parser code and types are generated (internally) meant that i had to increment patch version 2 times, to successfully be able to release to the extension marketplaces. Notable changes: Added au3 DocBlock `@link` tag support Added syntax highlighting for au3 DocBlock and legacy UDF headers 2 things i would like feedback on, if possible: About the new syntax highlighting: Let me know if and/or how you like or dislike it. Performance: small changes to how the parser worked with some parser rules, to better generate types. Smaller tests indicated it was same or faster, but it can very much depend how it traverses through the code. Let me know if you notice any slow down, so I can look into fixing it ASAP! Feedback can be here, via an issue or via the discussion for the release.
    5 points
  19. I am getting ready to publish a production update for SciTE4AutoI3, so have a SciTE4AutoIt3 v25.205.1420.0 release candidate ready and uploaded to Beta for those willing to test this installer before releasing it. Would appreciate hearing whether there are still issues with it as it has been a major overhaul since the last production version back in 2021. My main drives at this moment are to get the setup ready for better supporting Visual Studio Code as the default editor for AutoIt3, as I am convinced that there is an added benefit using VSC over SciTE. I have no intent to drop the SciTE upgrades, but do prefer to stop development & support of all the written LUA script functionalities. This is a list of the current changes at a high level: SciTE updated from v4.4.6 to v5.5.4 and includes both the x86 and x64 version selectable at install time Include the major LUA changes for Dynamic add Variables & Functions & #Include functionality. See here for details. This can be Simply disabled when old behavior is preferred by settings dynamic.include=n Utilities (Tidy.exe/au3Stripper/Au3check) can now process mixed encoded files and special characters in the filenames, so they do not require AutoIt3Wrappper anymore. The Included au3check v3.3.17.1 is an update of the standard latest au3check v3.3.16.1 included in the AutoIt3 installer. The new au3check now also supports mixed encoded files and special characters in the filenames and can be used without AutoIt3Wrapper for those cases. The installer will check the current version and replace it with this version when it is < v3.3.17.1. A copy of the old version will be made to AutoIt3\SciTE\Au3Check The installer will prompt for SciTE.exe x86 or x64 version Whether you want to change to VSCode as your default Editor for the "Edit" & "Open" options for AU3 files. What to do with Double Click, either Open or Run with AutoIt3. (also an option to change in SciTE Config) For those few that are currently using the Dynamic Beta version: There are a few minor changes since the last version published: AutoComplete #include lines wasn't working when dynamic.include=n was set. I have added the option to limited the number of entries shown in the AutoComplete dropdown to make it much more responsive when e.g. typing $a : # Define the max entries is a Variable/Func dropdown autocomplete list for speed reasons. autocomplete_dropdown_max=200
    5 points
  20. Let's not make this topic more difficult than it is and stick for now to VSCode/SciTE. One can always decide to go down an alternative path later when VSCode is working.
    5 points
  21. 5 points
  22. BinaryBrother

    RustDesk UDF

    Here it is. ; #CURRENT# ===================================================================================================================== ; _RustDesk_Config ; _RustDesk_DebugEnable ; _RustDesk_Deploy ; _RustDesk_GenerateRandomPassword ; _RustDesk_GetID ; _RustDesk_GetLatestVersion ; _RustDesk_GetLocalVersion ; _TustDesk_isInstalled ; _RustDesk_SetPassword ; _RustDesk_Start ; =============================================================================================================================== Update: 1/10/25 - Added _RustDesk_Config() for those who need to configure a custom relay. Update: 1/23/25 - Overhauled some portions of the code with redundancy and timers. Update: 1/26/25 - Inched closer to UDF-Spec and added Constants. Update: 1/27/25 - Finished UDF-Spec Update: 2/4/2025 - Disregard nightly builds for the download. Current.zip
    5 points
  23. I modified one of my old script from 2014: ;Coded by UEZ #include <GUIConstantsEx.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172 Global Const $hGUI = GUICreate("GDI+ Test", 200, 100) GUISetBkColor(0x505050) Global Const $iPicBtn = GUICtrlCreatePic("", 50, 28, 100, 44) Global $aButtons = _GDIPlus_BitmapCreateRoundedButtonAndText("install", 100, 44) _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) GUISetState() Global $aMouseInfo, $bShow = False, $bHide = False Do If WinActive($hGUI) Then $aMouseInfo = GUIGetCursorInfo($hGUI) ;hover simulation Switch $aMouseInfo[4] Case $iPicBtn _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[1])) $bShow = True $bHide = False Case Else _WinAPI_DeleteObject(GUICtrlSendMsg($iPicBtn, $STM_SETIMAGE, $IMAGE_BITMAP, $aButtons[0])) $bHide = True $bShow = False EndSwitch EndIf Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($aButtons[0]) _WinAPI_DeleteObject($aButtons[1]) _GDIPlus_Shutdown() Exit Case $iPicBtn MsgBox(0, "Information", "Button pressed") EndSwitch Until False ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GDIPlus_BitmapCreateRoundedButtonAndText ; Description ...: Draw rounded button ; Syntax ........: _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight[, $iBgColor = 0xFF1BA0E1[, $iFontSize = 16[, $sFont = "Times New Roman"[, ; $iHoverColor = 0xFFC9388C[, $iFrameSize = 2[, $iFontFrameColor = 0x408AD5EA[, $iFontColor = 0xFFFFFFFF]]]]]]) ; Parameters ....: $sString - A string value. ; $iWidth - An integer value. ; $iHeight - An integer value. ; $iBgColor - [optional] An integer value. Default is 0xFF1BA0E1. ; $iFontSize - [optional] An integer value. Default is 16. ; $sFont - [optional] A string value. Default is "Times New Roman". ; $iHoverColor - [optional] An integer value. Default is 0xFFC9388C. ; $iFrameSize - [optional] An integer value. Default is 2. ; $iFontFrameColor - [optional] An integer value. Default is 0x408AD5EA. ; $iFontColor - [optional] An integer value. Default is 0xFFFFFFFF. ; Return values .: an array with 2 GDI bitmap handles -> [0]: default button, [1]: hover button ; Author ........: UEZ ; Version .......: 0.85 build 2025-01-12 ; Modified ......: ; Remarks .......: Dispose returned GDI bitmap handles when done ; Example .......: Yes ; =============================================================================================================================== Func _GDIPlus_BitmapCreateRoundedButtonAndText($sString, $iWidth, $iHeight, $iBgColor = 0xFF1BA0E1, $iFontSize = 16, $sFont = "Times New Roman", $iHoverColor = 0xF0FFFFFF, $iFrameSize = 2, $iFontFrameColor = 0x408AD5EA, $iFontColor = 0xFFFFFFFF) ;some checks If $sString = "" Then Return SetError(1, 0, 0) If Int($iWidth) < $iFrameSize * 2 Then Return SetError(2, 0, 0) If Int($iHeight) < $iFrameSize * 2 Then Return SetError(3, 0, 0) ;create font objects Local Const $hFormat = _GDIPlus_StringFormatCreate() Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iWidth, $iHeight) _GDIPlus_StringFormatSetAlign($hFormat, 1) ;center string on X axis _GDIPlus_StringFormatSetLineAlign($hFormat, 1) ;center string on Y axis ;create bitmap and graphics context handles Local Const $aBitmaps[2] = [_GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight), _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)] Local Const $aGfxCtxt[2] = [_GDIPlus_ImageGetGraphicsContext($aBitmaps[0]), _GDIPlus_ImageGetGraphicsContext($aBitmaps[1])] ;set drawing quality _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[0], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt[1], $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt[0], $GDIP_TEXTRENDERINGHINTANTIALIASGRIDFIT) ;define brush and pen objects Local Const $hBrushFontColor = _GDIPlus_BrushCreateSolid($iFontColor) ;, $hBrushBGColor = _GDIPlus_BrushCreateSolid($iBgColor) Local Const $hPenFontFrameColor = _GDIPlus_PenCreate($iFontFrameColor, $iFrameSize), $hPenHoverColor = _GDIPlus_PenCreate($iHoverColor, $iFrameSize) ;create path object Local Const $hPath = _GDIPlus_PathCreate() ;create cloned path object for string measurement Local Const $hPath_Dummy = _GDIPlus_PathClone($hPath) _GDIPlus_PathAddString($hPath_Dummy, $sString, $tLayout, $hFamily, 0, $iFontSize, $hFormat) _GDIPlus_PathStartFigure($hPath) Local $fArcSize = $iWidth * 0.33333 _GDIPlus_PathAddArc($hPath, $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, 180, -90) ;BR _GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iHeight - $fArcSize - $iFrameSize, $fArcSize, $fArcSize, -270, -90) ;BL _GDIPlus_PathAddArc($hPath, $iWidth - $fArcSize - $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, 0, -90) ;TR _GDIPlus_PathAddArc($hPath, $iFrameSize, $iFrameSize, $fArcSize, $fArcSize, -90, -90) ;TL _GDIPlus_PathCloseFigure($hPath) Local Const $hPath_Clone = _GDIPlus_PathClone($hPath) Local Const $hBrushBGColor = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetSurroundColor($hBrushBGColor, $iBgColor) _GDIPlus_PathBrushSetCenterColor($hBrushBGColor, 0xFFFFFFFF) _GDIPlus_PathBrushSetCenterPoint($hBrushBGColor, $iWidth / 2, $iHeight / 2) _GDIPlus_PathBrushSetSigmaBlend($hBrushBGColor, 1, 0.33333) _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushBGColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) _GDIPlus_PathReset($hPath) ;add string to path _GDIPlus_PathAddString($hPath, $sString, $tLayout, $hFamily, 1, $iFontSize, $hFormat) ;clear bitmap and draw string _GDIPlus_GraphicsFillPath($aGfxCtxt[0], $hPath, $hBrushFontColor) _GDIPlus_GraphicsDrawPath($aGfxCtxt[0], $hPath, $hPenFontFrameColor) ;draw rectangle on cloned bitmap for hover effect _GDIPlus_GraphicsDrawImageRect($aGfxCtxt[1], $aBitmaps[0], 0, 0, $iWidth, $iHeight) _GDIPlus_GraphicsDrawPath($aGfxCtxt[1], $hPath_Clone, $hPenHoverColor) ;dispose object resources _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_PathDispose($hPath) _GDIPlus_PathDispose($hPath_Dummy) _GDIPlus_PathDispose($hPath_Clone) _GDIPlus_GraphicsDispose($aGfxCtxt[0]) _GDIPlus_GraphicsDispose($aGfxCtxt[1]) _GDIPlus_BrushDispose($hBrushFontColor) _GDIPlus_BrushDispose($hBrushBGColor) _GDIPlus_PenDispose($hPenFontFrameColor) _GDIPlus_PenDispose($hPenHoverColor) ;create GDI bitmap for later usage Local $aHBitmaps[2] = [_GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[0]), _GDIPlus_BitmapCreateHBITMAPFromBitmap($aBitmaps[1])] ;dispose GDI+ bitmaps _GDIPlus_BitmapDispose($aBitmaps[0]) _GDIPlus_BitmapDispose($aBitmaps[1]) Return $aHBitmaps EndFunc ;==>_GDIPlus_BitmapCreateRoundedButtonAndText
    5 points
  24. The example: The UDFish: The back story: I put together "Win 11 - My own border color" and looking at the logs I've found that I had a handle leak. The leak got fixed but I wanted ( out of OCD ? ) to have the script report on it's status. Ok, easy enough, I'll IPC the request. But I don't wanna have it in the main loop, constantly asking "are we there yet ?, are we there yet ?, ..." . I could not find a copy'n'paste UDF, that did that I wanted to have, so I had to code it 🥲 Now you can copy'n'paste it How does it work: When WM_COPYDATA gets a message, it puts the data in a global array that gets accessed by any user function triggered by AdlibRegister() after X mSec. You can set the AdlibRegister() time with WMCDIPC_AdlibTime(). Without a parameter it will return the current value. Can set the user function with WMCDIPC_AdlibFunc()**. Without a parameter it will return the current value. The UDF has notes that will hint it's use. Hope you find it useful. Edit: This is v2.0 ( yey ! ) ** there now is a WMCDIPC_AdlibRegister(func,time) that can do that too. This version allows running all Au3Stripper arguments, so that's good. Added WMCDIPC_PrintCallback() to handle the one line of debug in the UDF. Also added a return in case the script is already busy running in Adlib, therefore unable to process the IPC request right there and then. The int return is "0xFADE" and the string has how many mSec it's been busy. Giving the user a chance to know it "FADEd away" and formulate a resend or what not. Since is a new version, added WMCDIPC_Version(), just in case of a future one. But all in all, I think that this UDF is complete and needs no other functionality for the scenario it would be used at. Edit: This is v2.1 ( wow ! ) Added in the loop. Why ?. Well, the project that I wrote this for is GUIOnEventMode=1. Having the "are we there yet ?" is much slower given that a long Sleep() is common in that option. But the example I posted is GUIOnEventMode=0. It does use GUIGetMsg() to handle messages and CPU usage so, why not have the trigger right there. So that's what I added in this version. And obviously responds much faster than scheduling an Adlib. Edit: ..and this is v2.1.1 ( child proofing ? ) I was thinking that it would be nice to tell, the new to this UDF, that a set of choices would not work ( not as extreme as in MsgBox_Extn() but, something ). Also to run ControlViewer just in case of an "oops". where you can select a script, press DEL, and process close it, if something went wrong. ( and I use it a lot ) So there: for all those that should be sleeping at 3 AM but want to code and screw up, because the brain is sleeping regardless of will.
    5 points
  25. Here is a very simple example using the method described earlier by argumentum. Note the use of static variables. Doing it that way prevents the need to define those variables as Global. The example script sets up Ctrl+w and Ctrl+j as hotkeys to show how the method can be used for multiple hotkeys. The payload in each hotkey function will only execute if the hotkey is fired twice within the specified time, which in this case is 500 milliseconds (.5 seconds). Press ESC to exit the example. #include <Constants.au3> #include <Misc.au3> ;Declare constants Const $DOUBLE_CLICK_TIME = 500 ;Declare global vars Global $ghUserDll = DllOpen("user32.dll"), _ $ghCtrlWTimer = TimerInit(), _ $ghCtrlJTimer = TimerInit() ;Set hotkey(s) HotKeySet("^w", do_ctrl_w) HotKeySet("^j", do_ctrl_j) ;Loop until ESC pressed While 1 If _IsPressed("1B", $ghUserDll) then ExitLoop WEnd ;========================================================================== ; These hotkey functions only do something if called twice within a ; specified time ($DOUBLE_CLICK_TIME) ;========================================================================== Func do_ctrl_w() ;Declare vars Static $iPrevTime = 0 Local $iCurrTime = TimerDiff($ghCtrlWTimer) ;If function called twice within specified time If $iCurrTime < ($iPrevTime + $DOUBLE_CLICK_TIME) Then ;Do something MsgBox($MB_ICONINFORMATION, "INFO", "CTRL+W double click occurred.") ;Reset timer $ghCtrlWTimer = TimerInit() EndIf ;Reset previous Time to current time $iPrevTime = TimerDiff($ghCtrlWTimer) EndFunc Func do_ctrl_j() ;Declare vars Static $iPrevTime = 0 Local $iCurrTime = TimerDiff($ghCtrlJTimer) ;If function called twice within specified time If $iCurrTime < ($iPrevTime + $DOUBLE_CLICK_TIME) Then ;Do something MsgBox($MB_ICONINFORMATION, "INFO", "CTRL+J double click occurred.") ;Reset timer $ghCtrlJTimer = TimerInit() EndIf ;Reset previous Time to current time $iPrevTime = TimerDiff($ghCtrlJTimer) EndFunc
    5 points
  26. i found solution here (Thanks to LarsJ ) https://www.autoitscript.com/forum/topic/205154-using-objcreateinterface-and-objectfromtag-functions/ Methods/properties of the description tag string must be in correct Vtable order. (I learned what Vtable is) ; https://www.autoitscript.com/forum/topic/212211-solved-setthumbnailtooltip #include <GUIConstantsEx.au3> $hGUI = GUICreate("AutoIt v3", 400, 100) GUISetState() _SetThumbnailTooltip($hGUI, "AutoIt v3" & @CRLF & "including a line breaker" & @CRLF & "in gui ThumbnailTooltip") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) Func _SetThumbnailTooltip($hWnd, $sText) ; Declare the CLSID, IID, and interface description for ITaskbarList3. Local Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}" Local Const $sIID_ITaskbarList3 = "{ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf}" Local Const $sTagITaskbarList3 = "HrInit hresult();" & _ "AddTab hresult(hwnd);" & _ "DeleteTab hresult(hwnd);" & _ "ActivateTab hresult(hwnd);" & _ "SetActiveAlt hresult(hwnd);" & _ "MarkFullscreenWindow hresult(hwnd;boolean);" & _ "SetProgressValue hresult(hwnd;uint64;uint64);" & _ "SetProgressState hresult(hwnd;int);" & _ "RegisterTab hresult(hwnd;hwnd);" & _ "UnregisterTab hresult(hwnd);" & _ "SetTabOrder hresult(hwnd;hwnd);" & _ "SetTabActive hresult(hwnd;hwnd;dword);" & _ "ThumbBarAddButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarUpdateButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarSetImageList hresult(hwnd;ptr);" & _ "SetOverlayIcon hresult(hwnd;ptr;wstr);" & _ "SetThumbnailTooltip hresult(hwnd;wstr);" & _ "SetThumbnailClip hresult(hwnd;ptr);" ; Create the object. Local $oTB = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList3, $sTagITaskbarList3) ; Initialize the iTaskbarList3 object. $oTB.HrInit() ; Attempt to set the tooltip for the taskbar thumbnail $oTB.SetThumbnailTooltip($hWnd, $sText) EndFunc ;==>_SetThumbnailTooltip
    5 points
  27. Added the ability to load a custom CSS file where you can change the look of help pages as you would with any html file displaying in Internet Explorer. Also, all external links open in your default browser. This area is to share your CSS coloring or report a problem with the file. Examples of how it could look are: Buuf: Dark: Light ( default ) or just forego all themes and use High Contrast in the OS The general idea is that is your PC. Make it look as you wish The file is in the file downloads area. Replace the v3.3.16.1 CHM with the one in the ZIP along with the CSS file of your choosing to the same folder the CHM is at.
    5 points
  28. @Melba23 & @Nine Deleting the menu control seems to do the job. It will position to the very left of the GUI all existing menuitem(s) control(s) . Does this work for you ? #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $Form1 = GUICreate("Form1", 615, 437, 192, 124) $mDummymenu = GUICtrlCreateMenu("this menu control will be deleted") $menu1 = GUICtrlCreateMenuItem("click me", -1) $menu2 = GUICtrlCreateMenuItem("click me again", -1) GUICtrlDelete($mDummymenu) ; <====================== GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $menu1 MsgBox($MB_TOPMOST ,'yes!', 'it works') Case $menu2 MsgBox($MB_TOPMOST,'yes!', 'it works again') EndSwitch WEnd
    5 points
  29. If you want the text scrolling to continue even when you drag the GUI or even when an MsgBox() is in action, you can use _WinAPI_SetTimer instead of AdlibRegister, as in this slightly modified version of your script. ... But if you don't care, then forget it ... #include <GUIConstants.au3> #include <WinAPISysWin.au3> $guiWidth = 300 $hGUI = GUICreate("Main GUI", $guiWidth, 70) $sString = "This is a long string that scrolls smoothly and infinitely in a short label control." ; Create a child GUI for scrolling label $iMargin = 10 $sGap = " " $iLabelWidth = $guiWidth - $iMargin * 2 $hChildGUI = GUICreate("", $iLabelWidth, 20, 10, 10, $WS_CHILD, -1, $hGUI) GUISetFont(12, 400, 0, "Arial") ; Create a label wide enough to hold a long string without truncation $idLabel = GUICtrlCreateLabel($sString, 0, 0, 2000, 20, BitOR($SS_NOPREFIX, $SS_LEFTNOWORDWRAP)) ; Get the string width $tmpLabel = GUICtrlCreateLabel($sString, 0, 0, -1, 20, BitOR($SS_NOPREFIX, $SS_LEFTNOWORDWRAP)) $iStringWidth = ControlGetPos($hChildGUI, "", $tmpLabel)[2] - 9 ; Label is wider than the string width by 9 pixels GUICtrlDelete($tmpLabel) GUISetState(@SW_SHOW, $hGUI) GUISetState(@SW_SHOW, $hChildGUI) ; Update the label data if the string width is larger than the label width If $iStringWidth > $iLabelWidth Then GUICtrlSetData($idLabel, $sString & $sGap & $sString) $iScrollPos = 0 $iMarquee = 0 $iScrollDelay = 40 ; AdlibRegister("_Marquee", $iScrollDelay) ; -- setup timer-- Local $hTimerProc = DllCallbackRegister('_Marquee', 'none', 'hwnd;uint;uint_ptr;dword') Local $iTimerID = _WinAPI_SetTimer(0, 0, $iScrollDelay, DllCallbackGetPtr($hTimerProc)) ; ---------------- EndIf MsgBox(64, "Info", "text scrolls") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; -- clean timer-- _WinAPI_KillTimer(0, $iTimerID) DllCallbackFree($hTimerProc) ; ---------------- Func _Marquee($hWnd, $iMsg, $iTimerID, $iTime) #forceref $hWnd, $iMsg, $iTimerID, $iTime $iMarquee += 1 If $iMarquee < 3000 / $iScrollDelay Then Return ; 3 seconds of halt when $sString comes to the initial position $iScrollPos -= 1 If - $iScrollPos = $iStringWidth + StringLen($sGap) * 4 Then ; Initialize the $idLabel's position $iMarquee = 0 $iScrollPos = 0 EndIf GUICtrlSetPos($idLabel, $iScrollPos, 0) EndFunc ;==>_Marquee
    4 points
  30. Hi everybody This script displays a big MessageBox having a height higher than @DesktopHeight While the MessageBox is displayed, you can "navigate" inside it like this : * Mouse Left-click drag : to move the window up and down (displaying a new panel of lines) * Mouse Right-click : to display the window at its initial position * Up key * Down key * PageUp Key (Fn + up key on some laptops) * PageDown Key (Fn + down key on some laptops) * Home Key (Fn + left key on some laptops) * End Key (Fn + right key on some laptops) The 6 keyboard keys allow to navigate inside the window. Click on a button (placed at top of the window) to make your choice. All this could have been scripted more easily using a GUI, an Edit control containing the text to display, plus the buttons to choose from, but I just wanted to try it using a native MessageBox #include <APISysConstants.au3> ; $GCL_HCURSOR #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WinAPIRes.au3> ; _WinAPI_LoadCursor() #include <WinAPISysWin.au3> ; _WinAPI_SetClassLongEx() #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Opt("GUICloseOnESC", 0) ;1=ESC closes (default), 0=ESC won't close Global $g_hGUI, $g_hDLL = DllOpen("user32.dll") Global $g_aCaption, $g_sTitle Example() ;=========================================== Func Example() $g_hGUI = GUICreate("Big MsgBox example (7b)", 400, 200) GUICtrlCreateLabel("Number of lines in MsgBox (2 - 1588)", 10, 20, 180, 20, $SS_SUNKEN) Local $idNbLines = GUICtrlCreateInput("200", 200, 20, 35, 20, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER)), $iNbLines GUICtrlSetLimit($idNbLines, 4) Local $idMsgBox = GUICtrlCreateButton("Big MsgBox", 10, 60, 100, 25, $BS_DEFPUSHBUTTON) Local $idExit = GUICtrlCreateButton("Exit", 10, 110, 100, 25) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idExit ExitLoop Case $idMsgBox Local $iRet = Prepare_MsgBox(GUICtrlRead($idNbLines)) If $iRet Then MsgBox($MB_TOPMOST, "Big MsgBox return value : " & $iRet, Retrieve_Caption($iRet), 0, $g_hGUI) GUICtrlSetState($idNbLines, $GUI_FOCUS) EndSwitch WEnd DllClose($g_hDLL) EndFunc ;==>Example ;=========================================== Func Prepare_MsgBox(Const $iNbLines) If $iNbLines < 2 Or $iNbLines > 1588 Then MsgBox($MB_TOPMOST, "Error", "Enter a number of lines between 2 and 1588", 0, $g_hGUI) Return ; 0 EndIf Local $sTxt = "Line 1 : first line" & @crlf For $i = 2 To $iNbLines - 1 $sTxt &= "Line " & $i & @crlf Next $sTxt &= "Line " & $iNbLines & " : last line" Dim $g_aCaption[3][3] = [ ["Cancel"], ["Try Again"], ["Continue"] ] ; 1st column = button caption, 2nd = button handle, 3rd = button ID $g_sTitle = "MsgBox with 3 buttons" Local $iChoice = _MsgBox(BitOr($MB_CANCELTRYCONTINUE, $MB_TOPMOST), $g_sTitle, $sTxt, 0, $g_hGUI) ;~ Dim $g_aCaption[2][3] = [ ["Yes"], ["No"] ] ;~ $g_sTitle = "MsgBox with 2 buttons" ;~ Local $iChoice = _MsgBox(BitOr($MB_YESNO, $MB_TOPMOST), $g_sTitle, $sTxt, 0, $g_hGUI) ;~ Dim $g_aCaption[1][3] = [ ["Hello"] ] ;~ $g_sTitle = "MsgBox with 1 button" ;~ Local $iChoice = _MsgBox(BitOr($MB_OK, $MB_TOPMOST), $g_sTitle, $sTxt, 0, $g_hGUI) Return $iChoice EndFunc ;==>Prepare_MsgBox ;=========================================== Func _MsgBox($iFlag, $g_sTitle, $sText, $iTimeOut = 0, $hWnd = 0) GUIRegisterMsg($WM_HELP , "WM_HELP") Local $hTimerProc = DllCallbackRegister('_MsgBoxTimerProc', 'none', 'hwnd;uint;uint_ptr;dword') Local $iTimerID = _WinAPI_SetTimer(0, 0, 10, DllCallbackGetPtr($hTimerProc)) Local $iChoice = MsgBox($iFlag, $g_sTitle, $sText, $iTimeOut, $hWnd) _WinAPI_KillTimer(0, $iTimerID) DllCallbackFree($hTimerProc) GUIRegisterMsg($WM_HELP, "") Return $iChoice EndFunc ;==>_MsgBox ;=========================================== Func _MsgBoxTimerProc($hWnd, $iMsg, $iTimerID, $iTime) If WinExists($g_sTitle) Then _WinAPI_KillTimer(0, $iTimerID) Local $hMsgBox = WinGetHandle($g_sTitle) For $i = 0 To Ubound($g_aCaption) - 1 ControlSetText($hMsgBox, "", "Button" & ($i + 1), $g_aCaption[$i][0]) $g_aCaption[$i][1] = ControlGetHandle($hMsgBox, "", "Button" & ($i + 1)) $g_aCaption[$i][2] = _WinAPI_GetDlgCtrlID($g_aCaption[$i][1]) ; remember OK button ID is 1 ($MB_OKCANCEL) or 2 ($MB_OK) ... ; ... msdn "If a message box has a Cancel button, the function returns the IDCANCEL value (2) if either the ESC key is pressed ; or the Cancel button is selected." ; "If the message box has no Cancel button, pressing ESC will no effect - unless an MB_OK button is present. ; If an MB_OK button is displayed and the user presses ESC, the return value will be IDOK (1)" [personal: only one case for this] Next Local $aPosMsgBox = WinGetPos($hMsgBox) Local $bTooHigh = ($aPosMsgBox[3] > @DesktopHeight + 15) ? True : False If $bTooHigh Then Local $aPosButton, $aPosStatic = ControlGetPos($hMsgBox, "", "Static1") ; the text area For $i = 0 To Ubound($g_aCaption) - 1 $aPosButton = ControlGetPos($hMsgBox, "", "Button" & ($i + 1)) WinMove($g_aCaption[$i][1], "", $aPosButton[0], $aPosStatic[1]) Next WinMove(ControlGetHandle($hMsgBox, "", "Static1"), "", $aPosStatic[0], $aPosStatic[1] + $aPosButton[3] + 10) _WinAPI_RedrawWindow($hMsgBox) ; +++ Send("{F1}") ; => Func WM_HELP EndIf EndIf EndFunc ;==>_MsgBoxTimerProc ;============================================== Func WM_HELP($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam If WinExists($g_sTitle) Then ; MessageBox window always exists at this stage Local $hMsgBox = WinGetHandle($g_sTitle) Local $aPosMsgBox = WinGetPos($hMsgBox), $aPosMsgBox_Init = $aPosMsgBox Local $aWinPos, $aMPos, $aMPosOld Local $hCursor = _WinAPI_LoadCursor(0, $OCR_SIZEALL) ; $OCR_SIZENS ok too Local $iPrev = _WinAPI_SetClassLongEx($hMsgBox, $GCL_HCURSOR, $hCursor) ; see "147c.au3" _ClearBuffer("0D") ; Enter key (in case pressed too long on button 'Big MsgBox' in main GUI, so it won't select a button in MsgBox) While 1 If WinActive($hMsgBox) Then Select Case _IsPressed("01", $g_hDLL) ; "01" = Left mouse button $aMPosOld = MouseGetPos() While _IsPressed("01", $g_hDLL) $aMPos = MouseGetPos() If $aMPos[1] <> $aMPosOld[1] Then $aWinpos = WinGetPos($hMsgBox) If ($aMPos[0] - 1 > $aWinpos[0]) And ($aMPos[0] + 1 < $aWinpos[0] + $aWinpos[2]) Then WinMove($hMsgBox, "", Default, $aWinpos[1] + ($aMPos[1] - $aMPosOld[1])) $aMPosOld = $aMPos EndIf EndIf Sleep(10) Wend Case _IsPressed("02", $g_hDLL) ; Right mouse button WinMove($hMsgBox, "", $aPosMsgBox_Init[0], $aPosMsgBox_Init[1]) Case _IsPressed("09", $g_hDLL) ; Tab key _ClearBuffer("09") _ChangeFocus($hMsgBox, "09") Case _IsPressed("0D", $g_hDLL) ; Enter key _ClearBuffer("0D") ControlClick($hMsgBox, "", ControlGetFocus($hMsgBox)) Case _IsPressed("1B", $g_hDLL) ; Esc key _ClearBuffer("1B") For $i = 0 To Ubound($g_aCaption) - 1 If $g_aCaption[$i][2] = 2 Then ; Cancel button (or OK button when alone : see msdn notes above) ControlClick($hMsgBox, "", $g_aCaption[$i][2]) EndIf Next Case _IsPressed("21", $g_hDLL) ; PageUp Key (Fn + up key on most laptops) _ClearBuffer("21") $aPosMsgBox = WinGetPos($hMsgBox) WinMove( $hMsgBox, "", Default, ($aPosMsgBox[1] + @DesktopHeight > 0) ? 0 : $aPosMsgBox[1] + @DesktopHeight ) Case _IsPressed("22", $g_hDLL) ; PageDown Key (Fn + down key on most laptops) _ClearBuffer("22") $aPosMsgBox = WinGetPos($hMsgBox) WinMove( $hMsgBox, "", Default, _ ($aPosMsgBox[3] + $aPosMsgBox[1] - @DesktopHeight < @DesktopHeight + 15) ? @DesktopHeight - $aPosMsgBox[3] : $aPosMsgBox[1] - @DesktopHeight ) Case _IsPressed("23", $g_hDLL) ; End Key (Fn + right key on most laptops) $aPosMsgBox = WinGetPos($hMsgBox) WinMove($hMsgBox, "", Default, @DesktopHeight - $aPosMsgBox[3]) Case _IsPressed("24", $g_hDLL) ; Home Key (Fn + left key on most laptops) WinMove($hMsgBox, "", Default, 0) Case _IsPressed("25", $g_hDLL) ; Left key _ClearBuffer("25") _ChangeFocus($hMsgBox, "25") Case _IsPressed("26", $g_hDLL) ; Up Key $aPosMsgBox = WinGetPos($hMsgBox) WinMove($hMsgBox, "", Default, ($aPosMsgBox[1] + 12 > 0) ? 0 : $aPosMsgBox[1] + 12) Case _IsPressed("27", $g_hDLL) ; Right key _ClearBuffer("27") _ChangeFocus($hMsgBox, "27") Case _IsPressed("28", $g_hDLL) ; Down Key $aPosMsgBox = WinGetPos($hMsgBox) WinMove( $hMsgBox, "", Default, _ ($aPosMsgBox[3] + $aPosMsgBox[1] - 12 < @DesktopHeight) ? @DesktopHeight - $aPosMsgBox[3] : $aPosMsgBox[1] - 12 ) EndSelect EndIf If Not BitAND(WinGetState($hMsgBox), $WIN_STATE_VISIBLE) Then ; one of MsgBox buttons was chosen by user ExitLoop EndIf Sleep(10) WEnd _WinAPI_SetClassLongEx($hMsgBox, $GCL_HCURSOR, $iPrev) ; needed, or cursor $OCR_SIZEALL will show... in final MsgBox from main loop EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_HELP ;============================================== Func _ClearBuffer($sKey) While _IsPressed($sKey, $g_hDLL) Sleep(10) Wend EndFunc ;==>_ClearBuffer ;============================================== Func _ChangeFocus($hMsgBox, $sKey) Local $iCtrlGetFocus, $iCtrlSetFocus, $iStyle $iCtrlGetFocus = StringRight(ControlGetFocus($hMsgBox), 1) ; 1/2/3 (last char of "Button1"/"Button2"/"Button3") If $sKey = "27" Or $sKey = "09" Then ; Right key (27) or Tab (09) $iCtrlSetFocus = $iCtrlGetFocus < Ubound($g_aCaption) ? $iCtrlGetFocus + 1 : 1 Else ; Left key (25) $iCtrlSetFocus = $iCtrlGetFocus > 1 ? $iCtrlGetFocus - 1 : Ubound($g_aCaption) EndIf ControlFocus($hMsgBox, "", "Button" & $iCtrlSetFocus) $iStyle = _WinAPI_GetWindowLong($g_aCaption[$iCtrlGetFocus - 1][1], $GWL_STYLE) _WinAPI_SetWindowLong($g_aCaption[$iCtrlGetFocus - 1][1], $GWL_STYLE, BitXOR($iStyle, $BS_DEFPUSHBUTTON)) $iStyle = _WinAPI_GetWindowLong($g_aCaption[$iCtrlSetFocus - 1][1], $GWL_STYLE) _WinAPI_SetWindowLong($g_aCaption[$iCtrlSetFocus - 1][1], $GWL_STYLE, BitOR($iStyle, $BS_DEFPUSHBUTTON)) EndFunc ;==>_ChangeFocus ;=========================================== Func Retrieve_Caption($iRet) If Ubound($g_aCaption) = 1 Then ; $MB_OK Return $g_aCaption[0][0] Else For $i = 0 To Ubound($g_aCaption) - 1 If $g_aCaption[$i][2] = $iRet Then Return $g_aCaption[$i][0] ; button ID always = $iRet (except for $MB_OK, see note msdn above) Next EndIf MsgBox($MB_TOPMOST, "Warning", "This message should never be displayed", 0, $g_hGUI) EndFunc ;==>Retrieve_Caption Update Feb 24, 2025 : Left key, Right key, Tab, Enter, Spacebar, Esc These 6 keys react now like they do in any MsgBox Feb 27, 2025 : minor correction
    4 points
  31. I guess I'm mixing too many different program languages these days, so goofed up pretty much with that last version. Anyway, it should be fixed with the latest Beta installer containing an update for AutoIt3Wrapper v25.205.1420.2 ... and did test properly this time.
    4 points
  32. Here's a script that does it with the Ctrl + Win + T hotkey. #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_Res_ProductName=WinTogleOnTop.au3 #AutoIt3Wrapper_Res_Description=Togle Window OnTop with 'Ctrl + Win + T' #AutoIt3Wrapper_Res_Fileversion=0.0.0.1 #AutoIt3Wrapper_Icon=WinTogleOnTop.ICO #include <WindowsConstants.au3> #include <WinAPISys.au3> TraySetIcon("WinTogleOnTop.ico") Opt("TrayAutoPause", 0) Global $g_ActWnd HotKeySet("#^t", "Cmd_WinTogleOnTop") ; Ctrl + Win + T" & @CRLF ;********************************** While Sleep(50) _GetActiveWindow() WEnd ;********************************** ;---------------------------------------------------------------------------------------- Func _GetActiveWindow() Local $AnyWindow = WinGetHandle("[ACTIVE]") If $g_ActWnd <> $AnyWindow Then $g_ActWnd = $AnyWindow ;ConsoleWrite("$g_ActWnd=" & $g_ActWnd & "; " & WinGetTitle($g_ActWnd) & @CRLF) EndIf EndFunc ;==>_GetActiveWindow ;---------------------------------------------------------------------------------------- Func Cmd_WinTogleOnTop() Local $iStyle = _WinAPI_GetWindowLong($g_ActWnd, $GWL_EXSTYLE) Local $iStyleTopMost = BitOR($iStyle, $WS_EX_TOPMOST) Local $aWPos = WinGetPos($g_ActWnd) If $iStyle = $iStyleTopMost Then WinSetOnTop($g_ActWnd, "", 0) ToolTip(" ", $aWPos[0], $aWPos[1], "Normal", 1) Else WinSetOnTop($g_ActWnd, "", 1) ToolTip(" ", $aWPos[0], $aWPos[1], "On top", 3) EndIf Sleep(1000) ToolTip("") EndFunc ;==>Cmd_WinTogleOnTop ;----------------------------------------------------------------------------------------
    4 points
  33. argumentum

    WinActiveBorder()

    WinActiveBorder.zip ( Source and icon. You compile your own. ) I draws a border on the active window. A rehash of @careca's code, so don't think too highly of me And is not perfect but, it tends to do what it claims. My happy new year code
    4 points
  34. Cheers Gianni AutoIt x64 was having trouble - So if anyone uses that by default, here's the same code with the DllCalls swapped out for inbult _GDIPlus_* funcs. ; source ; https://autoit.de/thread/17855-led-laufschrift/ ; ; reference for this script (by Eukalyptus): ; https://autoit.de/thread/17855-led-laufschrift/?postID=140164#post140164 #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GDIPlusConstants.au3> ; #include "LEDTXT.au3" ; (by Eukalyptus) already embedded here below Local $sText1 = "Hello friends! ☺ best wishes for a happy holiday and a happy new year (me)" Local $sText2 = "Let us greet together this new year that ages our friendship without aging our hearts. (Victor Hugo)" Local $sText3 = "The best time to plant a tree was 20 years ago. The second best time is now. (Chinese proverb)" Local $sText4 = "The future belongs to those who believe in the beauty of their dreams. (Eleanor Roosevelt)" Local $sText5 = "In the end, what matters is not the years of your life, but the life you put into those years. (Abraham Lincoln)" HotKeySet("{ESC}", "_Exit") _GDIPlus_Startup() $hGuiTrans = GUICreate("", @DesktopWidth, 300, 0, 0, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hGuiTrans, 0xABCDEF) GUISetState() $hGui = GUICreate("", @DesktopWidth, 400, 0, 300, Default, $WS_EX_TOPMOST) ; WinSetTrans($hGui, "", 100) GUISetState() #cs parameters info: $hGui: Handle to the window $sText: The text $iX: X position of the scrolling text $iY: Y position $iW: Length $iH: Height $iType: Appearance of the LEDs 0=Round with 3D effect, 1=Square with 3D, 2=Round, 3=Square; (the last two are filled and/or outlined, depending on which colors are <>0) $iLedW = X-size of an LED $iLedH = Y-size of an LED $nLedOnCol1 = Color 1 of the ON LEDs (foreground for 3D, fill color for $iType 2 and 3) $nLedOnCol2 = Color 2 of the ON LEDs (background for 3D, color of the outline for $iType 2 and 3) $nLedOffCol1 = Color 1 of the OFF LEDs $nLedOffCol2 = Color 2 of the OFF LEDs $nBkColor = Background color $iDistW = X-distance of the LEDs $iDistH = Y-distance of the LEDs $sFont = Font $iTextSize = Font size $iTextOpt = Font options (see _GDIPlus_FontCreate ) $iTextOffY = Y offset of the font #ce $aLed1 = _LEDTXT_Create_Gdi($hGuiTrans, $sText1, 0, 0, @DesktopWidth, 50, 0, 2, 2, 0xFFFFAA00, 0xFF000000, 0xAA111122, 0xAA000000, 0, 0, 0, "Courier New", 40, 1) $aLed2 = _LEDTXT_Create_Gdi($hGuiTrans, $sText2, 0, 50, @DesktopWidth, 50, 3, 2, 2, 0, 0xFF0088FF, 0, 0xFF000000, 0, 0, 0, "Arial", 40, 1) $aLed3 = _LEDTXT_Create_Gdi($hGuiTrans, $sText3, 0, 100, @DesktopWidth, 100, 1, 4, 4, 0xFFFF0000, 0xFF000000, 0, 0, 0xFFABCDEF, 1, 1, "Times New Roman", 80, 1) $aLed4 = _LEDTXT_Create_Gdi($hGuiTrans, $sText4, 0, 200, @DesktopWidth, 100, 1, 4, 4, 0xFF00FF00, 0xFF000000, 0xFFABCDEF, 0xFFABCDEF, 0xFFABCDEF, 0, 0, "Arial", 80, 1) $aLed5 = _LEDTXT_Create_Gdi($hGui, $sText5, 0, 0, @DesktopWidth, 350, 0, 14, 14, 0xFF00FF00, 0xFF00AA00, 0x44111119, 0x4400EE00, 0x44000000, 0, 0, "Arial", 410, 1, -60) GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND") While 1 _LEDTXT_Step($aLed1, 1) _LEDTXT_Step($aLed2, -1) _LEDTXT_Step($aLed3, 1) _LEDTXT_Step($aLed4, -1) _LEDTXT_Step($aLed5, 1) _WinAPI_RedrawWindow($hGuiTrans, 0, 0, 5) _WinAPI_RedrawWindow($hGui, 0, 0, 5) Sleep(10) WEnd Func _WM_ERASEBKGND($hWnd, $Msg, $wParam, $lParam) Switch $hWnd Case $hGuiTrans _LEDTXT_Draw($aLed1) _LEDTXT_Draw($aLed2) _LEDTXT_Draw($aLed3) _LEDTXT_Draw($aLed4) Case $hGui _LEDTXT_Draw($aLed5) EndSwitch Return True EndFunc ;==>_WM_ERASEBKGND Func _Exit() _LEDTXT_Destroy($aLed1) _LEDTXT_Destroy($aLed2) _LEDTXT_Destroy($aLed3) _LEDTXT_Destroy($aLed4) _LEDTXT_Destroy($aLed5) _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit ; =============================== ; LEDTXT.au3 (by Eukalyptus) ; =============================== Func _LEDTXT_Step(ByRef $aLed, $iDir = 1) $aLed[6] -= $aLed[8] * $iDir Select Case $aLed[6] + $aLed[7] < 0 $aLed[6] = 0 Case $aLed[6] > 0 $aLed[6] = -$aLed[7] EndSelect EndFunc ;==>_LEDTXT_Step Func _LEDTXT_Draw($aLed) Local $iPos = Round($aLed[6]) - Mod(Round($aLed[6]), $aLed[8]) Switch $aLed[10] Case True Switch $iPos Case -$aLed[7] To -$aLed[7] + $aLed[4] _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], -$iPos, 0, $iPos + $aLed[7], $aLed[5], $aLed[2], $aLed[3], $iPos + $aLed[7], $aLed[5]) If $aLed[6] + $aLed[7] < $aLed[4] Then _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], 0, 0, $aLed[4] - ($iPos + $aLed[7]), $aLed[5], $aLed[2] + $iPos + $aLed[7], $aLed[3], $aLed[4] - ($iPos + $aLed[7]), $aLed[5]) Case Else _GDIPlus_GraphicsDrawImageRectRect($aLed[0], $aLed[1], -$iPos, 0, $aLed[4], $aLed[5], $aLed[2], $aLed[3], $aLed[4], $aLed[5]) EndSwitch Case Else Switch $iPos Case -$aLed[7] To -$aLed[7] + $aLed[4] _WinAPI_BitBlt($aLed[0], $aLed[2], $aLed[3], $aLed[2] + $iPos + $aLed[7], $aLed[5], $aLed[1], -$iPos, 0, $MERGECOPY) If $aLed[6] + $aLed[7] < $aLed[4] Then _WinAPI_BitBlt($aLed[0], $aLed[2] + $iPos + $aLed[7], $aLed[3], $aLed[4] - ($iPos + $aLed[7]), $aLed[5], $aLed[1], 0, 0, $MERGECOPY) Case Else _WinAPI_BitBlt($aLed[0], $aLed[2], $aLed[3], $aLed[4], $aLed[5], $aLed[1], -$iPos, 0, $MERGECOPY) EndSwitch EndSwitch EndFunc ;==>_LEDTXT_Draw Func _LEDTXT_Create_GdiPlus($hGui, $sText, $iX, $iY, $iW, $iH, $iType, $iLedW = 8, $iLedH = 8, $nLedOnCol1 = 0xFFFFAA00, $nLedOnCol2 = 0xFF000000, $nLedOffCol1 = 0xAA111122, $nLedOffCol2 = 0xAA000000, $nBkColor = 0xFF000000, $iDistW = 0, $iDistH = 0, $sFont = "Arial", $iTextSize = 0, $iTextOpt = 1, $iTextOffY = 0) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui) Local $hLedOn = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOnCol1, $nLedOnCol2) Local $hLedOff = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOffCol1, $nLedOffCol2) Local $hLed, $iWidth $hLed = _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, $iWidth) Local $aReturn[11] $aReturn[0] = $hGraphics $aReturn[1] = $hLed $aReturn[2] = $iX $aReturn[3] = $iY $aReturn[4] = $iW $aReturn[5] = $iH $aReturn[6] = 0 $aReturn[7] = $iWidth $aReturn[8] = $iLedW + $iDistW $aReturn[9] = 0 $aReturn[10] = True ; True = _GdiPlus, False=_WinApi Return $aReturn EndFunc ;==>_LEDTXT_Create_GdiPlus Func _LEDTXT_Create_Gdi($hGui, $sText, $iX, $iY, $iW, $iH, $iType, $iLedW = 8, $iLedH = 8, $nLedOnCol1 = 0xFFFFAA00, $nLedOnCol2 = 0xFF000000, $nLedOffCol1 = 0xAA111122, $nLedOffCol2 = 0xAA000000, $nBkColor = 0xFF000000, $iDistW = 0, $iDistH = 0, $sFont = "Arial", $iTextSize = 0, $iTextOpt = 1, $iTextOffY = 0) Local $bGdiStarted = True If Not $__g_hGDIPDll Then $bGdiStarted = False _GDIPlus_Startup() EndIf Local $hDC = _WinAPI_GetDC($hGui) Local $hGraphics = _GDIPlus_GraphicsCreateFromHDC($hDC) Local $hLedOn = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOnCol1, $nLedOnCol2) Local $hLedOff = _LEDTXT_Create_Led($hGraphics, $iType, $iLedW - $iDistW, $iLedH - $iDistH, $nLedOffCol1, $nLedOffCol2) Local $hLed, $iWidth $hLed = _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, $iWidth) Local $hBmpDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hLed) _WinAPI_SelectObject($hBmpDC, $hBmp) Local $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hLed) Local $aReturn[11] $aReturn[0] = $hDC $aReturn[1] = $hBmpDC $aReturn[2] = $iX $aReturn[3] = $iY $aReturn[4] = $iW $aReturn[5] = $iH $aReturn[6] = 0 $aReturn[7] = $iWidth $aReturn[8] = $iLedW + $iDistW $aReturn[9] = $hBmp ; zum späteren destroy?! $aReturn[10] = False ; True = _GdiPlus, False=_WinApi _GDIPlus_GraphicsDispose($hGraphics) If Not $bGdiStarted Then _GDIPlus_Shutdown() Return $aReturn EndFunc ;==>_LEDTXT_Create_Gdi Func _LEDTXT_Destroy($aLed) Switch $aLed[10] Case True _GDIPlus_BitmapDispose($aLed[1]) _GDIPlus_GraphicsDispose($aLed[0]) Case Else _WinAPI_DeleteObject($aLed[9]) _WinAPI_ReleaseDC(0, $aLed[1]) _WinAPI_DeleteDC($aLed[0]) EndSwitch EndFunc ;==>_LEDTXT_Destroy Func _LEDTXT_Create_Bmp($hGraphics, $sText, $iW, $iH, $iLedW, $iLedH, $hLedOn, $hLedOff, $iDistW, $iDistH, $sFont, $iTextSize, $iTextOpt, $iTextOffY, $nBkColor, ByRef $iReturnW) $sText = StringReplace($sText, @LF, "") $iW -= Mod($iW, $iLedW + $iDistW) If Not $iTextSize Then $iTextSize = $iH Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFont = _GDIPlus_FontCreate($hFamily, $iTextSize, $iTextOpt, 2) Local $tLayout = _GDIPlus_RectFCreate($iW, 0, 0, 0) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sText, $hFont, $tLayout, $hFormat) Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width")) + $iW $iWidth -= Mod($iWidth, $iLedW + $iDistW) Local $iHeight = $iH ;Ceiling(DllStructGetData($aInfo[0], "Height")) DllStructSetData($aInfo[0], "Y", $iTextOffY) Local $hBmpTxt = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Local $hBmpLed = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics) Local $hBmpTmp = _GDIPlus_BitmapCreateFromGraphics($iLedW, $iHeight, $hGraphics) Local $hGfxTxt = _GDIPlus_ImageGetGraphicsContext($hBmpTxt) Local $hGfxLed = _GDIPlus_ImageGetGraphicsContext($hBmpLed) Local $hGfxTmp = _GDIPlus_ImageGetGraphicsContext($hBmpTmp) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) _GDIPlus_GraphicsClear($hGfxTxt, 0xFF000000) If $nBkColor Then _GDIPlus_GraphicsClear($hGfxLed, $nBkColor) _GDIPlus_GraphicsDrawStringEx($hGfxTxt, $sText, $hFont, $aInfo[0], $hFormat, $hBrush) Local $BitmapData = _GDIPlus_BitmapLockBits($hBmpTxt, $iW, 0, $iWidth - $iW, $iHeight, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $Stride = DllStructGetData($BitmapData, "Stride") Local $Width = DllStructGetData($BitmapData, "Width") Local $Height = DllStructGetData($BitmapData, "Height") Local $Scan0 = DllStructGetData($BitmapData, "Scan0") Local $PixelData = DllStructCreate("ubyte lData[" & (Abs($Stride) * $Height - 1) & "]", $Scan0) If $hLedOff Then For $i = 0 To $Height - 1 Step $iLedH + $iDistH _GDIPlus_GraphicsDrawImage($hGfxTmp, $hLedOff, 0, $i) Next For $i = 0 To $iW - 1 Step $iLedW + $iDistW _GDIPlus_GraphicsDrawImage($hGfxLed, $hBmpTmp, $i, 0) Next EndIf For $col = 0 To $Width - 1 Step $iLedW + $iDistW If $hLedOff Then _GDIPlus_GraphicsDrawImage($hGfxLed, $hBmpTmp, $col + $iW, 0) For $row = 0 To $Height - 1 Step $iLedH + $iDistH If DllStructGetData($PixelData, 1, $row * $Stride + ($col * 4) + 1) Then _GDIPlus_GraphicsDrawImage($hGfxLed, $hLedOn, $col + $iW, $row) Next Next _GDIPlus_BitmapUnlockBits($hBmpTxt, $BitmapData) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_BitmapDispose($hBmpTxt) _GDIPlus_GraphicsDispose($hGfxTxt) _GDIPlus_BitmapDispose($hBmpTmp) _GDIPlus_GraphicsDispose($hGfxTmp) _GDIPlus_GraphicsDispose($hGfxLed) $iReturnW = $iWidth Return $hBmpLed EndFunc ;==>_LEDTXT_Create_Bmp Func _LEDTXT_Create_Led($hGraphics, $iType, $iWidth, $iHeight, $nColor1, $nColor2) If Not $nColor1 And Not $nColor2 Then Return 0 Local $hBmp = _GDIPlus_BitmapCreateFromGraphics($iWidth + 1, $iHeight + 1, $hGraphics) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($hBmp) Switch $iType Case 0 Local $hPen = _GDIPlus_PenCreate() Local $hPath = _GDIPlus_PathCreate() _GDIPlus_PathAddEllipse($hPath, 0, 0, $iWidth, $iHeight) Local $hBrushGrad = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetGammaCorrection($hBrushGrad, True) Local $aColors[2] = [1, $nColor2] _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrushGrad, $aColors) _GDIPlus_PathBrushSetCenterColor($hBrushGrad, $nColor1) _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrushGrad) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_GraphicsDrawEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrushGrad) _GDIPlus_PathDispose($hPath) Case 1 Local $hPen = _GDIPlus_PenCreate() Local $hPath = _GDIPlus_PathCreate() _GDIPlus_PathAddRectangle($hPath, 0, 0, $iWidth, $iHeight) Local $hBrushGrad = _GDIPlus_PathBrushCreateFromPath($hPath) _GDIPlus_PathBrushSetGammaCorrection($hBrushGrad, True) Local $aColors[2] = [1, $nColor2] _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrushGrad, $aColors) _GDIPlus_PathBrushSetCenterColor($hBrushGrad, $nColor1) _GDIPlus_GraphicsFillPath($hGfx, $hPath, $hBrushGrad) _GDIPlus_PathCloseFigure($hPath) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrushGrad) _GDIPlus_PathDispose($hPath) Case 2 If $nColor1 Then Local $hBrush = _GDIPlus_BrushCreateSolid($nColor1) _GDIPlus_GraphicsFillEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_BrushDispose($hBrush) EndIf If $nColor2 Then Local $hPen = _GDIPlus_PenCreate($nColor2) _GDIPlus_GraphicsDrawEllipse($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) EndIf Case 3 If $nColor1 Then Local $hBrush = _GDIPlus_BrushCreateSolid($nColor1) _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_BrushDispose($hBrush) EndIf If $nColor2 Then Local $hPen = _GDIPlus_PenCreate($nColor2) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $iWidth, $iHeight, $hPen) _GDIPlus_PenDispose($hPen) EndIf EndSwitch _GDIPlus_GraphicsDispose($hGfx) Return $hBmp EndFunc ;==>_LEDTXT_Create_Led
    4 points
  35. Here my take on it : #include <WinAPISys.au3> #include <GDIPlus.au3> #include <GuiConstants.au3> Opt("MustDeclareVars", True) Global $hGUI, $hGUI2, $hGUI3 Example() Func Example() _GDIPlus_Startup() $hGUI = GUICreateEx("main.png", 100, 100) $hGUI2 = GUICreateEx("item.png", 150, 400, $hGUI) $hGUI3 = GUICreateEx("item.png", 400, 400, $hGUI) GUIRegisterMsg($WM_NCHITTEST, WM_NCHITTEST) GUIRegisterMsg($WM_MOUSELEAVE, WM_MOUSELEAVE) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _GDIPlus_Shutdown() EndFunc ;==>Example Func GUICreateEx($sImage, $iPosX = -1, $iPosY = -1, $hParent = 0) Local $hImage = _GDIPlus_ImageLoadFromFile($sImage) Local $hWnd = GUICreate("", -1, -1, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $hParent ? $WS_EX_MDICHILD : 0), $hParent) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_UpdateLayeredWindowEx($hWnd, -1, -1, $hBitmap) _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hImage) GUISetState() Return $hWnd EndFunc ;==>GUICreateEx Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam) Switch $hWnd Case $hGUI Return $HTCAPTION Case $hGUI2 ConsoleWrite("hovering GUI2" & @CRLF) Case $hGUI3 ConsoleWrite("hovering GUI3" & @CRLF) EndSwitch _WinAPI_TrackMouseEvent($hWnd, $TME_LEAVE) EndFunc ;==>WM_NCHITTEST Func WM_MOUSELEAVE($hWnd, $msg, $wParam, $lParam) ConsoleWrite("leaving " & $hWnd & @CRLF) Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOUSELEAVE Func GUIUpdate($sImage, $hWnd) Local $hImage = _GDIPlus_ImageLoadFromFile($sImage) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_UpdateLayeredWindowEx($hWnd, -1, -1, $hBitmap) _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hImage) EndFunc ;==>GUIUpdate
    4 points
  36. @Nine does this work for you ? ; SetBitmap($hGUI, $hImage, 255) _WinAPI_UpdateLayeredWindowEx($hGUI, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)) If it works, then we shouldn't need Function SetBitmap() and its 18 lines.
    4 points
  37. Here modern coding (removed useless code) : #include <WinAPISysWin.au3> #include <WinAPIConstants.au3> #include <GDIPlus.au3> #include <GuiComboBox.au3> #include <File.au3> #include <WindowsConstants.au3> #include <GuiConstants.au3> #include <ButtonConstants.au3> Opt("MustDeclareVars", True) Global Const $AC_SRC_ALPHA = 1 Example() Func Example() ; Load PNG file as GDI bitmap _GDIPlus_Startup() Local $sPngSrc = @ScriptDir & "\LaunchySkin.png" Local $hImage = _GDIPlus_ImageLoadFromFile($sPngSrc) ; Extract image width and height from PNG Local $iWidth = _GDIPlus_ImageGetWidth($hImage) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) ; Create layered window Local $hGUI = GUICreate("", $iWidth, $iHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED) Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _WinAPI_UpdateLayeredWindowEx($hGUI, -1, -1, $hBitmap) ; Register notification messages GUIRegisterMsg($WM_NCHITTEST, WM_NCHITTEST) GUISetState() WinSetOnTop($hGUI, "", $WINDOWS_ONTOP) ; As per help file : ; When using $WS_EX_MDICHILD the position is relative to client area of the parent window. ; With $WS_EX_LAYERED it is possible to have a transparent picture on a background picture defined in the parent window. ; To have a transparent picture, create the GUI with the WS_EX_LAYERED extended style. ; The left-top pixel will be used as the transparency color. ; If several pictures are created the last picture defines the transparent color. GUICreate("", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI) GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $iWidth, $iHeight) ; makes the whole child GUI transparent GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("Type the name of a file on" & @CR & "your desktop and press Enter", 50, 30, 140, 60) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0xFFFFFF) ; combo box listing all items on desktop Local $idCombo = GUICtrlCreateCombo("", 210, 30, 250, -1, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) GUICtrlSetFont($idCombo, 10) ; set default button for Enter key activation - renders outside GUI window Local $idButton = GUICtrlCreateButton("", 0, 0, 0, 0, $BS_DEFPUSHBUTTON) GUISetState() ; get list of files on desktop, show in combobox Local $aFileList = _FileListToArray(@DesktopDir), $sRun _ArraySort($aFileList, 0, 1) GUICtrlSetData($idCombo, _ArrayToString($aFileList, "|", 1)) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton $sRun = GUICtrlRead($idCombo) ExitLoop EndSwitch WEnd If $sRun And FileExists(@DesktopDir & "\" & $sRun) Then Beep(2000, 50) ShellExecute($sRun, "", @DesktopDir) EndIf _WinAPI_DeleteObject($hBitmap) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() EndFunc ;==>Example Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) Return $HTCAPTION EndFunc ;==>WM_NCHITTEST
    4 points
  38. Nine

    AutoIt Snippets

    Owner Draw Combo Box with default $CBS_DROPDOWN. Not so obvious as it seems. #include <WinAPIConv.au3> #include <WinAPIGdi.au3> #include <GUIConstants.au3> #include <Constants.au3> #include <GuiComboBox.au3> Opt("MustDeclareVars", True) Global Const $tagDRAWITEMSTRUCT = "uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;hwnd hwndItem;handle hDC;dword rcItem[4];ptr itemData" Global Const $ODA_DRAWENTIRE = 1 Global Const $ODS_SELECTED = 1 Global $idCombo Example() Func Example() GUICreate("Owner Draw", 300, 200) $idCombo = GUICtrlCreateCombo("", 10, 10, 185, 20, BitOR($CBS_HASSTRINGS, $CBS_OWNERDRAWFIXED, $GUI_SS_DEFAULT_COMBO)) Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25) GUICtrlSetData($idCombo, "1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17") GUISetState() Local $aAccelKeys[1][2] = [["{ENTER}", $idCombo]] GUISetAccelerators($aAccelKeys) GUIRegisterMsg($WM_COMMAND, WM_COMMAND) GUIRegisterMsg($WM_DRAWITEM, WM_DRAWITEM) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idClose ExitLoop EndSwitch WEnd EndFunc ;==>Example Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $idCtrl = _WinAPI_LoWord($wParam), $iCode = _WinAPI_HiWord($wParam) If $idCtrl = $idCombo And ($iCode = $CBN_KILLFOCUS Or $iCode = $CBN_SELCHANGE) Then Validate($idCtrl) Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func Validate($idComboBox) Local Static $sSelection Local $sComboRead = GUICtrlRead($idComboBox) If $sSelection = $sComboRead Then Return Local $iList = _GUICtrlComboBox_FindStringExact($idComboBox, $sComboRead) If $iList = -1 Then GUICtrlSendMsg($idComboBox, $CB_SETCURSEL, -1, 0) $sSelection = "" ConsoleWrite("Invalid data" & @CRLF) Else $sSelection = $sComboRead ConsoleWrite("Currently displaying: " & $sComboRead & @CRLF) If _GUICtrlComboBox_GetCurSel($idComboBox) = -1 Then _GUICtrlComboBox_SetCurSel($idComboBox, $iList) EndIf EndFunc ;==>Validate Func WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam) If $wParam <> $idCombo Then Return $GUI_RUNDEFMSG Local $tDraw = DllStructCreate($tagDRAWITEMSTRUCT, $lParam), $sText If $tDraw.itemAction = $ODA_DRAWENTIRE Then Local $tRECT = DllStructCreate($tagRECT, DllStructGetPtr($tDraw, "rcItem")) Local $hBrush = _WinAPI_CreateSolidBrush(BitAND($tDraw.itemState, $ODS_SELECTED) ? 0xFFCDAD : Mod($tDraw.itemID, 2) ? 0xFFFFFF : 0xE0E0E0) _WinAPI_FillRect($tDraw.hDC, $tRECT, $hBrush) $tRECT.Left += 5 $tRECT.Top += 2 _GUICtrlComboBox_GetLBText($tDraw.hwndItem, $tDraw.itemID, $sText) _WinAPI_DrawText($tDraw.hDC, $sText, $tRECT, $DT_LEFT) _WinAPI_DeleteObject($hBrush) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_DRAWITEM Note : you can tab, enter, up arrow, down arrow to validate the combo input field.
    4 points
  39. Just uploaded SciTEx86.zip & SciTEx64.zip which contain the Latest SciTE 5.5.3 versions released 9 October 2024.
    4 points
  40. KaFu

    Font Viewer

    Found a copy of 1.4 thanks to SMF 😋 in my archive drive at the location "E:\__code\TB_TurboBooster\Workbench\_testcode\FontViewer_source.zip" 🙄. Updated that too to 3.3.16.1, here's a copy of that plus the original code FontViewer_1.4.zip Additionally fixed a bug in the enumeration of the system fonts. ; $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, StringTrimLeft($REG_KEY_TRUETYPE, 5)) ; needs to be $hKey = _WinAPI_RegOpenKey($HKEY_LOCAL_MACHINE, StringTrimLeft($REG_KEY_TRUETYPE, 5),BitOR($KEY_QUERY_VALUE , $KEY_WOW64_32KEY))
    4 points
  41. Version 1.6.1 has just been released! The function snippet, now uses "func" instead of "fun" for the string prefix. Variables declared via for loops are now recognized by the extension. include statements that fail to resolve, should no longer have links added to them. Sorry for the slow release. Personal things, combined with my vscode and docker that keeps crashing due to running out of memory, have delayed this release by at least a month. 😕 Anyway, i am currently looking into: adding errors for things like include statements that fail to resolve. improving the function signature helper (currently it disappears if the parser fails on that line, like when adding a comma within the parentheses, but there is nothing between the comma and the closing parenthesis) adding setting for omitting included functions and variables with the "__" prefix from the completion suggestions.
    4 points
  42. ioa747

    ITaskbarList4 interface

    Here is an attempt to approximate the ITaskbarList3 interface, which was quite a headache for me, since all C++ is new to me https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/shell/taskbar-extensions.md https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-itaskbarlist3 The code may have omissions or excesses, as for the writing where I was stuck and did not understand asking the AI So if someone more experienced has any tips, I'd be happy to hear them everything takes place in the taskbar thumbnail, is displayed when the mouse pointer get over the taskbar icon I put it as a UDF in a separate file so that the main script is cleaner Example.au3 ; https://www.autoitscript.com/forum/topic/212223-itaskbarlist4-interface/?do=edit ;---------------------------------------------------------------------------------------- ; Title...........: Example.au3 ; Description.....: Example howto use ITaskbarList3 interface ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.0.0.3 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include "TaskbarList.au3" ; * <-- Global $bRedyflag = False ; Register to receive the message that our button is ready GUIRegisterMsg(_WinAPI_RegisterWindowMessage("TaskbarButtonCreated"), "_TaskbarReady") ; Create a sample GUI window Global $hGUI = GUICreate("ITaskbarList Example", 330, 200) Global $idIcon = GUICtrlCreateIcon(@ScriptDir & "\Res\imageres-81.ico", -1, 200, 5, 128, 128) Global $idButton = GUICtrlCreateButton("Click Me", 10, 10) Global $ImageList1 = _GUIImageList_Create(32, 32, 5) _GUIImageList_AddIcon($ImageList1, @ScriptDir & "\Res\prev.ico", 0, True) _GUIImageList_AddIcon($ImageList1, @ScriptDir & "\Res\play.ico", 0, True) _GUIImageList_AddIcon($ImageList1, @ScriptDir & "\Res\stop.ico", 0, True) _GUIImageList_AddIcon($ImageList1, @ScriptDir & "\Res\next.ico", 0, True) GUISetState(@SW_SHOW, $hGUI) Global Enum $iTBtnPrev = 1000, $iTBtnPlay, $iTBtnStop, $iTBtnNext ; Register a handler for WM_COMMAND messages GUIRegisterMsg($WM_COMMAND, "_OnThumbnailButtonClick") ; Add a button to the taskbar thumbnail toolbar ; dwMask, iId, iBitmap, hIcon, szTip, dwFlags Global $dwMask = BitOR($THB_BITMAP, $THB_TOOLTIP, $THB_FLAGS) Global $aTButtons[4][6] = [ _ [$dwMask, $iTBtnPrev, 0, 0, "prev", 0], _ [$dwMask, $iTBtnPlay, 1, 0, "play", 0], _ [$dwMask, $iTBtnStop, 2, 0, "stop", 0], _ [$dwMask, $iTBtnNext, 3, 0, "next", 0]] While Not $bRedyflag Sleep(10) WEnd TB_ThumbBarSetImageList($hGUI, $ImageList1) TB_ThumbBarAddButtons($hGUI, 4, $aTButtons) ; Selects a portion of a window's client area to display as that window's thumbnail in the taskbar. TB_SetThumbnailClip($hGUI, 200, 0, 200 + 128, 128) ; Specifies or updates the text of the tooltip that is displayed when the mouse pointer rests on an individual preview thumbnail in a taskbar button flyout. Local $sTxt = "" $sTxt &= " Title...........: Example.au3" & @CRLF $sTxt &= " Description.....: Example howto use ITaskbarList3 " & @CRLF $sTxt &= " AutoIt Version..: 3.3.16.1 Script Version: 1.0" TB_SetThumbnailTooltip($hGUI, $sTxt) Global $hIcon Global $iCnt = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton ; Applies an overlay to a taskbar button to indicate application status or a notification to the user. $iCnt += 1 ConsoleWrite("$iCnt=" & $iCnt & @CRLF) $hIcon = TB_GetIconHandle($iCnt > 10 ? @ScriptDir & "\Res\trffc14.ico" : @ScriptDir & "\Res\" & $iCnt & ".ico") TB_SetOverlayIcon($hGUI, $hIcon, String($iCnt)) EndSwitch WEnd GUIDelete($hGUI) ;-------------------------------------------------------------------------------------------------------------------------------- ; Function to handle the taskbar ready event Func _TaskbarReady($hWnd, $msg, $wParam, $lParam) Switch $hWnd Case $hGUI ; The taskbar button is ready ConsoleWrite("--- Taskbar button ready ---" & @CRLF) $bRedyflag = True EndSwitch EndFunc ;==>_TaskbarReady ;-------------------------------------------------------------------------------------------------------------------------------- ; Function to handle thumbnail button clicks Func _OnThumbnailButtonClick($hWnd, $msg, $wParam, $lParam) ; Extract the button ID from the wParam Local $iButtonID = BitAND($wParam, 0xFFFF) Switch $iButtonID Case 1000 ; progress status in Thumbnail icon ConsoleWrite("- progress status in Thumbnail icon Button Clicked: " & $iButtonID & @CRLF) ; Load an icon $hIcon = TB_GetIconHandle(@ScriptDir & "\Res\comres-15.ico") TB_SetOverlayIcon($hGUI, $hIcon, "Wait") For $i = 1 To 100 TB_SetProgress($hGUI, $i, 100) Sleep(25) Next TB_Flash($hGUI, 4, 300) $hIcon = TB_GetIconHandle($iCnt > 10 ? @ScriptDir & "\Res\trffc14.ico" : @ScriptDir & "\Res\" & $iCnt & ".ico") TB_SetOverlayIcon($hGUI, $hIcon, String($iCnt)) Case 1001 ; Flash the taskbar icon RED ConsoleWrite("- Flash the taskbar icon RED Button Clicked: " & $iButtonID & @CRLF) For $i = 1 To 4 TB_SetProgressState($hGUI, 4) Sleep(300) TB_SetProgressState($hGUI, 0) Sleep(300) Next TB_SetProgressState($hGUI, 0) Sleep(1000) For $i = 1 To 4 TB_SetProgressState($hGUI, 4) TB_SetProgress($hGUI, 100, 100) Sleep(300) TB_SetProgressState($hGUI, 0) TB_SetProgress($hGUI, 0, 100) Sleep(300) Next TB_SetProgressState($hGUI, 0) Case 1002 ; Flash the taskbar icon YELLOW ConsoleWrite("- Flash the taskbar icon YELLOW Button Clicked: " & $iButtonID & @CRLF) For $i = 1 To 4 TB_SetProgressState($hGUI, 8) Sleep(300) TB_SetProgressState($hGUI, 0) Sleep(300) Next TB_SetProgressState($hGUI, 0) Sleep(1000) For $i = 1 To 4 TB_SetProgressState($hGUI, 8) TB_SetProgress($hGUI, 100, 100) Sleep(300) TB_SetProgressState($hGUI, 0) TB_SetProgress($hGUI, 0, 100) Sleep(300) Next TB_SetProgressState($hGUI, 0) Case 1003 ; progress status in Thumbnail icon ConsoleWrite("- progress status in Thumbnail icon Button Clicked: " & $iButtonID & @CRLF) ; Load an icon $hIcon = TB_GetIconHandle(@ScriptDir & "\Res\comres-15.ico") TB_SetOverlayIcon($hGUI, $hIcon, "Wait") For $i = 1 To 100 Switch $i Case 60 To 84 TB_SetProgressState($hGUI, 8) ;YELLOW Case 85 To 100 TB_SetProgressState($hGUI, 4) ;RED EndSwitch TB_SetProgress($hGUI, $i, 100) Sleep(25) Next TB_Flash($hGUI, 4, 300) TB_SetProgressState($hGUI, 0) $hIcon = TB_GetIconHandle($iCnt > 10 ? @ScriptDir & "\Res\trffc14.ico" : @ScriptDir & "\Res\" & $iCnt & ".ico") TB_SetOverlayIcon($hGUI, $hIcon, String($iCnt)) EndSwitch EndFunc ;==>_OnThumbnailButtonClick TaskbarList.au3 #include-once #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_Description=ITaskbarList4 interface #AutoIt3Wrapper_Res_Fileversion=0.0.0.3 #AutoIt3Wrapper_Res_ProductName=TaskbarList.au3 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; https://www.autoitscript.com/forum/topic/212223-itaskbarlist4-interface ; https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/shell/taskbar-extensions.md ; https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-registertab ; https://www.autoitscript.com/forum/topic/139260-autoit-snippets/?do=findComment&comment=1536397 ; Images must be 32-bit and of dimensions GetSystemMetrics(SM_CXICON) x GetSystemMetrics(SM_CYICON). #include <WinAPISysWin.au3> #include <GuiImageList.au3> #Region ;**** CONSTANTS **** ; THUMBBUTTONFLAGS Used by THUMBBUTTON to control specific states and behaviors of the button. Global Enum $THBF_ENABLED, $THBF_DISABLED, $THBF_DISMISSONCLICK, $THBF_NOBACKGROUND = 4, $THBF_HIDDEN = 8, $THBF_NONINTERACTIVE = 10 ; THUMBBUTTONMASK Used by the THUMBBUTTON structure to specify which members of that structure contain valid data. Global Enum $THB_BITMAP = 1, $THB_ICON, $THB_TOOLTIP = 4, $THB_FLAGS = 8 ; Used by the ITaskbarList3::SetProgressState method to specify tab properties. Global Enum $TBPF_NOPROGRESS, $TBPF_INDETERMINATE, $TBPF_NORMAL, $TBPF_ERROR = 4, $TBPF_PAUSED = 8 ; Used by the ITaskbarList4::SetTabProperties method to specify tab properties. Global Enum $STPF_NONE, $STPF_USEAPPTHUMBNAILALWAYS, $STPF_USEAPPTHUMBNAILWHENACTIVE, $STPF_USEAPPPEEKALWAYS = 4, $STPF_USEAPPPEEKWHENACTIVE = 8 Global Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}" ; Win2000 Global Const $sIID_ITaskbarList2 = "{602D4995-B13A-429b-A66E-1935E44F4317}" ; WinXP Global Const $sIID_ITaskbarList3 = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}" ; Win7 Global Const $sIID_ITaskbarList4 = "{C43DC798-95D1-4BEA-9030-BB99E2983A1A}" ; Win7 Global Const $tagITaskbarList = _ "HrInit hresult();" & _ "AddTab hresult(hwnd);" & _ "DeleteTab hresult(hwnd);" & _ "ActivateTab hresult(hwnd);" & _ "SetActiveAlt hresult(hwnd);" Global Const $tagITaskbarList2 = $tagITaskbarList & _ "MarkFullscreenWindow hresult(hwnd;boolean);" Global Const $tagITaskbarList3 = $tagITaskbarList2 & _ "SetProgressValue hresult(hwnd;uint64;uint64);" & _ "SetProgressState hresult(hwnd;int);" & _ "RegisterTab hresult(hwnd;hwnd);" & _ "UnregisterTab hresult(hwnd);" & _ "SetTabOrder hresult(hwnd;hwnd);" & _ "SetTabActive hresult(hwnd;hwnd;dword);" & _ "ThumbBarAddButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarUpdateButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarSetImageList hresult(hwnd;ptr);" & _ "SetOverlayIcon hresult(hwnd;ptr;wstr);" & _ "SetThumbnailTooltip hresult(hwnd;wstr);" & _ "SetThumbnailClip hresult(hwnd;ptr);" Global Const $tagITaskbarList4 = $tagITaskbarList3 & _ "SetTabProperties hresult(hwnd;int);" ; Used by methods of the ITaskbarList3 interface to define buttons used in a toolbar embedded in a window's thumbnail representation. Global Const $tagTHUMBBUTTON = "dword dwMask;" & _ "uint iId;" & _ "uint iBitmap;" & _ "handle hIcon;" & _ "wchar szTip[260];" & _ "dword dwFlags" #EndRegion ;**** CONSTANTS **** Global Const $g__oTB = __TB_Init() ; #INTERNAL_USE_ONLY# ----------------------------------------------------------------------------------------------------------- ; Name...........: __TB_Init() ; Description....: Initializes the taskbar list object. ; Syntax.........: __TB_Init() ; Parameters.....: None. ; Return values..: $oTB, an object representing the taskbar list. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist-hrinit ;-------------------------------------------------------------------------------------------------------------------------------- Func __TB_Init() Local $oTB = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList3, $tagITaskbarList3) $oTB.HrInit() Return $oTB EndFunc ;==>__TB_Init #Region ;**** ITaskbarList interface **** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_ActivateTab ; Description....: Activates an item on the taskbar. The window is not actually activated. ; Syntax.........: TB_ActivateTab($hWnd) ; Parameters.....: $hWnd - Handle to the tab control. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist-activatetab ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_ActivateTab($hWnd) Return $g__oTB.ActivateTab($hWnd) EndFunc ;==>TB_ActivateTab ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_AddTab ; Description....: Adds a new tab to the taskbar. ; Syntax.........: TB_AddTab($hWnd) ; Parameters.....: $hWnd - A handle to the window to be added to the taskbar. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist-addtab ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_AddTab($hWnd) Return $g__oTB.AddTab($hWnd) EndFunc ;==>TB_AddTab ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_DeleteTab ; Description....: Deletes a tab from the taskbar. ; Syntax.........: DeleteTab($hWnd) ; Parameters.....: $hWnd - A handle to the window to be deleted from the taskbar. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist-deletetab ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_DeleteTab($hWnd) Return $g__oTB.DeleteTab($hWnd) EndFunc ;==>TB_DeleteTab ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetActiveAlt ; Description....: Sets the active alternate for a toolbar control. ; Syntax.........: TB_SetActiveAlt($hWnd) ; Parameters.....: $hWnd - A handle to the window to be marked as active. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: This function is only available on Windows Win2000 and later versions of the operating system. ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist-setactivealt ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetActiveAlt($hWnd) Return $g__oTB.SetActiveAlt($hWnd) EndFunc ;==>TB_SetActiveAlt #EndRegion ;**** ITaskbarList interface **** #Region ;**** ITaskbarList2 interface **** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_MarkFullscreenWindow ; Description....: Marks a window as fullscreen. ; Syntax.........: TB_MarkFullscreenWindow($hWnd, $bFullscreen) ; Parameters.....: $hWnd - The handle of the window to be marked. ; $bFullscreen - Boolean value indicating whether the window should be marked as fullscreen (True) or not (False). ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: his function is only available on Windows WinXP and later versions of the operating system. ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist2-markfullscreenwindow ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_MarkFullscreenWindow($hWnd, $bFullscreen) Return $g__oTB.MarkFullscreenWindow($hWnd, $bFullscreen) EndFunc ;==>TB_MarkFullscreenWindow #EndRegion ;**** ITaskbarList2 interface **** #Region ;**** ITaskbarList3 interface **** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_RegisterTab ; Description....: Registers a tab in the thumbnail toolbar. ; Syntax.........: TB_RegisterTab($hWndTab, $hWndMDI) ; Parameters.....: $hWndTab - Handle to the tab window. ; $hWndMDI - The handle of the main window (the MDI client area). ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-registertab ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_RegisterTab($hWndTab, $hWndMDI) Return $g__oTB.RegisterTab($hWndTab, $hWndMDI) EndFunc ;==>TB_RegisterTab ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetOverlayIcon ; Description....: Sets the overlay icon for a toolbar button. ; Syntax.........: TB_SetOverlayIcon($hWnd, $hIcon, $sAltText = "") ; Parameters.....: $hWnd - The handle of the window whose associated taskbar button receives the overlay. ; $hIcon - Handle to the icon to be used as the overlay image. ; $sAltText - Alternative text for the button. If this parameter is an empty string, ; the function will use the current value of the TB_SETTOOLTIPS message. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: This function is only available on Windows Vista and later. ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setoverlayicon ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetOverlayIcon($hWnd, $hIcon, $sAltText = "") Return $g__oTB.SetOverlayIcon($hWnd, $hIcon, $sAltText) EndFunc ;==>TB_SetOverlayIcon ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetProgressState ; Description....: Sets the progress state of a taskbar button. ; Syntax.........: TB_SetProgressState($hWnd, $iFlags) ; Parameters.....: $hWnd - The handle of the window in which the progress of an operation is being shown. ; $iFlags - Flags that specify the new progress state. Can be one of the following values: ; | (0) $TBPF_NOPROGRESS - Stops displaying progress and returns the button to its normal state. ; | (1) $TBPF_INDETERMINATE - The progress indicator does not grow in size, but cycles repeatedly along the length of the taskbar button. ; | (2) $TBPF_NORMAL - The progress indicator grows in size from left to right in proportion to the estimated amount of the operation completed. ; | (4) $TBPF_ERROR - The progress indicator turns red to show that an error has occurred in one of the windows that is broadcasting progress. ; | (8) $TBPF_PAUSED - The progress indicator turns yellow to show that progress is currently stopped in one of the windows but can be resumed by the user. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setprogressstate ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetProgressState($hWnd, $iFlags) Return $g__oTB.SetProgressState($hWnd, $iFlags) EndFunc ;==>TB_SetProgressState ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetProgress ; Description....: Sets the progress value of a taskbar button. ; Syntax.........: TB_SetProgress($hWnd, $iCurrent, $iCompleted) ; Parameters.....: $hWnd - The handle of the window whose associated taskbar button is being used as a progress indicator. ; $iCurrent - The current progress value. ; $iCompleted - The completed progress value. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: nine ; Notes .........: ; Link ..........: https://www.autoitscript.com/forum/topic/139260-autoit-snippets/page/26/#comment-1536397 ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetProgress($hWnd, $iCurrent, $iCompleted) Return $g__oTB.SetProgressValue($hWnd, $iCurrent, $iCompleted) EndFunc ;==>TB_SetProgress ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetTabActive ; Description....: Sets the active tab in a thumbnail tooltip control. ; Syntax.........: TB_SetTabActive($hWndTab, $hWndMDI, $iReserved = 0) ; Parameters.....: $hWndTab - Handle of the active tab window. This handle must already be registered through RegisterTab. ; $hWndMDI - The handle of the main window (the MDI client area). ; $iReserved - Reserved for future use. Must be set to zero. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: Note that this function is likely only useful in the context of an MDI application, ; where multiple tabs are managed by a single client area. ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-settabactive ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetTabActive($hWndTab, $hWndMDI, $iReserved = 0) Return $g__oTB.SetTabActive($hWndTab, $hWndMDI, $iReserved) EndFunc ;==>TB_SetTabActive ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetTabOrder ; Description....: Sets the tab order of a toolbar control. ; Syntax.........: TB_SetTabOrder($hWndTab, $hWndInsertBefore) ; Parameters.....: $hWndTab - The handle of the tab window whose thumbnail is being placed. This value is required, must already be registered through ITaskbarList3::RegisterTab ; $hWndInsertBefore - Handle to the window that will precede the specified window in the tab order. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-settaborder ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetTabOrder($hWndTab, $hWndInsertBefore) Return $g__oTB.SetTabOrder($hWndTab, $hWndInsertBefore) EndFunc ;==>TB_SetTabOrder ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetThumbnailClip ; Description....: Selects a portion of a window's client area to display as that window's thumbnail in the taskbar. ; Syntax.........: TB_SetThumbnailClip($hWnd, $iLeft, $iTop, $iRight, $iBottom) ; Parameters.....: $hWnd - The handle to a window represented in the taskbar. ; $iLeft - The left coordinate of the clipping rectangle. ; $iTop - The top coordinate of the clipping rectangle. ; $iRight - The right coordinate of the clipping rectangle. ; $iBottom - The bottom coordinate of the clipping rectangle. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setthumbnailclip ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetThumbnailClip($hWnd, $iLeft, $iTop, $iRight, $iBottom) Local $tRECTClip = DllStructCreate($tagRECT) DllStructSetData($tRECTClip, "Left", $iLeft) DllStructSetData($tRECTClip, "Top", $iTop) DllStructSetData($tRECTClip, "Right", $iRight) DllStructSetData($tRECTClip, "Bottom", $iBottom) Return $g__oTB.SetThumbnailClip($hWnd, DllStructGetPtr($tRECTClip)) EndFunc ;==>TB_SetThumbnailClip ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetThumbnailTooltip ; Description....: Sets a tooltip for a thumbnail in the taskbar. ; Syntax.........: TB_SetThumbnailTooltip($hWnd, $sTooltip) ; Parameters.....: $hWnd - Handle to the window that contains the thumbnail. ; $sTooltip - Tooltip text to be displayed. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: The tooltip will be displayed when the user hovers their mouse over the thumbnail. ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-setthumbnailtooltip ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetThumbnailTooltip($hWnd, $sTooltip) Return $g__oTB.SetThumbnailTooltip($hWnd, $sTooltip) EndFunc ;==>TB_SetThumbnailTooltip ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_ThumbBarAddButtons ; Description....: Adds buttons to the thumbnail toolbar. ; Syntax.........: TB_ThumbBarAddButtons($hWnd, $iButtonCount, $aButtons) ; Parameters.....: $hWnd - Handle to the window that contains the thumbnail image. ; $iButtonCount - Number of buttons to add. ; $aButtons - Array of button data. Each element in the array should be a structure with the following fields: ; - dwMask - Mask of valid fields in this structure. Can be a combination of THUMBBUTTONMASK ; $THB_BITMAP = 1, $THB_ICON, $THB_TOOLTIP = 4, $THB_FLAGS = 8 ; - iId - Unique identifier for the button. This value is returned in the $iButtonIndex parameter of the TB_ThumbBarButtonPressed notification code. ; - iBitmap - Handle to the bitmap that will be displayed on the button. ; - hIcon - Handle to the icon that will be displayed on the button. ; - szTip - Tooltip text for the button. ; - dwFlags - Flags that specify the behavior of the button. Can be a combination of THUMBBUTTONFLAGS ; $THBF_ENABLED=0, $THBF_DISABLED=1, $THBF_DISMISSONCLICK=2, $THBF_NOBACKGROUND=4, $THBF_HIDDEN=8, $THBF_NONINTERACTIVE=10. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-thumbbaraddbuttons ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_ThumbBarAddButtons($hWnd, $iButtonCount, $aButtons) ; Create a struct for each button ; dwFlags(THBF_ENABLED=0, THBF_DISABLED=0x1, THBF_DISMISSONCLICK=0x2, THBF_NOBACKGROUND=0x4, THBF_HIDDEN=0x8, THBF_NONINTERACTIVE=0x10) ; Get the size of the THUMBBUTTON structure Local $iStructSize = DllStructGetSize(DllStructCreate($tagTHUMBBUTTON)) ; Calculate the total memory size needed for all button structures Local $pButtonsMemory = DllStructCreate("byte[" & ($iStructSize * $iButtonCount) & "]") If @error Then MsgBox(16, "Error", "Failed to create memory structure for buttons. Error: " & @error) Return EndIf ; Loop through and initialize each button structure For $i = 0 To $iButtonCount - 1 ; Create a THUMBBUTTON struct at the correct memory location Local $pCurrentButton = DllStructCreate($tagTHUMBBUTTON, DllStructGetPtr($pButtonsMemory) + ($iStructSize * $i)) If @error Then MsgBox(16, "Error", "Failed to create DllStruct for button " & ($i + 1) & ". Error: " & @error) Return EndIf ; Populate the struct with button data DllStructSetData($pCurrentButton, "dwMask", $aButtons[$i][0]) DllStructSetData($pCurrentButton, "iId", $aButtons[$i][1]) DllStructSetData($pCurrentButton, "iBitmap", $aButtons[$i][2]) DllStructSetData($pCurrentButton, "hIcon", $aButtons[$i][3]) DllStructSetData($pCurrentButton, "szTip", $aButtons[$i][4]) DllStructSetData($pCurrentButton, "dwFlags", $aButtons[$i][5]) ; Validate if data was set correctly If @error Then MsgBox(16, "Error", "Failed to set data for button " & ($i + 1) & ". Error: " & @error) Return EndIf Next ; Call the ThumbBarAddButtons method Local $hResult = $g__oTB.ThumbBarAddButtons($hWnd, $iButtonCount, DllStructGetPtr($pButtonsMemory)) If $hResult <> 0 Then MsgBox(16, "Error", "Failed to add thumbnail toolbar buttons. HRESULT: " & $hResult) EndIf EndFunc ;==>TB_ThumbBarAddButtons ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_ThumbBarSetImageList ; Description....: Sets the image list for a thumb bar. ; Syntax.........: TB_ThumbBarSetImageList($hWnd, $hImageList) ; Parameters.....: $hWnd - The handle of the window whose thumbnail representation contains the toolbar to be updated. ; $hImageList - Handle to an image list containing the images for the thumb bar. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-thumbbarsetimagelist ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_ThumbBarSetImageList($hWnd, $hImageList) $g__oTB.ThumbBarSetImageList($hWnd, $hImageList) EndFunc ;==>TB_ThumbBarSetImageList ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_ThumbBarUpdateButtons ; Description....: Updates the buttons in a thumbnail toolbar. ; Syntax.........: TB_ThumbBarUpdateButtons($hWnd, $iButtonCount, $aButtons) ; Parameters.....: $hWnd - The handle of the window whose thumbnail representation contains the toolbar. ; $iButtonCount- Number of buttons in the array. ; $aButtons - Array of button data. Each element in the array should be a structure with the following fields: ; - dwMask - Mask of valid fields in this structure. Can be a combination of THUMBBUTTONMASK ; $THB_BITMAP = 1, $THB_ICON, $THB_TOOLTIP = 4, $THB_FLAGS = 8 ; - iId - Unique identifier for the button. This value is returned in the $iButtonIndex parameter of the TB_ThumbBarButtonPressed notification code. ; - iBitmap - Handle to the bitmap that will be displayed on the button. ; - hIcon - Handle to the icon that will be displayed on the button. ; - szTip - Tooltip text for the button. ; - dwFlags - Flags that specify the behavior of the button. Can be a combination of THUMBBUTTONFLAGS ; $THBF_ENABLED=0, $THBF_DISABLED=1, $THBF_DISMISSONCLICK=2, $THBF_NOBACKGROUND=4, $THBF_HIDDEN=8, $THBF_NONINTERACTIVE=10. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-thumbbarupdatebuttons ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_ThumbBarUpdateButtons($hWnd, $iButtonCount, $aButtons) ; Create a struct for each button ; dwFlags(THBF_ENABLED=0, THBF_DISABLED=0x1, THBF_DISMISSONCLICK=0x2, THBF_NOBACKGROUND=0x4, THBF_HIDDEN=0x8, THBF_NONINTERACTIVE=0x10) ; Get the size of the THUMBBUTTON structure Local $iStructSize = DllStructGetSize(DllStructCreate($tagTHUMBBUTTON)) ; Calculate the total memory size needed for all button structures Local $pButtonsMemory = DllStructCreate("byte[" & ($iStructSize * $iButtonCount) & "]") If @error Then MsgBox(16, "Error", "Failed to create memory structure for buttons. Error: " & @error) Return EndIf ; Loop through and initialize each button structure For $i = 0 To $iButtonCount - 1 ; Create a THUMBBUTTON struct at the correct memory location Local $pCurrentButton = DllStructCreate($tagTHUMBBUTTON, DllStructGetPtr($pButtonsMemory) + ($iStructSize * $i)) If @error Then MsgBox(16, "Error", "Failed to create DllStruct for button " & ($i + 1) & ". Error: " & @error) Return EndIf ; Populate the struct with button data DllStructSetData($pCurrentButton, "dwMask", $aButtons[$i][0]) DllStructSetData($pCurrentButton, "iId", $aButtons[$i][1]) DllStructSetData($pCurrentButton, "iBitmap", $aButtons[$i][2]) DllStructSetData($pCurrentButton, "hIcon", $aButtons[$i][3]) DllStructSetData($pCurrentButton, "szTip", $aButtons[$i][4]) DllStructSetData($pCurrentButton, "dwFlags", $aButtons[$i][5]) ; Validate if data was set correctly If @error Then MsgBox(16, "Error", "Failed to set data for button " & ($i + 1) & ". Error: " & @error) Return EndIf Next ; Call the ThumbBarUpdateButtons method Local $hResult = $g__oTB.ThumbBarUpdateButtons($hWnd, $iButtonCount, DllStructGetPtr($pButtonsMemory)) If $hResult <> 0 Then MsgBox(16, "Error", "Failed to Update thumbnail toolbar buttons. HRESULT: " & $hResult) EndIf EndFunc ;==>TB_ThumbBarUpdateButtons ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_UnregisterTab ; Description....: Unregisters a tab from the toolbar. ; Syntax.........: TB_UnregisterTab($hWndTab) ; Parameters.....: $hWndTab - The handle of the tab window whose thumbnail is being removed. ; This is the same value with which the thumbnail was registered as part the group through RegisterTab ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist3-unregistertab ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_UnregisterTab($hWndTab) Return $g__oTB.UnregisterTab($hWndTab) EndFunc ;==>TB_UnregisterTab #EndRegion ;**** ITaskbarList3 interface **** #Region ;**** ITaskbarList4 interface **** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_SetTabProperties ; Description....: Sets the properties of a tab in a toolbar control. ; Syntax.........: TB_SetTabProperties($hWndTab, $stpFlags) ; Parameters.....: $hWndTab - The handle of the tab window that is to have properties set. This handle must already be registered through RegisterTab. ; $stpFlags - A combination of the following values: ; |(0) STPF_NONE : No specific property values are specified. ; The default behavior is used: the tab window provides a thumbnail and peek image, either live or static as appropriate. ; |(1) $STPF_USEAPPTHUMBNAILALWAYS : Always use the thumbnail provided by the main application frame window rather than a thumbnail provided by the individual tab window. ; Do not combine this value with STPF_USEAPPTHUMBNAILWHENACTIVE; doing so will result in an error. ; |(2) $STPF_USEAPPTHUMBNAILWHENACTIVE : When the application tab is active and a live representation of its window is available, ; use the main application's frame window thumbnail. At other times, use the tab window thumbnail. ; Do not combine this value with STPF_USEAPPTHUMBNAILALWAYS; doing so will result in an error. ; |(4) $STPF_USEAPPPEEKALWAYS : Always use the peek image provided by the main application frame window rather than a peek image provided by the individual tab window. ; Do not combine this value with STPF_USEAPPPEEKWHENACTIVE; doing so will result in an error. ; |(8) $STPF_USEAPPPEEKWHENACTIVE : When the application tab is active and a live representation of its window is available, ; show the main application frame in the peek feature. At other times, use the tab window. ; Do not combine this value with STPF_USEAPPPEEKALWAYS; doing so will result in an error. ; Return values..: Success - Returns a zero value if successful ; Failure - Returns a non-zero value indicating the error code. ; Author ........: ioa747 ; Notes .........: ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-itaskbarlist4-settabproperties ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_SetTabProperties($hWndTab, $stpFlags) Return $g__oTB.SetTabProperties($hWndTab, $stpFlags) EndFunc ;==>TB_SetTabProperties #EndRegion ;**** ITaskbarList4 interface **** #Region ;**** Extra **** ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_Flash ; Description....: Flashes a taskbar button. ; Syntax.........: TB_Flash($hWnd, $iTimes = 3, $iDelay = 300) ; Parameters.....: $hWnd - Handle to the taskbar button. ; $iTimes - Number of times to flash (default is 3). ; $iDelay - Delay between flashes in milliseconds (default is 300). ; Return values..: None. ; Author ........: nine ; Notes .........: This function uses the TaskbarButton class to interact with taskbar buttons. For more information, see the AutoIt documentation. ; Link ..........: https://www.autoitscript.com/forum/topic/139260-autoit-snippets/page/26/#comment-1536397 ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_Flash($hWnd, $iTimes = 3, $iDelay = 300) For $i = 1 To $iTimes $g__oTB.SetProgressState($hWnd, 0) Sleep($iDelay) $g__oTB.SetProgressValue($hWnd, 100, 100) Sleep($iDelay) Next $g__oTB.SetProgressState($hWnd, 0) EndFunc ;==>TB_Flash ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TB_GetIconHandle ; Description....: Returns a handle to an icon. ; Syntax.........: TB_GetIconHandle($iconFilePath, $iconIndex = 0) ; Parameters.....: $iconFilePath - The path of the file that contains the icon. ; $iconIndex - The index of the icon in the file. Default is 0. ; Return values..: Success - A handle to the icon. ; Failure - 0, and sets @error to 1. ; Author ........: ioa747 ; Notes .........: This function uses the ExtractIcon function from the shell32.dll library. ; Link ..........: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-extracticona ; Dependencies...: _WinAPI_GetModuleHandle, DllCall ;-------------------------------------------------------------------------------------------------------------------------------- Func TB_GetIconHandle($iconFilePath, $iconIndex = 0) Local $hInstance = _WinAPI_GetModuleHandle(0) Local $aResult = DllCall("shell32.dll", "hwnd", "ExtractIcon", "hwnd", $hInstance, "str", $iconFilePath, "uint", $iconIndex) If @error Then Return SetError(1, 0, 0) EndIf Return $aResult[0] EndFunc ;==>TB_GetIconHandle #EndRegion ;**** Extra **** Please, every comment is appreciated! leave your comments and experiences here! Thank you very much ITaskbarList_V3.7z
    4 points
  43. seadoggie01

    AutoIt Snippets

    Expanding on Nine's task bar adventures... The overlay icon and tooltip were the only other interesting task bar things to me, so I added those + examples #include <GUIConstantsEx.au3> #include <WinAPIIcons.au3> ; For _WinAPI_DestroyIcon #include <WinAPIShellEx.au3> ; For _WinAPI_ShellExtractIcon Global Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}" Global Const $sIID_ITaskbarList3 = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}" Global Const $tagITaskbarList3 = _ "HrInit hresult();" & _ "AddTab hresult(hwnd);" & _ "DeleteTab hresult(hwnd);" & _ "ActivateTab hresult(hwnd);" & _ "SetActiveAlt hresult(hwnd);" & _ "MarkFullscreenWindow hresult(hwnd;boolean);" & _ "SetProgressValue hresult(hwnd;uint64;uint64);" & _ "SetProgressState hresult(hwnd;int);" & _ "RegisterTab hresult(hwnd;hwnd);" & _ "UnregisterTab hresult(hwnd);" & _ "SetTabOrder hresult(hwnd;hwnd);" & _ "SetTabActive hresult(hwnd;hwnd;dword);" & _ "ThumbBarAddButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarUpdateButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarSetImageList hresult(hwnd;ptr);" & _ "SetOverlayIcon hresult(hwnd;ptr;wstr);" & _ "SetThumbnailTooltip hresult(hwnd;wstr);" & _ "SetThumbnailClip hresult(hwnd;ptr);" Example() Func Example() Local $hGUI = GUICreate("AutoIt v3", 400, 100) GUISetState() Local $oTaskBar = TB_Init() TB_ToolTip($oTaskBar, $hGUI, "Working...") ; Load an icon -- this is a blue refresh on Win11 Local $hIcon = _WinAPI_ShellExtractIcon(@SystemDir & "\shell32.dll", 238, 32, 32) TB_SetOverlayIcon($oTaskBar, $hGUI, $hIcon, "Blue refresh") For $i = 1 To 100 TB_SetProgress($oTaskBar, $hGUI, $i, 100) Sleep(25) Next ; Destroy the old icon _WinAPI_DestroyIcon($hIcon) Local $hSecondIcon = _WinAPI_ShellExtractIcon(@SystemDir & "\shell32.dll", 300, 32, 32) TB_SetOverlayIcon($oTaskBar, $hGUI, $hSecondIcon, "Green checkmark") TB_Flash($oTaskBar, $hGUI, 4, 300) TB_ToolTip($oTaskBar, $hGUI, "Waiting for you to close the window") While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Clear the icon overlay TB_SetOverlayIcon($oTaskBar, $hGUI, Null) _WinAPI_DestroyIcon($hSecondIcon) EndFunc ;==>Example Func TB_Init() Local $oTB = ObjCreateInterface($sCLSID_TaskbarList, $sIID_ITaskbarList3, $tagITaskbarList3) $oTB.HrInit() Return $oTB EndFunc ;==>TB_Init Func TB_SetProgress(ByRef $oTB, $hWnd, $iCurrent, $iCompleted) $oTB.SetProgressValue($hWnd, $iCurrent, $iCompleted) EndFunc ;==>TB_SetProgress Func TB_Flash(ByRef $oTB, $hWnd, $iTimes, $iDelay) For $i = 1 To $iTimes $oTB.SetProgressState($hWnd, 0) Sleep($iDelay) $oTB.SetProgressValue($hWnd, 100, 100) Sleep($iDelay) Next $oTB.SetProgressState($hWnd, 0) EndFunc ;==>TB_Flash ; These are icons added to your taskbar icon, showing status usually. Each window only gets 1. Set $hIcon to NULL to clear. ; (Win11) Teams uses this to show your status (busy, free, inactive) and Outlook uses it to show if you have an unread email Func TB_SetOverlayIcon(ByRef $oTB, $hWnd, $hIcon, $sAltText = "") $oTB.SetOverlayIcon($hWnd, $hIcon, $sAltText) EndFunc ;==>TB_SetOverlayIcon ; Depending on settings and version, this may be difficult to see. On Win11 with taskbar previews, it is only visible after hovering over the preview window. Func TB_ToolTip(ByRef $oTB, $hWnd, $sTooltip) $oTB.SetThumbnailTooltip($hWnd, $sTooltip) EndFunc ;==>TB_ToolTip
    4 points
  44. Or a full interface version : #include <Constants.au3> Opt("MustDeclareVars", True) Interface() Func Interface() Local Const $sTagIDispatch = _ "GetTypeInfoCount hresult(dword*);" & _ "GetTypeInfo hresult(dword;dword;ptr*);" & _ "GetIDsOfNames hresult(struct*;struct*;dword;dword;struct*);" & _ "Invoke hresult(uint;struct*;dword;word;struct*;struct*;ptr;uint*);" Local Const $sCLSID_NetworkListManager = "{DCB00C01-570F-4A9B-8D69-199FDBA5723B}" Local Const $sIID_INetworkListManager = "{DCB00000-570F-4A9B-8D69-199FDBA5723B}" Local Const $sTag_INetworkListManager = $sTagIDispatch & _ "GetNetworks hresult(int;ptr*);" & _ "GetNetwork hresult(ptr;ptr*)" & _ "GetNetworkConnections hresult(ptr*);" & _ "GetNetworkConnection hresult(ptr;ptr*);" & _ "IsConnectedToInternet hresult(short*);" & _ "IsConnected hresult(short*);" & _ "GetConnectivity hresult(int_ptr*);" & _ "SetSimulatedProfileInfo hresult(struct*);" & _ "ClearSimulatedProfileInfo hresult();" Local Const $sIID_IEnumNetworkConnections = "{DCB00006-570F-4A9B-8D69-199FDBA5723B}" Local Const $sTag_IEnumNetworkConnections = $sTagIDispatch & _ "NewEnum hresult(ptr*);" & _ "Next hresult(int;ptr*;int*);" & _ "Skip hresult(int);" & _ "Reset hresult();" & _ "Clone hresult(ptr*);" Local Enum $NLM_CONNECTIVITY_DISCONNECTED, $NLM_CONNECTIVITY_IPV4_NOTRAFFIC, $NLM_CONNECTIVITY_IPV6_NOTRAFFIC, _ $NLM_CONNECTIVITY_IPV4_SUBNET = 0x10, $NLM_CONNECTIVITY_IPV4_LOCALNETWORK = 0x20, $NLM_CONNECTIVITY_IPV4_INTERNET = 0x40, _ $NLM_CONNECTIVITY_IPV6_SUBNET = 0x100, $NLM_CONNECTIVITY_IPV6_LOCALNETWORK = 0x200, $NLM_CONNECTIVITY_IPV6_INTERNET = 0x400 Local Const $sIID_INetworkConnection = "{DCB00005-570F-4A9B-8D69-199FDBA5723B}" Local Const $sTag_INetworkConnection = $sTagIDispatch & _ "GetNetwork hresult(ptr*)" & _ "IsConnectedToInternet hresult(boolean*);" & _ "IsConnected hresult(boolean*);" & _ "GetConnectivity hresult(int*);" & _ "GetConnectionId hresult(clsid*);" & _ "GetAdapterId hresult(clsid*);" & _ "GetDomainType hresult(int*);" Local Enum $NLM_NETWORK_CATEGORY_PUBLIC, $NLM_NETWORK_CATEGORY_PRIVATE, $NLM_NETWORK_CATEGORY_DOMAIN_AUTHENTICATED Local Const $sIID_INetwork = "{DCB00002-570F-4A9B-8D69-199FDBA5723B}" Local Const $sTag_INetwork = $sTagIDispatch & _ "GetName hresult(wstr*);" & _ "SetName hresult(wstr);" & _ "GetDescription hresult(wstr*);" & _ "SetDescription hresult(wstr);" & _ "GetNetworkId hresult(clsid*);" & _ "GetDomainType hresult(int*);" & _ "GetNetworkConnections hresult(ptr*);" & _ "GetTimeCreatedAndConnected hresult(int*;int*;int*;int*);" & _ "IsConnectedToInternet hresult(boolean*);" & _ "IsConnected hresult(boolean*);" & _ "GetConnectivity hresult(int*);" & _ "GetCategory hresult(int*);" & _ "SetCategory hresult(int);" Local $pNWCs, $iNum, $pConn, $oNWC, $sGUID, $pNet, $oNet, $sName Local $oNLM_INetworkListManager = ObjCreateInterface($sCLSID_NetworkListManager, $sIID_INetworkListManager, $sTag_INetworkListManager) If Not IsObj($oNLM_INetworkListManager) Then Exit MsgBox($MB_OK, "Error", "INetworkListManager") $oNLM_INetworkListManager.GetNetworkConnections($pNWCs) Local $oNWCs = ObjCreateInterface($pNWCs, $sIID_IEnumNetworkConnections, $sTag_IEnumNetworkConnections) If Not IsObj($oNWCs) Then Exit MsgBox($MB_OK, "Error", "IEnumNetworkConnections") While True $oNWCs.Next(1, $pConn, $iNum) If Not $iNum Then ExitLoop $oNWC = ObjCreateInterface($pConn, $sIID_INetworkConnection, $sTag_INetworkConnection) If Not IsObj($oNWC) Then Exit MsgBox($MB_OK, "Error", "INetworkConnection") $oNWC.GetAdapterId($sGUID) ConsoleWrite("GetAdapterId: " & $sGUID & @CRLF) $oNWC.GetNetwork($pNet) $oNet = ObjCreateInterface($pNet, $sIID_INetwork, $sTag_INetwork) If Not IsObj($oNet) Then Exit MsgBox($MB_OK, "Error", "INetwork") $oNet.GetName($sName) ConsoleWrite("GetName: " & $sName & @CRLF) WEnd EndFunc ;==>Interface
    4 points
  45. Here is a pic of the reworked script, it should be finished in a few days. Maybe I should open a new topic for this, or continue here ?
    4 points
  46. genius257

    Class syntax in AutoIt

    I've made a transpiler for converting AutoIt-like class syntax into AutoIt code. GIthub: https://github.com/genius257/au3class/ Example for the syntax: #include-once Class Example $property = Null Func __construct($ts = 'now') $this.property = 0 EndFunc Func __destruct() ; Destructor code here. EndFunc Func method() Return "something" EndFunc Get Func dynamic() Return $this.dynamic & $this.property EndFunc Set Func dynamic($value) $this.property += 1 $this.dynamic = $value EndFunc EndClass $oExample = Example() $oExample.dynamic = 12 MsgBox(0, "", $oExample.dynamic) MsgBox(0, "", $oExample.method()) $oExample = Null class properties are defined as variables within the Class structure class methods are defined as function declarations within the Class structure property getters and setters need to have Get or Set in front of their function declaration Getter and setter can access their own underlying property, without triggering the getter or setter for said variable. Version 2 produces more code than version 1, but does not need any other scripts included to work. Version 2 is also faster than version 1, since version 2 creates specific code for looking up class members, instead of relying on AutoItObject_Internal with it's dynamic properties lookup. See the example folder on Github for building and using this: https://github.com/genius257/au3class/tree/master/Example
    4 points
  47. Not trying to re-invent the wheel here, but I found some examples that did A-L-O-T that I didn't think was necessary (like forcing owner-drawn), the sparse number of the web examples were failing miserably too. It looked like @argumentum was taking the path I was on, his is much more feature rich ( 😅 ) ... Anyway, I was going to add a font option using this subclass method (Thanks to @LarsJ for his subclass method, saved me some time) but I am out of time and if I don't post this now, I will probably forget to post it later (Yep, age is getting there). @LarsJ - GUIRegisterMsg20 - @argumentum ComboBox Set DROPDOWNLIST Colors/size UDF (Lots-O-Stuff) Here's my short and sweet (I don't think I ever code anything short.. or sweet) Edit 2024-04-10: Added the font change functions, pay attention to the fact that there are 3 different hwnds, the control hwnd, the edit hwnd as well as the listbox hwnd for the combo box. There are 4 functions, one changes all 3, the others change each of the other hwnds. Edit-2 2024-04-10: So I was going to use the forum members meticulous eyes to find issues, but I seemed to find a few that I didn't notice before myself. - Wrong array bounds in font au3 was fixed - Multi color (LB and Edit different colors) fixed (mistakenly used 1 brush ... oops) for color au3 - Missing edit color logic fixed for color au3 GUIComboBox.2024.04.10-002.zip
    4 points
  48. This UDF provides algorithms for fuzzy string comparison and the associated similarity search in string arrays. It offers functions for character-based comparisons, comparing the phonetics of words and the geometric distance of characters on a keyboard. In this way, typing errors can be recognized, similar-sounding words can be detected and other spellings of words can be included in further processing. The current function list of the UDF: --------- fuzzy array handling: _FS_ArraySearchFuzzy - finds similar entries for a search value in an array _FS_ArrayToPhoneticGroups - groups the values of an array according to their phonetics --------- character-based metrics: _FS_Levenshtein - calculate the levenshtein distance between two strings _FS_OSA - calculate the OSA ("optimal string alignment") between two strings _FS_Hamming - calculate the hamming distance between two strings --------- phonetic metrics: _FS_Soundex_getCode - calculate the soundex code for a given word to represent the pronounciation in english _FS_Soundex_distance - calculate the soundex-pattern for both input values _FS_SoundexGerman_getCode - calculate the modified soundex code for german language for a given word to represent the pronounciation in german _FS_SoundexGerman_distance - calculate the soundexGerman-pattern for both input values _FS_Cologne_getCode - calculate the cologne phonetics code for german language for a given word to represent the pronounciation in german _FS_Cologne_distance - calculate the cologne phonetics distance between both input values --------- key-position based metrics: _FS_Keyboard_GetLayout - return a map with coordinates for the characters for using in _FS_Keyboard_Distance_Chars() _FS_Keyboard_Distance_Chars - calculates the geometric key spacing between two characters on a keyboard _FS_Keyboard_Distance_Strings - calculate the keyboard-distance between two strings >>sourcecode and download on github<<
    4 points
  49. @UEZ, nice. I've fiddled with the UEZ listing a bit you can now rotate the image visually with a slider you can also finely adjust the rotation with two buttons I also added 2 "rulers", one vertical and one horizontal, which you can move by clicking on them and dragging them, in order to have a reference to control the orientation of the image ;Coded by UEZ 2024-03-16 ; [few mods by Gianni :) ] #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ; --- rulers ----- Global $iThickness = 4 Global $hGUI1 = GUICreate("", @DesktopWidth, $iThickness, 0, @DesktopHeight / 2, $WS_POPUP, $WS_EX_TOPMOST) GUICtrlCreateLabel("", 0, 0, @DesktopWidth, $iThickness, -1, $GUI_WS_EX_PARENTDRAG) GUISetBkColor(0x00ff00, $hGUI1) WinSetTrans($hGUI1, "", 127) GUISetState(@SW_SHOW, $hGUI1) Global $hGUI2 = GUICreate("", $iThickness, @DesktopHeight, @DesktopWidth / 2, 0, $WS_POPUP, $WS_EX_TOPMOST) GUICtrlCreateLabel("", 0, 0, $iThickness, @DesktopHeight, -1, $GUI_WS_EX_PARENTDRAG) GUISetBkColor(0x00ff00, $hGUI2) WinSetTrans($hGUI2, "", 127) GUISetState(@SW_SHOW, $hGUI2) ; ---------------- Global $sFile = "cover.jpg" ;FileOpenDialog("Select an image", "", "Images (*.jpg;*.png;*.gif;*.bmp)") If @error Then Exit Const $fPI = ACos(-1) _GDIPlus_Startup() Global $hImage = _GDIPlus_ImageLoadFromFile($sFile) Global $aDim = _GDIPlus_ImageGetDimension($hImage) Global Const $hGUI = GUICreate("Image Rotate", $aDim[0], $aDim[1] + 50) Global Const $hDC = _WinAPI_GetDC($hGUI) Global Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $aDim[0], $aDim[1]) Global Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Global Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Global Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) Global Const $hPen = _GDIPlus_PenCreate(0xFFFFFFFF) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, 4) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) Global $hButton1 = GUICtrlCreateButton(' < ', 10, $aDim[1] + 10, 40) Global $Slider = GUICtrlCreateSlider(60, $aDim[1] + 10, 360, 25) GUICtrlSetLimit(-1, 360, 0) ; change min/max value Global $hButton2 = GUICtrlCreateButton(' > ', 430, $aDim[1] + 10, 40) Global $hSlider = GUICtrlGetHandle($Slider) Global $Dummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_HSCROLL, "WM_HVSCROLL") ;horz slider GUISetState(@SW_SHOW, $hGUI) _ImageRefresh() ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Dummy _GDIPlus_ImageRotate($hImage, GUICtrlRead($Slider)) _ImageRefresh() Case $hButton1 _FineTuning(1) Case $hButton2 _FineTuning(2) EndSwitch WEnd _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_ReleaseDC($hGUI, $hDC) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _GDIPlus_PenDispose($hPen) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Func _FineTuning($iDirection) Local Static $iAngle Local Static $iSliderPos = GUICtrlRead($Slider) If $iSliderPos <> GUICtrlRead($Slider) Then $iAngle = 0 $iSliderPos = GUICtrlRead($Slider) EndIf Switch $iDirection Case 1 $iAngle -= .1 If $iAngle < 0 Then $iAngle = .9 $iSliderPos -= 1 If $iSliderPos < 0 Then $iSliderPos = 359 GUICtrlSetData($Slider, $iSliderPos) EndIf Case 2 $iAngle += .1 If $iAngle > .9 Then $iAngle = 0 $iSliderPos += 1 If $iSliderPos > 359 Then $iSliderPos = 0 GUICtrlSetData($Slider, $iSliderPos) EndIf EndSwitch _GDIPlus_ImageRotate($hImage, $iSliderPos + $iAngle) _ImageRefresh() EndFunc ;==>_FineTuning Func _ImageRefresh() _GDIPlus_GraphicsClear($hCanvas) _GDIPlus_GraphicsDrawImageRect($hCanvas, $hImage, 0, 0, $aDim[0], $aDim[1]) _WinAPI_BitBlt($hDC, 0, 0, $aDim[0], $aDim[1], $hDC_backbuffer, 0, 0, $SRCCOPY) EndFunc ;==>_ImageRefresh Func _GDIPlus_ImageRotate($hImage, $fDegree) ; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fDegree = ' & $fDegree & @TAB & '>Error code: ' & @error & @CRLF) ;### Debug Console Local $hMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($hMatrix, $aDim[0] / 2, $aDim[1] / 2) _GDIPlus_MatrixRotate($hMatrix, $fDegree) _GDIPlus_MatrixTranslate($hMatrix, -$aDim[0] / 2, -$aDim[1] / 2) _GDIPlus_GraphicsSetTransform($hCanvas, $hMatrix) _GDIPlus_MatrixDispose($hMatrix) EndFunc ;==>_GDIPlus_ImageRotate Func WM_HVSCROLL($hwnd, $iMsg, $wParam, $lParam) #forceref $hwnd, $iMsg, $wParam, $lParam Switch $iMsg Case $WM_HSCROLL Switch $lParam Case $hSlider GUICtrlSendToDummy($Dummy, GUICtrlRead($Slider)) EndSwitch Case $WM_VSCROLL EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_HVSCROLL
    4 points
×
×
  • Create New...