Many URLS in One Variable Breaks Script
Posted: 07 Jul 2019, 13:46
Greetings and thanks for your help! I find I cannot get Autohotkey to work with a long list of contiguous URL-text that does not contain any linebreaks at all. My proof of concept below works great but breaks when many URLS are placed in a block variable. The URLS are contiguous and have no line breaks at all: just one long string because that's what the FireFox Copy All Tabs addon yields. I'm trying to add line breaks to the URLS by replacing the string "mynewline," which is the only separator in my block of URL-text.
The errors I get as I try to work through this are:
1 Variable too long
2 This parameter contains a variable name missing its ending percent sign.
THANK YOU for your input!
The errors I get as I try to work through this are:
1 Variable too long
2 This parameter contains a variable name missing its ending percent sign.
THANK YOU for your input!
Code: Select all
; Replace String "MyNewLine" with Line Breaks `r`n
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance, Force
#InstallKeybdHook
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetTitleMatchMode, 2
;MsgBox %A_AhkPath%
;#include %A_AhkPath%\Lib\ScrollBox.ahk ; cannot use a variable to find ScrollBox.ahk in the Autohotkey.exe directory tree?
#include C:\Program Files\AutoHotkey\Lib\ScrollBox.ahk
;VarSetCapacity(user, 111110240000)
;Msgbox %user%
return
F4::
ReplaceStringWithLineBreaks:
TextToManipulate =
(
fat bunny
big bun
lonely bun
fat BOOOBOOOBOOOny
big BOOOBOOOBOOO
lonely BOOOBOOOBOOO
hellomynewlinehello
hellomynewlinehello
)
sleep 200
String1 = bun
String2 = mynewline
sleep 100
InputVar1 = %TextToManipulate%
;MsgBox % clipboard
;gosub LineBreakGui
StringReplace, OutPutVar1, InputVar1, %String1%,BOOOBOOOBOOO, All
sleep 200
StringReplace, OutPutVar2, OutPutVar1, %String2%,`r`n, All
sleep 200
;MsgBox % OutPutVar2
clipboard := OutPutVar2
gosub LineBreakGui
return
MyLinks2:
clipboard =
(
long url text goes here but breaks scripts many ways:
Variable too long
percent signs break script too
This parameter contains a variable name missing its ending percent sign.
)
goto MyLinks1
return
MyLinks1:
Gui, Submit
Gui, Destroy
YourNewLineString = "mynewline"
StringReplace, YourLineBreaksVar, clipboard, %YourNewLineString%,BOOOBOOOBOOO, All
sleep 200
;MsgBox % YourLineBreaksVar
clipboard := YourLineBreaksVar
ClipBoardContents := "Your LineBreaks Have Been Added and Clipboard now contains: `r`n" clipboard
sleep 200
ScrollBox(ClipBoardContents, "p w b1 f{s12 cBlack, Lucida Console} x5 y10 h700 w900")
MsgBox % clipboard
sleep 300
return
LineBreakGui:
Gui default
gui, font, s12, Verdana
Gui, Add, Picture, x0 y0 w610 h385 +0x4000000, ;%A_ScriptDir%\img\anon.png
Gui, Color, 000000
Gui, Font, cwhite
Gui, Add, Text, yp+40, `n To Replace all instances of MyNewLine with Line Breaks `n Hit the Big Button ! `n`n F4 key to re-open this window `n`n Esc key to exit
;~ Gui, Add, Text, yp+20, Enter Directory of Kontakt Library Below
;~ Gui, Add, Text, yp+20, WE FOUND an UNUSED Number below!
;~ Gui, Add, Text, xp+10 yp+44, k2lib0
Gui, Font, cblack
;Gui, Add, Edit, yp+40 vSomeVariableFive, %SomeTestLinksAndText%
gui, font, s24, Verdana
Gui, Font, cwhite
Gui, Add, Button, Default gMyLinks1, Proof of Concept Button
Gui, Add, Button, Default gMyLinks2, Too Many Contiguous URLS Button Will not Work?
Gui Show, , Window
Return
Esc::
Gui, Destroy
return
;======================= STANDARD AUTOHOTKEY FOOTER
RAlt::
IfWinActive, SciTE
{
sendinput ^s
sleep 300
}
IfWinExist, DebugView
{
;MsgBox hello
ControlSend, , ^x, DebugView
sleep 300
}
Reload
return
^Esc::
exitapp
return
BIGEXIT:
exit