Skip to content

Instantly share code, notes, and snippets.

@JoeGlines
Last active September 12, 2021 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoeGlines/e9bd56ecb8f954030b6bd88e7a65026a to your computer and use it in GitHub Desktop.
Save JoeGlines/e9bd56ecb8f954030b6bd88e7a65026a to your computer and use it in GitHub Desktop.
Put items in a format for in-list query
;*******************************************************
; Want a clear path for learning AutoHotkey; Take a look at our AutoHotkey Udemy courses. They're structured in a way to make learning AHK EASY
; Right now you can get a coupon code here: https://the-Automator.com/Learn
;*******************************************************
;~ #Include <default_Settings>
#SingleInstance,Force
;***********save clipboard to retore later*******************
Store:=ClipboardAll ;Store full version of Clipboard
clipboard = ; Empty the clipboard
SendInput, ^c ;changd from Send 11/23
ClipWait, 1
If ErrorLevel { ;Added errorLevel checking
MsgBox, No text was sent to clipboard
Return
}
;***********remove blank lines*******************
Loop,parse,Clipboard,`n`r ;loops through lines
{
New:=RegExReplace(A_LoopField,"^\s?$","") ;if line only has white space
If (new!="")
NewText.=new "`r`n"
}
Clipboard:=NewText
NewText:=""
;***********clean up the text*******************
Trimmed:=RegExReplace(clipboard, "m)^\s?(.*)\s?$","$1") ;trim spaces from both sides
;***********************wrap special characthers********************************.
StringReplace, Trimmed, Trimmed, &amp;, '||'&amp;'||',All ;wrap commas
StringReplace, Trimmed, Trimmed, ', '',All ; double up ' so it escapes it
;***********************Create groups of 999********************************.
Loop,
{
NewStr := RegExReplace(Trimmed, "`r`n", "','",1,998,1) ;998 is max
AddBreak := RegExReplace(NewStr, "`r`n", "`n`r*****************" . (A_Index*1000)+1 . "*****************`r",1,1,1)
If (AddBreak=NewStr) ;check to see if done looping through all items
break
Trimmed:=AddBreak ;
}
Clipboard := RegExReplace(NewStr, "','$", "") ; Delete ending ','
;***********restore clipboard*******************
SendEvent , ^v
Sleep, 50
Clipboard:=Store
;***********wipe out vars of <strong> SQL in list</strong>*******************
New:="" , newstr:="" , newText:="" , Trimmed:="" , Addbreak:="" ; Empty vars
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment