The script only works if it is written from the first line.

Get help with using AutoHotkey and its commands and hotkeys
reluct
Posts: 61
Joined: 28 Nov 2018, 05:07

Re: The script only works if it is written from the first line.

17 Aug 2019, 00:26

I do exactly the same.
The second part I can’t understand where I have to check it.
gregster
Posts: 2950
Joined: 30 Sep 2013, 06:48

Re: The script only works if it is written from the first line.

17 Aug 2019, 01:28

I just showed that both script versions create the same result (if I use them like I described). After all, they are almost exactly the same and I cannot reproduce the differing results that you claim to get.
But ok, wonderful, you do exactly the same, but you claim to get other results - please show these results (and how you got them). Step by step. Show the script you used...
gregster
Posts: 2950
Joined: 30 Sep 2013, 06:48

Re: The script only works if it is written from the first line.

17 Aug 2019, 11:22

Video "not found" 🤷‍♂️

Edit: So, it's probably rather this URL: https://vimeo.com/354353950 !?

What I could take away from your video:
  • If the third-party program is running, it conflicts with the AHK script. That's totally possible, like I already said (and might be a solvable problem, or not, but it can only be a next step ). I wanted to focus on the pure AHK script(s) first, for systematical reasons and because of your claim of differing results.
  • As soon, as you stop the third-party program - and copy some strings - the AHK script is working as expected.
So, can we agree that the AHK script works as it should be, as long as no other clipboard-related software is interfering !?!

If you look at my previous post, I wrote that I wanted to check your claim that your original and my slightly modified script work differently - but clearly, your video wasn't about that question.
So, I assume that we can also agree that, in general, both script versions are functionally the same (at least, as long as there are no conflicts with third-party programs).


If we are now on the same page about these questions, then we can try to solve the conflict with the third-party program (but to be clear: at this point, it's unsure, if it will possible to solve the conflict with this Spartan program)... do we agree?
reluct
Posts: 61
Joined: 28 Nov 2018, 05:07

Re: The script only works if it is written from the first line.

17 Aug 2019, 16:34

Yes, I need a script that will work with this program because I can not do without it.
I understand that this problem can be insoluble.
gregster
Posts: 2950
Joined: 30 Sep 2013, 06:48

Re: The script only works if it is written from the first line.

17 Aug 2019, 18:36

Ok, then I will take a look at the Spartan trial version tomorrow.
But I am surprised that a commercial clipboard manager wouldn't already have an easy way to do what the AHK script does and offer some hotkeys...
gregster
Posts: 2950
Joined: 30 Sep 2013, 06:48

Re: The script only works if it is written from the first line.

17 Aug 2019, 22:57

Like expected, Spartan messes around with the clipboard and triggers OnClipBoardChange several times after you copy a new string and this overwrites the variable contents you want to use with Numpad8. One solution is probably to not use OnClipBoardChange at all - and instead create a hotkey for Ctrl+c instead.

Please try this with Spartan running:

Code: Select all

; auto-exec section:
gosub clipshift	
return	; end of auto-execute section

; [...] your other hotkeys

#If
$^c::	; Ctrl+c
Send ^c
gosub clipshift
return 

clipshift:
ClipOld := (ClipOld != "") ? ClipNew : Clipboard
ClipNew := clipboard 
return 

Numpad8:: SendInput %ClipOld%	; pastes "old", previous clipboard (but current clipboard on script start)
reluct
Posts: 61
Joined: 28 Nov 2018, 05:07

Re: The script only works if it is written from the first line.

18 Aug 2019, 00:26

Does not work. It stops copying text after running the script.
gregster
Posts: 2950
Joined: 30 Sep 2013, 06:48

Re: The script only works if it is written from the first line.

18 Aug 2019, 01:15

reluct wrote:
18 Aug 2019, 00:26
Does not work. It stops copying text after running the script.
This is pretty vague again - this communication is clearly not working.
I can't follow, the script works here as expected; Spartan, too, afaics - at least the main functions. At the same time.

I don't have access to your computer - perhaps you have other programs or scripts interfering.
Perhaps you have changed some of the many options of Spartan.
If you don't start to do some serious debugging on your own computer, nobody will.
reluct
Posts: 61
Joined: 28 Nov 2018, 05:07

Re: The script only works if it is written from the first line.

18 Aug 2019, 01:56

gregster wrote:
18 Aug 2019, 01:15
This is pretty vague again - this communication is clearly not working.
What is vague if, after running your script, the ability to copy is lost.
No other programs are running.
Try the portable version https://dropmefiles.com/aKvq2
gregster
Posts: 2950
Joined: 30 Sep 2013, 06:48

Re: The script only works if it is written from the first line.

18 Aug 2019, 02:10

What means after running? After starting the script (while it's running) or after you exited the script? Have you tried to run the script as admin? In which order did you start Spartan and the script ? What have you tried for troubleshooting?
The removal of the label made perfect sense, now there is not much to go on...

If the portable version doesn't work together with AHK, I don't think I can help you - try the non-portable version. Perhaps ask at the Spartan forum, if they have an idea, what their portable version is doing different, how it is hijacking the clipboard and Ctrl+c and how to handle it in combination with other programs that work with the clipboard and define hotkeys.
reluct
Posts: 61
Joined: 28 Nov 2018, 05:07

Re: The script only works if it is written from the first line.

18 Aug 2019, 02:30

What means after running?
This means that when the script is turned on, even without a running Spartan , Ctrl+c not work.
gregster
Posts: 2950
Joined: 30 Sep 2013, 06:48

Re: The script only works if it is written from the first line.

18 Aug 2019, 03:50

Only if you forget to add the #If. And even then...
But that is definitely something you should start with, when you are doing the debugging on your computer.
reluct
Posts: 61
Joined: 28 Nov 2018, 05:07

Re: The script only works if it is written from the first line.

18 Aug 2019, 04:15

I use the code that you gave me in the message above.
gregster
Posts: 2950
Joined: 30 Sep 2013, 06:48

Re: The script only works if it is written from the first line.

18 Aug 2019, 04:17

Okay, that is definitely something you should start with, when you are doing the debugging on your computer. It works here as expected. There is probably something interfering on your computer. Does Ctrl+c generally work as copy on your keyboard layout?
Please make sure to report back, when you find the reason.
reluct
Posts: 61
Joined: 28 Nov 2018, 05:07

Re: The script only works if it is written from the first line.

18 Aug 2019, 07:28

If someday I find out the cause of the problem, I will inform you.
In any case, thanks for really trying to help.
reluct
Posts: 61
Joined: 28 Nov 2018, 05:07

Re: The script only works if it is written from the first line.

20 Aug 2019, 07:17

gregster wrote:
18 Aug 2019, 04:17
Please make sure to report back, when you find the reason.
I found another script http://drozdman.blogspot.com/2013/07/autohotkey-scripts-get-last-content-of.html

Code: Select all

;*********************** Old Clipboard ********************************** 
toggle=1
ClipNew := clipboard
ClipOld11 := "Ø"
ClipOld :=" "
number_of_clips=11

OnClipboardChange:
if (toggle=0) {
return
}else if RegExMatch(clipboard, "mi)<html>|<body>|<title>|vlc-record|<title>|<!--|</div>"){
return 
; }else if (StrLen(clipboard)>2000){
; return 
}else{
  if (ClipOld1 == clipboard OR  clipboard == ClipNew)
return

ClipOld10 := ClipOld9
ClipOld9 := ClipOld8
ClipOld8 := ClipOld7
ClipOld7 := ClipOld6
ClipOld6 := ClipOld5
ClipOld5 := ClipOld4
ClipOld4 := ClipOld3
ClipOld3 := ClipOld2
ClipOld2 := ClipOld1

/* 

Loop %number_of_clips% { 
step := number_of_clips - A_Index
if (step<=1)
break 
prev:= step - 1 
if (Clip_Old%step% != Clip_Old%prev%){
Clip_Old%step% := Clip_Old%prev%
} 
}
*/

ClipOld1 := ClipNew
ClipOld:=ClipOld1

ClipNew := clipboard

}
return

p:: SendInput %ClipOld% 

;_________________________________________ LWin & Space::


LWin & Space:: ; Send, ^v 
index=1
CoordMode,ToolTip,Screen

Clip1 := SubStr(clipboard, 1, 100) "`n" SubStr(clipboard, 101, 100) "`n" SubStr(clipboard, 201, 100) "`n" SubStr(clipboard, 301, 100) "`n" SubStr(clipboard, 401, 100) 
Clip1 := RegExReplace(Clip1, "`n`n","") 

if (StrLen(clipboard)<=70){
ToolTip, % "Clipboard ("StrLen(clipboard ) " long) `n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯`n" Clip1 "`n ̢" 
}else

ToolTip, % "Clipboard ("StrLen(clipboard ) " long) `n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯`n" Clip1 "`n ̢" ,500, 330 
KeyWait, Space
SetTimer, 2_Key_Down_Timer, 100 
ClipPaste:=clipboard

KeyWait, LWin
SetTimer, 2_Key_Down_Timer, off
ToolTip
clipboard_backup := clipboard
Clipboard:=ClipPaste
Send ^v
; SendInput %ClipPaste% ; too slow 
clipboard := clipboard_backup

2_Key_Down_Timer: 
if (GetKeyState("Space", "P") = 1) { 
if index> 11
return
ClipPaste:=ClipOld%index%
CoordMode,ToolTip,Screen

Clip2 := SubStr(ClipPaste, 1, 100) "`n"SubStr(ClipPaste, 101, 100)"`n"SubStr(ClipPaste, 201, 100)"`n"SubStr(ClipPaste, 301, 100)"`n"SubStr(ClipPaste, 401, 100) 
Clip2 := RegExReplace(Clip2, "`n`n","") 

if (StrLen(ClipPaste)<=70){
ToolTip, % "#" index " ("StrLen(ClipPaste) ")" "`n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯`n" Clip2 "`n ̢" 
}else 

ToolTip, % "#" index " ("StrLen(ClipPaste) ") " "`n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯`n" Clip2 "`n ̢" ,500, 330

index+=1
}
KeyWait, Space 
return 
return

;^b:: SendInput %ClipOld%
;LAlt & Space:: Gosub, Show_Clipboard ;SendInput %clipboard%

;---------------------------------------------- LShift & Space::

LShift & Space::
index_Clip=2
CoordMode,ToolTip,Screen
;Clip1 := SubStr(clipboard, 1, 150) "`n" SubStr(clipboard, 151, 150) "`n" SubStr(clipboard, 301, 150) "`n" SubStr(clipboard, 451, 150) "`n" SubStr(clipboard, 601, 150) 
Clip1 := SubStr(clipboard, 1, 100) "`n" SubStr(clipboard, 101, 100) "`n" SubStr(clipboard, 201, 100) "`n" SubStr(clipboard, 301, 100) "`n" SubStr(clipboard, 401, 100) 
Clip1 := RegExReplace(Clip1, "`n`n`n","") 

;Clip3 := (StrLen(ClipOld1)>0) ? SubStr(ClipOld1, 1, 150) "`n" SubStr(ClipOld1, 151, 150) "`n" SubStr(ClipOld1, 301, 150) "`n" SubStr(ClipOld1, 451, 150) "`n" SubStr(ClipOld1, 601, 150) : "" 
Clip3 := (StrLen(ClipOld1)>0) ? SubStr(ClipOld1, 1, 100) "`n" SubStr(ClipOld1, 201, 100) "`n" SubStr(ClipOld1, 301, 100) "`n" SubStr(ClipOld1, 401, 100) "`n" SubStr(ClipOld1, 501, 100) : "" 
Clip3 := RegExReplace(Clip3, "`n`n`n","") 

;ToolTip, % "Clipboard ("StrLen(clipboard)"): `n‾‾‾‾‾‾‾‾‾‾‾`n" Clip1 "`n`n_________________________________________ `n‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ `nClip1 (" StrLen(ClipOld)"): `n‾‾‾‾‾‾‾‾‾‾`n" Clip3 "`n___",400, 330 
;ToolTip, % "Clipboard ("StrLen(clipboard)"): `n¯¯¯¯¯¯¯¯¯¯¯`n" Clip1 "`n`n_________________________________________ `n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ `nClip1 (" StrLen(ClipOld1)"): `n¯¯¯¯¯¯¯¯¯¯¯`n" Clip3 "`n ̢",400, 330 
ToolTip, % "Clipboard ("StrLen(clipboard)"): `n¯¯¯¯¯¯¯¯¯¯¯`n" Clip1 "`n`n_________________________________________ `n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ `n#1 (" StrLen(ClipOld1)"): `n¯¯¯¯¯¯¯¯¯¯¯`n" Clip3 "`n ̢",500, 330 

KeyWait, Space
SetTimer, 2_Key_Down_Timer_2, 100 
ClipPaste:=clipboard

KeyWait, LShift 
SetTimer, 2_Key_Down_Timer_2, off
ToolTip

2_Key_Down_Timer_2: 
if (GetKeyState("Space", "P") = 1) { 
if index_Clip> 10
return
ClipPaste:=ClipOld%index_Clip%
index_Clip2:=index_Clip +1
ClipPaste2:=ClipOld%index_Clip2%
CoordMode,ToolTip,Screen
Clip2 := SubStr(ClipPaste, 1, 100) "`n"SubStr(ClipPaste, 101, 100)"`n"SubStr(ClipPaste, 201, 100)"`n"SubStr(ClipPaste, 301, 100)"`n"SubStr(ClipPaste, 401, 100) 
Clip2 := RegExReplace(Clip2, "`n`n","") 

Clip4 := SubStr(ClipPaste2, 1, 100) "`n" SubStr(ClipPaste2, 201, 100) "`n" SubStr(ClipPaste2, 301, 100) "`n" SubStr(ClipPaste2, 401, 100) "`n" SubStr(ClipPaste2, 501, 100) 
Clip4 := RegExReplace(Clip4, "`n`n","") 
ToolTip, % "#" index_Clip " (" StrLen(ClipPaste)"): `n‾‾‾‾‾‾‾‾‾‾`n" Clip2 "`n_________________________________________ `n‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ `n#" index_Clip2 " (" StrLen(ClipPaste2) "): `n‾‾‾‾‾‾‾‾‾‾`n" Clip4 "`n ̢" ,500, 330 

index_Clip+=2 
}
KeyWait, Space 
return 
return


^Space:: Gosub, Show_Clips_All 

Show_Clips_All: 
AutoTrim, On 
Clips1 := "#0 (" StrLen(clipboard)"): `n" SubStr(Clipboard, 1, 50) "`n______________________`n" "#1 (" StrLen(ClipOld)"): `n" SubStr(ClipOld1, 1, 50) "`n______________________`n" "#2 (" StrLen(ClipOld2)"): `n" SubStr(ClipOld2, 1, 50)"`n______________________`n" "#3 (" StrLen(ClipOld3)"): `n" SubStr(ClipOld3, 1, 50)"`n______________________`n" "#4 (" StrLen(ClipOld4)"): `n" SubStr(ClipOld4, 1, 50)"`n______________________`n" "#5 (" StrLen(ClipOld5)"): `n" SubStr(ClipOld5, 1, 50) 
Clips2 := "#6 (" StrLen(ClipOld6)"): `n" SubStr(ClipOld6, 1, 50) "`n______________________`n" "#7 (" StrLen(ClipOld7)"): `n" SubStr(ClipOld7, 1, 100) "`n______________________`n" "#8 (" StrLen(ClipOld8)"): `n" SubStr(ClipOld8, 1, 50)"`n______________________`n" "#9 (" StrLen(ClipOld9)"): `n" SubStr(ClipOld9, 1, 50)"`n______________________`n" "#10 (" StrLen(ClipOld10)"): `n" SubStr(ClipOld10, 1, 50) 
CoordMode,ToolTip,Screen
ToolTip %Clips1%`n______________________`n%Clips2%,500, 200 
;Sleep 3000
loop {
Sleep 3000
If !MouseIsOver("ahk_class tooltips_class32") 
break
}
ToolTip 
return




MouseIsOver(WinTitle) {
MouseGetPos,,, Win
return WinExist(WinTitle . " ahk_id " . Win)
}
It works with Spartan.
But it works only from the first line.
And if you use it to combine with another script, then it does not work.

Code: Select all

q::
Send [sound:video/
Send p ; Old Clipboard script
return

Return to “Ask For Help”

Who is online

Users browsing this forum: chngrcn, Google [Bot], Odlanir and 49 guests