Leaderboard
Popular Content
Showing content with the highest reputation on 09/11/2024 in all areas
-
TaskPin
argumentum and one other reacted to ioa747 for a topic
New versions are available ( in the first post ) TaskPin.au3 0.0.0.9 and TaskPinEditor.au3 0.0.0.9 I added Dark Mode, to match to my taskbar by following the instructions I found here In pre-existing settings, you can set it manually by adding the GuiDarkMode=1 key to the ini.file in the [GUI_Settings] section have fun Thank you very much2 points -
the script uses CUIAutomation2.au3 UDF from https://www.autoitscript.com/forum/topic/201683-ui-automation-udfs/ Functions to interact with the taskbar. ; https://www.autoitscript.com/forum/topic/212266-functions-to-interact-with-the-taskbar/ ;---------------------------------------------------------------------------------------- ; Title...........: _TaskBar.au3 ; Description.....: Function to interact with the taskbar. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 2.0 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #NoTrayIcon #include ".Includes\CUIAutomation2.au3" ; * <- "https://www.autoitscript.com/forum/topic/201683-ui-automation-udfs/" #include <GUIConstantsEx.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <Array.au3> Example() ;-------------------------------------------------------------------------------------------------------------------------------- Func Example() Local $aTBPos, $sTxt, $a ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ;Get information from NotifyArea $sTxt &= "let's take the Everything program for example" & @CRLF $sTxt &= 'first we find the tray icon in NotifyArea' & @CRLF $sTxt &= '(NotifyArea = $iAreaId 2 )' & @CRLF & @CRLF $sTxt &= ' _TaskBar(2, "something not exist")' & @CRLF & @CRLF $sTxt &= '$sSearchString = "something not exist"' & @CRLF $sTxt &= 'to show us all the results' & @CRLF & @CRLF $sTxt &= 'the console only shows results when it doesn''t match' & @CRLF _Msg($sTxt) _TaskBar(2, "something not exist") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Double-click in NotifyArea $sTxt &= "now we know that the target icon " & @CRLF $sTxt &= "starts with the word 'Everything'" & @CRLF & @CRLF $sTxt &= "Now we can send Click, Right-click, or Double-click" & @CRLF & @CRLF $sTxt &= "send Double-click to tray icon" & @CRLF $sTxt &= "(Double-click = $iActionId 4 )" & @CRLF & @CRLF $sTxt &= ' _TaskBar(2, "Everything", 4)' & @CRLF _Msg($sTxt) $aTBPos = _TaskBar(2, "Everything", 4) $a = $aTBPos[0][1] ConsoleWrite($aTBPos[0][1] & ", Rect: " & $a[0] & ", " & $a[1] & ", " & $a[2] & ", " & $a[3] & @CRLF) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Right-click & send in RunningAppsArea $sTxt &= "now that the window has opened it created a new" & @CRLF $sTxt &= "icon down in the task bar to RunningApps area" & @CRLF & @CRLF $sTxt &= '(RunningAppsArea = $iAreaId 1 )' & @CRLF $sTxt &= "(Right-click = $iActionId 3 )" & @CRLF & @CRLF $sTxt &= '_TaskBar(1, "Everything", 3, "{UP}{ENTER}")' & @CRLF & @CRLF $sTxt &= '$sOption = "{UP}{ENTER}"' & @CRLF $sTxt &= 'Right-click and Send' & @CRLF _Msg($sTxt) _TaskBar(1, "Everything", 3, "{UP}{ENTER}") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Everything' icon from NotifyArea" & @CRLF $sTxt &= "to OverflowNotifyArea" & @CRLF & @CRLF $sTxt &= '(NotifyArea = $iAreaId 2 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = "OverflowButton" )' & @CRLF & @CRLF $sTxt &= '_TaskBar(2, "Everything", 5, "OverflowButton")' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(2, "Everything", 5, "OverflowButton") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Everything' icon from OverflowNotifyArea" & @CRLF $sTxt &= "back to NotifyArea at old position" & @CRLF & @CRLF $sTxt &= '(OverflowNotifyArea = $iAreaId 3 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = "X:" & $a[2] )' & @CRLF & @CRLF $sTxt &= '_TaskBar(3, "Everything", 5, "X:" & $a[2])' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(3, "Everything", 5, "X:" & $a[2]) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Right-click & send in RunningAppsArea $sTxt &= 'Next step open Notepad' & @CRLF $sTxt &= 'Right-click on tray icon and Pin to taskbar' & @CRLF & @CRLF $sTxt &= 'Right-click and Send 2 UP && ENTER' & @CRLF $sTxt &= ' _TaskBar("Notepad -", 1, 3, "{UP 2}{ENTER}")' & @CRLF _Msg($sTxt) ShellExecute("notepad") WinWaitActive("[CLASS:Notepad]", "") _TaskBar(1, "Notepad -", 3, "{UP 2}{ENTER}") WinClose("[CLASS:Notepad]", "") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Notepad' icon 3 positions to the Left" & @CRLF & @CRLF $sTxt &= '(RunningAppsArea = $iAreaId 1 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = -3 )' & @CRLF & @CRLF $sTxt &= '_TaskBar(1, "Notepad", 5, -3)' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(1, "Notepad", 5, -3) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Notepad' icon 3 positions to the Right" & @CRLF & @CRLF $sTxt &= '(RunningAppsArea = $iAreaId 1 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = 3 )' & @CRLF & @CRLF $sTxt &= '_TaskBar(1, "Notepad", 5, 3)' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(1, "Notepad", 5, 3) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Notepad' icon at positions 0" & @CRLF & @CRLF $sTxt &= '(RunningAppsArea = $iAreaId 1 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = "index:0" )' & @CRLF & @CRLF $sTxt &= '_TaskBar(1, "Notepad", 5, "index:0")' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(1, "Notepad", 5, "index:0") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Notepad' icon at last positions" & @CRLF $sTxt &= "by using $sOption = X:n" & @CRLF & @CRLF $sTxt &= '(RunningAppsArea = $iAreaId 1 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = "X:" & @DesktopWidth )' & @CRLF & @CRLF $sTxt &= '_TaskBar(1, "Notepad", 5, "X:" & @DesktopWidth)' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(1, "Notepad", 5, "X:" & @DesktopWidth) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ;Get information from RunningAppsArea $sTxt &= "at this step" & @CRLF $sTxt &= "we trap the Notepad pin with" & @CRLF $sTxt &= "($iActionId 1 = Get the button positions and label.)" & @CRLF & @CRLF $sTxt &= "move the mouse over the Notepad pin" & @CRLF _Msg($sTxt) $aTBPos = _TaskBar(1, "Notepad", 1) $a = $aTBPos[0][1] Local $iMsgBoxAnswer, $bLoop = True While $bLoop If IsMouseOverRect($a) Then $iMsgBoxAnswer = MsgBox(292, "Rect: " & $a[0] & ", " & $a[1] & ", " & $a[2] & ", " & $a[3], "do you want to get out of the loop?") Select Case $iMsgBoxAnswer = 6 ;Yes $bLoop = False EndSelect EndIf Sleep(300) WEnd ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Right-click & send in RunningAppsArea $sTxt &= 'Now UnPin Notepad pin' & @CRLF $sTxt &= 'Right-click and Send UP & ENTER' & @CRLF $sTxt &= 'UnPin from taskbar' & @CRLF & @CRLF $sTxt &= ' _TaskBar(1, "Notepad -", 3, "{UP}{ENTER}")' & @CRLF & @CRLF $sTxt &= 'here attention if there is notepad++ taskpin, it unpin this' & @CRLF $sTxt &= 'because it is more forward and starts with word notepad' & @CRLF _Msg($sTxt) _TaskBar(1, "Notepad", 3, "{UP}{ENTER}") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Right-click & send in OverflowNotifyArea $sTxt &= 'Now for (OverflowNotifyArea = $iAreaId 3 ) ' & @CRLF & @CRLF $sTxt &= ' Right-click and Send 5 UP on bluetooth' & @CRLF & @CRLF $sTxt &= ' _TaskBar(3, "bluetooth", 3, "{UP 5}")' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(3, "bluetooth", 3, "{UP 5}") Sleep(5000) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ;Get information from RunningAppsArea $sTxt &= "or you can call only with the $iAreaId parameter," & @CRLF $sTxt &= "1 - Get the button positions and labels" & @CRLF $sTxt &= "and take the whole table for any use" & @CRLF & @CRLF $sTxt &= '$aTBPos = _TaskBar(1)' & @CRLF & @CRLF _Msg($sTxt) $aTBPos = _TaskBar(1) _ArrayDisplay($aTBPos) _Msg("Exit") EndFunc ;==>Example ;-------------------------------------------------------------------------------------------------------------------------------- Func _Msg($sMsg) Local $hGui = GUICreate("Msg", 395, 237, @DesktopWidth * 0.1, @DesktopHeight * 0.5, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) GUISetFont(11, 400, 0, "DejaVu Sans Condensed") GUICtrlCreateLabel($sMsg, 5, 10, 376, 181) Local $Button_OK = GUICtrlCreateButton("OK", 160, 200, 75, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button_OK ExitLoop EndSwitch WEnd GUIDelete($hGui) EndFunc ;==>_Msg ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _TaskBar ; Description....: Function to interact with the taskbar. ; Syntax.........: _TaskBar ( $iAreaId = 1, $sSearchString = "@All", $iActionId = 1, $sOption = "", $sUserToolBarPar = "index:1" ) ; Parameters.....: $iAreaId - The ID of Area to interact with. Can be one of the following values: ; 1 - RunningAppsArea - Running applications. (Default) ; 2 - NotifyArea - Notification area. ; 3 - OverflowNotifyArea - Overflow Notification Area. ; $sSearchString - The string to search for in the button labels. Matches partial string from the start. (Default = "@All") ; $iActionId - The action to perform. Can be one of the following values: ; 1 - Get the button positions and labels. (Default) ; 2 - Click on a button with the specified label. ; 3 - Right-click on a button with the specified label. ; 4 - Double-click on a button with the specified label. ; 5 - Click&Drag a button with the specified label to specify X axis place ; $sOption - [optional] Additional parameter required by some commands. (Default = "") ; if $iActionId = 2, $sOption = "SendKeys" - Extra string to send after click. ; "{UP 2}{ENTER}" send 2 UP and ENTER to elect the specify menu ; if $iActionId = 3, $sOption = "SendKeys" - Extra string to send after click. ; "o" send o to select the open menu ; if $iActionId = 5, $sOption = "NumberToMove" - number of place to move, posive = Right, negative = Left ; "3" move button, 3 positions to the Right ; "-3" move button, 3 positions to the Left ; "index:3" move button, to positions 3 ; "X:300" move button, to X coordinate ; "OverflowButton" move button from NotifyArea, to OverflowNotifyArea and vice versa ; Return values..: Success - An 2D Array containing the rect positions of the button that match the search string. ; $a[i][0]=Label, $a[i][1]=$aRect Array | $aRect[0]=Left, $aRect[1]=Top, $aRect[2]=Right, $aRect[3]=Bottom. ; - if $sSearchString does not match, it returns 2D Array of all items. ; Failure - return error message if there is an error. ; Author.........: ioa747 ; Modified.......: ; Related .......: This function uses the CUIAutomation2.au3 "https://www.autoitscript.com/forum/topic/201683-ui-automation-udfs/" ; Link ..........: ;-------------------------------------------------------------------------------------------------------------------------------- Func _TaskBar($iAreaId = 1, $sSearchString = "@All", $iActionId = 1, $sOption = "") Local $hWndTray = WinGetHandle("[CLASS:Shell_TrayWnd]") ; Taskbar Local $hOverflowButton = ControlGetHandle($hWndTray, "", "Button2") Local $hToolbar Switch $iAreaId Case 1 ;RunningAppsArea Local $hRebar = ControlGetHandle($hWndTray, "", "[CLASS:ReBarWindow32]") Local $hMSTaskSwWClass = ControlGetHandle($hRebar, "", "[CLASS:MSTaskSwWClass]") $hToolbar = ControlGetHandle($hMSTaskSwWClass, "", "[CLASS:MSTaskListWClass]") Case 2 ;NotifyArea Local $hTrayNotify = ControlGetHandle($hWndTray, "", "[CLASS:TrayNotifyWnd]") Local $hSysPager = ControlGetHandle($hTrayNotify, "", "[CLASS:SysPager]") $hToolbar = ControlGetHandle($hSysPager, "", "ToolbarWindow321") Case 3 ;OverflowNotifyArea Local $hWndOverflow = WinGetHandle("[CLASS:NotifyIconOverflowWindow]") $hToolbar = ControlGetHandle($hWndOverflow, "", "ToolbarWindow321") Case Else Return _EW("wrong $iAreaId") EndSwitch ; https://www.autoitscript.com/forum/topic/133222-manipulate-system-tray-program-right-click-choose-option/page/2/#comment-1499538 ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If Not IsObj($oUIAutomation) Then Return _EW("$oUIAutomation ERR") ;ConsoleWrite("$oUIAutomation OK" & @CRLF) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement($pDesktop) $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oDesktop) Then Return _EW("$oDesktop ERR") ;ConsoleWrite("$oDesktop OK" & @CRLF) ; Get element by handle Local $pElement, $oElement $oUIAutomation.ElementFromHandle($hToolbar, $pElement) $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oElement) Then Return _EW("$oElement ERR") ;ConsoleWrite("$oElement OK" & @CRLF) ; Get condition (ControlType = Button) Local $pCondition, $oCondition $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition) $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition) If Not IsObj($oCondition) Then Return _EW("$oCondition ERR") ;ConsoleWrite("$oCondition OK" & @CRLF) ; Find all buttons Local $pElementArray, $oElementArray, $iElements $oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray) $oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) $oElementArray.Length($iElements) If Not IsObj($oElementArray) Then Return _EW("$oElementArray ERR") ; Get array of buttons Local $aElements[$iElements] For $i = 0 To $iElements - 1 $oElementArray.GetElement($i, $pElement) $aElements[$i] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) Next ; Get name and position for each button $UIA_LegacyIAccessibleNamePropertyId Local $sValue, $aPos[4], $aBtnArray[$iElements][2] Local $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom") Local $iChrCnt = StringLen($sSearchString) Local $sHelpTxt, $bMatch = False Local $aExtract, $aResult For $i = 0 To UBound($aElements) - 1 $aElements[$i].GetCurrentPropertyValue($UIA_NamePropertyId, $sValue) $aElements[$i].CurrentBoundingRectangle($tRect) $aPos[0] = $tRect.Left $aPos[1] = $tRect.Top $aPos[2] = $tRect.Right $aPos[3] = $tRect.Bottom $aBtnArray[$i][0] = $sValue $aBtnArray[$i][1] = $aPos $sHelpTxt &= $i & ") " & $aBtnArray[$i][0] & @CRLF If StringLeft($aBtnArray[$i][0], $iChrCnt) = $sSearchString Then $aExtract = _ArrayExtract($aBtnArray, $i, $i) $bMatch = True $sHelpTxt = "" ExitLoop EndIf Next $aResult = ($bMatch ? $aExtract : $aBtnArray) ; only if $sSearchString not match and <> "@No@" If $sSearchString <> "@No@" Then ConsoleWrite($sHelpTxt) Local $aMpos, $iAdjust Switch $iActionId Case 1 ;Get Return $aResult Case 2, 3, 4 ; 2=$MOUSE_CLICK_LEFT ; 3=$MOUSE_CLICK_RIGHT ; 4=$MOUSE_DBL_CLICK_LEFT ; only if $sSearchString match If UBound($aResult) = 1 Then Local $iClick = ($iActionId = 4 ? 2 : 1) Local $iButton = ($iActionId = 3 ? $MOUSE_CLICK_RIGHT : $MOUSE_CLICK_LEFT) $aPos = $aResult[0][1] ;ConsoleWrite("$aPos =" & $aPos[0] & ", " & $aPos[1] & ", " & $aPos[2] & ", " & $aPos[3] & @CRLF) $iAdjust = ($aPos[2] - $aPos[0]) / 2 $aMpos = MouseGetPos() ;Bakup mouse position If $iAreaId = 3 Then ControlClick($hWndTray, "", $hOverflowButton) ;fist click the Overflow Button MouseClick($iButton, $aPos[0] + $iAdjust, $aPos[1] + $iAdjust, $iClick, 1) If $sOption Then WinActivate($hWndTray) Opt("SendKeyDownDelay", 50) ;you may need to raise Opt("SendKeyDelay", 50) ;you may need to raise Send($sOption) Opt("SendKeyDelay", 5) ;5 milliseconds - Default Opt("SendKeyDownDelay", 5) ;5 milliseconds - Default Send("{ESC}") EndIf MouseMove($aMpos[0], $aMpos[1], 1) ;restore mouse position Return $aResult EndIf Case 5 ; 5=Click&Drag ; only if $sSearchString match If UBound($aResult) = 1 Then $aPos = $aResult[0][1] ;ConsoleWrite("$aPos =" & $aPos[0] & ", " & $aPos[1] & ", " & $aPos[2] & ", " & $aPos[3] & @CRLF) $iAdjust = ($aPos[2] - $aPos[0]) / 2 Local $iBtnWidth = $aPos[2] - $aPos[0] Local $iX2 Local $aOption = StringSplit($sOption, ":") If $aOption[0] = 2 Then If $aOption[1] = "X" Then $iX2 = Int($aOption[2]) ConsoleWrite("$iX2=" & $iX2 & @CRLF) ElseIf $aOption[1] = "Index" Then Local $aIdx = $iAreaId = 1 ? _TaskBar(1, "@No@") : _TaskBar(2, "@No@") $aOption[2] = Int($aOption[2]) If $aOption[2] > UBound($aIdx) - 1 Then Return _EW("wrong Click&Drag $sOption Index:ERR") Local $a = $aIdx[$aOption[2]][1] $iX2 = $a[0] Else Return _EW("wrong Click&Drag $sOption") EndIf Else $sOption = Int($sOption) $iX2 = $aPos[0] + $iAdjust + $iBtnWidth * $sOption EndIf If $sOption = "OverflowButton" Then ; RunningAppsArea not suporting If $iAreaId = 1 Then Return _EW("wrong Click&Drag $sOption, RunningAppsArea not suporting OverflowButton") Local $aCtrlPos = ControlGetPos($hWndTray, "", $hOverflowButton) ;Drag Position = OverflowButton $iX2 = $aCtrlPos[0] + $aCtrlPos[2] / 2 EndIf $aMpos = MouseGetPos() ;Bakup mouse position ; if OverflowNotifyArea fist click the Overflow Button If $iAreaId = 3 Then ControlClick($hWndTray, "", $hOverflowButton) MouseClickDrag($MOUSE_CLICK_LEFT, $aPos[0] + $iAdjust, $aPos[1] + $iAdjust, $iX2, @DesktopHeight - $iAdjust, 1) WinActivate($hWndTray) Send("{ESC}") MouseMove($aMpos[0], $aMpos[1], 1) ;restore mouse position Return $aResult EndIf Case Else Return _EW("wrong $iActionId") EndSwitch ;_ArrayDisplay($aBtnArray) EndFunc ;==>_TaskBar ;-------------------------------------------------------------------------------------------------------------------------------- Func IsMouseOverRect($aRect) If Not IsArray($aRect) Then Return _EW("Not array found") Local $Width = $aRect[2] - $aRect[0] Local $Height = $aRect[3] - $aRect[1] $aRect[2] = $Width $aRect[3] = $Height ;$aRect[0]=X ;$aRect[1]=Y ;$aRect[2]=Width ;$aRect[3]=Height Local $aMpos = MouseGetPos() If $aMpos[0] > $aRect[0] And $aMpos[1] > $aRect[1] And $aMpos[0] < $aRect[0] + $aRect[2] And $aMpos[1] < $aRect[1] + $aRect[3] Then Return True EndIf Return False EndFunc ;==>IsMouseOverRect ;-------------------------------------------------------------------------------------------------------------------------------- Func _EW($sString, $iLine = @ScriptLineNumber) ConsoleWrite("! (" & $iLine & ") " & $sString & @CRLF) EndFunc ;==>_EW ;-------------------------------------------------------------------------------------------------------------------------------- And while we're on the subject of TaskBar, here's another related one ;---------------------------------------------------------------------------------------- ; Title...........: ShellTrayRefresh.au3 ; Description.....: Refreshes ShellTray to remove leftover zombie icons ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ; https://www.autoitscript.com/forum/topic/139260-autoit-snippets/page/25/#comment-1529091 ;---------------------------------------------------------------------------------------- Func ShellTrayRefresh() Local $aStartPos = MouseGetPos() Local $hTrayWnd = WinGetHandle("[CLASS:Shell_TrayWnd]") Local $hTlb = ControlGetHandle($hTrayWnd, "", "ToolbarWindow323") Local $hBtn = ControlGetHandle($hTrayWnd, "", "Button2") Local $aPos = ControlGetPos($hTrayWnd, "", $hBtn) Local $aTPos = ControlGetPos($hTrayWnd, "", $hTlb) For $i = ($aPos[0] - 1) + ($aPos[2] / 2) To $aPos[0] + $aPos[2] + $aTPos[2] Step $aPos[2] MouseMove($i, @DesktopHeight - 3, 1) ;~ ConsoleWrite("$i=" & $i & @CRLF) ;~ Sleep(10) Next MouseMove($aStartPos[0], $aStartPos[1], 1) EndFunc ;==>ShellTrayRefresh as well as the link ITaskbarList4 interface Please, every comment is appreciated! leave your comments and experiences here! Thank you very much1 point
-
Ellipsis styles (3 dots)
ioa747 reacted to pixelsearch for a topic
Hi everybody Yesterday I found a script from @Melba23 where he used Ellipsis styles (3 dots) for label controls and I never heard about them before. Here is the script, where I added code for 3rd/4th labels and comments : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $spath = "C:\I am a very long path\Which needs to be\Shortened to fit\In the label.txt" $hGUI = GUICreate("Test on ellipsis (3 dots)", 500, 250) GUICtrlCreateLabel($sPath, 10, 10, 300, 40, $DT_PATH_ELLIPSIS) ; in fact SS_ENDELLIPSIS GUICtrlSetBkColor(-1, 0xC0FFFF) GUICtrlCreateLabel($sPath, 10, 70, 300, 40, $DT_END_ELLIPSIS) ; in fact SS_PATHELLIPSIS GUICtrlSetBkColor(-1, 0xFFFF00) GUICtrlCreateLabel($sPath, 10, 130, 300, 40, $DT_WORD_ELLIPSIS) ; 0x00040000 (but this is the WS_SIZEBOX style, nice effect on label !) GUICtrlSetBkColor(-1, 0xC0FF00) GUICtrlCreateLabel($sPath, 10, 190, 300, 40, 0x0000C000) ; SS_WORDELLIPSIS GUICtrlSetBkColor(-1, 0xC0FFFF) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd #cs Melba23's comments : "Note that I am pretty sure the 2 values [$DT_PATH_ELLIPSIS and $DT_END_ELLIPSIS] have been reversed in the [Windows]Constants file as I would have labelled them the other way round. But MS work in strange ways and perhaps they really are that way." :) My research : 1) Found in WindowsConstants.au3 and in WinUser.h : DrawText() Format Flags #define DT_PATH_ELLIPSIS 0x00004000 #define DT_END_ELLIPSIS 0x00008000 #define DT_WORD_ELLIPSIS 0x00040000 2) Not found in WindowsConstants.au3 but found in WinUser.h : Static Control Constants #define SS_ENDELLIPSIS 0x00004000 #define SS_PATHELLIPSIS 0x00008000 #define SS_WORDELLIPSIS 0x0000C000 #ce imho the Ellipsis styles applied to label (static) controls should be the ones found on msdn page (i.e. Static Control Styles : SS_ENDELLIPSIS, SS_PATHELLIPSIS and SS_WORDELLIPSIS) but not the ones found in the script above (DT_END_ELLIPSIS, DT_PATH_ELLIPSIS and DT_WORD_ELLIPSIS) which should be applied to the Draw Text function. First of all, the corresponding styles don't have the same value (see comments at the end of the script) though it's not an issue in this case for two of them, as both 0x00004000 and 0x00008000 can't be mixed with GUI styles, but what about the 3rd ellipsis style (the Word ellipsis style) ? See what happens in the script when I wrongly use the DT_WORD_ELLIPSIS style for the 3rd label : It's value of 0x00040000 is the same as the WS_SIZEBOX Gui style (0x00040000) . That's why we see the 3rd label with a raised edge and a sizing border, which doesn't look bad at all (I'll have to remember that !) but the style did not fulfill its role. The 4th label shows the style that should be applied : SS_WORDELLIPSIS (0x0000C000) instead of DT_WORD_ELLIPSIS (0x00040000) For the record, as I didn't see any display difference between label 1 (SS_ENDELLIPSIS) and label 4 (SS_WORDELLIPSIS) then I searched on the Web and found this link on Stackoverflow If you're curious to see a difference between both styles, you can try this on the _WinAPI_DrawText example, with the following change (not the best change but well... at least we can see different displays) : _WinAPI_DrawText($g_hDC, "Hello world!", $g_tRECT, $DT_CENTER) ; original line in help file example ; _WinAPI_DrawText($g_hDC, "Hi" & @crlf & " world, how are you ?", $g_tRECT, $DT_END_ELLIPSIS) ; _WinAPI_DrawText($g_hDC, "Hi" & @crlf & " world, how are you ?", $g_tRECT, $DT_WORD_ELLIPSIS) Thanks Melba23 for this Ellipsis discovery and just feel free to comment if I wrote anything wrong. Have a great week-end1 point -
Generate interactive line graphics, pie charts and much more with IE and chart.js
argumentum reacted to qsek for a topic
Just wanted to share a quick proof of concept with some performance testing. GraphGDIPlus lacked performance and interactivity for me so i searched new way to generate graphs. Potential is huge especially when you consider using d3.js instead of chart.js #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Array.au3> #include <File.au3> #include <Date.au3> #include <IE.au3> Opt("GuiOnEventMode", 1) $oIE = ObjCreate("Shell.Explorer.2") $Form1 = GUICreate("Embedded Web control Test", 1140, 380, _ (@DesktopWidth - 1140) / 2, (@DesktopHeight - 380) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlCreateObj($oIE, 10, 10, 1120, 360) GUICtrlSetResizing ( -1, 1 ) GUISetOnEvent(-3, "_MyExit", $Form1) GUISetState() Func _MyExit() Exit EndFunc ConsoleWrite("generating dataset..." & @CRLF) ; generate a 5k line dataset ; string $datastr = "" For $i = 0 To 2000 $date = _DateAdd("n", $i, "2021/02/14 00:00:00") $datastr &= $date&","&Random(1,500,1)& @CRLF next $datastr = StringTrimRight($datastr, 2) ; array Dim $dataarr[0][2] _ArrayAdd ( $dataarr, $datastr, 0, ",", @CRLF) ConsoleWrite("finished." & @CRLF& @CRLF) $oIE.navigate( "about:blank") $html = "" Sethtml() _IEDocWriteHTML($oIE, $html) _IEAction ( $oIE, "refresh" ) _IELoadWait($oIE) ;~ ; watch your variable/function case with that notation! $ohJS = $oIE.document.parentwindow.JSglobal ;~ ; need to eval [0], javascript arrays are not compatible with autoit arrays or object collections $dset = $ohJS.eval("myChart.data.datasets[0]") $dset.label = "Test1: init dataset with jsvariable.push()" $ohJS.myChart.update() ConsoleWrite("Test1: init dataset with jsvariable.push()"& @CRLF) $ti = TimerInit() ; Test1 $glabels = $ohJS.myChart.data.labels For $i = 0 To UBound($dataarr)-1 If Mod($i,1000) = 0 then ConsoleWrite($i & @CRLF) $glabels.push($dataarr[$i][0]) $dset.data.push($dataarr[$i][1]) next $ohJS.myChart.update() ConsoleWrite("Test1: "&Round(TimerDiff($ti),1)&" ms"& @CRLF) Sleep(2000) $ohJS.GraphClearData() Sleep(1000) ConsoleWrite("Test2: init dataset with passing datastring to js function"& @CRLF) $ti = TimerInit() ; Test2 $ohJS.InitGraphWithData($datastr) $ohJS.myChart.update() ConsoleWrite("Test2: "&Round(TimerDiff($ti),1)&" ms"& @CRLF) Sleep(2000) $ohJS.GraphClearData() $dset.label = "Test3: add data with jsvariable.push()" $ohJS.myChart.update() ConsoleWrite("Test3: add data with jsvariable.push()"& @CRLF) $ti = TimerInit() ; Test3 $glabels = $ohJS.myChart.data.labels For $i = 0 To 500 If Mod($i,100) = 0 then $dset.label = "Test3: add data with jsvariable.push() ("&$i&"/500)" $date = _DateAdd("n", $i, "2021/02/14 00:00:00") $glabels.push($date) $dset.data.push(Random(1,500+$i,1)) $ohJS.myChart.update() Next ConsoleWrite("Test3: "&Round(TimerDiff($ti),1)&" ms"& @CRLF) $ohJS.GraphClearData() ConsoleWrite("Test4: add data with passing datastring to js function" & @CRLF) $ti = TimerInit() ; Test4 For $i = 0 To 500 If Mod($i,100) = 0 then $dset.label = "Test4: add data with passing datastring to js function ("&$i&"/500)" $date = _DateAdd("n", $i, "2021/02/14 00:00:00") $ohJS.GraphAddData($date&","&Random(1,500+$i,1)) If Mod($i,100) = 0 then $dset.label = "Test4: add data with passing datastring to js function ("&$i&"/500)" Next ConsoleWrite("Test4: "&Round(TimerDiff($ti),1)&" ms"& @CRLF) ConsoleWrite("testing ended" & @CRLF) $dset.label = "You can click on points" $ohJS.myChart.update() While 1 For $i = 0 To $ohJS.clickedPoints.length -1 $label = $ohJS.eval("myChart.data.labels[clickedPoints["&$i&"]._index].format('YYYY/MM/DD hh:mm:ss');") $value = $ohJS.eval("myChart.data.datasets[clickedPoints["&$i&"]._datasetIndex].data[clickedPoints["&$i&"]._index];") ConsoleWrite("You clicked at " & $label & ", "&$value & @CRLF) Next $ohJS.clickedPoints = "" Sleep(10) WEnd exit Func Sethtml() $html = "<!DOCTYPE html>" & @CRLF & _ "<html lang='en'>" & @CRLF & _ "" & @CRLF & _ "<head>" & @CRLF & _ " <meta charset='UTF-8'>" & @CRLF & _ " <meta http-equiv='X-UA-Compatible' content='IE=edge' >" & @CRLF & _ " <script src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'></script>" & @CRLF & _ " <script src='https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js'></script>" & @CRLF & _ " <script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js'></script>" & @CRLF & _ " <title>My Chart</title>" & @CRLF & _ "</head>" & @CRLF & _ "" & @CRLF & _ "<body>" & @CRLF & _ " <div class='container'> <canvas id='myChart' width='100' height='30'></canvas></div>" & @CRLF & _ "" & @CRLF & _ " <script>" & @CRLF & _ " var JSglobal = (1,eval)('this');" & @CRLF & _ " var au3data = ['test','123'];" & @CRLF & _ " var clickedPoints = '';" & @CRLF & _ " Chart.defaults.global.animation.duration = 0;" & @CRLF & _ " Chart.defaults.global.hover.animationDuration = 0;" & @CRLF & _ " Chart.defaults.global.animation.easing = 'linear';" & @CRLF & _ " Chart.defaults.global.elements.line.tension = 0;" & @CRLF & _ " Chart.defaults.global.elements.line.backgroundColor = 'rgba(255, 99, 132, 0.2)';" & @CRLF & _ " Chart.defaults.global.elements.line.borderColor = 'rgba(255, 99, 132, 1)';" & @CRLF & _ "" & @CRLF & _ " Chart.defaults.global.responsiveAnimationDuration = 0;" & @CRLF & _ " //Chart.defaults.line.showLines = false;" & @CRLF & _ " Chart.defaults.line.spanGaps = false;" & @CRLF & _ "" & @CRLF & _ " function GraphClearData() {" & @CRLF & _ " myChart.data.datasets[0].data = [];" & @CRLF & _ " myChart.data.labels = [];" & @CRLF & _ " myChart.update(0);" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " function InitGraphWithData(datastring, rowdelim, coldelim) {" & @CRLF & _ " rowdelim = typeof rowdelim !== 'undefined' ? rowdelim : '\n';" & @CRLF & _ " coldelim = typeof coldelim !== 'undefined' ? coldelim : ',';" & @CRLF & _ " GraphClearData();" & @CRLF & _ "" & @CRLF & _ " var allLinesArray = datastring.split('\n');" & @CRLF & _ " if (allLinesArray.length > 0) {" & @CRLF & _ " for (var i = 0; i < allLinesArray.length; i++) {" & @CRLF & _ " var rowData = allLinesArray[i].split(',');" & @CRLF & _ " if (rowData[0] != '') {" & @CRLF & _ " myChart.data.labels.push(moment(rowData[0], 'YYYY/MM/DD hh:mm:ss'));" & @CRLF & _ " myChart.data.datasets[0].data.push(rowData[1]);" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " myChart.update();" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ "" & @CRLF & _ " function GraphAddData(datastring, rowdelim, coldelim) {" & @CRLF & _ " rowdelim = typeof rowdelim !== 'undefined' ? rowdelim : '\n';" & @CRLF & _ " coldelim = typeof coldelim !== 'undefined' ? coldelim : ',';" & @CRLF & _ "" & @CRLF & _ " var allLinesArray = datastring.split('\n');" & @CRLF & _ " if (allLinesArray.length > 0) {" & @CRLF & _ " for (var i = 0; i < allLinesArray.length; i++) {" & @CRLF & _ " var rowData = allLinesArray[i].split(',');" & @CRLF & _ " if (rowData[0] != '') {" & @CRLF & _ " //alert('adding '+rowData[0]+', '+rowData[1]);" & @CRLF & _ " myChart.data.labels.push(moment(rowData[0], 'YYYY/MM/DD hh:mm:ss'));" & @CRLF & _ " myChart.data.datasets[0].data.push(rowData[1]);" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " myChart.update();" & @CRLF & _ " }" & @CRLF & _ "" & @CRLF & _ " var ctx = document.getElementById('myChart').getContext('2d');" & @CRLF & _ "" & @CRLF & _ " document.getElementById('myChart').onclick = function(evt) {" & @CRLF & _ " clickedPoints = myChart.getElementsAtEvent(evt);" & @CRLF & _ " };" & @CRLF & _ "" & @CRLF & _ " var myChart = new Chart(ctx, {" & @CRLF & _ " type: 'line'," & @CRLF & _ " data: {" & @CRLF & _ " datasets: [{" & @CRLF & _ " label: ''," & @CRLF & _ " }]" & @CRLF & _ " }," & @CRLF & _ " options: {" & @CRLF & _ " responsive: 'true'," & @CRLF & _ " scales: {" & @CRLF & _ " xAxes: [{" & @CRLF & _ " type: 'time'," & @CRLF & _ " time: {" & @CRLF & _ " displayFormats: {" & @CRLF & _ " minute: 'DD.MMM H:m'" & @CRLF & _ " }" & @CRLF & _ " }," & @CRLF & _ " distribution: 'linear'," & @CRLF & _ " ticks: {" & @CRLF & _ " source: 'auto'" & @CRLF & _ " }," & @CRLF & _ " bounds: 'bounds'" & @CRLF & _ " }]" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " });" & @CRLF & _ "" & @CRLF & _ " myChart.update();" & @CRLF & _ "" & @CRLF & _ " <!-- setInterval(function() { -->" & @CRLF & _ " <!-- updateChart() -->" & @CRLF & _ " <!-- }, 5000); -->" & @CRLF & _ " </script>" & @CRLF & _ "</body>" & @CRLF & _ "" & @CRLF & _ "</html>" & @CRLF EndFunc1 point -
Extended Message Box - New Version: 16 Feb 24
hudsonhock reacted to Melba23 for a topic
Are you annoyed by the limitations of the standard Windows message dialog created by MsgBox? Would you like to have coloured backgrounds and text? To choose the justification and font? Do you want to be able to place the message box other than in the centre of the screen? Centred on your GUI, for example, or at a particular location on screen? What about having user-defined text on as many buttons as you need? And user-defined icons? Or a visible countdown of the timeout? Finally, would you like to choose whether the message box has a button on your already too-crowded taskbar? If the answer to any of these questions is "YES" then the ExtMsgBox UDF is for you! [NEW VERSION] 16 Feb 24 Changed: Some additional functionality added to the "TimeOut" parameter of _ExtMsgBox: - A positive integer sets the EMB timeout as before. - A negative integer will double the size of the countdown timer if it is used. - A colon-delimited string (eg: "10:5") will set the normal EMB timeout (first integer) and will also initially disable the EMB buttons for the required period (second integer). New UDF and examples in the zip. Older version changes: ChangeLog.txt As always, I realise nearly all of the DLL calls in these UDFs could be made by using commands in other UDFs like WinAPI.au3 - but as with all my UDFs (which you can find in my sig below) I am trying to prevent the need for any other include files. The UDF and examples (plus StringSize) in zip format: ExtMsgBox.zip Courteous comments and constructive criticisms welcome - guess which I prefer! M231 point -
This script: ;https://autoit.de/index.php?thread/86082-treeview-root-verbergen/&postID=691139#post691139 #include <File.au3> #include <WindowsConstants.au3> Global $sPath = @ScriptDir Global $hGui = GUICreate('TreeView-Example', 400, 600) Global $idTreeView = GUICtrlCreateTreeView(10, 10, 380, 580, Default, $WS_EX_CLIENTEDGE) GUISetState() _CreatePath($sPath, $idTreeView) Do Until GUIGetMsg() = -3 Func _CreatePath($sPath, $idParent) Local $aFolder, $aFiles, $idItem If StringRight($sPath, 1) <> '\' Then $sPath &= '\' $aFolder = _FileListToArray($sPath, '*', $FLTA_FOLDERS) If Not @error Then For $i = 1 To $aFolder[0] $idItem = GUICtrlCreateTreeViewItem($aFolder[$i], $idParent) _CreatePath($sPath & $aFolder[$i], $idItem) Next EndIf $aFiles = _FileListToArray($sPath, '*', $FLTA_FILES) If @error Then Return For $i = 1 To $aFiles[0] $idItem = GUICtrlCreateTreeViewItem($aFiles[$i], $idParent) Next EndFunc does same as yours with native GUICtrlCreateTreeViewItem and _FileListToArray.1 point