Should work
This commit is contained in:
@@ -1,20 +1,27 @@
|
|||||||
#region Header
|
#region Header
|
||||||
|
|
||||||
|
$Version = "1.0.0"
|
||||||
|
|
||||||
#Dependencies
|
#Dependencies
|
||||||
[Reflection.Assembly]::LoadWithPartialName("System.Windows/Forms") | Out-Null
|
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
|
||||||
Add-Type -AssemblyName System.Windows.Forms
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
Add-Type -AssemblyName PresentationFramework
|
Add-Type -AssemblyName PresentationFramework
|
||||||
|
|
||||||
|
|
||||||
#Hide Console Window
|
#Hide Console Window
|
||||||
Add-Type -Name Window -Namespace Console -MemberDefinition '
|
Add-Type -Name Window -Namespace Console -MemberDefinition '
|
||||||
[DllImport("Kernal32.dll")]
|
[DllImport("Kernel32.dll")]
|
||||||
public static extern IntPtr GetConsoleWindow();
|
public static extern IntPtr GetConsoleWindow();
|
||||||
|
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
|
public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
|
||||||
'
|
'
|
||||||
|
|
||||||
|
$consolePtr = [Console.Window]::GetConsoleWindow()
|
||||||
|
[Console.Window]::ShowWindow($consolePtr, 0) > $null
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Talking across runspaces
|
#Talking across runspaces
|
||||||
$Sync = [Hashtable]::Synchronized(@{})
|
$Sync = [Hashtable]::Synchronized(@{})
|
||||||
|
|
||||||
@@ -28,28 +35,16 @@
|
|||||||
$script = [Powershell]::Create().AddScript({
|
$script = [Powershell]::Create().AddScript({
|
||||||
Param ($Keys)
|
Param ($Keys)
|
||||||
|
|
||||||
$sleep = ".5"
|
while($sync["x"] -eq 1){
|
||||||
while($X -eq $null){
|
$keys = $keys -split ","
|
||||||
sleep $sleep
|
Foreach ($key in $keys){
|
||||||
[System.Windows.Forms.SendKeys]::SendWait("{4}")
|
Start-Sleep -Milliseconds 500
|
||||||
sleep $sleep
|
[System.Windows.Forms.SendKeys]::SendWait("{$key}")
|
||||||
[System.Windows.Forms.SendKeys]::SendWait("{3}")
|
}
|
||||||
sleep $sleep
|
|
||||||
[System.Windows.Forms.SendKeys]::SendWait("{2}")
|
|
||||||
sleep $sleep
|
|
||||||
[System.Windows.Forms.SendKeys]::SendWait("{3}")
|
|
||||||
sleep $sleep
|
|
||||||
[System.Windows.Forms.SendKeys]::SendWait("{1}")
|
|
||||||
sleep $sleep
|
|
||||||
[System.Windows.Forms.SendKeys]::SendWait("{3}")
|
|
||||||
sleep $sleep
|
|
||||||
[System.Windows.Forms.SendKeys]::SendWait("{5}")
|
|
||||||
sleep $sleep
|
|
||||||
[System.Windows.Forms.SendKeys]::SendWait("{3}")
|
|
||||||
}
|
}
|
||||||
}).AddArgument($Keys)
|
}).AddArgument($Keys)
|
||||||
|
|
||||||
$runsapce = [RunspaceFactory]::CreateRunspace()
|
$runspace = [RunspaceFactory]::CreateRunspace()
|
||||||
$runspace.ApartmentState = "STA"
|
$runspace.ApartmentState = "STA"
|
||||||
$runspace.Threadoptions = "ReuseThread"
|
$runspace.Threadoptions = "ReuseThread"
|
||||||
$runspace.open()
|
$runspace.open()
|
||||||
@@ -65,12 +60,42 @@
|
|||||||
#region Form
|
#region Form
|
||||||
|
|
||||||
$form = New-Object System.Windows.Forms.Form
|
$form = New-Object System.Windows.Forms.Form
|
||||||
$form.text = "Keypresser"
|
$form.text = "Keypresser Version $Version"
|
||||||
$Form.Size = "500,500"
|
$Form.Size = "450,110"
|
||||||
|
$Form.FormBorderStyle = 'FixedDialog'
|
||||||
|
$form.TopMost = $True
|
||||||
$Form.Add_FormClosing({Get-Process -id $pid | Stop-Process})
|
$Form.Add_FormClosing({Get-Process -id $pid | Stop-Process})
|
||||||
|
|
||||||
|
$KeysLabel = New-Object 'System.Windows.Forms.Label'
|
||||||
|
$KeysLabel.text = "Enter in the keys you wish to be pressed seperated by a comma `",`""
|
||||||
|
$KeysLabel.Width = '425'
|
||||||
|
$KeysLabel.Location = New-Object System.Drawing.Point(5,5)
|
||||||
|
$form.controls.add($KeysLabel)
|
||||||
|
|
||||||
|
$KeysTextBox = New-Object 'System.Windows.Forms.TextBox'
|
||||||
|
$KeysTextBox.Location = New-Object System.Drawing.Point(5,25)
|
||||||
|
$KeysTextBox.Width = '425'
|
||||||
|
$form.controls.add($KeysTextBox)
|
||||||
|
|
||||||
|
$KeysButton = New-Object 'System.Windows.Forms.Button'
|
||||||
|
$KeysButton.Location = New-Object System.Drawing.Point(5,45)
|
||||||
|
$KeysButton.text = "Start"
|
||||||
|
$KeysButton.add_click({
|
||||||
|
|
||||||
|
if ($KeysButton.text -ne "Stop"){
|
||||||
|
$KeysButton.text = "Stop"
|
||||||
|
$sync["x"] = 1
|
||||||
|
$Keys = $KeysTextBox.text
|
||||||
|
Keypress $Keys
|
||||||
|
}
|
||||||
|
Else{
|
||||||
|
$KeysButton.text = "Start"
|
||||||
|
$sync["x"] = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
$form.controls.add($KeysButton)
|
||||||
|
|
||||||
#endregion Form
|
#endregion Form
|
||||||
|
|
||||||
|
[Windows.Forms.Application]::Run($form)
|
||||||
Reference in New Issue
Block a user