copy timestamp with ctrl left double click on each one separately

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

copy timestamp with ctrl left double click on each one separately

11 Jan 2023, 06:50

this is my text

Code: Select all

02:06:36 gsglkjhslighasik 01:35:41 khjlkhlkhhlkhj 02:20:12


Code: Select all

^LButton::
if (A_PriorHotkey <> A_ThisHotkey Or A_TimeSincePriorHotkey > 400)
		Return
hhmmss:=Grabline()
Send,{Right}
return

Grabline() {
	Clipbackup := ClipboardAll 
	Clipboard := ""
	MouseClick, Left,,, 3 
	Send, ^c 
	ClipWait, 1, 1 
	hhmmss := Clipboard 
	Clipboard := Clipbackup 
	Return hhmmss
}
How can i copy each one of them individually ? any help would much appreciated.

with some regex replace i could get the first timestamp without any problem
the problem i am facing is based on my my mouse location i need to grab the timestamp below it.
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: copy timestamp with ctrl left double click on each one separately

11 Jan 2023, 08:07

Just a different idea for selecting the individual time.

Code: Select all

#Requires AutoHotkey v1.1.33
F3:: ; Enable "LButton up" to capture the selected time
on := True
SoundBeep 1500
Return

#If on
~LButton Up::
Clipboard := "", on := False
Send ^c
ClipWait 0
If !ErrorLevel {
 RegExMatch(Clipboard, "\d\d:\d\d:\d\d", time)
 Clipboard := time
 MsgBox 64, Time, % time
} Else MsgBox 48, Error, An error occurred while waiting for the clipboard.
Return
#If

Code: Select all

#Requires AutoHotkey v2.0

F3:: { ; Enable "LButton up" to capture the selected time
 Global on := True
 SoundBeep 1500
}

#HotIf on
~LButton Up:: {
 Global on := False
 A_Clipboard := ""
 Send '^c'
 If ClipWait(1) {
  RegExMatch(A_Clipboard, "\d\d:\d\d:\d\d", &time)
  A_Clipboard := time[]
  MsgBox time[], 'Time', 64
 } Else MsgBox 'An error occurred while waiting for the clipboard.', 'Error', 48
}
#HotIf
ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

Re: copy timestamp with ctrl left double click on each one separately

11 Jan 2023, 08:30

mikeyww wrote:
11 Jan 2023, 08:07
Just a different idea for selecting the individual time.
Thank you for the reply ,
how ever what i am trying to do is actually a little different.
when i double click any where on the the time stamp it should copy it to clip board.

lets say if i click on timestamp 1 , it should only copy timestamp 1.
similarly if i click on timestamp 2 , it should only copy timestamp 2.

etc

this is what i came up with so far,

Code: Select all

^LButton::
if (A_PriorHotkey <> A_ThisHotkey Or A_TimeSincePriorHotkey > 400)
		Return
Click
SendInput, {Shift Down}
loop,5
SendInput, {left}{Ctrl Down}{right}+{left}{Ctrl Up}
SendInput, {Shift up}
SendInput, {left}
SendInput, {Shift Down}
loop,5
SendInput, {right}{Ctrl Down}{left}+{right}{Ctrl Up}
SendInput, {Shift up}
lipbackup := ClipboardAll 
Clipboard := ""
Send, ^c 
ClipWait, 1, 1 
hhmmss := Clipboard 
RegExMatch(hhmmss, "(h*\d{1,2}(?:\.|:)\d{1,2}(?:\.|:)\d{1,2})|(h*\d{1,2}(?:\.|:)\d{1,2})",hhmmss)
return

but its slow in action
i think i will have to grab full line to clipboard then iterate each time stamp on a single line and based on my mouse position return desired time stamp ( something like that )
Last edited by ananthuthilakan on 11 Jan 2023, 08:45, edited 1 time in total.
ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

Re: copy timestamp with ctrl left double click on each one separately

11 Jan 2023, 08:38

OH shooot!
the above code is only working inside obsidian editor and notepad++
it fails in simple notepad and wordpad
not in any other editor :headwall:

an interesting effect in microsoft word , that it can grab first time stamp in a line where ever i click in that line :dance: :lolno:
ananthuthilakan
Posts: 188
Joined: 08 Jul 2019, 05:37
Contact:

Re: copy timestamp with ctrl left double click on each one separately

11 Jan 2023, 13:39

mikeyww wrote:
11 Jan 2023, 11:23
Idea: viewtopic.php?p=498517#p498517
Thank for the idea :superhappy:

Code: Select all

^LButton::
if (A_PriorHotkey <> A_ThisHotkey Or A_TimeSincePriorHotkey > 400)
		Return
Clipboard := ""
Click,2
SendInput, +{Home}
Send ^c
ClipWait, 0
s1:=Clipboard , Clipboard:=""
SendInput, +{End}
Send ^c
ClipWait, 0
s2:=Clipboard ,s1 := SubStr(s1, -8), s2 := SubStr(s2, 1,8)
SendInput, {Ctrl up}
click
SendInput, {Right}
;~ click
hhmmss:= s1 . s2
RegExMatch(hhmmss, "(h*\d{1,2}(?:\.|:)\d{1,2}(?:\.|:)\d{1,2})|(h*\d{1,2}(?:\.|:)\d{1,2})",hhmmss)
Clipboard := hhmmss
Return
this can grab from non edit boxes as long as we can select word.

but i ended up with OCR viewtopic.php?f=6&t=36047

Code: Select all

#include <Vis2> ; https://www.autohotkey.com/boards/viewtopic.php?f=6&t=36047
^LButton::
if (A_PriorHotkey <> A_ThisHotkey Or A_TimeSincePriorHotkey > 400)
		Return
MouseClick, Left,,, 2
SendInput,{Right}^{Right 2}	
MouseGetPos  OutputVarX, OutputVarY
srr:=[186,623,200,50]
srr.1:= OutputVarX-100
srr.2:= OutputVarY-25
hhmmss := OCR(srr)
RegExMatch(hhmmss, "(h*\d{1,2}(?:\.|:)\d{1,2}(?:\.|:)\d{1,2})|(h*\d{1,2}(?:\.|:)\d{1,2})",hhmmss)
Clipboard := hhmmss
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], bobstoner289, Google [Bot], peter_ahk, Spawnova and 347 guests