Mikeyww, I don't want to waste your time, so I will call Microsoft support and HP support to see if it is a Windows or HP issue.
But briefly, here are the answers to your questions:
"Are you asking a question about Microsoft Windows, a question about an AutoHotkey script, a question about AutoHotkey, or none of these?
I thought I was asking a question about an AutoHotKey script. But after months more testing, I think it is a Windows or HP problem, since I've determined that - most of the time - the Windows clipboard has stopped working when I'm experiencing these problems.
"What does "AHK scripts won't run" mean? "
Many of my scripts loop through files, and store information (such as the file path) into clipboard and then into a variable, which is used later in the script. When this issue arises (around 3 times a day), the ahk scripts post the following error message: "Error: SetClipboardData".
Then my ahk scripts which use the clipboard won't work (and even my built in Windows clipboard often doesn't work) until I do one or more - sometimes
all - of the following things: (1) reboot my computer, (2) defrag my hard drive, (3) clean my registry, (4) clear the windows clipboard, or (5) run windows diagnostic commands like run cmd.exe /c dism.exe /online /cleanup-image /restorehealth,,show and run cmd.exe /c sfc /scannow,,show
But OCCASSIONALLY, the issue will resolve itself - and the clipboard and ahk scripts which rely on the clipboard will start working again - even if I don't do anything.
"What actually happens?"
Please see previous answer.
"What is the script that will not run?"
Around 30 of my scripts won't run when this happens. Here is one example, for a script to search through my Outlook emails (I'VE INDICATED WHERE IT BREAKS):
Code: Select all
#SingleInstance Force
SetTitleMatchMode, 2
If A_IsAdmin && !RegExMatch(DllCall("GetCommandLine", "str"), " /restart(?!\S)") {
Try Run "%A_AhkPath%" /restart "%A_ScriptFullPath%"
ExitApp
}
Process, Priority, , Realtime
SetTimer, ForceExitApp, 240000
lst := ""
Attachments := ""
From := ""
To := ""
cc := ""
Subject := ""
Loop, files, C:\Clients\*, R
If !InStr(A_LoopFileDir, "\Closed") & !InStr(A_LoopFileDir, "\Potential") & (A_LoopFileName = "Clip Box.txt")
{
FileReadLine, var, % A_LoopFileFullPath, 2
lst .= var "|"
}
sort, lst, D|
Gui, Font, s10
Gui, Add, Text, xm w70, Client:
Gui, Add, DropDownList, x+m w250 r100 vVarX, % lst
Gui, Add, Text, xm w70, Subject
Gui, Add, ComboBox, x+m w250 vMySubject, ClientShortestName|MatterShort|MatterLong
Gui, Add, Text, xm w70, Attachments:
Gui, Add, DropDownList, x+m w246 vMyAttachment,|hasattachments:yes
Gui, Add, Text, xm w70, From:
Gui, Add, ComboBox, x+m w250 vMyFrom, Client|OC
Gui, Add, Text, xm w70, To:
Gui, Add, ComboBox, x+m w250 vMyTo, Client|OC
Gui, Add, Text, xm w70, cc:
Gui, Add, ComboBox, x+m w250 vMycc, Client|OC
Gui, Add, Text, xm w70, Free Form:
Gui, Add, Edit, x+m w250 vFreeFormSubjectVar
Gui, Add, Text, xm w70,
Gui, Add, Text, xm w70, Date Range
Gui, Add, DropDownList, x+m w250 vDateRange, |On Date|Before Date|After Date|Between Dates
Gui, Add, MonthCal, vStartDate
Gui, Add, MonthCal, vEndDate
Gui, Add, Text, xm w70,
Gui, Add, Button, x+m w250, Done
Gui, Show,, Client?
Return
ButtonDone:
Gui, Submit, Hide
FormatTime, StartDate, %StartDate%, M/d/yyyy
FormatTime, EndDate, %EndDate%, M/d/yyyy
Sleep, 1000
FileRead, Contents, C:\Clients\%VarX%\Client and Party Info\Clip Box.txt
Sleep, 1000
Clipboard:= Contents ; HERE IS WHERE THE SCRIPT BREAKS AROUND 3 TIMES A DAY AND THROWS AN ERROR MESSAGE. THE SCRIPT WON'T START WORKING AGAIN UNTIL I GO THROUGH THE WHOLE SONG AND DANCE MENTIONED ABOVE.
Sleep, 100
Var1 := % StrSplit(clipboard,"`r").1
Var2 := % StrSplit(clipboard,"`r").2
Var3 := % StrSplit(clipboard,"`r").3
Var8 := % StrSplit(clipboard,"`r").8
Var10 := % StrSplit(clipboard,"`r").10
Var11 := % StrSplit(clipboard,"`r").11
Var14 := % StrSplit(clipboard,"`r").14
if (MyFrom = "Client")
{
RealFrom = From:%Var8%
}
if (MyFrom = "OC")
{
RealFrom = From:%Var14%
}
if !(MyFrom = "OC") & !(MyFrom = "Client") & !(MyFrom = "")
{
RealFrom = From:%MyFrom%
}
if (MyTo = "Client")
{
RealTo = To:%Var8%
}
if (MyTo = "OC")
{
RealTo = To:%Var14%
}
if !(MyTo = "OC") & !(MyTo = "Client") & !(MyTo = "")
{
RealTo = To:%MyTo%
}
if (Mycc = "Client")
{
Realcc = cc:%Var8%
}
if (Mycc = "OC")
{
Realcc = cc:%Var14%
}
if !(Mycc = "OC") & !(Mycc = "Client") & !(Mycc = "")
{
Realcc = cc:%Mycc%
}
if (MySubject = "ClientShortestName")
{
RealSubject = subject:%Var1%
}
if (MySubject = "MatterShort")
{
RealSubject = subject:%Var10%
}
if (MySubject = "MatterLong")
{
RealSubject = subject:%Var11%
}
if !(MySubject = "ClientShortestName") & !(MySubject = "MatterShort") & !(MySubject = "MatterLong") & !(MySubject = "")
{
RealSubject = subject:%MySubject%
}
if (DateRange = "On Date")
{
RealDateRange = Received:%StartDate%
}
if (DateRange = "Before Date")
{
RealDateRange = Received:<%StartDate%
}
if (DateRange = "After Date")
{
RealDateRange = Received:>%StartDate%
}
if (DateRange = "Between Dates")
{
RealDateRange = Received:%StartDate%..%EndDate%
}
FreeFormSubjectVar := RegExReplace(FreeFormSubjectVar,"\.? *(\n|\r)+","")
MyAttachment := RegExReplace(MyAttachment,"\.? *(\n|\r)+","")
RealFrom := RegExReplace(RealFrom,"\.? *(\n|\r)+","")
RealTo := RegExReplace(RealTo,"\.? *(\n|\r)+","")
Realcc := RegExReplace(Realcc,"\.? *(\n|\r)+","")
RealSubject := RegExReplace(RealSubject,"\.? *(\n|\r)+","")
Gui, Submit, Hide
if !(RealFrom="")
{
RealFrom = AND (%RealFrom%)
}
if !(RealTo="")
{
RealTo = AND (%RealTo%)
}
if !(Realcc="")
{
Realcc = AND (%Realcc%)
}
service := "WSearch"
RunWait % "sc.exe CONFIG " service " start=auto",, Hide
RunWait % "sc.exe CONFIG " service " start",, Hide
RunWait % "sc.exe START " service,, Hide
RunWait % "sc.exe CONTINUE " service,, Hide
IfWinExist ahk_exe OUTLOOK.EXE
WinActivate, Outlook ahk_class rctrl_renwnd32
else
run, "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE"
WinWait ahk_exe OUTLOOK.EXE
WinActivate, Outlook ahk_class rctrl_renwnd32
WinWaitActive ahk_exe OUTLOOK.EXE
Sleep, 1000
SendInput, !q
Sleep, 900
SendInput, ^a
Sleep, 500
Send {Backspace}
Sleep, 500
clipboard = %FreeFormSubjectVar%%RealSubject% %RealFrom%%RealTo%%Realcc% %MyAttachment%%RealStartDate%%RealDateRange%
SendInput, %FreeFormSubjectVar%%RealSubject% %RealFrom%%RealTo%%Realcc% %MyAttachment%%RealStartDate%%RealDateRange%
Return
ForceExitApp:
SetTimer, ForceExitApp, Off
ExitApp