How to Drag & Drop with Powershell ps1 script?

How to Drag & Drop with Powershell ps1 script?



I have a simple program that has drag & drop functionality.



I want to drag from pixel point (x1,y1) to pixel point (x2,y2) and release the mouse.



How can I automate this with Powershell?
Following this basic tutorial, I can open the program and sendkeys.. but how to drag/drop?


add-type -AssemblyName microsoft.VisualBasic
add-type -AssemblyName System.Windows.Forms

Notepad

start-sleep -Milliseconds 500

#[Microsoft.VisualBasic.Interaction]::AppActivate("GUI_APP_I_USE")
[Microsoft.VisualBasic.Interaction]::AppActivate("Notepad")

[System.Windows.Forms.SendKeys]::SendWait("Hello")
#[Some.Library.I.Drag.Drop.With]::DragStart(x1,y1)
#[Some.Library.I.Drag.Drop.With]::DragEnd(x2,y2)




1 Answer
1



I don't think you should be looking into dragging and dropping. Instead, you can detect a mousedown event and a mouseup event which would be the same as a drag and drop.



So you click on the pixel (MouseDown), get its color and drag it around. When you drop it (MouseUp), you update the new pixel location with the color, and remove it from the old location.



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)