winapi - Delphi weird issue with clipboard -
i'm trying out read window text (a console kind of window) using application. how it.
1. send ctrl+a , ctrl + c using 'sendkey' terminal
// ctrl + keybd_event(vk_control, 0, 0, 0); fn_sendkeys('a'); keybd_event(vk_control, 0, keyeventf_keyup, 0); // ctrl + c keybd_event(vk_control, 0, 0, 0); fn_sendkeys('c'); keybd_event(vk_control, 0, keyeventf_keyup, 0);
2. once copied, saved txt file clipboard
function tform1.fn_save_clipboard_text_tofile(sfileto: string): boolean; var success: boolean; counter: integer; begin success := false; counter := 1; while ((not success) , (counter < 6)) begin result := clipboard.hasformat(cf_unicodetext); if result try tfile.writealltext(sfileto, clipboard.astext); success := true; except on exception begin fn_delay(1); counter := counter + 1; end; end; end; end;
3. process information in txt file reading it
everything works perfectly, except when ctrl + c on memo, within application, prior sending ctrl + c window. when ctrl + c within memo, , try save clip board text in application, throws exception saying "cannot open clipboard - access denied".
it works 100% when not copy operation on memo prior screen copy. strange thing is, fails 100% if copy/paste in memo prior screen read.
could please me identify, doing wrong here?
Comments
Post a Comment