Note that there are some explanatory texts on larger screens.

plurals
  1. POClipboard.GetText overrides clipboard?
    primarykey
    data
    text
    <p>Here is what im trying to do: There is some game which writes some info about item under mouse cursor into clipboard when i press Ctrl-C. Im trying to grab that info and select some stuff i need from it. Im doing it like this:</p> <pre><code> //at form load RegisterHotKey(this.Handle, 0, 0x002, (int)Keys.C); protected override void WndProc(ref Message m) { if (m.Msg == 0x0312) { int id = m.WParam.ToInt32(); if (id == 0) { System.Threading.Thread.Sleep(155); //ive thought if i add some delay it would help but it doesnt... string textFromClipboard = Clipboard.GetText(); if (textFromClipboard.Contains("Itemlevel: ")) { // do some stuff with data IF it exists in clipboard, doesnt important what i do - i never get here } } } base.WndProc(ref m); } </code></pre> <p>So basically, when i press Ctrl-C in-game without this program on - all works fine, info copied in clipboard. When i turn program on - clipboard stays same as it was before i press Ctrl-C in-game. How do i prevent this? How do i get text from clipboard correctly? Maybe the way i get this text is wrong? Or maybe that registered hotkey interferes with game hotkey so it doesn't work anymore?</p> <p>update: Ive figured out some simple solution, but very rough and barbaric. But it works fine. </p> <pre><code> public static void KeyDown(System.Windows.Forms.Keys key) { keybd_event((byte)key, 0x45, 0x0001 | 0, 0); } public static void KeyUp(System.Windows.Forms.Keys key) { keybd_event((byte)key, 0x45, 0x0001 | 0x0002, 0); } protected override void WndProc(ref Message m) { if (m.Msg == 0x0312) { int id = m.WParam.ToInt32(); if (id == 0) { ToggleHotkeys(false); KeyDown(Keys.Control); KeyDown(Keys.C); KeyUp(Keys.C); KeyUp(Keys.Control); System.Threading.Thread.Sleep(155); //if i comment this sleep - code executes too fast, making first Ctrl-C press //capture nothing, second press outputs results for first item //third press - for second item, ... string textFromClipboard = Clipboard.GetText(); if (textFromClipboard.Contains("Itemlevel: ")) { //do stuff with data } ToggleHotkeys(true); } } base.WndProc(ref m); } </code></pre> <p>Maybe there is more clever way to solve this problem?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload