topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Monday November 10, 2025, 9:33 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Recent Posts

Pages: prev1 ... 15 16 17 18 19 [20] 21 22 23 24 25 ... 225next
476
Changed it a little w.r.t. what's regarded as an App.
477
Post New Requests Here / Re: "IDEA" : Key Press to Replace R-Clik Navigation
« Last post by 4wd on April 03, 2019, 04:25 AM »
Shift + F10 ?

On some laptops it's sometimes the Fn + Right Control keys, (on my Dell anyway), some keyboard also use the right Windows key, (if they have one).

Or do you want a hot-key to replace the combined action: Context menu->WinAmp->Execute
478
Highly recommend what Shades said above, invest in a decent file manager.

Doing it a little differently:

2019-04-02 17_46_04.png

Put the shortcut in C:\Users\<user>\AppData\Roaming\Microsoft\Windows\SendTo, edit its Properties to point to wherever you've put the script.

Edit the path to the script:
Code: Text [Select]
  1. C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\PoSh\MoveMovies.ps1"


  • Right-click on the folder with the movies (MP4, MKV, FLV, AVI) -> Send To -> MoveMovies
  • Select the destination folder
  • Enter the gigabyte value of files to move

Hitting Cancel at any requester will exit, as will running out of space, or entering a GB value out of range.

It only checks the available space on the destination once before moving files so if you happen to copy other things to the destination that reduce the expected space then the Move-Item will fail and an error will popup, (in theory).

There's also a popup when it's finished and if you enter a number out of range.

That's about it for error checking, (hey, it's a 100% improvement over my usual error checking routines).

NOTE: Windows doesn't allow Send To on root directories so it won't work for them.  Could always add a couple of lines to call the function to ask for a Source directory instead of having it passed via Send To ... an exercise for the user.

Code: PowerShell [Select]
  1. <#
  2.   MoveMovies.ps1
  3. #>
  4. param (
  5.   [string]$source
  6. )
  7.  
  8. Add-Type -AssemblyName System.Windows.Forms
  9.  
  10. Function Get-Folder {
  11.   $objForm = New-Object System.Windows.Forms.FolderBrowserDialog
  12.   $objForm.Description = "Select destination folder"
  13.   $objForm.SelectedPath = [System.Environment+SpecialFolder]'MyComputer'
  14.   $objForm.ShowNewFolderButton = $false
  15.   $result = $objForm.ShowDialog()
  16.   if ($result -eq "OK") {
  17.     return $objForm.SelectedPath
  18.   } else {
  19.     return $null
  20.   }
  21. }
  22.  
  23. Function Get-MoveSize {
  24.   param (
  25.     [int]$max
  26.   )
  27.   [void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
  28.  
  29.   $title = 'Move Movies'
  30.   $msg = "Total GBs of files to move [1-$($max)]: "
  31.  
  32.   $text = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)
  33.   return (($text/1) * 1Gb)
  34. }
  35.  
  36. Function Send-Notification {
  37. # https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/windows-scripting/x83z1d9f(v=vs.84)
  38.   param (
  39.     [string]$msg,
  40.     [int]$type
  41.   )
  42.   $wshell = New-Object -ComObject Wscript.Shell -ErrorAction Stop
  43.   $wshell.Popup($msg, 0, "MoveMovies", $type) | Out-Null
  44. }
  45.  
  46.  
  47. $dest = (Get-Folder)
  48. if ($dest -ne $null) {
  49.   # Get disk volume label
  50.   $dDrive = ($dest | Split-Path -Qualifier)
  51.   # Get disk free space, round down to nearest whole number
  52.   $dFree = [math]::Round((gwmi Win32_LogicalDisk -Filter "DeviceID='$($dDrive)'").FreeSpace / 1Gb)
  53. } else {
  54.   break
  55. }
  56.  
  57. $moveSize = (Get-MoveSize $dFree)
  58. if (($moveSize -lt 1) -or ($moveSize -gt ($dFree * 1Gb))) {
  59.   Send-Notification "Input outside acceptable range!" 16
  60.   break
  61. }
  62.  
  63. Write-Host $dest $moveSize $dDrive ($dFree * 1Gb)
  64.  
  65. # Get list of videos in source directory
  66. $videos = (Get-ChildItem "$($source)\*" -Include *.mp4,*.mkv,*.flv,*.avi | Sort Name)
  67. for ($i = 0; $i -lt $videos.Count; $i++) {
  68.   if ($videos[$i].Length -lt $moveSize) {
  69.     Move-Item -LiteralPath "$($videos[$i].FullName)" -Destination "$($dest)"
  70.     if ($?) {
  71.       $moveSize -= $videos[$i].Length
  72.     } else {
  73.       Send-Notification "Moving file failed!" 16
  74.       break
  75.     }
  76.   } else {
  77.     Send-Notification "Maximum number of files moved into space available/allowed" 64
  78.     break
  79.   }
  80. }
479
General Software Discussion / Re: Windows 10 Announced
« Last post by 4wd on April 02, 2019, 03:58 AM »
"Prevents others from tampering with important security features."

By others they probably mean anyone who isn't Microsoft themselves and that switch is just there as a placebo effect.
480
To get the script to work on my PC I had to do these things
- the multi line comments at the top gave errors, but changing /* and */ to <# and #> fixed that.

Ooops, my bad, I added the comment after pasting into the post ... should've tested it.
I've updated the code/archive.
 
- run the cmd window as administrator
- add the Bypass argument, like so

Wasn't necessary if run from a PowerShell console, even just right-click on the script and choose Run with Powershell but you'd bump up against the ExecutionPolicy restriction - which does get to be a real PITA sometimes.  In theory you can right-click->Properties and select something like Trust this file under the Security tab ... but I haven't seen it for awhile so I may be mis-remembering.

Shouldn't need Admin privileges since you're only writing to a directory that the user owns anyway ... just tried it here, no Admin required, just had to answer '(Y)es' to the ExecutionPolicy question that pops up.

The same task can also be created manually (and deleted if no longer needed) through the Task Scheduler (win+I and search for "schedule tasks").
Not a very end-user friendly way to set this up though.

Perhaps this post which shows setting/deleting a scheduled task in Powershell may help?

Give the task a static name and have the script just check if it's there at each run using schtasks /query <taskname>, implement if it isn't and have an optional argument to the script Apps2Shortcut.ps1 -Remove to remove it if the task is no longer required.
481
Simple Powershell script, it'll create an "Installed-Apps" folder on the Desktop and populate it with shortcuts for installed ... err ... apps.

For this purpose it regards any AUMID that contains a ! and doesn't end in .exe as a valid app - as distinct from every program installed.

Run it from a Powershell console using: .\Apps2Shortcut.ps1

For some reason I couldn't get it to run from a shortcut but that's probably my fault.

You will probably get an error if you run the extracted script from the archive due to Execution Policy, there are 3 solutions:
  • Copy/Paste the script below as a new script
  • Mark the script as trusted, (it has a zone identifier in its ADS which marks it as not from the local machine)
  • Change your Execution Policy using Set-ExecutionPolicy

Standard Disclaimer: Works for me  :)

Code: PowerShell [Select]
  1. <#
  2.   Apps2Shortcut.ps1
  3. #>
  4. Function Create-Shortcut {
  5.   param (
  6.     [string]$name,
  7.     [string]$aumid
  8.   )
  9.   # Create a Shortcut with Windows PowerShell
  10.   $WScriptShell = New-Object -ComObject WScript.Shell
  11.   $Shortcut = $WScriptShell.CreateShortcut($name)
  12.   $Shortcut.TargetPath = "$env:SystemRoot\explorer.exe"
  13.   $Shortcut.Arguments = "shell:Appsfolder\$($aumid)"
  14.   $Shortcut.Save()
  15. }
  16.  
  17. $DesktopPath = [Environment]::GetFolderPath("Desktop")
  18.  
  19. if (!(Test-Path "$($DesktopPath)\Installed-Apps")) {
  20.   New-Item "$($DesktopPath)\Installed-Apps" -ItemType Directory | Out-Null
  21. }
  22.  
  23. $apps = (Get-StartApps)
  24. for ($i = 0; $i -lt $apps.Count; $i++) {
  25.   if (($apps[$i].AppID).contains("!") -and (($apps[$i].AppID).Substring(($apps[$i].AppID).Length - 4) -ne '.exe')) {
  26.     Create-Shortcut "$($DesktopPath)\Installed-Apps\$($apps[$i].Name).lnk" $apps[$i].AppID
  27.   }
  28. }

Hopefully you'll end up with something like this:

2019-04-01 10_38_59.png

To run a Powershell command from AHK you'll probably need to use: powershell.exe -C "Get-StartApps | Out-File D:\test.txt"

Use -C to run commands directly, -F to run a script.
482
General Software Discussion / Re: Listing the unused
« Last post by 4wd on March 30, 2019, 06:57 AM »
List files sorted by Last Access time:

Code: Text [Select]
  1. dir <file spec> /s /od /ta

eg. List all MP3 files on D:\

Code: Text [Select]
  1. d:
  2. cd \
  3. dir *.mp3 /s /od /ta
483
General Software Discussion / Re: youtube downloader?
« Last post by 4wd on March 30, 2019, 06:52 AM »
SlimJet browser and hit the download button.
tnx. free?

Yep

https://www.slimjet.com/
It works! Tnx!
I need a YT banner ad blocker now. =)

SlimJet is based on Chrome sourcecode so try Video Adblocker for Youtube
484
Living Room / Re: Share your photos! Travel shots, photoblogs, etc.
« Last post by 4wd on March 24, 2019, 05:11 AM »
Sunny but bloody cold.
PANO_20190324_094617.jpg
IMG_20190324_092433221_HDR.jpg
485
Living Room / Re: Share your photos! Travel shots, photoblogs, etc.
« Last post by 4wd on March 22, 2019, 01:30 PM »
Brexit got delayed...also...Are you up near Whitby?
-Stephen66515 (March 22, 2019, 12:49 PM)

Yep ... on both counts.

At Staithes for 6 months.
IMG_20170607_130310.jpg
486
Living Room / Re: Share your photos! Travel shots, photoblogs, etc.
« Last post by 4wd on March 22, 2019, 12:39 AM »
IMG_20190321_182747949.jpg

Greetings from the UK, it's Brexit -7 days (+/- nobody knows and probably no longer cares).

Which leads to:
IMG_20190321_175757498.jpg
487
Doesn't Moto have a transfer app?

Not for at least 2 years, out of interest I went looking when I got my G5+

Google's backup of apps/settings is hit or miss, sometimes it works, sometimes it doesn't, sometimes you can't even enable it - which I can't even though It has worked on my current phone previously.

The only 100% working method I've found is unlock the bootloader, install TWRP, root it using Magisk or something else, and then install Titanium Backup + Root - something I've done with every Android device I've ever bought.
488
General Software Discussion / Re: youtube downloader?
« Last post by 4wd on March 19, 2019, 10:09 PM »
SlimJet browser and hit the download button.
tnx. free?

Yep

https://www.slimjet.com/
489
General Software Discussion / Re: youtube downloader?
« Last post by 4wd on March 18, 2019, 01:34 PM »
SlimJet browser and hit the download button.
490
Just need to test for the existence of the output file:

Code: PowerShell [Select]
  1. if (!(Test-Path $outFile)) {
  2. ...
  3. }

Added, try it now, (haven't tested it but it should work).
491
Many thanks again to 4wd for the great help. ;)

Thanks, edited my OP, now does the lot, (.html, .htm, .mht).

Updated
492
I don't know if this is possible but it would be great if the Powershell could exclude converting htm and html files that are smaller than 3ko ?

You already have the answer, same idea as deleting the small PDFs.

Code: PowerShell [Select]
  1. $aFiles = (Get-ChildItem -Include *.html,*.htm -Path ($srcFolder + "*") -Recurse | Where-Object {$_.Length -gt 3kb} )

As for Chrome, I couldn't get it to work from PowerShell either, I'll have another look when I have time.

But you do have the args wrong, should be:
Code: PowerShell [Select]
  1. $args = "`"$($infile)`" --headless --print-to-pdf=`"$($outFile)`""

Just the arguments for the command.

Could try adding a working directory also:

Code: PowerShell [Select]
  1. Start-Process -FilePath "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -Wait -NoNewWindow -ArgumentList $args -WorkingDirectory "C:\Program Files (x86)\Google\Chrome\Application"
493
Added *.htm to the Get-ChildItem filter so no need to edit and run separately, (not tested but works in other scripts - just remove it if there's a problem).

As for .mht, you could use PowerShell to pass them through the IE core to output as PDF ... so goes the theory.

Alternatively, convert to HTML first then run the script, interesting blog post: http://raywoodcocksl...-html-mht-files.html
494
Something quick in PowerShell using wkhtmltopdf, (put the executable in the same directory as the script), and Chrome.

Recursively converts .html, .htm, and .mht to PDF files.

Btw, if it looks familiar, 90% came from here.


Run it from a PoSh console or use a shortcut with the following as the Target, (assuming shortcut in the same folder as the script):
Code: Text [Select]
  1. %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -sta -NoProfile -ExecutionPolicy Bypass -File "CTP.ps1"

CTP.ps1
Code: PowerShell [Select]
  1. <#
  2.   CTP.ps1
  3.  
  4.   Convert .htm(l) and .mht to PDF
  5. #>
  6.  
  7. Function Get-Folder {
  8.   Add-Type -AssemblyName System.Windows.Forms
  9.   $FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
  10.   [void]$FolderBrowser.ShowDialog()
  11.   $temp = $FolderBrowser.SelectedPath
  12.   If($temp -eq '') {Exit}
  13.   Return $temp
  14. }  
  15.  
  16. If($PSVersionTable.PSVersion.Major -lt 3) {
  17.   Write-Host '** Script requires at least Powershell V3 **'
  18. } else {
  19.   Write-Host 'Choose input folder: ' -NoNewline -BackgroundColor DarkGreen -ForegroundColor White
  20.   $srcFolder = (Get-Folder)
  21.   Write-Host $srcFolder
  22.   Write-Host 'Choose output folder: ' -NoNewline -BackgroundColor DarkGreen -ForegroundColor White
  23.   Do {$dstFolder = (Get-Folder)} While($dstFolder -eq $srcFolder)
  24.   Write-Host $dstFolder
  25.  
  26.   # PowerShell doesn't care how many stacked '\' there are in a path, multiples will always be seen as one
  27.   # ie. C:\\\\Windows = C:\Windows
  28.   # Means you can just add to the path without worrying about the trailing character
  29.   # Collect all files bigger than 3kB
  30.   $aFiles = (Get-ChildItem -Include *.html,*.htm,*.mht -Path ($srcFolder + "\*") -Recurse | Where-Object {$_.Length -gt 3kb} )
  31.   for($i = 0; $i -lt $aFiles.Count; $i++) {
  32.     $inFile = [string]$aFiles[$i]
  33. # Substitute destination folder for source folder and tack .pdf on the end
  34. # Could probably replace the extension instead ... but laziness and all that
  35.     $outFile = $dstFolder + $inFile.Replace($srcFolder, "") + '.pdf'
  36. # If output file doesn't exist then process
  37.     if (!(Test-Path $outFile)) {
  38. # Grab the parent of the output file, create the folder structure if it doesn't exist
  39.       $temp = Split-Path $outFile -Parent
  40.       if (!(Test-Path $temp)) {
  41.         New-Item $temp -ItemType Directory | Out-Null
  42.       }
  43.  
  44.       Write-Host 'File:' $inFile -BackgroundColor DarkBlue -ForegroundColor Yellow
  45. # Switch command based on the last 3 characters of the file name, anything that isn't 'mht' gets processed
  46. # as htm(l)
  47.       switch ($inFile.Substring([Math]::Max($inFile.Length - 3, 0))) {
  48.         mht {
  49.           $args = "`"$($inFile)`" --headless --print-to-pdf=`"$($outFile)`""
  50.           Start-Process -FilePath "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -Wait -NoNewWindow -ArgumentList $args
  51.           }
  52.         default {
  53.           $args = "-p 127.0.0.1 -q `"$($inFile)`" `"$($outFile)`""
  54.           Start-Process -FilePath ".\wkhtmltopdf.exe" -Wait -NoNewWindow -ArgumentList $args
  55.           }
  56.       }
  57.     }
  58.   }
  59. }
  60. Write-Host ''
  61. Write-Host 'Close window to exit ...'
  62. cmd /c pause | out-null
495
Living Room / Re: Looking for "Smart"watch Recommendations
« Last post by 4wd on March 06, 2019, 11:40 PM »
Jokes aside, now I gotta go research the bip 2 and see if I need to wait for it or not.

Not really much concrete info available atm just hearsay, speculation, rumours, and wish lists.  The pre-order page that was up is no longer accessible but the specs it had were similar to the BIP1 with the exceptions:
  • 5ATM Water Resistance
  • No Barometric sensor
  • A little narrower

But I'd wait until it appeared on Amazfit's website before taking those as gospel.
496
Living Room / Re: Looking for "Smart"watch Recommendations
« Last post by 4wd on March 06, 2019, 06:19 PM »
Just a couple of notes on the BIP:

  • For the basic stuff nothing other than the supplied app is required, (Mi Fit), so it's fine for Notifications, Step Counter, Heart Rate, Sleep Analysis, etc, etc.
  • The BIP2 is soon to be available, (was available for pre-order for a short time) - 5ATM Water Resistance, slightly narrower, loses the Barometric sensor, albeit at a higher price - but it may prompt sales on the BIP1.

I think Apple has the best Smart Watch.

I'm looking for a smartwatch that won't murder my bank, has good battery life, and that will let me view my [Android] phone's notifications without having to take it out of my pocket.

0 out of 3 ain't that bad ... I guess.
497
Living Room / Re: How to calculate the area of a graph?
« Last post by 4wd on March 06, 2019, 03:42 PM »
http://www.mathwords...ea_under_a_curve.htm

Bearing in mind it's been 40+ years since I had to stare cross-eyed at this stuff I would have thought that since the graph was seemingly created using sampled data rather than a formula that you would have had to use the age old method of slicing and dicing the area into trapezoids, calculating their area, and then adding them together?

Or given the data you could probably just stick it into Excel and have it do it.
498
Found Deals and Discounts / Re: [FREE] Packt Book of the Day
« Last post by 4wd on March 05, 2019, 01:08 AM »
It seems Packt's free learning has had some changes this year.

Now there are free videos instead of just eBooks. :Thmbsup:
But more importantly, now it seems you don't get free downloadable eBooks anymore. You only get HTML access to the books. :down: :'(

Any code examples are still downloadable but I've kind of stopped looking since having to read a book online is a P.I.T.A.

They do have a mobile app though that allows offline reading ... might look at that at some point, (but pretty useless unless I invest in a new tablet with Android 4.4+).
499
Living Room / Re: Is there any compact portable browser?
« Last post by 4wd on March 04, 2019, 07:57 AM »
@Curt: Didn't install it at all: extract to Ram drive, open CLI, execute it, browse web.
500
NOTE: If you already get more than 20GB month DO NOT input the code, it's likely you will be reduced to 20GB/month.

Currently you can get 20GB/month on free accounts at Windscribe with the following code: EXPAND20

To get 20GB you need to sign up and add a verified email address, (which will get you 10GB), then input the voucher code to increase it to 20GB.
Pages: prev1 ... 15 16 17 18 19 [20] 21 22 23 24 25 ... 225next