mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-22 18:15:47 +02:00
Rewrite image paste click simulation to use CEF events instead of WinAPI
This commit is contained in:
parent
53c8272e01
commit
ee9d9196f5
@ -109,15 +109,7 @@ public void TryPasteImage(){
|
||||
}
|
||||
|
||||
public void ClickUploadImage(int offsetX, int offsetY){
|
||||
form.InvokeSafe(() => {
|
||||
Point prevPos = Cursor.Position;
|
||||
|
||||
Cursor.Position = form.PointToScreen(new Point(offsetX, offsetY));
|
||||
NativeMethods.SimulateMouseClick(NativeMethods.MouseButton.Left);
|
||||
Cursor.Position = prevPos;
|
||||
|
||||
form.OnImagePastedFinish();
|
||||
});
|
||||
form.InvokeAsyncSafe(() => form.TriggerImageUpload(offsetX, offsetY));
|
||||
}
|
||||
|
||||
public void ScreenshotTweet(string html, int width, int height){
|
||||
|
@ -406,8 +406,10 @@ public void OnImagePasted(){
|
||||
browser.ExecuteScriptAsync("TDGF_tryPasteImage()");
|
||||
}
|
||||
|
||||
public void OnImagePastedFinish(){
|
||||
browser.ExecuteScriptAsync("TDGF_tryPasteImageFinish()");
|
||||
public void TriggerImageUpload(int offsetX, int offsetY){
|
||||
IBrowserHost host = browser.GetBrowser().GetHost();
|
||||
host.SendMouseClickEvent(offsetX, offsetY, MouseButtonType.Left, false, 1, CefEventFlags.None);
|
||||
host.SendMouseClickEvent(offsetX, offsetY, MouseButtonType.Left, true, 1, CefEventFlags.None);
|
||||
}
|
||||
|
||||
public void TriggerTweetScreenshot(){
|
||||
|
@ -344,6 +344,11 @@
|
||||
};
|
||||
|
||||
var clickUpload = function(){
|
||||
$(document).one("uiFilesAdded", function(){
|
||||
getScroller().scrollTop(prevScrollTop);
|
||||
$(".js-drawer").find(".js-compose-text").first()[0].focus();
|
||||
});
|
||||
|
||||
var button = $(".js-add-image-button").first();
|
||||
|
||||
var scroller = getScroller();
|
||||
@ -395,13 +400,6 @@
|
||||
lastPasteElement = null;
|
||||
}
|
||||
};
|
||||
|
||||
window.TDGF_tryPasteImageFinish = function(){
|
||||
setTimeout(function(){
|
||||
getScroller().scrollTop(prevScrollTop);
|
||||
$(".js-drawer").find(".js-compose-text").first()[0].focus();
|
||||
}, 10);
|
||||
};
|
||||
})();
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user