AutoHotkey script for you: File preview (thumbnail) in Total Commander

English support forum

Moderators: white, Hacker, petermad, Stefan2

wetware05
Junior Member
Junior Member
Posts: 64
Joined: 2023-05-15, 16:10 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *wetware05 »

Hi, white.

As every script has changes that can be accepted or may not suit all people, each script may suit one or the other. If I were as you suggest, there was only one script that might not suit everyone. A history of changes is also maintained, for those who want to know how a new capability has been implemented.

Anyway, if any moderate thinks I have to change it, I do. In terms of consumption size in the forum database, it must be minimal.
User avatar
white
Power Member
Power Member
Posts: 4595
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *white »

2wetware05
I did not suggest anything, I informed you of the possibilities.
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *Fla$her »

Code: Select all

---------------------------
Error:  Call to nonexistent function.

Specifically: UIA_Interface()
--->	279: ret := UIA_Interface()

The program will exit.
---------------------------
Overquoting is evil! 👎
wetware05
Junior Member
Junior Member
Posts: 64
Joined: 2023-05-15, 16:10 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *wetware05 »

Ok *white, don't worry, and sorry if I could have disturbed you.

*Fla$her, the libraries must be downloaded. The script must be stored in the first directory, which contains a subdirectory called "lib".

https://mega.nz/file/5RAUhCTR#GNZ7-6tbjYXVTIQoGc_4oepQIbQtNysO5IaAyVBihTo

(The file "Mouse over the file (do not need click) to preview the contents (Total Commander).ahk" is the first version, it can be deleted. "Mouse over the file (do not need click) to preview the contents.ahk" is the original version of "suzu", which does not work in Total Commander.)

Control of multiple monitors is not working well :( . I'm trying to figure it out...
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *Fla$her »

wetware05 wrote: 2023-06-01, 23:02 UTC *Fla$her, the libraries must be downloaded. The script must be stored in the first directory, which contains a subdirectory called "lib".

https://mega.nz/file/5RAUhCTR#GNZ7-6tbjYXVTIQoGc_4oepQIbQtNysO5IaAyVBihTo
Previously, there was a zip on this link and there were only 3 libs. But with the update there was another problem:

Code: Select all

---------------------------
UIA Startup Error
---------------------------
IUIAutomation Interface is not registered.
---------------------------
ОК   
---------------------------
Overquoting is evil! 👎
wetware05
Junior Member
Junior Member
Posts: 64
Joined: 2023-05-15, 16:10 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *wetware05 »

In the "lib" directory of the download there are these files:

UIA_Browser.ahk
UIA_Constants.ahk
UIA_Interface.ahk
BTT.ahk
Gdip_All.ahk
NonNull.ahk
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *Fla$her »

I know.
Overquoting is evil! 👎
wetware05
Junior Member
Junior Member
Posts: 64
Joined: 2023-05-15, 16:10 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *wetware05 »

I'am sorry *Fla$her, i wanted to finish fixing the script before sharing a zip file again. :?

I have fixed that the images do not go off the screen, in systems with several monitors (not so necessary in TCM but yes for the desktop or the explorer).

Code: Select all

; Mouse over to the file to preview the content without clicking. Support ahk,txt,ini,jpg,jpeg,png,bmp,tif format.
; You must enable "show file ext name" in explorer.
; You must activate the current screen (click), or when you switch between Explorer, desktop or TCM
; In Total Commander you have to activate (Click) when you change panel.
; You need to check "Show command line" in "configuration", "Layout", in Total Commander
; https://www.autohotkey.com/boards/viewtopic.php?t=90001
;================================================================
; Modified code to add a border to the image, created by Hellbent
; Total Commander support added by WetWare05
; https://www.autohotkey.com/boards/viewtopic.php?p=523384
;================================================================
#Requires AutoHotkey v1.1.33

SetBatchLines, -1
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

CoordMode, Mouse, Screen

maxStr:=200
Global NoW, SetColor, StateC, MaxWidth, MaxHeight, Margin, StateC, Mode, Transp, NameControl
NoW:=""

If numDisplays=1
 {
 Return
 }
Else
 {
 Loop %numDisplays%
  {
   MultiMon:=1
   SysGet, Mon, Monitor, %A_Index%
   SizeMon[A_Index]:= MonRight
  }
 }

if !FileExist("NewConfig.ini")
 {
  IniWrite, 500, NewConfig.ini, Preview_TCM, MaxWidth
  IniWrite, 500, NewConfig.ini, Preview_TCM, MaxHeight
  IniWrite, 8, NewConfig.ini, Preview_TCM, Margin
  IniWrite, 0x99FFFF00, NewConfig.ini, Preview_TCM, SetColor
  IniWrite, 230, NewConfig.ini, Preview_TCM, Transp
  IniWrite, Window7, NewConfig.ini, Preview_TCM, NameControl
 }

If !MaxWidth
 {
  IniRead, MaxWidth, NewConfig.ini, Preview_TCM, MaxWidth
 }
If !MaxHeight
 {
  IniRead, MaxHeight, NewConfig.ini, Preview_TCM, MaxHeight
 }
 If !Margin
 {
  IniRead, Margin, NewConfig.ini, Preview_TCM, Margin
 }
If !SetColor
 {
  IniRead, SetColor, NewConfig.ini, Preview_TCM, SetColor
 }
If !Transp
 {
  IniRead, Transp, NewConfig.ini, Preview_TCM, Transp
 }
If !NameControl
 {
  IniRead, NameControl, NewConfig.ini, Preview_TCM, NameControl
 } 
 
 TempMaxH:= MaxHeight
 TempMaxW:= MaxWidth 

SetTimer, preview, 50

init:
; close system file info tip.
RegRead, ShowInfoTip, HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, ShowInfoTip
RegWrite, REG_DWORD, HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, ShowInfoTip, 0
pToken := Gdip_Startup()
OnExit, GdipExit
PreviewWindow := CreatePreviewWindow( MaxWidth , MaxHeight )
return

CreatePreviewWindow( Width , Height ){
	local Obj := {}
	Gui, New, -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs +HwndhPreview
	Obj.Hwnd := hPreview
	Gui, Show, NA
	Obj.Width := Width
	Obj.Height := Height
	Obj.hbm  := CreateDIBSection( Obj.Width , Obj.Height )
	Obj.hdc  := CreateCompatibleDC()
	Obj.obm  := SelectObject( Obj.hdc , Obj.hbm )
	Obj.G    := Gdip_GraphicsFromHDC( Obj.hdc )
	Gdip_SetInterpolationMode( Obj.G , 0)
	
	return obj
}

preview:
 Current := GetFileUnderMouse()

  if (Displayed != Current.Path)
  {
    Displayed := Current.Path
    Ext       := Current.Ext
    if Ext in ahk,txt,ini
    {
      UpdateLayeredWindow( PreviewWindow.Hwnd , PreviewWindow.hdc, , , , , 0) ;<<<--
      File := FileOpen(Current.Path, "r")
      btt(File.Read(maxStr),,,,"Style5")
      File.Close()
    }
    else if Ext in jpg,jpeg,png,bmp,tif
    {
      btt()
      ShowPreview( Current.Path , PreviewWindow ) ;<<<<<----------
    }
    else
    {
      btt()
      UpdateLayeredWindow( PreviewWindow.Hwnd , PreviewWindow.hdc, , , , , 0)  ;<<<--
    }
  }
return

ShowPreview( Path , PreviewWindow ){
	
	pBitmap := Gdip_CreateBitmapFromFile( path )
	Bwidth := Gdip_GetImageWidth( pBitmap )
	Bheight := Gdip_GetImageHeight( pBitmap )
	
	MaxWidth := PreviewWindow.Width - 2 * Margin
	MaxHeight := PreviewWindow.Height - 2 * Margin
	
	if( BWidth > MaxWidth ){
		Width := MaxWidth
		Height := MaxWidth * ( BHeight / BWidth )
		
		if( Height > MaxHeight ){
			Height := MaxHeight
			Width := MaxHeight * ( BWidth / BHeight )
		}
		
	}else if( BHeight > MaxHeight ){
		Height := MaxHeight
		Width := MaxHeight * ( BWidth / BHeight )

	}else{
		Width := BWidth
		Height := BHeight
	}
			
	Gdip_GraphicsClear( PreviewWindow.G ) ;clear the graphics to start with a fresh canvas to draw on
	Brush := Gdip_BrushCreateSolid( SetColor ) ; create a brush and give it a color (AARRGGBB) 4B7CFA "0x99000000" FFFF00
	GDIP_FillRectangle( PreviewWindow.G , Brush , 0 , 0 , width + 2 * Margin , height + 2 * Margin ) ;use the brush to fill a rectangle on the graphics
	Gdip_DeleteBrush( Brush ) ;delete the brush to free the memory ( alt is to have a "Memory Leak" )
	Gdip_DrawImage( PreviewWindow.G , pBitmap , Margin , Margin , width , height ) ;Draw the resized image on the graphics
	MouseGetPos, x, y ;get the current mouse position
	
	SizeMon := []
	SysGet, numDisplays, MonitorCount

	Loop % numDisplays {
	 SysGet, Mon, Monitor, %A_Index%
	 SizeMon.Push( [Monleft, MonRight, MonTop] )
	StateMon:=1
	}
       			
	ActMon:= MWAGetMonitor()
	Over=0
	NewPos=""
	xOffSet:=16
	yOffSet:=16
	
       If Margin => 15
	{
	 yOffSet:=35
	}
	
	If Margin > 30
	{
	 yOffSet:=70
	}
	
	TempTop:= SizeMon[ActMon,3]
	TempY:= y-Height
	If (TempY<0 or TempY<TempTop)
	{
	 Over:=1
	 NewPos:=1
	}
	
       Marg:=margin*4 ;5
       xt:= x+Width
       
       if (xt>SizeMon[ActMon,2])
	 {
	  x:= (SizeMon[ActMon,2]-Width)-marg
	  If Over=0
	   {
	    y:= y-50
	   }
	  } 
               	
	If NewPos=1
	 {
	  UpdateLayeredWindow( PreviewWindow.Hwnd , PreviewWindow.hdc , x+xOffSet , y+yOffSet , PreviewWindow.Width , PreviewWindow.Height , Alpha := Transp ) ;draw the graphics onto the window and reposition it at an offset of the cursor.
	 }
	Else
	UpdateLayeredWindow( PreviewWindow.Hwnd , PreviewWindow.hdc , x+xOffSet , (y-Height)-yOffSet , PreviewWindow.Width , PreviewWindow.Height , Alpha := Transp )
 }

GdipExit:
  RegWrite, REG_DWORD, HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, ShowInfoTip, %ShowInfoTip%
  Gdip_DisposeImage(pBitmap)
  Gdip_DeleteGraphics(G)
  SelectObject(hdc, obm)
  DeleteDC(hdc)
  DeleteObject(hbm)
	Gdip_Shutdown(pToken)
	ExitApp
return

^p::
NotifyTrayClick_201:
Pause , Toggle
Return

; https://www.autohotkey.com/boards/viewtopic.php?t=51788
; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=69925
GetFileUnderMouse()
{
  static Windows:=ComObjCreate("Shell.Application").Windows

  MouseGetPos, , , hwnd, CtrlClass
  WinGetClass, WinClass, ahk_id %hwnd%

try if WinActive("ahk_exe TOTALCMD.exe") or WinActive("ahk_exe TOTALCMD64.exe")
 {
  If (WinActive("ahk_exe TOTALCMD.exe") || State=2)
 {
  Gosub, Find_Control
 }

If (WinActive("ahk_exe TOTALCMD64.exe") || State=1)
 {
  Gosub, Find_Control64
 }

If !NoW
 {
  If WinActive("ahk_exe TOTALCMD.exe")
  {
   Gosub, Find_Control
  }
 If WinActive("ahk_exe TOTALCMD64.exe")
  {
   Gosub, Find_Control64
  }
 }

;GetKeyState, state, Ctrl
 ;if (state = "D")
 ;{
  ret:= UIA_Interface()
 
  ControlGetText sPath, % NoW
  stringRight, RLast, sPath, 1
  sPath:=StrReplace(sPath,">","")
  Element := ret.ElementFromPoint()
  itemName := Element.GetCurrentPropertyValue(30005)
  if (itemName == "")
	itemName := "No 'Name'"

  RegExMatch(itemName, "^[^\t]*", Reg)
  FullPath:= sPath Reg
    
        SplitPath, FullPath, , , OutExtension, OutNameNoExt
        ret := {}
        ret.Path := sPath "\" Reg
        ret.Ext  := OutExtension
        ret.Name := OutNameNoExt
        return, ret
  }
;}
Else
  try if (WinClass = "CabinetWClass" && CtrlClass = "DirectUIHWND2")
  {
    oAcc := Acc_ObjectFromPoint()
    Name := Acc_Parent(oAcc).accValue(0)
    NonNull(Name, oAcc.accValue(0))

    if (Name="")
      return

    for window in Windows
      if (window.hwnd = hwnd)
      {
        FolderPath := RegExReplace(window.Document.Folder.Self.Path, "(\w+?\:)\\$", "$1") ; “d:\” 转换为 “d:” — “d:\” convertido a “d:”

        SplitPath, Name, , , OutExtension, OutNameNoExt
        ret := {}
        ret.Path := FolderPath "\" Name
        ret.Ext  := OutExtension
        ret.Name := OutNameNoExt

        return, ret
      }
  }
  else if (WinClass = "Progman" || WinClass = "WorkerW")
  {
    oAcc := Acc_ObjectFromPoint(ChildID)
    Name := ChildID ? oAcc.accName(ChildID) : ""

    if (Name="")
      return

    SplitPath, Name, , , OutExtension, OutNameNoExt
    ret := {}
    ret.Path := A_Desktop "\" Name
    ret.Ext  := OutExtension
    ret.Name := OutNameNoExt

    return, ret
  }
}

Acc_Init() {
	Static h
	If Not h
		h:=DllCall("LoadLibrary","Str","oleacc","Ptr")
}
Acc_ObjectFromPoint(ByRef _idChild_ = "", x = "", y = "") {
	Acc_Init()
	If	DllCall("oleacc\AccessibleObjectFromPoint", "Int64", x==""||y==""?0*DllCall("GetCursorPos","Int64*",pt)+pt:x&0xFFFFFFFF|y<<32, "Ptr*", pacc, "Ptr", VarSetCapacity(varChild,8+2*A_PtrSize,0)*0+&varChild)=0
	Return ComObjEnwrap(9,pacc,1), _idChild_:=NumGet(varChild,8,"UInt")
}
Acc_Parent(Acc) { 
	try parent:=Acc.accParent
	return parent?Acc_Query(parent):
}
Acc_Query(Acc) { ; thanks Lexikos - www.autohotkey.com/forum/viewtopic.php?t=81731&p=509530#509530
	try return ComObj(9, ComObjQuery(Acc,"{618736e0-3c3d-11cf-810c-00aa00389b71}"), 1)
}

NotifyTrayClick(P*) {              ;  v0.41 by SKAN on D39E/D39N @ tiny.cc/notifytrayclick
Static Msg, Fun:="NotifyTrayClick", NM:=OnMessage(0x404,Func(Fun),-1),  Chk,T:=-250,Clk:=1
  If ( (NM := Format(Fun . "_{:03X}", Msg := P[2])) && P.Count()<4 )
     Return ( T := Max(-5000, 0-(P[1] ? Abs(P[1]) : 250)) )
  Critical
  If ( ( Msg<0x201 || Msg>0x209 ) || ( IsFunc(NM) || Islabel(NM) )=0 )
     Return
  Chk := (Fun . "_" . (Msg<=0x203 ? "203" : Msg<=0x206 ? "206" : Msg<=0x209 ? "209" : ""))
  SetTimer, %NM%,  %  (Msg==0x203        || Msg==0x206        || Msg==0x209)
    ? (-1, Clk:=2) : ( Clk=2 ? ("Off", Clk:=1) : ( IsFunc(Chk) || IsLabel(Chk) ? T : -1) )
Return True
}
;
; AutoHotkey Version: 1.1.12.00
; Language:       English
; Dev Platform:   Windows 7 Home Premium x64
; Author:         Joe DF  |  http://joedf.co.nr  |  joedf@users.sourceforge.net
; Date:           August 20th, 2013
;
; Script Function:
;	Color Dialog Example script.
;
;<<<<<<<<  HEADER END  >>>>>>>>>

;Set starting default value to RGB(44,197,89), Just a random colour
;RGBval:=RGB(Rval:=44,Gval:=197,Bval:=89)

^!F8::
stringRight, RSix, SetColor, 6
TColor:="0x" RSix
R:= (TColor&0xFF0000)>>16, G:= (TColor&0x00FF00)>>8, B:= TColor&0xFF

RGBval:=RGB(Rval:= R, Gval:= G, Bval:= B)
;Create Color Dialog GUI
Gui, Add, Text, x0 y10 w40 h20 +Right, Red
Gui, Add, Text, x0 y30 w40 h20 +Right, Green
Gui, Add, Text, x0 y50 w40 h20 +Right, Blue
Gui, Add, Slider, x40 y10 w190 h20 AltSubmit +NoTicks +Range0-255 vsR gSliderSub, %Rval%
Gui, Add, Slider, x40 y30 w190 h20 AltSubmit +NoTicks +Range0-255 vsG gSliderSub, %Gval%
Gui, Add, Slider, x40 y50 w190 h20 AltSubmit +NoTicks +Range0-255 vsB gSliderSub, %Bval%
Gui, Add, Edit, x230 y10 w45 h20 gEditSub veR +Limit3 +Number, %Rval%
Gui, Add, UpDown, Range0-255 vuR gUpDownSub, %Rval%
Gui, Add, Edit, x230 y30 w45 h20 gEditSub veG +Limit3 +Number, %Gval%
Gui, Add, UpDown, Range0-255 vuG gUpDownSub, %Gval%
Gui, Add, Edit, x230 y50 w45 h20 gEditSub veB +Limit3 +Number, %Bval%
Gui, Add, UpDown, Range0-255 vuB gUpDownSub, %Bval%
Gui, Add, Progress, x285 y10 w60 h60 +Border Background%RGBval% vpC
Gui, Add, Text, x285 y10 w60 h60 +Border vtP cWhite +BackgroundTrans, Preview
Gui, Add, Button, x120 y80 w110 h20 vbS gButtonSub, Select Color ;Copy to Clipboard
Gui, Show, w351 h105, Simple Color Dialog
return

EditSub:
	;Get Values
	GuiControlGet,Rval,,eR
	GuiControlGet,Gval,,eG
	GuiControlGet,Bval,,eB
	;Set preview
	gosub set
	;Make Everything else aware
	GuiControl,,uR,%Rval%
	GuiControl,,uG,%Gval%
	GuiControl,,uB,%Bval%
	GuiControl,,sR,%Rval%
	GuiControl,,sG,%Gval%
	GuiControl,,sB,%Bval%
return

UpDownSub:
	;Get Values
	GuiControlGet,Rval,,uR
	GuiControlGet,Gval,,uG
	GuiControlGet,Bval,,uB
	;Set preview
	gosub set
	;Make Everything else aware
	GuiControl,,eR,%Rval%
	GuiControl,,eG,%Gval%
	GuiControl,,eB,%Bval%
	GuiControl,,sR,%Rval%
	GuiControl,,sG,%Gval%
	GuiControl,,sB,%Bval%
return

SliderSub:
	;Get Values
	GuiControlGet,Rval,,sR
	GuiControlGet,Gval,,sG
	GuiControlGet,Bval,,sB
	;Set preview
	gosub set
	;Make Everything else aware
	GuiControl,,eR,%Rval%
	GuiControl,,eG,%Gval%
	GuiControl,,eB,%Bval%
	GuiControl,,uR,%Rval%
	GuiControl,,uG,%Gval%
	GuiControl,,uB,%Bval%
return

set:
	;Convert values to Hex
	RGBval:=RGB(Rval,Gval,Bval)
	;Display Tooltip
	ToolTip Red: %Rval%`nGreen: %Gval%`nBlue: %Bval%`nHex: %RGBval%
	;Make tooltip disappear after 375 ms (3/8th of a second)
	SetTimer, RemoveToolTip, 375
	;Apply colour to preview
	GuiControl,+Background%RGBval%,pC
return

RemoveToolTip:
	SetTimer, RemoveToolTip, Off ;Turn timer off
	ToolTip ;Turn off tooltip
return

ButtonSub:
	;Remove '0x' prefix to hex color code, saving it directly to the clipboard
	;StringReplace,Clipboard,RGBval,0x99
	StringReplace,SetColor,RGBval,0x
	SetColor:="0x99" SetColor
	;MsgBox, % SetColor . " " . RGBval
	;Display Last selected values... (these values can later be used), and Notify the user
	;MsgBox,64,Simple Color Dialog,RGB: (%Rval%, %Gval%, %Bval%)`nHex: %RGBval%`nCopied to Clipboard!
	;Skip Directly GuiClose
	Gui, Destroy
	Return

^!s::
Xpos:= Floor((A_ScreenWidth/2)-450)
Ypos:= Floor((A_ScreenHeight/2)-200)
Gui, Size: +HwndGuiID +AlwaysOnTop
Gui, Size: Add, Button, x300 y16 w65 h20 GNewSize, OK
Gui, Size: Add, Button, x300 y46 w65 h20 gCancel, Cancel
Gui, Size: Font, S9 Bold, Verdana
Gui, Size: Add, Text, x5 y16 w90 h20, Max. Width:
Gui, Size: Add, edit, x95 y16 w60 h20 vFmaxW, %TempMaxW%
Gui, Size: Add, Text, x5 y46 w90 h20, Max.   High:
Gui, Size: Add, edit, x95 y46 w60 h20 vFmaxH, %TempMaxH%
Gui, Size: Add, Text, x170 y16 w70 h20, Transp.:
Gui, Size: Add, edit, x230 y16 w60 h20 vFtrans , %Transp%
Gui, Size: Add, Text, x170 y46 w70 h20, Margin :
Gui, Size: Add, edit, x230 y46 w60 h20 vFmarg , %margin%
Gui, Size: Show, x%xpos% y%ypos% h80 w370, Image Preview Configuration
Return

#If WinActive("ahk_id " GuiID)
Enter::
NumPadEnter::
NewSize:
Gui, Size: Submit
If !FmaxW
 {
  MaxWidth:=500
 }
Else 
{
MaxWidth:=FmaxW
IniWrite, %MaxWidth%, NewConfig.ini, Preview_TCM, MaxWidth
}

If !FmaxH
 {
  MaxHeight:=500
 }
Else 
{
MaxHeight:=FmaxH
IniWrite, %MaxHeight%, NewConfig.ini, Preview_TCM, MaxHeight
}

If !Ftrans or Ftrans>256
 {
  Transp:=Transp
 }
Else 
{
Transp:=Ftrans
IniWrite, %Ftrans%, NewConfig.ini, Preview_TCM, Transp
}

If !Fmarg
 {
  Margin:=16
 }
Else 
{
Margin:=Fmarg
IniWrite, %Fmarg%, NewConfig.ini, Preview_TCM, Margin
}
Gui, Size: Destroy
Gosub, Init
Return

Cancel:
Gui, Size: Destroy
Return

;^F8::
Find_Control:
Now:=""
Loop, 30
 {
 NewWin:= "TMyPanel" A_Index
 ControlGetText PPath, % NewWin
 StringRight, RLast, PPath, 1
 If RLast=>
   {
   NoW:= NewWin
   State=1
   Break 
   }
 }
Return

;^F9::
Find_Control64:
Now:=""
Loop, 30
 {
 NewWin:= "Window" A_Index
 ControlGetText PPath, % NewWin
 StringRight, RLast, PPath, 1
 If RLast=>
   {
   NoW:= NewWin
   State=2
   Break 
   }
 }
Return

;Function to convert Decimal RGB to Hexadecimal RBG, Note: '0' (zero) padding is unnecessary
RGB(r, g, b) {
	;Shift Numbers
	var:=(r << 16) + (g << 8) + b
	;Save current A_FormatInteger
	OldFormat := A_FormatInteger
	;Set Hex A_FormatInteger mode
	SetFormat, Integer, Hex
	;Force decimal number to Hex number
	var += 0
	;set original A_FormatInteger mode
	SetFormat, Integer, %OldFormat%
	return var
}

; Funtion By Maestr0 https://www.autohotkey.com/boards/viewtopic.php?f=6&t=54557

MWAGetMonitor(Mx := "", My := "")
{
	if  (!Mx or !My) 
	{
		; if Mx or My is empty, revert to the mouse cursor placement
		Coordmode, Mouse, Screen	; use Screen, so we can compare the coords with the sysget information`
		MouseGetPos, Mx, My
	}

	SysGet, MonitorCount, 80	; monitorcount, so we know how many monitors there are, and the number of loops we need to do
	Loop, %MonitorCount%
	{
		SysGet, mon%A_Index%, Monitor, %A_Index%	; "Monitor" will get the total desktop space of the monitor, including taskbars

		if ( Mx >= mon%A_Index%left ) && ( Mx < mon%A_Index%right ) && ( My >= mon%A_Index%top ) && ( My < mon%A_Index%bottom )
		{
			ActiveMon := A_Index
			break
		}
	}
	return ActiveMon
}

#Include <NonNull>
#Include <Gdip_All>
New .zip file with everything you need:
https://mega.nz/file/tJQjQBhZ#WY8VJ5mu3w-_avCSvFSq53lc3IdJSIaIhe4wz_Tm0uQ
KozakMak
Senior Member
Senior Member
Posts: 352
Joined: 2021-05-24, 12:39 UTC
Location: UA

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *KozakMak »

2wetware05
okey, can you modify script with some user options in the beginning of the file?
Example:
ShowOnlyInTC=1\0
KeyToActivate=RCtrl
OS: Win10 | TC: latest x64
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *Fla$her »

wetware05 wrote: 2023-06-03, 10:12 UTC #Requires AutoHotkey v1.1.33
What about v1.1.36.02?
Overquoting is evil! 👎
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *Horst.Epp »

Fla$her wrote: 2023-06-03, 11:38 UTC
wetware05 wrote: 2023-06-03, 10:12 UTC #Requires AutoHotkey v1.1.33
What about v1.1.36.02?
Compiles and runs here fine with the combined 2.02 and v1.1.36.01 setup.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *Fla$her »

Horst.Epp wrote: 2023-06-03, 11:51 UTC with the combined 2.02
I don't use 2.xx. I have a portable AutoHotkeyU32.exe (1.1.36.02) as part of the assembly.
Overquoting is evil! 👎
wetware05
Junior Member
Junior Member
Posts: 64
Joined: 2023-05-15, 16:10 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *wetware05 »

KozakMak, the script is paused (or asleep) by left-clicking on its icon, in the inbox or by Ctrl+p (it's an on/off switch). In the first scripts it was like you said: it was activated only if you had the Ctrl key. In lines 266 to 268 and 289 (symbol "}" as closure of the action), there is the option that you say "commented". That is, a semicolon (;) has been placed in front of it, so that it does not work. If you remove the symbol ; it has to work. Change Ctrl to RCtrl.

As it is now:

Code: Select all

;GetKeyState, state, Ctrl
 ;if (state = "D")
 ;{
...................
...................
;}
I can add a switch to activate/deactivate the option to work or not when pressing RCtrl. Already for Monday.
(I don't know what you mean by ShowOnlyInTC=1\0. A Switch to only work on TCM? or only on one of the TCM panels).

*Fla$her is AutoHotkey v1.1.33 or higher before V2. I have version 1.1.36.02

Still not working?, try adding:

Code: Select all

#Include lib\UIA_Interface.ahk
on the line following of:
#Requires AutoHotkey v1.1.33
Fla$her
Power Member
Power Member
Posts: 2244
Joined: 2020-01-18, 04:03 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *Fla$her »

wetware05 wrote: 2023-06-03, 12:27 UTC Still not working?, try adding:

Code: Select all

#Include lib\UIA_Interface.ahk
on the line following of:
#Requires AutoHotkey v1.1.33
No, the same error.
Overquoting is evil! 👎
wetware05
Junior Member
Junior Member
Posts: 64
Joined: 2023-05-15, 16:10 UTC

Re: AutoHotkey script for you: File preview (thumbnail) in Total Commander

Post by *wetware05 »

Hi, Fla$her

UIAutomation communicates with the system through the .NET and .NET Framework libraries, maybe you have an outdated (or damaged) system .NET Framework library. What operating system do you have?

Check the integrity of the system files (Windows button with the right mouse button. Go to "Windows Terminal (Administrator) and type

Code: Select all

sfc /scannow 
and press enter.

The file that I have shared from AutoHotkey UIAutomation are the latest (updated two months ago by the author), which can be downloaded from here. https://github.com/Descolada/UIAutomation if you want to re-download them from the official site, you have to hit the "Code" and "Download ZIP" button.

I leave you a link to a somewhat older version, maybe your system will work with that old version (make a copy of the newer versions).

https://mega.nz/file/BU4CDDIK#Cis699GhGFE80dnPsFSMcWcdCz4RIPQKwRjc-pv2-no
Post Reply