Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/13/2024 in all areas

  1. Finally I found what was the culprit: a very old FF window which got shifted at the extreme corner of a desktop, making it essentially invisible. The only tab it carried was the one I was after in another tab of another FF window, but was set to a different part of the website. I confess having permanently 15-30 FF windows and many tabs each, all always open. Hard for me to do with much less. So everything works with the initial simple code and I flatly apologize for the noise and for wasting your time.
    2 points
  2. ioa747

    Round buttons

    collection of round buttons ; https://www.autoitscript.com/forum/topic/211721-round-buttons/ ;---------------------------------------------------------------------------------------- ; Title...........: RoundButtons.au3 ; Description.....: collection of round buttons ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Global $MyGui, $aBtn[7][2] Example() Func Example() $MyGui = GUICreate(" My GUI Icons", 300, 500) $aBtn[0][0] = 6 ; cnt of buttons $aBtn[1][1] = "red" $aBtn[1][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[1][1] & "_normal.ico", 0, 20, 20, 64, 64, $SS_NOTIFY) $aBtn[2][1] = "yellow" $aBtn[2][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[2][1] & "_normal.ico", 0, 20, 100, 64, 64, $SS_NOTIFY) $aBtn[3][1] = "green" $aBtn[3][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[3][1] & "_normal.ico", 0, 20, 180, 64, 64, $SS_NOTIFY) $aBtn[4][1] = "turquoise" $aBtn[4][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[4][1] & "_normal.ico", 0, 20, 260, 64, 64, $SS_NOTIFY) $aBtn[5][1] = "cyan" $aBtn[5][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[5][1] & "_normal.ico", 0, 20, 340, 64, 64, $SS_NOTIFY) $aBtn[6][1] = "magenta" $aBtn[6][0] = GUICtrlCreateIcon(@ScriptDir & "\Buttons\" & $aBtn[6][1] & "_normal.ico", 0, 20, 420, 64, 64, $SS_NOTIFY) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $aBtn[1][0] ConsoleWrite($aBtn[1][1] & @CRLF) Case $aBtn[2][0] ConsoleWrite($aBtn[2][1] & @CRLF) Case $aBtn[3][0] ConsoleWrite($aBtn[3][1] & @CRLF) Case $aBtn[4][0] ConsoleWrite($aBtn[4][1] & @CRLF) Case $aBtn[5][0] ConsoleWrite($aBtn[5][1] & @CRLF) Case $aBtn[6][0] ConsoleWrite($aBtn[6][1] & @CRLF) EndSwitch _IsOver() WEnd GUIDelete() EndFunc ;==>Example Func _IsOver() Local Static $iActive, $iClicked = 0 Local $aActive = GUIGetCursorInfo($MyGui) If $aActive[2] And $iClicked = 1 Then Return If $iActive <> $aActive[4] Then $iActive = $aActive[4] For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_hover.ico") Else GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_normal.ico") EndIf Next EndIf If $aActive[2] Or $iClicked = 1 Then For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then If $iClicked = 0 Then GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_click.ico") $iClicked = 1 Else GUICtrlSetImage($aBtn[$i][0], @ScriptDir & "\Buttons\" & $aBtn[$i][1] & "_hover.ico") $iClicked = 0 EndIf EndIf Next EndIf EndFunc ;==>_IsOver Extract buttons folder in @ScriptDir Buttons.zip Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    1 point
  3. ioa747

    Round buttons

    Method for Colorful Rectangle Buttons ; https://www.autoitscript.com/forum/topic/211721-round-buttons/ ;---------------------------------------------------------------------------------------- ; Title...........: RectButtonsSpecial.au3 ; Description.....: collection of rectangles buttons - Special Edition ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <StaticConstants.au3> ; ~~~~~~~~~~~~~~~~~ Example - what is ColorLight() Global $test = ColorLight(0xC800C8, 50) ConsoleWrite($test & @CRLF) $test = ColorLight(0xC800C8, 50, 1) ConsoleWrite($test & @CRLF) $test = ColorLight(0xC800C8, 50, 2) ConsoleWrite(StringFormat("RGB(%d,%d,%d)", $test[0], $test[1], $test[2]) & @CRLF & @CRLF) ; ~~~~~~~~~~~~ End of Example - what is ColorLight() Global $MyGui, $aBtn[6][2], $btnColor = 0xC800C8 $MyGui = GUICreate(@ScriptName, 180, 220) GUISetBkColor(0x000000) $aBtn[0][0] = 5 ; cnt of buttons $aBtn[1][0] = GUICtrlCreateLabel("Button1", 10, 20, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[1][1] = 0xA64500 GUICtrlSetBkColor(-1, $aBtn[1][1]) $aBtn[2][0] = GUICtrlCreateLabel("Button2", 10, 60, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[2][1] = 0x826E00 GUICtrlSetBkColor(-1, $aBtn[2][1]) $aBtn[3][0] = GUICtrlCreateLabel("Button3", 10, 100, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[3][1] = 0x268000 GUICtrlSetBkColor(-1, $aBtn[3][1]) $aBtn[4][0] = GUICtrlCreateLabel("Button4", 10, 140, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[4][1] = 0x0094FF GUICtrlSetBkColor(-1, $aBtn[4][1]) $aBtn[5][0] = GUICtrlCreateLabel("Button5", 10, 180, 150, 30, BitOR($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFFFF) $aBtn[5][1] = 0x9600D5 GUICtrlSetBkColor(-1, $aBtn[5][1]) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch _IsOver() WEnd ;-------------------------------------------------------------------------------------------------------------------------------- Func _IsOver() Local Static $iActive, $iClicked = 0 Local $aActive = GUIGetCursorInfo($MyGui) If $aActive[2] And $iClicked = 1 Then Return If $iActive <> $aActive[4] Then $iActive = $aActive[4] For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then GUICtrlSetBkColor($aBtn[$i][0], ColorLight($aBtn[$i][1], 30)) ;hover Else GUICtrlSetBkColor($aBtn[$i][0], $aBtn[$i][1]) ;normal EndIf Next EndIf If $aActive[2] Or $iClicked = 1 Then For $i = 1 To $aBtn[0][0] If $aBtn[$i][0] = $aActive[4] Then If $iClicked = 0 Then GUICtrlSetBkColor($aBtn[$i][0], ColorLight($aBtn[$i][1], -30)) ;click GUICtrlSetFont($aBtn[$i][0], 10, 800, 2, "MS Sans Serif") GUICtrlSetColor($aBtn[$i][0], 0xCCCCCC) $iClicked = 1 Else GUICtrlSetBkColor($aBtn[$i][0], ColorLight($aBtn[$i][1], 30)) ;hover GUICtrlSetFont($aBtn[$i][0], 10, 800, 0, "MS Sans Serif") GUICtrlSetColor($aBtn[$i][0], 0xFFFFFF) $iClicked = 0 _ButtonCaller($aBtn[$i][0]) EndIf EndIf Next EndIf EndFunc ;==>_IsOver ;-------------------------------------------------------------------------------------------------------------------------------- Func _ButtonCaller($Btn) Switch $Btn Case $aBtn[1][0] ConsoleWrite(GUICtrlRead($aBtn[1][0]) & @CRLF) Case $aBtn[2][0] ConsoleWrite(GUICtrlRead($aBtn[2][0]) & @CRLF) Case $aBtn[3][0] ConsoleWrite(GUICtrlRead($aBtn[3][0]) & @CRLF) Case $aBtn[4][0] ConsoleWrite(GUICtrlRead($aBtn[4][0]) & @CRLF) Case $aBtn[5][0] ConsoleWrite(GUICtrlRead($aBtn[5][0]) & @CRLF) Case $aBtn[6][0] ConsoleWrite(GUICtrlRead($aBtn[6][0]) & @CRLF) EndSwitch EndFunc ;==>_ButtonCaller ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: ColorLight() ; Description....: Returns a new color that is a combination of the $HexColor plus the amount of $Lightness it adds to all three RGB channels. ; Syntax.........: ColorLight($HexColor [, $Lightness [,$output]]) ; Parameters.....: $HexColor - The start color to be combined. ; $Lightness - The amount it adds to all three RGB channels. Negative number to subtract (darker) ; $output - Optional: The format of the output string: ; 0 = "0x" followed by the hexadecimal value of the new color (default) ; 1 = "#" followed by the hexadecimal value of the new color ; 2 = an array containing the red, green and blue values of the new color ; Return values..: The new color as a string or an array. ; Author ........: ioa747 ; Notes .........: ;-------------------------------------------------------------------------------------------------------------------------------- Func ColorLight($HexColor, $Lightness = 0, $sOutput = 0) If StringLeft($HexColor, 1) = "#" Then $HexColor = StringReplace($HexColor, "#", "0x") Local $sHexColor = Hex($HexColor, 6) ;ConsoleWrite("$sHexColor=" & $sHexColor & @CRLF) Local $aSplit = StringSplit($sHexColor, "") Local $aRGB[3] If $aSplit[0] = 6 Then $aRGB[0] = Dec($aSplit[1] & $aSplit[2], 0) $aRGB[1] = Dec($aSplit[3] & $aSplit[4], 0) $aRGB[2] = Dec($aSplit[5] & $aSplit[6], 0) ;ConsoleWrite(StringFormat("aRGB(%d,%d,%d)", $aRGB[0], $aRGB[1], $aRGB[2]) & @CRLF) Else ConsoleWrite("Something wrong $aSplit[0]=" & $aSplit[0] & @CRLF) Return SetError(1, 0, -1) EndIf Local $aNewRGB[] = [$aRGB[0] + $Lightness, $aRGB[1] + $Lightness, $aRGB[2] + $Lightness] If $aNewRGB[0] < 0 Then $aNewRGB[0] = 0 If $aNewRGB[0] > 255 Then $aNewRGB[0] = 255 If $aNewRGB[1] < 0 Then $aNewRGB[1] = 0 If $aNewRGB[1] > 255 Then $aNewRGB[1] = 255 If $aNewRGB[2] < 0 Then $aNewRGB[2] = 0 If $aNewRGB[2] > 255 Then $aNewRGB[2] = 255 ;ConsoleWrite(StringFormat("aNewRGB(%d,%d,%d)", $aNewRGB[0], $aNewRGB[1], $aNewRGB[2]) & @CRLF) Local $sColor ;$sOutput: 0:="0x" | 1:="#" | 2:=aRGB[R,G,B] Switch $sOutput Case 0, 1 $sColor = ($sOutput = 1 ? "#" : "0x") $sColor &= Hex(String($aNewRGB[0]), 2) $sColor &= Hex(String($aNewRGB[1]), 2) $sColor &= Hex(String($aNewRGB[2]), 2) ;ConsoleWrite("$sColor=" & $sColor & @CRLF & @CRLF) Case 2 $sColor = $aNewRGB EndSwitch Return $sColor EndFunc ;==>ColorLight ;-------------------------------------------------------------------------------------------------------------------------------- have fun Thank you very much
    1 point
  4. Thanks but sorry to say that it's actually much worse than mine, there are too many large areas that are blank, i need it evenly distributed as in the sample images i posted. I've been trying for days now, but not giving up, maybe I should try separating it all into funcs as in your code, though as i wrote earlier, I will only be feeding it 8bit grayscale so no need for the 24bit support your code has. I'll examine your script more thoroughly, I already tried clamping but will again, and look into the error distribution thingie. But please, anyone. try adding a consolewrite below the iNewColor and you will see why, copilots code doesnt work, or atleast is faulty. ; Set the new pixel color $iNewColor = _ColorSetRGB($aColor) consolewrite(Hex($iNewcolor, 8) & @crlf) _GDIPlus_BitmapSetPixel($hBitmap, $x, $y, $iNewColor) EndFunc ;==>_DistributeError
    1 point
  5. You can try ControlCommand() to get current selection in ComboBox.
    1 point
  6. Creo que si le das permitir la primera vez manualmente ya no te saldría esa ventana de permitir. I think once you click allow You will not get that request window again. PM I could probably help you. Escríbeme quizás podría ayudarte por privado. Saludos
    1 point
  7. ioa747

    SmartNote

    SmartNote tesseract Edition: SmartNote is a screen snip tool to snip screen area with OCR ability from tesseract 100+ languages I tried it in Windows 10 with the version tesseract-ocr-w32-setup-v5.3.0.20221214.exe Snipe new note Double Click the tray icon to start NewCapture or While Left Windows Key IsPressed, tap 2 times the Left Shift key (is useful when Capture menu or context menu). While start NewCapture point click anywhere to escape. (Does not catch smaller than 9*9 px) While start NewCapture escape with ESC SmartNote.au3 ; https://www.autoitscript.com/forum/topic/208600-smartnote/ ;---------------------------------------------------------------------------------------- ; Title...........: SmartNote.au3 ; Description.....: SmartNote is a screen snip tool to take Screenshot with OCR ability from Tesseract (100+ languages) ; AutoIt Version..: 3.3.16.1 Author: ioa747 ;---------------------------------------------------------------------------------------- #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=mmcndmgr-106.ico #AutoIt3Wrapper_Res_Description=SmartNote is a screen snip tool to take Screenshot with OCR ability from Tesseract (100+ languages) #AutoIt3Wrapper_Res_Fileversion=0.0.5.20240413 #AutoIt3Wrapper_Res_ProductName=SmartNote.au3 #AutoIt3Wrapper_Res_CompanyName=ioa747 #AutoIt3Wrapper_Res_LegalCopyright=ioa747 #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #NoTrayIcon If WinExists(StringTrimRight(@ScriptName, 4) & "_STUB") Then Exit 5 AutoItWinSetTitle(StringTrimRight(@ScriptName, 4) & "_STUB") If @AutoItX64 Then Exit MsgBox(262144 + 64, StringTrimRight(@ScriptName, 4), "Please run as 32bit", 60) #include <MsgBoxConstants.au3> #include <ScreenCapture.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <TrayConstants.au3> #include <Misc.au3> #include <Array.au3> #include <GDIPlus.au3> #include <Clipboard.au3> #include <String.au3> ; Initialization DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", -4) ; -4=PerMonitorAwareV2 Opt("MouseCoordMode", 1) ; 1=absolute, 0=relative, 2=client Opt("TrayMenuMode", 3) ; 0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. Opt("GUIOnEventMode", 1) ; 0=disabled, 1=OnEvent mode enabled ; tray entry to exit script Global $TRAY_ExitScript = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "TRAY_EVENT") ; separator TrayCreateItem("") ; tray entry to capture Global $TRAY_NewCapture = TrayCreateItem("Capture") TrayItemSetOnEvent(-1, "TRAY_EVENT") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "TRAY_EVENT") TraySetIcon("mmcndmgr.dll", -106) TraySetClick(16) ; $TRAY_CLICK_SECONDARYUP = 16 TraySetState($TRAY_ICONSTATE_SHOW) TraySetToolTip("SmartNote" & @CRLF & "Double Click to take new note") Global $mPos, $aRecPos[4], $hGUICapture, $block_gui Global $hDLL = DllOpen("user32.dll") ; array to hold the Contextmenu data Global $NoteGui[1][14] $NoteGui[0][0] = 0 ; cnt, Note_Handle $NoteGui[0][1] = "jpgPath" $NoteGui[0][2] = "Gui_Size" $NoteGui[0][3] = "ID_PicCtrl" $NoteGui[0][4] = "ID_ContextMenu" $NoteGui[0][5] = "ID_cMenuCopy" $NoteGui[0][6] = "ID_cMenuShareX" $NoteGui[0][7] = "ID_cMenuSave" $NoteGui[0][8] = "ID_cMenuOpen" $NoteGui[0][9] = "ID_cMenuOCR-eng" $NoteGui[0][10] = "ID_cMenuOCR-eng+ell" $NoteGui[0][11] = "ID_cMenuClose" $NoteGui[0][12] = "ID_Dummy_DeleteKey" $NoteGui[0][13] = "ID_Dummy_EnterKey" ; Check for leftover files Global $iFileExists = FileExists(@ScriptDir & "\tmp") If $iFileExists Then FileDelete(@ScriptDir & "\tmp\*.*") Else DirCreate(@ScriptDir & "\tmp") EndIf ;~ HotKeySet("{PGUP}", "_Array_Gui_display") ; *** Debug _ArrayDisplay($NoteGui, "$NoteGui") <<- HotKey ; ℹ️ While Left Windows Key IsPressed, tap 2 times the Left SHIFT key to start NewCapture, ; is useful when Capture menu or contex menu. ; While start NewCapture point click anywhere to escape. (does not catch smaller than 9*9 px) ; While start NewCapture escape with ESC Global $iShift ; loop until program exit ;************************************************ While Sleep(100) $iShift = 0 While _IsPressed("5B", $hDLL) ; 5B Left Windows key Sleep(100) If _IsPressed("A0", $hDLL) Then ; A0 Left SHIFT key While _IsPressed("A1", $hDLL) Sleep(100) WEnd $iShift += 1 EndIf If $iShift = 2 Then NewCapture() ExitLoop EndIf WEnd WEnd ;************************************************ ;---------------------------------------------------------------------------------------- Func NewCapture() ; NewCapture Local $aRecPos[4], $aMPos[2], $tPos ;, $aTipPos[4], $iX, $iY Local $iDeskWidth, $iDeskHeight, $iDeskLeft, $iDeskTop Local $sDevice, $hMonitor, $sCurDevice, $aData, $Status = 0 ; make Capture gui $hGUICapture = GUICreate("Capture_gui", 1, 1, 1, 1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetBkColor("0xFFFF00", $hGUICapture) ; $COLOR_YELLOW WinSetTrans($hGUICapture, "", 50) ; make mouse block gui $block_gui = GUICreate("block_gui", 1, 1, 1, 1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) WinSetTrans($block_gui, "", 1) GUISetState(@SW_SHOW, $block_gui) GUISetCursor($MCID_CROSS, 1, $block_gui) Sleep(200) Local $iMaxLoop = 1200, $iCntLoop = 0 While Sleep(10) $iCntLoop += 1 If $iCntLoop = $iMaxLoop Then ExitLoop ; get mouse coordinates $tPos = _WinAPI_GetMousePos() $aMPos[0] = DllStructGetData($tPos, 1) $aMPos[1] = DllStructGetData($tPos, 2) ; get $hMonitor from previously defined Mouse coordinates $hMonitor = _WinAPI_MonitorFromPoint($tPos) ; get monitor $aData appropriate for previously defined coordinates $aData = _WinAPI_GetMonitorInfo($hMonitor) If Not @error Then $sDevice = $aData[3] $iDeskLeft = DllStructGetData($aData[0], 1) $iDeskTop = DllStructGetData($aData[0], 2) $iDeskWidth = DllStructGetData($aData[0], 3) $iDeskHeight = DllStructGetData($aData[0], 4) EndIf ;move the $block_gui to active monitor If $sCurDevice <> $sDevice Then $sCurDevice = $sDevice ;ConsoleWrite("- $sCurDevice=" & $sCurDevice & @CRLF) WinMove($block_gui, "", $iDeskLeft, $iDeskTop, $iDeskWidth, $iDeskHeight) EndIf ; whait Left_mouse_button _IsPressed If _IsPressed("01", $hDLL) Then $Status = 1 $aMPos = MouseGetPos() $aRecPos[0] = $aMPos[0] $aRecPos[1] = $aMPos[1] ; Wait until key is released. While _IsPressed("01", $hDLL) Sleep(50) $aMPos = MouseGetPos() $aRecPos[2] = $aMPos[0] $aRecPos[3] = $aMPos[1] ; show Capture gui GUISetState(@SW_SHOW, $hGUICapture) WinMove($hGUICapture, "", $aRecPos[0], $aRecPos[1], $aRecPos[2] - $aRecPos[0], $aRecPos[3] - $aRecPos[1]) WEnd ElseIf _IsPressed("1B", $hDLL) Then ;1B=ESC key - emergency exit GUIDelete($hGUICapture) GUIDelete($block_gui) Return SetError(1, 1, 0) EndIf If $Status = 1 Then ExitLoop WEnd GUIDelete($hGUICapture) GUIDelete($block_gui) ;ConsoleWrite($aRecPos[0] & ";" & $aRecPos[1] & ";" & $aRecPos[2] - $aRecPos[0] & ";" & $aRecPos[3] - $aRecPos[1] & @CRLF) ; if bigger from 9*9 px then create note If ($aRecPos[2] - $aRecPos[0]) > 9 And ($aRecPos[3] - $aRecPos[1]) > 9 Then CreateNew_NoteGui($aRecPos) ; create new note ;Return $FilePath EndFunc ;==>NewCapture ;---------------------------------------------------------------------------------------- Func CreateNew_NoteGui($aRecPos) ; create new note gui Local $n, $aSize[2] ReDim $NoteGui[UBound($NoteGui) + 1][14] $NoteGui[0][0] += 1 $n = $NoteGui[0][0] $aSize[0] = $aRecPos[2] - $aRecPos[0] ; width $aSize[1] = $aRecPos[3] - $aRecPos[1] ; height ; create note GUI $NoteGui[$n][0] = GUICreate($NoteGui[$n][1], $aSize[0], $aSize[1], $aRecPos[0], $aRecPos[1], $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_RESIZED, "GUI_EVENT", $NoteGui[$n][0]) ; jpg Path for _ScreenCapture_Capture $NoteGui[$n][1] = @ScriptDir & "\tmp\image_" & $NoteGui[$n][0] & ".jpg" _ScreenCapture_Capture($NoteGui[$n][1], $aRecPos[0], $aRecPos[1], $aRecPos[2], $aRecPos[3]) ; save the Gui_Size $NoteGui[$n][2] = $aSize ; set jpg Path as GUI title WinSetTitle($NoteGui[$n][0], "", $NoteGui[$n][1]) ; Creates a Picture control $NoteGui[$n][3] = GUICtrlCreatePic($NoteGui[$n][1], 0, 0, 0, 0, -1, $GUI_WS_EX_PARENTDRAG) ; Creates a Label control just for $SS_GRAYFRAME GUICtrlCreateLabel("", 0, 0, $aSize[0], $aSize[1], $SS_GRAYFRAME) ; Creates a context menu $NoteGui[$n][4] = GUICtrlCreateContextMenu($NoteGui[$n][3]) ; MenuItem for the context menu "Copy to Clipboard" $NoteGui[$n][5] = GUICtrlCreateMenuItem("Copy to Clipboard" & @TAB & "ENTER", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_CopyToClipboard") ; MenuItem for the context menu "ID_cMenuShareX" $NoteGui[$n][6] = GUICtrlCreateMenuItem("Send to ShareX", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_ShareX") ; MenuItem for the context menu "Save as..." $NoteGui[$n][7] = GUICtrlCreateMenuItem("Save as...", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_SaveAs") ; MenuItem for the context menu "Open" $NoteGui[$n][8] = GUICtrlCreateMenuItem("Open", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_Open") ; separator GUICtrlCreateMenuItem("", $NoteGui[$n][4]) ; MenuItem for the context menu "OCR - eng" $NoteGui[$n][9] = GUICtrlCreateMenuItem("OCR - eng", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_OCR_Eng") ; MenuItem for the context menu "OCR - eng+ell" $NoteGui[$n][10] = GUICtrlCreateMenuItem("OCR - eng+ell", $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_OCR_EngEll") ; separator GUICtrlCreateMenuItem("", $NoteGui[$n][4]) ; MenuItem for the context menu "Close" $NoteGui[$n][11] = GUICtrlCreateMenuItem("Close" & @TAB & "DELETE" , $NoteGui[$n][4]) GUICtrlSetOnEvent(-1, "cm_Close") ; Display the GUI. GUISetState(@SW_SHOW, $NoteGui[$n][0]) $NoteGui[$n][12] = GUICtrlCreateDummy() $NoteGui[$n][13] = GUICtrlCreateDummy() Local $aAccelKeys[2][2] = [ ["{DELETE}", $NoteGui[$n][12] ], ["{ENTER}", $NoteGui[$n][13] ] ] GUISetAccelerators($aAccelKeys) GUICtrlSetOnEvent($NoteGui[$n][12], "cm_Close") GUICtrlSetOnEvent($NoteGui[$n][13], "cm_CopyToClipboard") Return $NoteGui[$n][0] EndFunc ;==>CreateNew_NoteGui ;---------------------------------------------------------------------------------------- Func SaveFileDlg($Active_title) ; Save file Dialog ; Create a constant variable in Local scope of the message to display in FileSaveDialog. Local Const $sMessage = "Choose a filename." ; Display a save dialog to select a file. Local $sFileSaveDialog = FileSaveDialog($sMessage, @ScriptDir & "\SET\", "image (*.jpg)", $FD_PATHMUSTEXIST) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file was saved.") Else ; Retrieve the filename from the filepath e.g. Example.jpg Local $sFileName = StringTrimLeft($sFileSaveDialog, StringInStr($sFileSaveDialog, "\", $STR_NOCASESENSEBASIC, -1)) ; Check if the extension .jpg is appended to the end of the filename. Local $iExtension = StringInStr($sFileName, ".", $STR_NOCASESENSEBASIC) ; If a period (dot) is found then check whether or not the extension is equal to .jpg If $iExtension Then ; If the extension isn't equal to .jpg then append to the end of the filepath. If Not (StringTrimLeft($sFileName, $iExtension - 1) = ".jpg") Then $sFileSaveDialog &= ".jpg" Else ; If no period (dot) was found then append to the end of the file. $sFileSaveDialog &= ".jpg" EndIf ; Display the saved file. ;ConsoleWrite("You saved the following file:" & @CRLF & $sFileSaveDialog & @CRLF) FileCopy($Active_title, $sFileSaveDialog, $FC_OVERWRITE + $FC_CREATEPATH) EndIf EndFunc ;==>SaveFileDlg ;---------------------------------------------------------------------------------------- Func NoteGui_Delete($hWnd) ; NoteGui_Delete For $i = 1 To $NoteGui[0][0] If $NoteGui[$i][0] = $hWnd Then _ArrayDelete($NoteGui, $i) $NoteGui[0][0] -= 1 ExitLoop EndIf Next EndFunc ;==>NoteGui_Delete ;---------------------------------------------------------------------------------------- Func PicToClip($Path) ; put image to clipboard (Thanks to @Nine) _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile($Path) Local $hBitmap1 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) Local $hBitmap2 = _WinAPI_CopyImage($hBitmap1, $IMAGE_BITMAP, 0, 0, $LR_COPYDELETEORG + $LR_COPYRETURNORG) _WinAPI_DeleteObject($hBitmap1) _GDIPlus_Shutdown() _ClipBoard_Open(0) _ClipBoard_Empty() _ClipBoard_SetDataEx($hBitmap2, $CF_BITMAP) _ClipBoard_Close() _WinAPI_DeleteObject($hBitmap2) EndFunc ;==>PicToClip ;---------------------------------------------------------------------------------------- Func TesseracOCR($ImagePath, $lang) ; perform ocr (Thanks to @JohnOne) ;~ ; $lang = more LangCode -> https://tesseract-ocr.github.io/tessdoc/Data-Files-in-different-versions.html ;~ ; more info at -> https://tesseract-ocr.github.io/tessdoc/Command-Line-Usage.html#simplest-invocation-to-ocr-an-image ;~ ; Of course you will have to install it first. -> https://github.com/UB-Mannheim/tesseract/wiki ;~ ; I tried it in Windows 10 with the version -> https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w32-setup-v5.3.0.20221214.exe Local $ResultTextPath, $OutPutPath, $Result ;C:\Program Files (x86)\Tesseract-OCR\tesseract.exe Local Const $TesseractExePath = @ProgramFilesDir & "\Tesseract-OCR\tesseract.exe" ; ℹ️ Give your path * <- $ResultTextPath = @ScriptDir & "\tmp\Result" $OutPutPath = $ResultTextPath & ".txt" ShellExecuteWait($TesseractExePath, '"' & $ImagePath & '" "' & $ResultTextPath & '" -l ' & $lang & ' --psm 6', "", "", @SW_HIDE) ;ConsoleWrite($TesseractExePath & ' "' & $ImagePath & '" "' & $ResultTextPath & '" -l ' & $lang & ' --psm 6' & @CRLF) If @error Then Exit MsgBox($MB_OK + $MB_TOPMOST + $MB_ICONERROR, "Error", @error) EndIf $Result = FileRead($OutPutPath) ;Remove last @LF Local $LastG = StringRight($Result, 1) If $LastG = @LF Then $Result = StringTrimRight($Result, 1) Local $Msg = @CRLF & @CRLF & _StringRepeat(@TAB, 4) & "Copy to ClipBoard ?" Local $iMsgBoxAnswer = MsgBox(4, "OCR Result", $Result & $Msg) If $iMsgBoxAnswer = 6 Then ;Yes ClipPut($Result) ToolTip("The text was copied to the clipboard") Sleep(1000) ToolTip("") EndIf FileDelete($OutPutPath) EndFunc ;==>TesseracOCR ;---------------------------------------------------------------------------------------- Func TRAY_EVENT() ; TRAY_Event Switch @TRAY_ID ; Check the last tray item identifier. Case $TRAY_EVENT_PRIMARYDOUBLE, $TRAY_NewCapture NewCapture() Case $TRAY_ExitScript DllClose($hDLL) Exit EndSwitch EndFunc ;==>TRAY_EVENT ;---------------------------------------------------------------------------------------- Func GUI_EVENT() ; GUI_EVENT Select Case @GUI_CtrlId = $GUI_EVENT_RESIZED Local $aSize For $i = 1 To $NoteGui[0][0] If $NoteGui[$i][0] = @GUI_WinHandle Then $aSize = $NoteGui[$i][2] WinMove(@GUI_WinHandle, "", Default, Default, $aSize[0], $aSize[1]) ControlMove(@GUI_WinHandle, "", "Static1", 0, 0, $aSize[0], $aSize[1]) ControlMove(@GUI_WinHandle, "", "Static2", 0, 0, $aSize[0], $aSize[1]) ExitLoop EndIf Next EndSelect EndFunc ;==>GUI_EVENT ;---------------------------------------------------------------------------------------- Func cm_CopyToClipboard() ; ContextMenu "Copy to Clipboard" Local $Active_title = WinGetTitle(@GUI_WinHandle) ToolTip("Copied to clipboard") PicToClip($Active_title) Sleep(500) ToolTip("") EndFunc ;==>cm_CopyToClipboard ;---------------------------------------------------------------------------------------- Func cm_ShareX() ; ContextMenu "Send to ShareX"" Local $Active_title = WinGetTitle(@GUI_WinHandle) PicToClip($Active_title) Sleep(100) Local $strLen = StringLen(@ScriptDir & "\tmp\image_") If StringLeft($Active_title, $strLen) = @ScriptDir & "\tmp\image_" Then GUIDelete(@GUI_WinHandle) FileDelete($Active_title) NoteGui_Delete(@GUI_WinHandle) EndIf ShellExecute("C:\Program Files\ShareX\ShareX.exe", "-imageeditor ") ; ℹ️ Give your path * <- Local $hShareXImageEd = WinWait("[TITLE:ShareX - Image editor; REGEXPCLASS:WindowsForms10\.Window\..\.app\.0\..+_r\d+_ad1]", "", 2) While WinExists($hShareXImageEd) ControlClick($hShareXImageEd, "", "[NAME:btnLoadImageFromClipboard]") Sleep(300) WEnd $hShareXImageEd = WinWait("[TITLE:ShareX - Image editor; REGEXPCLASS:WindowsForms10\.Window\..\.app\.0\..+_r\d+_ad1]", "", 2) WinActivate($hShareXImageEd) WinSetState($hShareXImageEd, "", @SW_MAXIMIZE) EndFunc ;==>cm_ShareX ;---------------------------------------------------------------------------------------- Func cm_SaveAs() ; ContextMenu "Save as..." Local $Active_title = WinGetTitle(@GUI_WinHandle) SaveFileDlg($Active_title) EndFunc ;==>cm_SaveAs ;---------------------------------------------------------------------------------------- Func cm_Open() ; ContextMenu "Open" Local $Active_title = WinGetTitle(@GUI_WinHandle) ShellExecute($Active_title) EndFunc ;==>cm_Open ;---------------------------------------------------------------------------------------- Func cm_OCR_Eng() ; ContextMenu "OCR - eng" Local $Active_title = WinGetTitle(@GUI_WinHandle) TesseracOCR($Active_title, "eng") EndFunc ;==>cm_OCR_Eng ;---------------------------------------------------------------------------------------- Func cm_OCR_EngEll() ; ContextMenu "OCR - eng+ell" Local $Active_title = WinGetTitle(@GUI_WinHandle) TesseracOCR($Active_title, "eng+ell") EndFunc ;==>cm_OCR_EngEll ;---------------------------------------------------------------------------------------- Func cm_Close() ; ContextMenu "Close" Local $Active_title = WinGetTitle(@GUI_WinHandle) Local $strLen = StringLen(@ScriptDir & "\tmp\image_") If StringLeft($Active_title, $strLen) = @ScriptDir & "\tmp\image_" Then GUIDelete(@GUI_WinHandle) FileDelete($Active_title) NoteGui_Delete(@GUI_WinHandle) ;ConsoleWrite("- WinClose " & @GUI_WinHandle & " & FileDelete " & $Active_title & @CRLF) EndIf EndFunc ;==>cm_Close ;---------------------------------------------------------------------------------------- Func _Array_Gui_display() ; *** Debug _ArrayDisplay($NoteGui) _ArrayDisplay($NoteGui, "$NoteGui") EndFunc ;==>NoteGui_display ;---------------------------------------------------------------------------------------- Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    1 point
  8. I also recommend you to try the example of _WinAPI_EnumDisplayMonitors, which give you the resolution and position of each monitor.
    1 point
  9. Something like this here? Global $hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]") Global $aFullScreen = WinGetPos($hFullScreen) MsgBox(0, "Test", "Screen Resolution of 2nd monitor: " & Abs($aFullScreen[2] - @DesktopWidth) & " x " & Abs($aFullScreen[3] - @DesktopHeight)) Should work only for 2 monitors.
    1 point
  10. Check out ControlGetHandle() Do $Finish = ControlGetHandle("Setup", "Finish", 1) Sleep(100) Until $Finish <> "" ControlClick("Setup", "Finish", 1) The "AutoIt Window Info Tool" is really helpful for such matters.
    1 point
×
×
  • Create New...