發表文章

目前顯示的是有「C#」標籤的文章

長輩視訊-window端

圖片
這邊主要是接收Arduino傳過來的指令,我用C#做的。 程式執行視窗 用這程式控制下面的網頁 先選擇好com port 在點下start就能夠開始執行了 //#define open_chrome_64bit //#define dont_open_chrome 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; using System.IO.Ports; //要使用serial port需要引用它 using System.Threading; using System.Diagnostics; using System.Runtime.InteropServices; namespace WindowsFormsApplication1 { public partial class Form1 : Form { StringComparer stringComparer = StringComparer.OrdinalIgnoreCase; SerialPort serialPort; bool continuethread = false; Thread readThread; int seriallifenum = 2; int seriallife; int serial_state = 0; public Form1() { InitializeComponent(); starbutton.Enabled = false; stopbutton.Enabled = false; ...

C# 系統音量調整由程式控制

public class demo { //運用WinAPI控制電腦靜音與音量 private const int APPCOMMAND_VOLUME_MUTE = 0x80000; private const int APPCOMMAND_VOLUME_UP = 0x0a0000; private const int APPCOMMAND_VOLUME_DOWN = 0x090000; private const int WM_APPCOMMAND = 0x319; //private static IntPtr Handle; public static Process p = Process.GetCurrentProcess(); [DllImport("user32.dll")] public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); public static void btnVup_Click() { // 聲音變大 SendMessageW(p.Handle, WM_APPCOMMAND, p.Handle, (IntPtr)APPCOMMAND_VOLUME_UP); } public static void btnVdown_Click() { // 聲音變小 SendMessageW(p.Handle, WM_APPCOMMAND, p.Handle, (IntPtr)APPCOMMAND_VOLUME_DOWN); } public static void btnMute_Click() { // 靜音 SendMessageW(p.Handle, WM_APPCOMMAND, p.Handle, (IntPtr)APPCOMMAND_VOLUME_MUTE); } /** * xp以下的電腦適用 * */ ...

C# 模擬鍵盤滑鼠控制電腦

滑鼠模擬 指定一個螢幕像素的座標位置 int x = 1255; int y = 161; Cursor.Position = new Point(x, y); ClassMouse.LeftClick(); //按下滑鼠左鍵 鍵盤模擬 官方文件 的範例是用小算盤程式,計算111*11= public class demo { [DllImport("USER32.DLL", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); // Activate an application window. [DllImport("USER32.DLL")] public static extern bool SetForegroundWindow(IntPtr hWnd); // Send a series of key presses to the Calculator application. public static void Calculator() { // Get a handle to the Calculator application. The window class // and window name were obtained using the Spy++ tool. IntPtr calculatorHandle = FindWindow("ApplicationFrameWindow", "小算盤"); // Verify that Calculator is a running process. if (calculatorHandle == IntPtr.Zero) { MessageBox.Show("Calculator is not running....

第一次學習 C#

開啟外部程式 http://abgne.tw/code-snippets/dotnet-process.html 控制滑鼠 https://dotblogs.com.tw/sam319/2009/12/24/12643 加入cs (外部程式碼) https://social.msdn.microsoft.com/Forums/zh-TW/0b27dfdb-76e1-434a-ba64-80c972da82e2/c2cs?forum=233 invoke http://blog.xuite.net/merci0212/wretch/141175679-%5B%E8%BD%89%E8%BC%89%5DC%23+Invoke%E7%9A%84%E7%94%A8%E6%B3%95 https://dotblogs.com.tw/darrent/2010/12/02/19848 thread close http://www.programmer-club.com.tw/ShowSameTitleN/csharp/606.html https://dotblogs.com.tw/alexwang/2016/10/03/124332 c#  serial ports readline https://msdn.microsoft.com/zh-tw/library/system.io.ports.serialport.readline(v=vs.110).aspx get port to combobox http://catcsharp.blogspot.tw/2014/02/cwinform-rs-232serialport.html