diff --git a/native/libwinbridge/bridge.cpp b/native/libwinbridge/bridge.cpp
index f83e26b..0621a5a 100644
--- a/native/libwinbridge/bridge.cpp
+++ b/native/libwinbridge/bridge.cpp
@@ -524,6 +524,31 @@ void trigger_paste() {
SendInput(vec.size(), vec.data(), sizeof(INPUT));
}
+void trigger_copy() {
+ std::vector vec;
+
+ INPUT input = { 0 };
+
+ input.type = INPUT_KEYBOARD;
+ input.ki.wScan = 0;
+ input.ki.time = 0;
+ input.ki.dwExtraInfo = 0;
+ input.ki.wVk = VK_CONTROL;
+ input.ki.dwFlags = 0; // 0 for key press
+ vec.push_back(input);
+
+ input.ki.wVk = 0x43; // C KEY
+ vec.push_back(input);
+
+ input.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release
+ vec.push_back(input);
+
+ input.ki.wVk = VK_CONTROL;
+ vec.push_back(input);
+
+ SendInput(vec.size(), vec.data(), sizeof(INPUT));
+}
+
// SYSTEM
@@ -699,3 +724,4 @@ int32_t set_clipboard_image(wchar_t *path) {
return result;
}
+
diff --git a/native/libwinbridge/bridge.h b/native/libwinbridge/bridge.h
index 77fa4d4..a5f1d89 100644
--- a/native/libwinbridge/bridge.h
+++ b/native/libwinbridge/bridge.h
@@ -79,6 +79,11 @@ extern "C" void delete_string(int32_t count);
*/
extern "C" void trigger_paste();
+/*
+ * Send the copy keyboard shortcut (CTRL+C)
+ */
+extern "C" void trigger_copy();
+
// Detect current application commands
/*
diff --git a/src/bridge/windows.rs b/src/bridge/windows.rs
index ff916fa..f7a4459 100644
--- a/src/bridge/windows.rs
+++ b/src/bridge/windows.rs
@@ -59,4 +59,5 @@ extern {
pub fn send_multi_vkey(vk: i32, count: i32);
pub fn delete_string(count: i32);
pub fn trigger_paste();
+ pub fn trigger_copy();
}
\ No newline at end of file
diff --git a/src/extension/script.rs b/src/extension/script.rs
index 554fdf5..16bd0ce 100644
--- a/src/extension/script.rs
+++ b/src/extension/script.rs
@@ -62,6 +62,7 @@ impl super::Extension for ScriptExtension {
.output()
};
+ println!("{:?}", output);
match output {
Ok(output) => {
let output_str = String::from_utf8_lossy(output.stdout.as_slice());
@@ -86,6 +87,7 @@ mod tests {
use crate::extension::Extension;
#[test]
+ #[cfg(not(target_os = "windows"))]
fn test_script_basic() {
let mut params = Mapping::new();
params.insert(Value::from("args"), Value::from(vec!["echo", "hello world"]));
@@ -94,15 +96,11 @@ mod tests {
let output = extension.calculate(¶ms, &vec![]);
assert!(output.is_some());
-
- if cfg!(target_os = "windows") {
- assert_eq!(output.unwrap(), "hello world\r\n");
- }else{
- assert_eq!(output.unwrap(), "hello world\n");
- }
+ assert_eq!(output.unwrap(), "hello world\n");
}
#[test]
+ #[cfg(not(target_os = "windows"))]
fn test_script_inject_args_off() {
let mut params = Mapping::new();
params.insert(Value::from("args"), Value::from(vec!["echo", "hello world"]));
@@ -111,15 +109,11 @@ mod tests {
let output = extension.calculate(¶ms, &vec!["jon".to_owned()]);
assert!(output.is_some());
-
- if cfg!(target_os = "windows") {
- assert_eq!(output.unwrap(), "hello world\r\n");
- }else{
- assert_eq!(output.unwrap(), "hello world\n");
- }
+ assert_eq!(output.unwrap(), "hello world\n");
}
#[test]
+ #[cfg(not(target_os = "windows"))]
fn test_script_inject_args_on() {
let mut params = Mapping::new();
params.insert(Value::from("args"), Value::from(vec!["echo", "hello world"]));
@@ -129,11 +123,6 @@ mod tests {
let output = extension.calculate(¶ms, &vec!["jon".to_owned()]);
assert!(output.is_some());
-
- if cfg!(target_os = "windows") {
- assert_eq!(output.unwrap(), "hello world jon\r\n");
- }else{
- assert_eq!(output.unwrap(), "hello world jon\n");
- }
+ assert_eq!(output.unwrap(), "hello world jon\n");
}
}
\ No newline at end of file
diff --git a/src/extension/shell.rs b/src/extension/shell.rs
index f8e014a..8ad9798 100644
--- a/src/extension/shell.rs
+++ b/src/extension/shell.rs
@@ -24,7 +24,7 @@ use regex::{Regex, Captures};
lazy_static! {
static ref POS_ARG_REGEX: Regex = if cfg!(target_os = "windows") {
- Regex::new("\\%(?P\\d+)").unwrap()
+ Regex::new("%(?P\\d+)").unwrap()
}else{
Regex::new("\\$(?P\\d+)").unwrap()
};
diff --git a/src/keyboard/windows.rs b/src/keyboard/windows.rs
index c4e110b..c7ee10a 100644
--- a/src/keyboard/windows.rs
+++ b/src/keyboard/windows.rs
@@ -73,4 +73,10 @@ impl super::KeyboardManager for WindowsKeyboardManager {
send_multi_vkey(0x25, count)
}
}
+
+ fn trigger_copy(&self) {
+ unsafe {
+ trigger_copy();
+ }
+ }
}
\ No newline at end of file