Click here to Skip to main content
15,885,757 members

Comments by _Q12_ (Top 200 by date)

_Q12_ 30-Aug-23 19:03pm View    
-Small little problem...
this code: keyCode == Keys.C retains the value and when I select something else and press only the C key, (not ctrl+C), it will copy the selected text. When I press again Ctrl+C, it will behave correctly. When I press again Ctrl+C, only the C key, (not ctrl+C), it will copy the selected text and so on. So one time will remain as copy on C and another time on Ctrl+c. Is jumping from 1 to another.
I need, after 1 successful copy with ctrl+c, to clean (probably the) -keyCode- variable. I already looked for a set function in pinvoke.com and is nothing there to reset this variable.
I made a couple of lines, by myself, but none worked, voila:
if (keyCode == Keys.C)
{
if (GetKeyState(VK_CONTROL) != 0)
{
label6.Text = textBoxMovieName.SelectedText;
//Clipboard.SetText(textBoxMovieName.SelectedText);
keyCode = Keys.None; GetKeyState(0); //reset the variable
m.Msg = (int)WM_KEYUP;
}
}
_Q12_ 30-Aug-23 17:35pm View    
Ive also followed your code back to the http://pinvoke.net and I find it there. Yah, you are good. I have to get used to this unmanaged code. I do it very rarely, and mostly with a hand from you guys here. So, my many thanks.
_Q12_ 30-Aug-23 17:31pm View    
OK, I didnt do this thing for a very long time....
I managed to inject your code into mine, after all. youpii.
And indeed is working - so THANK YOU VERY MUCH !
the trick was, adding those head lines like this:

[DllImport("USER32.dll")]
static extern short GetKeyState(int nVirtKey);

[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr LoadLibraryW(string lpLibFileName);
And after that, everything worked. Cool !!!
_Q12_ 30-Aug-23 17:30pm View    
Deleted
-deleted-
_Q12_ 30-Aug-23 17:24pm View    
Error 1 Duplicate 'DllImport' attribute - when Im using it like this:
[DllImport("USER32.dll")]
[DllImport("kernel32.dll", SetLastError = true)]