Skip to content

Commit

Permalink
Adding ClipBoard History WorkAround For File Renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Condon committed Nov 6, 2023
1 parent 543acdb commit 78a1f4b
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 26 deletions.
10 changes: 0 additions & 10 deletions .vscode/settings.json

This file was deleted.

13 changes: 13 additions & 0 deletions KPC/Clipboard/Rename Selected OC File From Clipboard History
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#PS
$OCPath = (Get-Process OneCommander).Path
if ($OCPath.Contains('WindowsApp')) {
$ParseOCPath = (Join-Path $Env:USERPROFILE '\OneCommander\')
}
elseif ($OCPath.Contains('Program Files')) {
$ParseOCPath = (Join-Path $Env:LOCALAPPDATA '\OneCommander\')
}
else {
$ParseOCPath = (Get-Item -LiteralPath $OCPath).Directory.FullName
}
& (Join-Path $ParseOCPath 'Resources\KPC\Set-OCVariables.ps1') -CurrentDir $CurrentDir -SelMultiple $SelectedFiles -OpDir $OpDir
& pwsh -File (Join-Path $ParseOCPath 'Resources\KPC\Invoke-PasteFromClipBoardHistory.ps1')
File renamed without changes.
4 changes: 2 additions & 2 deletions OC/Copy-SelFileOrDirToDroid.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ $PushButton.Location = New-Object System.Drawing.Size(200,500)
$MainForm.Controls.Add($PushButton)

$Global:PushTheFiles = ""
if ($OCVars.MultiSelection -ne "") {
if ($OCVars.SelectedFiles -ne "") {
$Global:PushTheFiles = {
$OCVars.MultiSelection | ForEach-Object {
$OCVars.SelectedFiles | ForEach-Object {
& $adbPath -s $InputTextBox.SelectedItem push $_ ("/sdcard/" + $InputTextBox2.SelectedItem)
}
$MainForm.Close()
Expand Down
Binary file removed OC/Export/ClipHist.clixml
Binary file not shown.
Binary file removed OC/Export/ClipHist.xml
Binary file not shown.
10 changes: 3 additions & 7 deletions OC/Get-CurrentClipboardHistory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ $asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | Where-O
function Await($WinRtTask, $ResultType) {
$asTask = $asTaskGeneric.MakeGenericMethod($ResultType)
$netTask = $asTask.Invoke($null, @($WinRtTask))
$netTask.GetAwaiter().GetResult() | Out-Null
$netTask.Wait(-1) | Out-Null
$netTask.Result
}
$null = [Windows.ApplicationModel.DataTransfer.Clipboard, Windows.ApplicationModel.DataTransfer, ContentType = WindowsRuntime]
$op = [Windows.ApplicationModel.DataTransfer.Clipboard]::GetHistoryItemsAsync()

$ClipHistResultsRaw = Await ($op) ([Windows.ApplicationModel.DataTransfer.ClipboardHistoryItemsResult])

try {
$ClipHistResults = $ClipHistResultsRaw.Items.Content.GetTextAsync()
$CLipHistResults = $ClipHistResultsRaw.Items.Content.GetTextAsync()
$ClipHistList = foreach ($ClipItem in $ClipHistResults) { Await($ClipItem) ([String]) }
}
catch {
Write-Host "Non Text On Clipboard History"
}
$ClipHistList | Export-Clixml -Path "$PSScriptRoot\Export\ClipHist.xml" -Force
2 changes: 1 addition & 1 deletion OC/Get-FileHashMD5ToClipboard.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$OCVars = Import-Clixml -Path ($PSScriptRoot + "\Export\Vars.xml")
$SelectedFiles = $OCVars.MultiSelection
$SelectedFiles = $OCVars.SelectedFiles
$SelectedFiles | ForEach-Object -Process {
$SelFileMD5Hash = Get-FileHash -LiteralPath $_ -Algorithm MD5
$SplitPathLeaf = Split-Path -Path $_ -Leaf
Expand Down
2 changes: 1 addition & 1 deletion OC/Get-PasteBinLinkOfFiles.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ $mainForm.ShowDialog()

$OCVars = Import-Clixml -Path ($PSScriptRoot + "\Export\Vars.xml")
$CurrentDir = $OCVars.CurrentDir
$SelectedFiles = $OCVars.MultiSelection
$SelectedFiles = $OCVars.SelectedFiles
$FilesInCurDir = Get-ChildItem -Path $CurrentDir -File -Force
$FilesNames = $FilesInCurDir.Name -join "`n"
if($SelectedFiles -ne ""){
Expand Down
2 changes: 0 additions & 2 deletions OC/Invoke-OCInit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ else {
Add-Content -Path $PROFILE -Value $RawProfileParsed
}
}
$VarHash = @{}
$VarHash | Export-Clixml -Path "$Path\Vars.xml"
48 changes: 48 additions & 0 deletions OC/Invoke-PasteFromClipBoardHistory.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Add-Type -AssemblyName System.Windows.Forms
Add-type -AssemblyName System.Drawing
powershell.exe -NoProfile -File "$PSScriptRoot\Get-CurrentClipBoardHistory.ps1"
$ClipHistList = Import-Clixml -Path "$PSScriptRoot\Export\ClipHist.xml"
$OCVars = Import-Clixml -Path "$PSScriptRoot\Export\Vars.xml"
$SelectedFile = $OCVars.SelectedFiles
$ClipHistForm = New-Object System.Windows.Forms.Form
$ClipHistForm.AutoSize = $true
$ClipHistForm.StartPosition = "CenterScreen"
$ClipHistForm.Margin = 50

$ListBox = New-Object System.Windows.Forms.ListBox
$ListBox.Size = New-Object System.Drawing.Size(800,800)
foreach ($ClipItem in $ClipHistList) {
if ($null -ne $ClipItem -and $ClipItem -ne "") {
if ($ClipItem.Length -gt 800) {
$ListBox.Items.Add(("$($ClipItem.Substring(0,100))" + "..."))
}
else {
$ListBox.Items.Add($ClipItem)
}
}
}

$PasteButton = New-Object System.Windows.Forms.Button
$PasteButton.Text = "Paste!"
$PasteButton.Size = New-Object System.Drawing.Size(100,50)
$PasteButton.Location= New-Object System.Drawing.Size(300,900)
$PBSB = {
$SelectedClipHistItem = $ListBox.SelectedItem.ToString()
$OCSP = Start-Process -PassThru -FilePath (Get-Command OneCommander).Path -ArgumentList "-filePath $SelectedFile"
$OCPID = $OCSP.MainWindowHandle
$wshell = New-Object -ComObject wscript.shell;
$wshell.AppActivate("$OCPID")
Start-Sleep 1
$wshell.SendKeys("{F2}")
Start-Sleep 1
$wshell.SendKeys("$SelectedClipHistItem")
$ClipHistForm.Close()

}
$PasteButton.Add_Click($PBSB)


$ClipHistForm.Controls.Add($ListBox)
$ClipHistForm.Controls.Add($PasteButton)

$ClipHistForm.ShowDialog()
2 changes: 1 addition & 1 deletion OC/Merge-Directories.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Add-Type -AssemblyName System.Drawing

$OCVars = Import-Clixml -Path (Join-Path $PSScriptRoot "\Export\Vars.xml")
$CurDir = $OCVars.CurrentDir
$OpDir = $OCVars.OppositeDir
$OpDir = $OCVars.OpDir

$FolderPathDialog = New-Object System.Windows.Forms.FolderBrowserDialog
$FolderPathDialog.Description = "Choose A Destination Path To Merge Both Panes Into"
Expand Down
4 changes: 2 additions & 2 deletions OC/Set-OCVariables.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ $SelMultList = ($SelMultiple -split "\r?\n")

$OCVarHash = @{
CurrentDir = $CurrentDir
MultiSelection = $SelMultList
OppositeDir = $OpDir
SelectedFiles = $SelMultList
OpDir = $OpDir
}
$OCVarHash | Export-Clixml -Path "$PSScriptRoot\Export\Vars.xml" -Force

1 change: 1 addition & 0 deletions debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[1106/134306.819:ERROR:registration_protocol_win.cc(107)] CreateFile: The system cannot find the file specified. (0x2)

0 comments on commit 78a1f4b

Please sign in to comment.