RohesKätzchen
RohesKätzchen
CC#
Created by RohesKätzchen on 5/28/2024 in #help
✅ Need help with with Input Simulator
Hello im currently writing a programm and i need to simulate the scroll wheel/middleclick button action im using https://github.com/michaelnoonan/inputsimulator does anyone know what i have to do to cast a middle click?
29 replies
CC#
Created by RohesKätzchen on 2/6/2024 in #help
Library to send mouse and key Inputs
I have a project where i need to send Mouse and Key Inputs on a Global level from my WindowsForms application. I need somethig like https://www.nuget.org/packages/H.InputSimulator#readme-tab, the only problem ive got with this library is that once i send the key i cant get it to be held down, a crucial point of the project is that i need to simulate the held down key for a small amount of time (for example if i hold the key down for 2 seconds i get: lllllllllllllllllllllllllllllll). Does anyone know a library that is able to do that or know a way to do that with the given library?
10 replies
CC#
Created by RohesKätzchen on 1/23/2024 in #help
✅ Global keypress Simulation?
hello, i have a project where i need to perform global mouse and key Presses, i cant seem to find a way, or Library that can do that, i need to read an array of strings, to perform the presses, and i need to be able to simulate holding down the key and mouse for an amount of time, do you know ways or Librarys to do that? i programm in VS and use windows forms c#. (something like this https://www.nuget.org/packages/H.InputSimulator#readme-tab (i cant get said extra functions to work here))
15 replies
CC#
Created by RohesKätzchen on 12/2/2023 in #help
✅ How to Update the original instance of my Main Form from another form
I have a Function i'd Like to call from my Mainform and from my second form( the function updates a listbox an my Mainform), to achieve that i created a new instance of my Mainform in my second form, but it apears to only update the listbox on the new Instance of my Main form not on the old one, how can i Update the listbox on the Original Mainform instance. (i apollogize for my bad english) This is the Function id Like to call that should update the listbox on my Mainform
public void showMacro() //Funktion die alle Dateien im macro Pfad in einer ListBox auflistet
{
MessageBox.Show("test");
if (Directory.Exists(macroPath))
{
string[] files = Directory.GetFiles(macroPath);
ltxMacroShowCase.Items.Clear();

foreach (string macro in files)
{
ltxMacroShowCase.Items.Add(Path.GetFileName(macro));
}
}
}
public void showMacro() //Funktion die alle Dateien im macro Pfad in einer ListBox auflistet
{
MessageBox.Show("test");
if (Directory.Exists(macroPath))
{
string[] files = Directory.GetFiles(macroPath);
ltxMacroShowCase.Items.Clear();

foreach (string macro in files)
{
ltxMacroShowCase.Items.Add(Path.GetFileName(macro));
}
}
}
This is the Button from my second form that i use to call my function on the first Form.
private void btnOkay_Click(object sender, EventArgs e)
{
try
{
Form1 f1 = new Form1();

File.WriteAllText(Path.Combine(Form1.macroPath, txbNameInput.Text), "");
f1.showMacro();
this.Close(); //erfolgreiches erstellen der macro Datei

}
catch (Exception ex)
{
MessageBox.Show("this is not a valid Name! " + ex.Message);
return;
}
}
private void btnOkay_Click(object sender, EventArgs e)
{
try
{
Form1 f1 = new Form1();

File.WriteAllText(Path.Combine(Form1.macroPath, txbNameInput.Text), "");
f1.showMacro();
this.Close(); //erfolgreiches erstellen der macro Datei

}
catch (Exception ex)
{
MessageBox.Show("this is not a valid Name! " + ex.Message);
return;
}
}
(i use windows Forms incase thats important)
8 replies
CC#
Created by RohesKätzchen on 10/11/2023 in #help
❔ ✅ Is there a Way to extend this code from this yt tutorial
so ive been following this yt tutorial https://www.youtube.com/watch?v=nTKTPqqFtrk, which shows a way to implement a keyboard hook(i think "^^) and it does work so far, but i was wondering if i could extend the code to show me which button is pressed and released rather than just givig me a messagebox with the notofication.(i apologize if my question is written poorly) here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace testform2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Hotkeys.Init(comboBox1);
}

protected override void WndProc(ref Message hotkey)
{
bool Visible = this.Visible;
base.WndProc(ref hotkey);

if(Visible && hotkey.Msg == 0x0312)
{
textBox1.Text += hotkey.Msg.ToString() + "\n\r";
//MessageBox.Show("Global Hotkey Pressed");
}
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
Hotkeys.SetHotKey(comboBox1, Handle);
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace testform2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Hotkeys.Init(comboBox1);
}

protected override void WndProc(ref Message hotkey)
{
bool Visible = this.Visible;
base.WndProc(ref hotkey);

if(Visible && hotkey.Msg == 0x0312)
{
textBox1.Text += hotkey.Msg.ToString() + "\n\r";
//MessageBox.Show("Global Hotkey Pressed");
}
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
Hotkeys.SetHotKey(comboBox1, Handle);
}
}
}
191 replies
CC#
Created by RohesKätzchen on 9/27/2023 in #help
❔ some sort of global keyboard and mouse detection?
hey, i want to write a programm where it is neccessary to detect save and play keyboard and mouse ,,events,, in and outside of my programm, and i dont know what to look up, it would be nice if someone could tell what to look into to achieve my goal?
11 replies
CC#
Created by RohesKätzchen on 9/26/2023 in #help
✅ my event handler cant find my textbox
So im new to prgramming and wanted to write a little programm that requres me to use a the input of a textbox to set a name, but for some reason my button click handler cant find my textbox.
private string createMacroFile()
{
Form nameInput = new Form();
nameInput.Text = "Name";
nameInput.Icon = SystemIcons.Question;
nameInput.MinimizeBox = false;
nameInput.MaximizeBox = false;
nameInput.FormBorderStyle = FormBorderStyle.FixedSingle;
nameInput.Size = new Size(200, 130);


Label labelA = new Label();
labelA.AutoSize = true;
labelA.Text = "Wie möchtest du den Macro nennen?";
nameInput.Controls.Add(labelA);

TextBox textBoxA = new TextBox();
textBoxA.Location = new Point(6, 23);
textBoxA.Width = 150;
nameInput.Controls.Add(textBoxA);

Button btnOkay = new Button();
btnOkay.Text = "Okay";
btnOkay.AutoSize = true;
btnOkay.Location = new Point(100, 50);
nameInput.AcceptButton = btnOkay;
btnOkay.Click += btnOkay_Click;
nameInput.Controls.Add(btnOkay);

Button btnCancel = new Button();
btnCancel.Text = "Cancel";
btnCancel.AutoSize = true;
btnCancel.Location = new Point(6, 50);
btnCancel.Click += btnCancel_Click;
nameInput.Controls.Add(btnCancel);

nameInput.ShowDialog();

return "test";
}

private void btnOkay_Click(object sender, EventArgs e)
{
File.WriteAllText(Path.Combine(macroPath, textBoxA.text), "");
}
private string createMacroFile()
{
Form nameInput = new Form();
nameInput.Text = "Name";
nameInput.Icon = SystemIcons.Question;
nameInput.MinimizeBox = false;
nameInput.MaximizeBox = false;
nameInput.FormBorderStyle = FormBorderStyle.FixedSingle;
nameInput.Size = new Size(200, 130);


Label labelA = new Label();
labelA.AutoSize = true;
labelA.Text = "Wie möchtest du den Macro nennen?";
nameInput.Controls.Add(labelA);

TextBox textBoxA = new TextBox();
textBoxA.Location = new Point(6, 23);
textBoxA.Width = 150;
nameInput.Controls.Add(textBoxA);

Button btnOkay = new Button();
btnOkay.Text = "Okay";
btnOkay.AutoSize = true;
btnOkay.Location = new Point(100, 50);
nameInput.AcceptButton = btnOkay;
btnOkay.Click += btnOkay_Click;
nameInput.Controls.Add(btnOkay);

Button btnCancel = new Button();
btnCancel.Text = "Cancel";
btnCancel.AutoSize = true;
btnCancel.Location = new Point(6, 50);
btnCancel.Click += btnCancel_Click;
nameInput.Controls.Add(btnCancel);

nameInput.ShowDialog();

return "test";
}

private void btnOkay_Click(object sender, EventArgs e)
{
File.WriteAllText(Path.Combine(macroPath, textBoxA.text), "");
}
7 replies