Ik maak een antwoord programma in C# waarbij je als je een vraagzin kopieert output krijgt vanuit een windows notificatie. Nu wil ik dat je ook automatisch kopieert als je de zin kopieert dus dat het niet meer nodig is om CTRL-C of rechtermuis klik en kopieren te klikken. Ik heb al wel gekeken naar middle mouseclick event. Maar dat heeft me tot nu toe nog niet verder geholpen.
dus wat ik simpelweg wil
- Kopieren als je tekst selecteerd
- Selectie op kopie verwijderen
Dit is mijn code:
dus wat ik simpelweg wil
- Kopieren als je tekst selecteerd
- Selectie op kopie verwijderen
Dit is mijn code:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| private void GetAnswer(string clipboardText) { //Loop through all questions and answers foreach (question q in questionList) { //If we have found an answer that is exactly the same show an Notification //Startwith zoekt naar alle vragen die matchen vanaf het begin van de zin en Endwith alle vragen die matchen vanaf het eind van de zin// if (q._question.StartsWith(clipboardText) || q._question.EndsWith(clipboardText)) { ShowNotification(q._question, q._answer); break; } } } private void ShowNotification(string question, string answer) { notifyIcon1.Icon = SystemIcons.Exclamation; notifyIcon1.BalloonTipTitle = question; notifyIcon1.BalloonTipText = answer; notifyIcon1.BalloonTipIcon = ToolTipIcon.Error; notifyIcon1.ShowBalloonTip(1000); } protected override void WndProc(ref Message m) { base.WndProc(ref m); { const int WM_DRAWCLIPBOARD = 0x308; if (m.Msg == WM_DRAWCLIPBOARD) { GetAnswer(Clipboard.GetText(TextDataFormat.UnicodeText)); } } } } } |