Scripting Languages

28K

Solutions

21K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have the below powershell script that I'm reading a file, then creating new files and appending a +1 on the end of.  At the beginning of the script, I'm clearing all of the files in the parent directory with a wildcard - but I don't want to do this.  I have another routine that will cleanup the files as they are cycled through.

Basically I'm trying to create a file, starting with comptuerlist1, but only if comptuerlist1 doesn't exist, then the next available number.

Any help is appreciated.


# Split inputlist.txt into blocks of 5
$linecount = 0 
$filenumber = 1 
# 13 over +1 into variable...
$sourcefilename = "c:\script\source\computerlist.txt"
$destinationfolderpath = "c:\Script\"
$destinationfilesize = "5"
$maxsize = [int]$destinationfilesize  

Remove-Item -path $destinationfolderpath\computerlist*  # remove, put in win10qa without wildcard.

Get-Content $sourcefilename | Measure-Object | ForEach-Object { $sourcelinecount = $_.Count } 

$content = get-content $sourcefilename | % { 
 Add-Content $destinationfolderpath\computerlist$filenumber.txt "$_" 
  $linecount ++ 
  If ($linecount -eq $maxsize) { 
    $filenumber++ 
    $linecount = 0 
  } 
} 
 
Clear-Content $sourcefilename

Open in new window

0
Hello experts,

I have in my AutoHotkey/Hotstring file multiple hotstrings that sendinput date.

I would like to convey them into a single hotstring and modulate them through a GUI.

The idea is the following:

 20200218_042035.png
Could you please help me to:

Set up the process behind to sendinput based on the selection.
I attached current version.

Thank you for your help.
DatesGui.ahk
1
Script to list logons on a specific domain controller, which the user actually logged onto that domain controller. Trying to look up examples and I just keep finding ways to find a specific user, I want all of the logons for the past X hours, of any user.
1
I would like to position this notification found in this script to show up at specific coordinates on the desktop.

What do I need to change in order to do this?

@echo off
mode 40,6
color 3f
setlocal
set /a Interval = 5
set /a Seconds = 0
:Loop

@echo off
cls
echo ****************************************
echo ****************************************
echo ****      PROCESS RUNNING       ****
echo ****************************************
echo **** Processing DATA.           ****
echo ****************************************
ping localhost -n 2 >nul

cls
0
Dear expert

Please help with the script below:

$test1 = 0

$test2 = 0

$CultureDateTimeFormat = (Get-Culture).DateTimeFormat

$DateFormat = $CultureDateTimeFormat.ShortDatePattern

$TimeFormat = $CultureDateTimeFormat.LongTimePattern

$DateTimeFormat = "$DateFormat $TimeFormat"

$DateTimeStart = [DateTime]::ParseExact("2020-02-17 17:10:03",$DateTimeFormat,[System.Globalization.DateTimeFormatInfo]::InvariantInfo,[System.Globalization.DateTimeStyles]::None)

$dateTimeStop = [DateTime]::ParseExact("2020-02-17 22:30:03",$DateTimeFormat,[System.Globalization.DateTimeFormatInfo]::InvariantInfo,[System.Globalization.DateTimeStyles]::None)

 

$task_1 = Get-ScheduledTask -TaskName *system* | where state -eq Ready | Get-ScheduledTaskInfo | where-object {$_.nextruntime -gt $datetimeStart -and $task_handel.nextruntime -lt $datetimeStop}

$task_2 = Get-ScheduledTask -TaskName *MSN* | where state -eq Ready | Get-ScheduledTaskInfo | where-object {$_.nextruntime -gt $datetimeStart -and $task_handel.nextruntime -lt $datetimeStop}

Open in new window


This script is under development so ignore the $test1 and 2. What I basicly need for now is to show the nextruntime of get-scheduledtask between the time in variables: $dateTimeStart and $dateTimeStop.  right now it shows all the task.... I guess problem is in the where-object {$_.nextruntime -gt $datetimeStart -and $task_handel.nextruntime -lt $datetimeStop}

Please help with this thanks.
0
Hello experts,

The following AutoHotkey script allows me to list files and folders based on folder reported.

;====================================
;Gui: list files and folders attributes
;====================================

^+f::
Gui,Add,Text,xm,Select folder for file listing:
Gui,Add,Edit,vFolderPath w400
Gui,Add,Text,,Select folders to process:
Gui,Add,Radio,Checked vRecurse,&Recurse
Gui,Add,Radio,x+10,&NoRecurse
Gui,Add,Text,xm,Select information to put in file listing:
Gui,Add,Radio,Checked vFileInfo,&Filename (without path)
Gui,Add,Radio,x+10,Filename with &Path
Gui,Add,Button,xm gButtonOKFilesFoldersListing Default,&OK
Gui,Add,Button,x+10 gButtonCancelFilesFoldersListing,&Cancel
Gui,Show,,File Listing
Return

ButtonOKFilesFoldersListing:
Gui,Submit
If (SubStr(FolderPath,0,1)!="\")
  FolderPath:=FolderPath . "\"
FormatTime,CurrentDateTimeFilesFolders,,yyyyMM
TempFile:=FolderPath . CurrentDateTimeFilesFolders . "_listing.txt"
FileList:=""
If (Recurse=1)
{
		LoopMode:="FDR"
}
Else
{
		LoopMode:="FD"
}
FileList:=""
Loop,Files,%FolderPath%*.*,%LoopMode%
{
  If (FileInfo=1)
		{
    FileList:=FileList . A_LoopFileName . "`n"
  }
		Else
		{
    FileList:=FileList . A_LoopFileFullPath . "`n"
		}
}
Msgbox,,,LoopMode:%LoopMode% `nFileInfo:%FileInfo%
Clipboard:=FileList
ClipWait,2 ; wait for information to appear on clipboard
If (ErrorLevel=1)
{
		MsgBox,4144,Error,No text appearing after 2 seconds
		Return
}
Sort,FileList
FileDelete,%TempFile%

Open in new window

1
Hello experts,
I am trying to set up a file listing through an AutoHotkey GUI.
Here are the requirements:
Through a GUI report folder path in which will be generated the file.
List files in a new file and open it.
The final need is to add the following new features:
-File name and file full path differentiation
-Immediate and recurse differentiation
I am quite sure that the best approach for this is radio. However prior to propose something I would like to know:-
-If code structure is ok or should I review it.
-What is the best option to create the 2*2 differentiation.
Functions with switch case?
The differentiation is based on the:
Loop, Files, %FolderPath%\*.*, FD, R ; for recurse, blank for immediate
FileList = %FileList%% A_LoopFileName %`n; for file name
FileList = %FileList%% A_LoopFileFullPath %`n; for file full path

I am aware that I need to do some file tuning and add the controls. However I will do it following your recommendations.

I attached my initial version.

Thank you for your help.
AppendFilesList.ahk
1
I have an interesting situation. I have a URL that returns data based on a 'search' parameter within the URL.. example: dvd_search.php?type=title&search='SomeData'

The Website has different areas that can be searched. Each are is accessed by 'clicking' a button (link) that takes you to that particular Page. From there you can query for data that is related to that Page/category.

The interesting part of this that the actual resulting URL looks the same no matter which page you are on... except it will only return data that is apropos to the page you are on.

I am trying to automate the Query process from within a VB.Net program and I am trying to use CURL to get the data into a file that I can parse.

I am not at all versed in the  use of CURL but I do know that this can probably be dome in CURL if I could figure out the proper syntax that would perform the desired function..

I am guessing here but I am assuming that the key to making this work is the 'Cookie' that is being generated, probably indicates which page 'I' am on and which 'Data Set' to use.

Any help is greatly appreitated.

Thanks in advance
Rick
0
Hello experts,

I would like to have your advice and feedback on the feasibility to have an AutoHotkey script in order to define a go to/go to previous action based on reported string. The idea is the following:
Through an GUI report the string involved by the go to/go to previous action.
20200213_165815.pngOnce I click on one of the go to buttons the cursor should be move to the string reported if it exists.
I am aware that this feature is already available in most of the text editing applications such as word however as far as I know the feature doesn't propose the move cursor as go to line cursor works.

Thank you in advance for your advice.

Regards,
Luis.
0
I would like to within a .bat file open a .gif file so that it displays for perhaps 5 seconds and then exits.
how can this be incorporated into a .bat script?
0
Hi Guys

I'm using Python 3.8.1 and below is a script I use

import glob
import numpy as np # for numerical operations
from moviepy.editor import VideoFileClip, concatenate

clip = VideoFileClip (print(glob.glob("*.mp4")))
cut = lambda i: clip.audio.subclip(i,i+1).to_soundarray(fps=22000) 
volume = lambda array: np.sqrt(((1.0*array)**2).mean())
volumes = [volume(cut(i)) for i in range(0,int(clip.audio.duration-2))]
averaged_volumes = np.array([sum(volumes[i:i+10])/10
                             for i in range(len(volumes)-10)])

increases = np.diff(averaged_volumes)[:-1]>=0
decreases = np.diff(averaged_volumes)[1:]<=0
peaks_times = (increases * decreases).nonzero()[0]
peaks_vols = averaged_volumes[peaks_times]
peaks_times = peaks_times[peaks_vols>np.percentile(peaks_vols,90)]

final_times=[peaks_times[0]]
for t in peaks_times:
    if (t - final_times[-1]) < 60:
        if averaged_volumes[t] > averaged_volumes[final_times[-1]]:
            final_times[-1] = t
    else:
        final_times.append(t)

final = concatenate([clip.subclip(max(t-5,0),min(t+5, clip.duration))
                     for t in final_times])
final.to_videofile('iFLY - Cut.mp4') # low quality is the default

Open in new window


When I run the script, I get an error, see below

['movie.mp4']
Traceback (most recent call last):
  File "C:\Highlights\soccer_cuts.py", line 16, in <module>
    clip = VideoFileClip (print(glob.glob("*.mp4")))
  File "C:\Python38\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 88, in __init__
    self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
  File "C:\Python38\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 32, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
  File "C:\Python38\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 245, in ffmpeg_parse_infos
    is_GIF = filename.endswith('.gif')
AttributeError: 'NoneType' object has no attribute 'endswith'

Open in new window


Looking through the error I found line 16 to be the issue

clip = VideoFileClip (print(glob.glob("*.mp4")))

Open in new window


What I'm trying to do with line 16 is set a variable, the file name movie may be called movie1 or movie 2 though there will always be just the 1 mp4 file within the folder called Highlights. I'm hoping you can assist me with this.

Any help is greatly appreciated.
0
Hello experts,

I am trying to find a mechanism through AutoHotkey=>Gui to repeat reported text based on iterations.
Here is my attempt:

Gui, Add, Text,,Text to iterate:
Gui, Add, Text,, Number of iterations:
Gui, Add, Edit, vTextReported ym  ; The ym option starts a new column of controls.
Gui, Add, Edit, vIterationsReported
Gui,Add,Button,xm gButtonOKEx Default,&OK
Gui,Add,Button,x+10 gButtonCancelEx,&Cancel
Gui, Show,, Iterate text
Return

ButtonOKEx:
Gui, Submit
Loop, Parse, TextReported, `n, `r
{
	TextReported2:=A_LoopField . "`n"
}
TextReported3:=RepeatText(TextReported2, IterationsReported)
MsgBox,,,%TextReported3%
Clipboard:=TextReported3
ClipWait,2 ; wait for information to appear on clipboard
If (ErrorLevel=1)
{
	MsgBox,4144,Error,Information did not appear on clipboard after two seconds
	Return
}
ButtonCancelEx:
Gui,Destroy
Return

;====================================
;Function used to repeat string
;====================================

RepeatText(string,times)
{
	loop %times%
		output .= string
		return output
}

Open in new window


Could you please provide some advice on the following:
1.Is there a better approach to repeat text? If so could you please help me to set up a function
2.Controls to set up can be related to text reported. If TextReported="" return? and if IterationReported is not numeric return? For the second I need a check through var is type as reported at:
here
or another approach is better?
3.I would like to modulate the repeat action with two options, repeat text at the same line or in a new line ie : TextReported2:=A_LoopField . "`n" to have text repeat in another line or through TextReported2:=A_LoopField .  A_Space to have it in the same line. Gui Radio is the best option to cover this need?
4.If you have some advice on the AutoHotkey structure reported above, please let me know.

Thank you in advance for your help.

Regards,
Luis.
1
Hi Guys

I have a python script that takes a video file called video.mp4 and cuts it down based on sound activity. See below. The python script is saved as PythonVideo.py in directory C:\Users\user\Desktop\Video

import numpy as np # for numerical operations
from moviepy.editor import VideoFileClip, concatenate

clip = VideoFileClip("video.mp4")
cut = lambda i: clip.audio.subclip(i,i+1).to_soundarray(fps=22000) 
volume = lambda array: np.sqrt(((1.0*array)**2).mean())
volumes = [volume(cut(i)) for i in range(0,int(clip.duration-1))]

increases = np.diff(averaged_volumes)[:-1]>=0
decreases = np.diff(averaged_volumes)[1:]<=0
peaks_times = (increases * decreases).nonzero()[0]
peaks_vols = averaged_volumes[peaks_times]
peaks_times = peaks_times[peaks_vols>np.percentile(peaks_vols,90)]

final_times=[peaks_times[0]]
for t in peaks_times:
    if (t - final_times[-1]) < 60:
        if averaged_volumes[t] > averaged_volumes[final_times[-1]]:
            final_times[-1] = t
    else:
        final_times.append(t)

final = concatenate([clip.subclip(max(t-5,0),min(t+5, clip.duration))
                     for t in final_times])
final.to_videofile('video1.mp4') # low quality is the default 

Open in new window


The issue here is when I run PythonVideo.py I get lines of error, see below. Is there something wrong I'm doing here? The python version I'm using 3.6.6

Traceback (most recent call last):
  File "C:\Users\user\Desktop\Video\PythonVideo.py", line 7, in <module>
    volumes = 

Open in new window

0
Hi Experts,

I'm trying to build in some error handling to tie the script below together and am stuck, any help with this is appreciated.

Issue:  for any computers that are offline, I'm getting RPC unabilable errors and these continue to process through the loop

Here is what I'm trying to accomplish:

1.  For error handling, is there a way to have a function determine whether the computer is up or not >  then return $true or $false and put into a condition for if.  If it's not up, is there a way to pause until it responds or break out of the loop for just that computer?  If it's up, then do patching/install functions in the workflow.

2.  In the process-monitor function (6) - I wanted to log into the .csv if this was online or offline.

3. I wanted to incorporate a function that checks for any missing or pending updates to determine if the workflow needs to be processed. (I left (2) empty for this), not sure how to accomplish this and then condition.  Here are the queries:

get-wmiobject -query "SELECT * FROM CCM_SoftwareUpdate WHERE ComplianceState = 0" -namespace "ROOT\ccm\ClientSDK"  #which updates are missing:

Open in new window


(get-wmiobject -query "SELECT * FROM CCM_SoftwareUpdate" -namespace "ROOT\ccm\ClientSDK").name  #show needed updates

Open in new window


-Then if the above are true, trigger all, which I have in (5):

([wmiclass]'ROOT\ccm\ClientSDK:CCM_SoftwareUpdatesManager').InstallUpdates([System.Management.ManagementObject[]] (get-wmiobject -query 'SELECT * FROM CCM_SoftwareUpdate' -namespace 'ROOT\ccm\ClientSDK'))

Open in new window


Here is what the script does, I've numbered all functions in order:
1 - Test-Connection
2 - detect missing/pending
3 - detect pending reboot
4 - run advert
5 - invoke all updates
6 - process monitor
6a - call from within process monitor function to send email

Thanks!


Open in new window

0
Hello experts,

I set up the following AutoHotkey script in order to retain or remove lines from a clipboard based on string reported in the GUI.

+^r::
AddTextEditWidth:=400
Gui,Add,Text
Gui,Add,Text,xm,Which operation to you want to performed?
Gui,Add,Radio,Checked vWhichOp xm,Retain
Gui,Add,Radio,x+20,Remove
Gui,Add,Text
Gui,Add,Text,xm,Enter the string related to retain or remove operation (or click Cancel not to add text):
Gui,Add,Edit,vAddTextRetainRemove xm w%AddTextEditWidth%
Gui,Add,Text
Gui,Add,Button,xm gButtonAddTextRetainRemoveOK Default,&OK
Gui,Add,Button,x+10 gButtonAddTextRetainRemoveCancel,&Cancel
Gui,Show,,Add text
Return

ButtonAddTextRetainRemoveOK:
Gui,Submit
Gui,Destroy
Send, ^c
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error,No text appeared on clipboard after initial Ctrl+c and waiting for one second
  Return
}
Else
ReferenceString:=AddTextRetainRemove
NewClipboardVar:=""
Loop,Parse,Clipboard,`n,`r
If (WhichOp=1) 
{
  If InStr(A_LoopField, ReferenceString)
    NewClipboardVar:=NewClipboardVar . A_LoopField . "`n"
}
Else
{
  If InStr(A_LoopField, ReferenceString)
    Continue
    NewClipboardVar:=NewClipboardVar . A_LoopField . "`n"
}
LastChar:=SubStr(NewClipboard,0,1) ; see if last char is CR or LF
If ((LastChar="`r") or (LastChar="`n"))
{
  StringTrimRight,NewClipboard,NewClipboard,1 ; last char is CR or LF - remove it
  LastChar:=SubStr(NewClipboard,0,1) ;  see if new last char is CR or LF
  If ((LastChar="`r") or (LastChar="`n")) ;
    

Open in new window

1
Hi Experts,

Looking for some expertise with this script.

Here is what the script does:

1) Reads from a text file with computer names and remotely runs a SCCM advertisement.

2) The advertisement opens some processes - which I have in a loop in this script.  

3) When the processes read 0 the loop is completed, then moves to the next command to RESTART the computer.

4) Is there any way to have this run 3 times, and then shutdown on the 3rd time?

$OutArray = @()
workflow foreachrerun {
    param([string[]]$computers)
    foreach –parallel ($computer in $computers) {
       InlineScript {
Function Start-CCMRerunAdvertisement {
    [CmdLetBinding()]Param(
        [Parameter(Mandatory=$true)][string]$computerName,
        [Parameter(Mandatory=$false)][string]$advertisementId = "*",
        [Parameter(Mandatory=$false)][string]$packageId = "*",
        [Parameter(Mandatory=$false)][int]$maxRun = 1
        #[Parameters(Mandatory=$false)][switch]$moreThanPing = $false
    )
    if($advertisementId -eq "*" -and $packageId -eq "*") {
        Write-Error "You must supply either an AdvertisementID or a PackageID"
        return "Missing Parameters"
        break
    }
    $searchString = "$advertisementId-$packageId-*" 
    if(!(Test-Connection -ComputerName $computername -ErrorAction SilentlyContinue)) {
        if($moreThanPing) { 
            if(!(Get-ChildItem "\\$computername\c$" -ErrorAction SilentlyContinue)) {
                Write-Error "System 

Open in new window

0
Have very large file that contains random number of lines (strings) between a pattern in the file for example INS. I need to capture all the lines starting with the patter "INS" up to before the next INS. Not sure if, Select-String, or ,Where-Object,  is the proper method. Not really sure where to start with this one.
0
Hello experts,

The following AutoHotkey allows me to add line number based on selection.

;====================================
;Add line numbers at the beginning of each line
;====================================
#If (!WinActive("ahk_exe excel.exe"))
^+l:: ; Ctrl+Shift+L - as always, make it whatever you want
SkipBlankLines:=True
MsgBox,4131,Do you want to number blank lines?,Press YES to number the blank lines`n`nPress NO not to number the blank lines`n`nPress CANCEL to exit/quit (not do any numbering)
IfMsgBox,Cancel
  Return
IfMsgBox,Yes
  SkipBlankLines:=False
Sleep, 50
Send, ^c
Sleep, 50
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error, No text appearing after one second
  Return
}
LineNum:=0
ClipboardVar:=Clipboard
UpdatedLines:=""
Loop,Parse,ClipboardVar,`n,`r
{
  If ((A_LoopField="") and (SkipBlankLines))
    LineNumOut:=""
  Else
  {
    LineNum:=LineNum+1
    LineNumOut:=LineNum . "."
  }
  UpdatedLines:=UpdatedLines . LineNumOut . A_LoopField . "`n"
}
LastChar:=SubStr(UpdatedLines,0,1) ; see if last char is CR or LF
If ((LastChar="`r") or (LastChar="`n"))
{
  StringTrimRight,UpdatedLines,UpdatedLines,1 ; last char is CR or LF - remove it
  LastChar:=SubStr(UpdatedLines,0,1) ;  see if new last char is CR or LF
  If ((LastChar="`r") or (LastChar="`n")) ;
    StringTrimRight,UpdatedLines,UpdatedLines,1 ; new last char is CR or LF - remove it
}
Clipboard:=UpdatedLines
Sleep, 50
Send, ^v
Return
#If

Open in new window


I would like to take as a reference to cover the following need:
1.Display a msgbox or a Gui with two options: 1 add string at the beginning 2 at the end
2.Display a second inputbox to report the string to add
3.Insert the string and replace the selection by revised text
Example:
1.I select the following text:
Text text
Text text
Text text
2.I Select 1 for adding text at the beginning
3.I enter the following string: 20200203_163112
4.The previous text will be replaced as following:
20200203_163112Text text
20200203_163112Text text
20200203_163112Text text

If you have questions, please contact me.

Thank you for your help.
0
Hi Guys

I'm trying to understand why the function "set nocount on" does not work in my MS SQL stored procedure script called [GetScore], see below

	declare @JSON		varchar	(max )
	declare @cmd		varchar	(100 )
	declare @cmd1		varchar	(8000)
	declare @deletefile varchar	(20	 )


	set @deletefile='LastScore.txt' 
	set @cmd= 'xp_cmdshell ''del "d:\Freak\' + @deletefile + '"''';
	set @cmd1 = ' ren d:\Freak\*.txt LastScore.txt'
	
        set nocount on
	exec master..xp_cmdshell @cmd1


	waitfor delay '00:00:01';

	select @JSON = BulkColumn from openrowset (bulk 'D:\Freak\LastScore.txt', single_clob) as j

	select * from openjson (@JSON) with 

	(
		LeaderboardName					varchar		(20)
	   ,LeaderboardNameFull				varchar		(20)
	   ,PlayerCount						varchar		(20)
	   ,PlayerName						varchar		(20)
	   ,Score							nvarchar	(20)
	   ,ZombiesKilled					varchar		(15)		'$.ScoreDetails.ZombiesKilled'
	   ,Accuracy						varchar		(50)		'$.ScoreDetails.Accuracy'
	   ,DamageTaken						varchar		(20)		'$.ScoreDetails.DamageTaken'
	   ,SecondsInLevel					varchar		(30)		'$.ScoreDetails.SecondsInLevel'
	   ,Deaths							varchar		(50)		'$.ScoreDetails.Deaths'
	)

	waitfor delay '00:00:01';

        set nocount on
	exec (@cmd)


	go

Open in new window


When I run the stored procedure [GetScore] I get 2 columns called Output, I don't know how to stop these columns from showing up in the result. I have attached a snip of the result after running the stored procedure, see below

Snip20200203_6.png
Any help is greatly appreciated
0
Dear expert

Code below is from my last request.

Now I am creating this again, due to I close the last one... because it took too long time stays as opened due to my flu...
The script below works, well only in html form, now I would like to make this works as well in outlook as html in mailform, well of course I didn't mention it in the pre question my bad.

The code:
      tr[Critical="True"]                  {background-color: orange;}
      td[BatchEndedOK="False"]      {background-color: red;}
      td[FileMissing="True"]            {background-color: red;}

browser seems understand it, however not in html for outlook mail. Is there a solution to it?

Thanks alot again.

$arr = @'
"Batchname",	"TimeStamp",			"BatchEndedOK",	"FileMissing"
"H60",			"2020-01-27 13:00:55",	"True",			"False"
"H61",			"2020-01-27 13:00:55",	"True",			"False"
"H52",			"2020-01-27 09:39:00",	"True",			"True"
"T60",			"2020-01-27 09:00:22",	"False",		"True"
"T60",			"2020-01-27 09:00:22",	"False",		"False"
'@ | ConvertFrom-Csv | % {$_.BatchEndedOK = $_.BatchEndedOK -eq 'True'; $_.FileMissing = $_.FileMissing -eq 'True'; $_}

$outFile = '.\BatchReport.html'
$title = 'Batch Report'
$htmlHead = @'
<style>
	body	{background-color:white;font-family:verdana;font-size:12px;}
	table	{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
	th		{border-width: 1px;padding: 0px;border-style: solid;border-color: black;padding:3px;background-color:#0dfc2d}
	td		{border-width: 1px;padding: 

Open in new window

0
Hello experts,

I have the following AutoHotkey to open my AutoHotkey file.

;====================================
;Open AutoHotkey file
;====================================
#If (!WinActive("ahk_exe excel.exe") or (!WinActive("ahk_exe SciTE.exe")))
+F2::
AhkFile:=A_ScriptFullPath
If (FileExist(SciTE1))
  Run, "%SciTE1%" "%AhkFile%"
Else
If (FileExist(SciTE2))
  Run, "%SciTE2%" "%AhkFile%"
Else
  MsgBox,4112,Error,Neither SciTE exists on your system.
Return
#If

Open in new window


I don't understand why the restriction is not applied when I launch the script from excel or SciTe.

The restriction works when I launch the AutoHotkey script from excel:

;====================================
;Open AutoHotkey file
;====================================
#If (!WinActive("ahk_exe excel.exe"))
+F2::
AhkFile:=A_ScriptFullPath
If (FileExist(SciTE1))
  Run, "%SciTE1%" "%AhkFile%"
Else
If (FileExist(SciTE2))
  Run, "%SciTE2%" "%AhkFile%"
Else
  MsgBox,4112,Error,Neither SciTE exists on your system.
Return
#If

Open in new window


Thank you for your help.
0
Hello Experts,

The following AutoHotkey function allows to select files attributes / components.
GetSelectedFile(hwnd:="",FileComponents:=1,GetDate:=1) {
; this function by sinkfaze: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=77#p395
  WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A")
  WinGetClass class, ahk_id %hwnd%
  if  (process = "explorer.exe")
    if  (class ~= "Progman|WorkerW") {
      ControlGet, files, List, Selected Col1, SysListView321, ahk_class %class%
      Loop, Parse, files, `n, `r
        ToReturn .= A_Desktop "\" A_LoopField "`n"
    }
    else  if (class ~= "(Cabinet|Explore)WClass") {
      for window in ComObjCreate("Shell.Application").Windows
        if  (window.hwnd==hwnd)
          sel :=  window.Document.SelectedItems
      for item in sel
      {
        FileFullPath:=item.path
        If (FileComponents=1)
          FileParts:=FileFullPath
        If (FileComponents=2)
          SplitPath,FileFullPath,,,,FileParts
        If (FileComponents=3)
          SplitPath,FileFullPath,FileParts
        If (GetDate>1)
        {
          ToReturn .= DateParse(item.ModifyDate) . A_Tab . FileParts . "`n"
          If (GetDate=2)
            Sort,ToReturn ; GetDate=2 --> modified date sorted ascending
          Else
            Sort,ToReturn,R ; GetDate=3 --> modified date sorted descending
        }
        else
          ToReturn .= FileParts "`n" ; GetDate=1 --> no date/sort
      }
    }
    return  

Open in new window

0
Hello experts,

The following AutoHotkey related to the article: https://www.experts-exchange.com/articles/29416 allows me to copy link to clipboard.

F5::
WinGetTitle,ActiveTitle,A ; get title of active window
IfInString,ActiveTitle,Mozilla Firefox ; check if active window is Firefox
 ShortcutKey:="a" ; send letter "a", Firefox shortcut for Copy Link Location
Else ; it is not Firefox
IfInString,ActiveTitle,Google Chrome ; check if active window is Chrome
 ShortcutKey:="e" ; send letter "e", Chrome shortcut for Copy Link Address
Else ; it is not Chrome
IfInString,ActiveTitle,Internet Explorer ; check if active window is IE
 ShortcutKey:="t{Enter}" ; send letter "t", IE shortcut for Copy Shortcut, but also needs Enter
Else ; it is not IE
IfInString,ActiveTitle,Opera ; check if active window is Opera
 ShortcutKey:="e" ; send letter "e", Opera shortcut for Copy Link Address
Else ; it is not Opera
{
 MsgBox,4112,Error,Active window is not a supported browser.
 Return ; 4112 above means put dialog on top and give it the red X (error/stop) icon
}
Clipboard:="" ; empty the clipboard
MouseClick,Right ; right-click at current mouse location
Sleep,60 ; wait for 60 milliseconds to make sure context menu is there
SendInput,%ShortcutKey% ; send shortcut to copy link
ClipWait,2 ; wait at most 2 seconds for short link to appear in clipboard
If (ErrorLevel=1) ; ErrorLevel set to 1 when wait period expires
{
 

Open in new window

0
Hello experts,

The following AutohotKey scripts allows me to copy files attributes based on selected files
;====================================
;Copy files attributes
;====================================

+F1::
Gui,Add,Radio,Checked vComponents xm,FileNoPathWithExt
Gui,Add,Radio,x+20,FileNoPathNoExt
Gui,Add,Radio,x+20,FileFullPath
Gui,Add,Button,xm Default,&OK
Gui,Add,Button,x+20,&Cancel
Gui,Show,,Copy to Clipboard
Return

ButtonOK:
Gui,Submit
Gui,Destroy
If (!WinActive("ahk_class CabinetWClass"))
{
  MsgBox,4144,Error,Active window is not Windows/File Explorer
  Return
}
AllFileComponents:=""
SelectedFiles:=GetSelectedFile("",False)
If (SelectedFiles="")
{
  MsgBox,4144,Error,No files are selected in Windows/File Explorer
  Return
}
Switch Components
{
  Case 1:
  Loop,Parse,SelectedFiles,`n,`r
  {
    FileFullPath:=A_LoopField
    SplitPath,FileFullPath,FileNoPathWithExt
    AllFileComponents:=AllFileComponents . FileNoPathWithExt . "`n"
  }
  Case 2:
  Loop,Parse,SelectedFiles,`n,`r
  {
    FileFullPath:=A_LoopField
    SplitPath,FileFullPath,,,,FileNoPathNoExt
    AllFileComponents:=AllFileComponents . FileNoPathNoExt . "`n"
  }
  Case 3:
  Loop,Parse,SelectedFiles,`n,`r
  {
    FileFullPath:=A_LoopField
    AllFileComponents:=AllFileComponents . FileFullPath . "`n"
  }
}
Clipboard:=AllFileComponents
ClipWait,2 ; wait for information to appear on clipboard
If (ErrorLevel=1)
  MsgBox,4144,Error,Information did not appear on clipboard after two seconds
Return

Open in new window

0
Hello experts,

The following AutoHotkey scripts allows me to remove extra lines and extra spaces:
;====================================
;Remove two consecutive extra lines
;====================================

^!Space::
Send ^c
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error,No text appeared on clipboard after initial Ctrl+c and waiting for one second
  Return
}
PreviousLineBlank:=False
NewClipboard:=""
Loop,Parse,Clipboard,`n,`r
{
  CurrentLine:=A_LoopField
  CurrentLineWithoutBlanks:=StrReplace(CurrentLine,A_Space) ; remove all spaces
  CurrentLineWithoutBlanks:=StrReplace(CurrentLineWithoutBlanks,A_Tab) ; remove all tabs
  If (CurrentLineWithoutBlanks="") ; see if current line is blank
  {
    If (PreviousLineBlank) ; current line is blank - see if previous one is
      Continue ; a consecutive blank line, so do not include it
    Else
    {
      NewClipboard:=NewClipboard . CurrentLine . "`n" ; not a consecutive blank line, so include it
      PreviousLineBlank:=True
    }
  }
  Else
  {
    NewClipboard:=NewClipboard . CurrentLine . "`n" ; current line is not blank, so include it
    PreviousLineBlank:=False
  }
}
LastChar:=SubStr(NewClipboard,0,1) ; see if last char is CR or LF
If ((LastChar="`r") or (LastChar="`n"))
{
  StringTrimRight,NewClipboard,NewClipboard,1 ; last char is CR or LF - remove it
  LastChar:=SubStr(NewClipboard,0,1) ;  see if new last char is CR or LF
  If ((LastChar="`r") or (LastChar="`n")) ;
    

Open in new window

0

Scripting Languages

28K

Solutions

21K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.