Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/20/2023 in all areas

  1. I have already posted the script in the German forum, but I would like to make it available here as well. Highlighting the active tab item in SciTE Individual: Frame color Text color Background color Text color if not saved Marker "Inactive item unsaved" Marker position "Inactive item unsaved" optionally 'top' / 'bottom' / 'none' Active item marking can be deactivated (if only unsaved marking is desired). The active item then receives the same marking as the inactive item when "unsaved". Colors can be loaded as a scheme via INI The compiled script can be ended with CMDLine parameter "/Exit". Since Windows 10, the windows have a very "flat" look. One of the consequences of this is that it is not immediately apparent which item is active in a Tab-Ctrl. When programming in SciTE, I usually have many tabs open at the same time. To make the active tab more visible, I draw it with a colored frame. In addition, unsaved tabs are marked separately with coloring of the top or bottom edge. The colors used for this can be stored individually as a scheme in an INI file. Some schemes are predefined at the beginning of the script. Just try out what you like best. I start the script via the autostart folder when Windows starts. Here are a few pictures: Active Tab Active Tab, unsaved Active Tab, BG: blue / Text: white ... BG: green / Text: white Active Tab, left & right idle unsaved Tabs Active Tab unsaved too ;-- TIME_STAMP 2023-03-23 10:16:34 v 0.5 #cs v 0.5 [fixed] Flickering, a variable assignment was incorrect [fixed] Marking has failed by using keys ("F6", "Shift+F6") to change the buffer selection v 0.4 [added] Exit via CMDLine with parameter "/Exit" [added] Optionally adjustable via INI [appearance]: - Mark active item: rect_highlight=true/false - Position of the marker for "Inactive item unsaved": idlepos=top/bottom/none v 0.3 [added] Separate marker (colored line top) for "Inactive item unsaved". v 0.2 [added] Separate marking (text color) for unsaved files. [added] Loading of colors from an INI (color schemes) possible #ce #include <FontConstants.au3> #include <GuiTab.au3> #include <Misc.au3> #include <WinAPIGdi.au3> #include <WinAPISys.au3> #include <WinAPIMisc.au3> #include <WindowsConstants.au3> Opt('TrayIconHide', 1) If $CMDLINE[0] And $CMDLINE[1] = '/Exit' Then ; CMD-Line: "@ScriptName.exe /Exit" Local $aProcessList = ProcessList(@ScriptName) For $i = 1 To $aProcessList[0][0] Step 1 If $aProcessList[$i][1] <> @AutoItPID Then ProcessClose($aProcessList[$i][1]) Next EndIf _Singleton(@ScriptName) ;~ HotKeySet("!{F8}", _End) ; <Alt><F8> Beenden OnAutoItExitRegister(_End) Global $sINI = StringFormat("%s\%s.ini", @ScriptDir, StringTrimRight(@ScriptName, 4)) Global $gm_SciTE[] $gm_SciTE.ExistsLast = 0 $gm_SciTE.ExistsCurr = 0 #cs The colors can be defined in an INI file in the script folder. If INI is not available, default colors are loaded. INI-Name = Name_of_the_Exe.ini [appearance] ; rect_highlight=true/false "false" does NOT highlight the active item, default: "true". rect_highlight=true ; idlepos=top/bottom/none "none" does NOT mark unsaved inactive files, default: "top". idlepos=top [scheme] ; Specify which of the defined schemes should be active. current=default ; One section for each scheme. [default] rect=0xCC483F text=0x800020 bg=0xFFFFFF unsaved=0x3030FF idle=0x3030FF [blue_invers] rect=0xCC483F text=0xFFF0F0 bg=0x800020 unsaved=0xA9A5F7 idle=0xA9A5F7 [green_invers] rect=0x005F00 text=0xEDFFED bg=0x409340 unsaved=0x1DE6B5 idle=0x1DE6B5 #ce ; appearance $gm_SciTE.bHighlight = (_IniOrDefault($sINI, 'rect_highlight', 'true', 'appearance') = 'true') $gm_SciTE.IdlePos = _IniOrDefault($sINI, 'idlepos', 'top', 'appearance') ; scheme: default (blue): $gm_SciTE.RectColor = _IniOrDefault($sINI, 'rect' , 0xCC483F) ; BGR $gm_SciTE.TextColor = _IniOrDefault($sINI, 'text' , 0x800020) ; BGR $gm_SciTE.BGColor = _IniOrDefault($sINI, 'bg' , 0xFFFFFF) ; BGR $gm_SciTE.TextColorUnsaved = _IniOrDefault($sINI, 'unsaved', 0x3030FF) ; BGR $gm_SciTE.IdleUnsaved = _IniOrDefault($sINI, 'idle' , 0x3030FF) ; BGR _CheckSciTE() ; the effect takes place immediately AdlibRegister(_CheckSciTE, 750) While True Sleep(5000) WEnd Func _End() AdlibUnRegister(_CheckSciTE) ;~ MsgBox(0, 'SciTE TabItem', 'Beendet!') Exit EndFunc Func _CheckSciTE() If ProcessExists("SciTE.exe") Then $gm_SciTE.ExistsCurr = 1 If $gm_SciTE.ExistsLast = 0 Then $gm_SciTE.ExistsLast = 1 If $gm_SciTE.bHighlight Then _DrawTabItem() AdlibRegister(_MouseHoversTab, 150) EndIf _MarkUnsavedIdleTab() Else $gm_SciTE.ExistsCurr = 0 If $gm_SciTE.ExistsLast = 1 Then $gm_SciTE.ExistsLast = 0 If $gm_SciTE.bHighlight Then AdlibUnRegister(_MouseHoversTab) EndIf EndIf EndFunc Func _MouseHoversTab() Local Static $iHoverLast = 1 ; when starting the program, exit from the item must be simulated Local $mTab = _SciTE_GetActiveTabInfo() If @error Then Return Local $tPoint = _WinAPI_GetMousePos(True, $mTab.hTab) Local $tRect = $mTab.RectItem Local $isHover = _WinAPI_PtInRect($tRect, $tPoint) If $isHover = 1 And $iHoverLast = 0 Then $iHoverLast = 1 ElseIf $isHover = 0 And $iHoverLast = 1 Then $iHoverLast = 0 Return _DrawTabItem() EndIf EndFunc Func _MarkUnsavedIdleTab() If $gm_SciTE.IdlePos = 'none' Then Return Local $hTab = __GetHwnd_SciTeTabCtrl() If @error Then Return SetError(1) Local $iActive = _GUICtrlTab_GetCurFocus($hTab) For $i = 0 To _GUICtrlTab_GetItemCount($hTab) -1 If $i = $iActive And $gm_SciTE.bHighlight Then ContinueLoop If StringRight(_GUICtrlTab_GetItemText($hTab, $i), 1) = '*' Then _DrawMarkerUnsaved($hTab, $i) EndIf Next EndFunc Func _DrawMarkerUnsaved($_hTab, $_iItem) Local $tRect = _GUICtrlTab_GetItemRectEx($_hTab, $_iItem) Local $tRectDraw = DllStructCreate("struct; long Left;long Top;long Right;long Bottom; endstruct") If $gm_SciTE.IdlePos = 'top' Then $tRectDraw.Left = $tRect.Left $tRectDraw.Top = $tRect.Top -1 $tRectDraw.Right = $tRect.Right $tRectDraw.Bottom = $tRect.Top Else $tRectDraw.Left = $tRect.Left $tRectDraw.Top = $tRect.Bottom +2 $tRectDraw.Right = $tRect.Right $tRectDraw.Bottom = $tRect.Bottom +3 EndIf Local $hDC = _WinAPI_GetDC($_hTab) Local $hPen = _WinAPI_CreatePen($PS_SOLID, 2, $gm_SciTE.IdleUnsaved) Local $hOldPen = _WinAPI_SelectObject($hDC, $hPen) _WinAPI_Rectangle($hDC, $tRectDraw) _WinAPI_SelectObject($hDC, $hOldPen) _WinAPI_DeleteObject($hPen) _WinAPI_ReleaseDC(0, $hDC) EndFunc Func _DrawTabItem() Local $mTab = _SciTE_GetActiveTabInfo() If @error Then Return Local $hDC = _WinAPI_GetDC($mTab.hTab) Local $hFont = _WinAPI_CreateFont(14.5, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Lucida Sans Unicode Standard') Local $hOldFont = _WinAPI_SelectObject($hDC, $hFont) Local $tRect = $mTab.RectItem ; extract to variable - otherwise no ByRef access possible Local $dY = (@OSVersion = "Win_7" ? 2 : 1) _WinAPI_InflateRect($tRect, 2, $dY) ; enlarge rectangle _WinAPI_OffsetRect($tRect, 0, 1) ; move rectangle down by 1px ; draw and fill rect Local $hPen = _WinAPI_CreatePen($PS_SOLID, 2, $gm_SciTE.RectColor) Local $hBrush = _WinAPI_CreateSolidBrush($gm_SciTE.BGColor) Local $hOldPen = _WinAPI_SelectObject($hDC, $hPen) Local $hOldBrush = _WinAPI_SelectObject($hDC, $hBrush) _WinAPI_Rectangle($hDC, $tRECT) ; draw text If StringRight($mTab.Item, 1) = '*' Then _WinAPI_SetTextColor($hDC, $gm_SciTE.TextColorUnsaved) Else _WinAPI_SetTextColor($hDC, $gm_SciTE.TextColor) EndIf _WinAPI_SetBkColor($hDC, $gm_SciTE.BGColor) ; move the text down a bit more _WinAPI_OffsetRect($tRect, 0, 3) _WinAPI_DrawText($hDC, $mTab.Item, $tRect, BitOR($DT_BOTTOM,$DT_CENTER)) ; clear ressources _WinAPI_SelectObject($hDC, $hOldFont) _WinAPI_DeleteObject($hFont) _WinAPI_SelectObject($hDC, $hOldPen) _WinAPI_DeleteObject($hPen) _WinAPI_SelectObject($hDC, $hOldBrush) _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC(0, $hDC) EndFunc Func _SciTE_GetActiveTabInfo() Local $mResult[], $hTab = __GetHwnd_SciTeTabCtrl() If @error Then Return SetError(1) $mResult.hTab = $hTab $mResult.Index = _GUICtrlTab_GetCurFocus($hTab) $mResult.Item = _GUICtrlTab_GetItemText($hTab, $mResult.Index) $mResult.RectItem = _GUICtrlTab_GetItemRectEx($hTab, $mResult.Index) Return $mResult EndFunc Func __GetHwnd_SciTE() Local $hScite = WinGetHandle('[ACTIVE]') If _WinAPI_GetClassName($hScite) = 'SciTEWindow' Then Return $hScite Else Return SetError(1, 0, Null) EndIf EndFunc Func __GetHwnd_SciTeTabCtrl() Local $hScite = __GetHwnd_SciTE() If @error Then Return SetError(1, 0, Null) Local $aChild, $hWndTab = Null $aChild = _WinAPI_EnumChildWindows($hScite) ; only visible If Not @error Then For $i = 1 To $aChild[0][0] If $aChild[$i][1] = "SciTeTabCtrl" Then $hWndTab = $aChild[$i][0] ExitLoop EndIf Next EndIf Return SetError(($hWndTab = Null ? 1 : 0), 0, $hWndTab) EndFunc ; read from INI if exists Func _IniOrDefault($_sINI, $_sKey, $_sDefault, $_sec=Null) Local $sVal = $_sDefault, $sSec = $_sec = Null ? 'scheme' : $_sec If FileExists($_sINI) Then If $sSec = 'scheme' Then $sSec = IniRead($_sINI, 'scheme', 'current', 'default') $sVal = IniRead($_sINI, $sSec, $_sKey, $_sDefault) EndIf Return $sVal EndFunc SciTE_DrawTabItem.au3
    2 points
  2. As far as I know, this UDF works with datatype Maps and therefore requires AutoIt version 3.3.16.1 or higher.
    2 points
  3. indeed, the carret isn't at the correct position yet when calling the internal function for calltip. This is corrected by adding this line to AutoItAutoComplete.lua line below line 645: ncarretpos = ncarretpos + 1 editor.SelectionNCaret[editor.MainSelection] = ncarretpos scite.MenuCommand(IDM_SHOWCALLTIP) -- Show ToolTip for Functions
    2 points
  4. Introduction This UDF will allow you to interact with any browser that supports the W3C WebDriver specifications. Supporting multiple browsers via the same code base is now possible with just a few configuration settings. Requirements JSON UDF https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn WinHTTP UDF https://www.autoitscript.com/forum/topic/84133-winhttp-functions/ WebDriver for desired browser Source Code You will always be able to find the latest version in the GitHub Repo Help / Support See the wiki for details on the UDF -- https://www.autoitscript.com/wiki/WebDriver Please post any questions, suggestions or errors in a new thread in the GH&S section. Previous support threads (Closed) https://www.autoitscript.com/forum/topic/192730-webdriver-udf-help-support/ https://www.autoitscript.com/forum/topic/201106-webdriver-udf-help-support-ii/ https://www.autoitscript.com/forum/topic/205553-webdriver-udf-help-support-iii/ https://www.autoitscript.com/forum/topic/208640-webdriver-udf-help-support-iv/
    1 point
  5. Andreik

    When to Sleep in a loop

    Nah, if you need to process an array or something there is no reason to sleep IMO. You want to process as fast as possible. CPU usage might be higher for a period of time but what good to have low CPU usage and slow running code?
    1 point
  6. Here a generic one: #include <GDIPlus.au3> #include <GUIConstantsEx.au3> _GDIPlus_Startup() $hGUI = GUICreate("", 800, 600) GUISetState() $hGfx = _GDIPlus_GraphicsCreateFromHWND($hGUI) $hBitmap = _GDIPlus_BitmapCreateFromScan0(800, 600) $hCanvas = _GDIPlus_ImageGetGraphicsContext($hBitmap) $hBrush = _GDIPlus_BrushCreateSolid(0xFF00FF00) $hPen = _GDIPlus_PenCreate(0xFF000000) $x = Random(100, 700) $y = Random(50, 150) $w = Random(50, 100) $h = Random(50, 100) $xp = 400 $yp = 500 $r = 800 $a = 0 Do _GDIPlus_GraphicsClear($hCanvas, 0xFFFFFFFF) _GDIPlus_GraphicsFillRect($hCanvas, $x, $y, $w, $h, $hBrush) $px = $xp + Cos($a) * $r $py = $yp + Sin($a) * $r _GDIPlus_GraphicsDrawLine($hCanvas, $xp, $yp, $px, $py, $hPen) If LineRectCollision($xp, $yp, $px, $py, $x, $y, $x + $w, $y + $h) Then _GDIPlus_BrushSetSolidColor($hBrush, 0xFFFF0000) Else _GDIPlus_BrushSetSolidColor($hBrush, 0xFF00FF00) EndIf $a -= 0.03 _GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap, 0, 0, 800, 600) Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hCanvas) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_ImageDispose($hBitmap) Func LineRectCollision($x1, $y1, $x2, $y2, $rectLeft, $rectTop, $rectRight, $rectBottom) ; Check if the starting point is inside the rectangle If $x1 >= $rectLeft And $x1 <= $rectRight And $y1 >= $rectTop And $y1 <= $rectBottom Then Return True EndIf Local $m = ($y2 - $y1) / ($x2 - $x1) ; Slope of the line Local $b = $y1 - $m * $x1 ; y-intercept of the line ; Check for intersection with each side of the rectangle If (($m * $rectLeft + $b >= $rectTop And $m * $rectLeft + $b <= $rectBottom) Or _ ($m * $rectRight + $b >= $rectTop And $m * $rectRight + $b <= $rectBottom) Or _ (($rectTop - $b) / $m >= $rectLeft And ($rectTop - $b) / $m <= $rectRight) Or _ (($rectBottom - $b) / $m >= $rectLeft And ($rectBottom - $b) / $m <= $rectRight)) Then ; Check if the line is moving towards the rectangle If ($x2 - $x1) * ($rectRight - $rectLeft) + ($y2 - $y1) * ($rectBottom - $rectTop) < 0 Then Return True ; Line intersects with the rectangle EndIf EndIf Return False ; No intersection EndFunc
    1 point
  7. Now you are getting very annoying. Stop whining it is too complicated for you, it is just about 15 lines of code. Start reading, testing, understanding and working. Otherwise, you will soon be alone, if not worst...
    1 point
  8. mLipok

    AutoIt Snippets

    This is my Window List checker: #RequireAdmin #include <Array.au3> #include <MsgBoxConstants.au3> #include <Process.au3> #include <WinAPISysWin.au3> Example() Func Example() ; Retrieve a list of window handles using a regular expression. The regular expression looks for titles that contain the word SciTE or Internet Explorer. Local $aWinList Local $iPID = 0 Local $iThread Local $s_Process_Name_current While 1 $aWinList = WinList() _ArrayColInsert($aWinList, 2) ; ProcessName _ArrayColInsert($aWinList, 3) ; PID _ArrayColInsert($aWinList, 4) ; Thread _ArrayColInsert($aWinList, 5) ; TEXT For $IDX = 1 To $aWinList[0][0] $iThread = _WinAPI_GetWindowThreadProcessId($aWinList[$IDX][1], $iPID) $s_Process_Name_current = _ProcessGetName($iPID) $aWinList[$IDX][2] = $s_Process_Name_current $aWinList[$IDX][3] = $iPID $aWinList[$IDX][4] = $iThread $aWinList[$IDX][5] = WinGetText($aWinList[$IDX][0]) Next _ArrayDisplay($aWinList, 'WinList - originall ordering') _ArraySort($aWinList, 0, 1, 0, 0) _ArrayDisplay($aWinList, 'WinList - ordering by Title') _ArraySort($aWinList, 0, 1, 0, 1) _ArrayDisplay($aWinList, 'WinList - ordering by HWND') _ArraySort($aWinList, 0, 1, 0, 2) _ArrayDisplay($aWinList, 'WinList - ordering by ProcessName') _ArraySort($aWinList, 0, 1, 0, 3) _ArrayDisplay($aWinList, 'WinList - ordering by PID') If $IDNO = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON2, "Question", _ "Check again ?") Then ExitLoop WEnd EndFunc ;==>Example
    1 point
  9. Yashied

    Icon Extract

    From #Include <WinAPIEx.au3> Global $aIcon[3] = [48, 32, 16] For $i = 0 To 2 $aIcon[$i] = _WinAPI_Create32BitHICON(_WinAPI_ShellExtractIcon(@SystemDir & '\shell32.dll', 32, $aIcon[$i], $aIcon[$i]), 1) Next _WinAPI_SaveHICONToFile(@ScriptDir & '\MyIcon.ico', $aIcon) For $i = 0 To 2 _WinAPI_DestroyIcon($aIcon[$i]) Next
    1 point
  10. Code Fixed: Mode 1: #include <File.au3> $file = "c:\yourfile.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) msgbox(0,'','the line ' & $i & ' is ' & $line) Next FileClose($file) Mode 2: #include <file.au3> $file = FileOpen("yourfile.txt", 0) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop MsgBox(0,'',$line) WEnd FileClose($file) Mode 3: #include <Array.au3> #include <File.au3> Local $aInput $file = "yourfile.txt" _FileReadToArray($file, $aInput) For $i = 1 to UBound($aInput) -1 MsgBox (0,'',$aInput[$i]) Next all tested!
    1 point
×
×
  • Create New...