Powershell将图像上传到https://www.artstation.com/ [英] Powershell Upload Image to https://www.artstation.com/

查看:71
本文介绍了Powershell将图像上传到https://www.artstation.com/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

内容

  • 问题
  • 问题信息
  • 背景/研究
  • 代码块
  • 资源


问题:

如何使用Powershell 编程/自动将图像上传到Artstation \ Project-页面?

?

在上传过程中无需人工输入即可选择文件.仅预定义的媒体数据.如果可以的话,最好使用powershell的内置功能.<​​/p>

(请参见下面的网页参考图片"ArtStation上传页面")



问题信息:

环境上下文:

  • 操作系统: Windows 10,V:1803,内部版本:17134.165
  • 平台: PC
  • Powershell : V:5.1.17134.165(台式机版),内部版本:10.0.17134.165,(runas Admin,ExecutionPolicy RemoteSigned)
  • InternetExplorer11 : V:11.165.17134.0,UpdateV:11.0.75(KB4339093)
  • 网站:: https://www.artstation.com/myartstation/projects/new


Artstation的'拖放'部分在中间带有'上传按钮',用于打开文件浏览器.(请参见图像 ArtStation上传页面).

我看到一些选择.

  1. 模拟文件拖动到拖动区域(似乎最简单)
  2. 在不使用button.click()
  3. 的情况下向文件浏览器传递要上传的文件
  4. Button.click()打开文件浏览器,使用单独的Powershell流程捕获文件浏览器,然后导航并选择要上传的文件.
  5. 手动在项目页面上创建/添加新的子级"Art-Work"元素



背景-研究:

嘿,我的第一篇文章.

我是新的Powershell用户和新程序员.我正试图修改生活质量应用程序,以通过Powershell将图像上传到Artstation.

大约两个星期(80多个小时)以来,我一直在努力寻找解决方法,该方法查看了数百个无收益的孔和部位.也许我不知道我在寻找什么,或者不使用会使我接近答案的查询.因此,我认为是时候该排队了,看看我是否可以得到一些帮助.请像我是个白痴一样向我解释一下.

关于如何通过Powershell上传图像,我还没有发现任何东西.或至少我听不懂.


到目前为止,我查看过的所有内容(可能都可以正常运行)都要求我知道将文件发送至何处. Invoke-WebRequest /Invoke-RestMethod,复制项-session 拖放 javaScript.唯一的问题是 我不知道 .我唯一拥有的是一个InternetExplorer.application ComObject,其中包含用于拖放区域"对象和文件上传按钮"对象的变量.它们都具有我不确定如何设置或所需的数据结构如何的方法和属性.


过去查询: (MFF,IE和Chrome;)

(我在很多次会议中都使用过的单词)
"powershell",v5,https,上传,图像,文件,artstation,数据传输,onDropEvent,复制项,html标签,html,javascript,拖放功能,输入功能,定义,ondrop,对象格式,https文件传输,将图像转换为叮咬,包,对象,$ ie.document.getelementId('image-input-upload').value =.\ $ myImage",检测,捕获,捕获,跟踪,查找,新,子,进程,文件浏览器,浏览器,导航,选择文件,分配,CTS,上传器,dllhost,sendkeys,AssemblyName,System.Windows.Forms,microsoft.VisualBasic,multiPartContent,set-clipboard,get-clipboard,fileAsBinaryString



代码块:

抱歉,这很难看或没有道理.一个简单的答案是,我不知道我在做什么.我只是在凑巧一些东西,希望它们能起作用.

 #<START_GLOBAL-VARIABLES>##<安全文件>##TODO:在设置为null之前清理内存#如果脚本运行中存在一个列表,则将其设置为nullif($ CredList.Keys){$ CredList = $ null}if($ keyWord.Count){$ keyWord = $ null}$ CredList = @ {}#TODO:删除调试元素#Debug变量轻松选择具有键"$ keyWord = @()#从文件中提取和解析安全数据$ CredBody =获取内容$ CertFile$ CredBody |ForEach-Object {$ s = $ _ -split,"$ keyWord + = [REGEX] :: Match($ s [0],(?< = www.).*?(?=.com)").groups [0] .value$ CredList.add($ s [0],($ s [1],$ s [2]))}#TODO:删除调试元素#<调试选项>##分割安全文件数据并重新打包在哈希表中$ keyWord = $ keyWord.GetEnumerator()|排序对象$ httpHost =($ CredList.Keys -imatch $ keyWord [0])$ ActiveKey =($ CredList [$ CredList.Keys -imatch $ keyWord [0]])###<END_GLOBAL-VARIABLES> ######<START_ARTSTATION> ###if($ httpHost -imatch'artstation'){#Todo:将其移至全球范围,以供其他艺术网站重用.#或创建一次并使用导航?更多/更少安全?#<在Artstation>#中创建IE窗口并添加poit$ ie =新对象-ComObject'InternetExplorer.Application'$ ie.visible = $ true$ ie.navigate($ httpHost)while($ ie.ReadyState -ne 4){start-sleep -m 100}##<START_LOGIN> ##if($ ie.Document.location.href -eq'https://www.artstation.com/users/sign_in'){#Todo:加密数据源+安全地将信息传递到网页#通过Windows安全窗口传递数据?#<查找所需的证书元素>#$ forms = $ ie.Document.forms |ForEach-Object {$ _ |ForEach-Object {if($ _.id -imatch'email'-or $ _.id -imatch'password'){return $ _}}}# 用户名$ UserForm = $ forms |哪里对象{$ _.id -imatch'email'}$ UserForm [0] .focus()$ ie.Document.activeElement.value = $ ActiveKey [0] [0]# 密码$ PassForm = $ forms |哪里对象{$ _.id -imatch'password'}$ PassForm [0] .focus()$ ie.Document.activeElement.value = $ ActiveKey [0] [1]#提交表格$ submitForm = $ ie.Document.forms [1] .elements |位置对象{$ _.name -imatch'button'}$ submitForm.focus()$ submitForm.click()while($ ie.ReadyState -ne 4){start-sleep -m 100}}##<END_LOGIN> ###TODO:删除调试元素#<调试选项>##导航到现有或新项目页面$ result = UserPrompt $ ie'这是一个新项目吗?''项目设置''问题'{$ ie.navigate("https://www.artstation.com/myartstation/projects/new")} {$ ie.navigate("https://www.artstation.com/marketplace/manage/products/new)} {$ null}while($ ie.ReadyState -ne 4){start-sleep -m 100}##<START_UPLOAD> ###拖放矩形"#< div class ="well drop-files文本中心hidden-sm hidden-xs" id ="dropzone">< label class ="btn btn-default" for =上传图片输入">< i class ="far fa-arrow-from-bottom fa-pad-right"</i>上传图像</label>< div class =" separator-sm</div>;< div class ="text-muted">上传或拖动& amp;放置图像</div></div>#图片:#< input accept ="image/jpeg,image/png,image/gif" id ="upload-image-input" multiple ="multiple" name ="asset [image] []" type ="file">#视频:#< a class ="btn btn-default" id ="project-add-video-btn" data-toggle ="modal" data-target =#add-video-modal" href =#"><; i class ="far fa-film fa-pad-right"</i>添加视频</a>#SketchFab#< a class ="btn btn-default" id ="project-add-3dmodel-btn" data-toggle ="modal" data-target =#add-3dmodel-modal" href =#"><; i class ="far fa-cube fa-pad-right"</i>添加Sketchfab</a>#Mar猴#< input multiple ="multiple" name ="asset [image] []" type ="file">#Pano#< a class ="btn btn-default" id ="project-add-pano-btn" href =#">< i class ="far icon-pano fa-pad-right"></i>添加360 Pano</a>#ProjectThumbnail#< label class ="upload-thumbnail-placeholder" for ="upload-thumbnail">< i class ="far fa-image fa-2x"</i>< div class ="small>上传或拖动& amp; amp;放置图像</div</label>##<START_POPULATE-FIELDS> ###<艺术图片>##图像#上传#字幕#ImageFitting#<缩略图图像>##图像#上传#<变量>#$ fielfToken ='title','description','medium','matter','adult','albmus','portfolio','software','Tags'$ Values ='这是我的头衔',``这幅画是为我的Twitch流制作的!稍等片刻.',数字3D"#<标题>##Text字段[a-z,0-9]$ titleToken = $ ie.Document.forms |ForEach-Object {$ _ |哪里对象{$ _.id -imatch $ fielfToken [0]}}$ titleToken [0] .value = $ Values [0]#<描述>##Text字段[a-z,0-9]$ descriptionToken = $ ie.Document.forms |ForEach-Object {$ _ |哪里对象{$ _.id -imatch $ fielfToken [1]}}$ descriptionToken.value = $ Values [1]#<中号#dropdown [v]#拉下拉选项$ mediumToken = $ ie.Document.forms |ForEach-Object {$ _ |哪里对象{$ _.id -imatch $ fielfToken [2]}}#将媒体下拉菜单设置为$ mediumToken.tostring()#<主题事项>##dropdown [v]#拉下拉选项#$ subjectToken#$ subjectToken#<成人内容>##checkbox [x]$ adultToken = $ ie.Document.forms |ForEach-Object {$ _ |哪里对象{$ _.id -imatch $ fielfToken [4]}}$ adultToken.click()#<软件>##Dropdown [v]#拉出软件列表#$ softwareToken#$ softwareToken#<START_TAGS>##选项1:上一个[] pr前一个[X]#选项2:"tag1","tag2","tag3"...#if上一个已勾选的复选框[x]#$ foundToken [1] .click()#if额外标签= @()#$ foundToken [0] .length#<END_TAGS>##<相册>##checkbox [x]列表(AlbumsA [],AlbumsB [],AlbumsC [])#获取可用相册列表$ albumsToken = $ ie.Document.forms |ForEach-Object {$ _ |哪里对象{$ _.classname -imatch'col-md-3'}}$ albumsToken.click()#<START_PORTFOLIO&#;#ArtStation.com复选框[x]#$ adultToken = $ ie.Document.forms |ForEach-Object {$ _ |哪里对象{$ _.id -imatch $ fielfToken [4]}}#$ adulToken.click()#MyWebsite复选框[x]#$ adultToken = $ ie.Document.forms |ForEach-Object {$ _ |哪里对象{$ _.id -imatch $ fielfToken [4]}}#$ adulToken.click()#<END_PORTFOLIO&#;#<评论>##完成审核后单击确定#编辑文字#重新上传媒体#<发布>##Save.click()#Publish.click()##<END_POPULATE-FIELDS> ###<注销>##$ signOut = $ ie.Document.all |Where-Object {$ _.classname -imatch'far fa-sign-out fa-fw fa-pad-right-x2'}#$ signOut.focus()#$ signOut.click()###<END_ARTSTATION> ###} 



资源:

链接:
* community.box.com/t5/Platform-and-Development-Forum/Upload-a-file-using-API-in-PowerShell/td-p/35660
* app.box.com/s/46hwgi48n31g42vuqjk67d01abceypij
* stackoverflow.com/questions/23059945/upload-a-file-to-box-com-using-powershell
* get-powershellblog.blogspot.com/2017/09/multipartform-data-support-for-invoke.html
* blog.majcica.com/2016/01/13/powershell-tips-and-tricks-multipartform-data-requests/
* blog.majcica.com/2016/01/15/uploading-xl-deploy-dar-package-via-powershell/
* github.com/react-dropzone/react-dropzone

解决方案

我知道您很久以前就发布了这个问题,但是您可以通过某种方式使用这种可能的方法.

 功能Click-DragControl{参数([Parameter(Position = 0,Mandatory = $ TRUE)][UIAutomation.UiElement]$ ObjectDragFrom,[Parameter(Position = 1,Mandatory = $ TRUE)][UIAutomation.UiElement]$ ObjectDragTo)$ newX = [Int]($ ObjectDragFrom.Current.BoundingRectangle.X +($ ObjectDragFrom.Current.BoundingRectangle.Width/2))$ newY = [Int]($ ObjectDragFrom.Current.BoundingRectangle.Y +($ ObjectDragFrom.Current.BoundingRectangle.Height/2))#如果对象位于可折叠窗口内,或者位于屏幕外,则返回的像素为< 0,0>.#因此,我们将恢复为较旧的单击方法,因为它可以爬网控件并仍然获得该项目.如果($ newX -eq 0-和$ newY -eq 0){$ ObjectDragFrom.Mouse.LeftButtonClick()返回$ true}[System.Windows.Forms.Cursor] :: Position =新对象System.Drawing.Point($ newX,$ newY)$ signature =@'[DllImport("user32.dll",CharSet = CharSet.Auto,CallingConvention = CallingConvention.StdCall)]公共静态外部void mouse_event(long dwFlags,long dx,long dy,long cButtons,long dwExtraInfo);'@$ SendMouseClick =添加类型-memberDefinition $ signature -name"Win32MouseEventNew"-命名空间Win32Functions -passThru尝试{$ SendMouseClick :: mouse_event(0x00000002,0,0,0,0);#鼠标左移}抓住{Write-Host(错误:在Click-Control中捕获了未处理的异常.原始错误:`n $ Global:Error [0]")返回$ FALSE}$ newX = [Int]($ ObjectDragTo.Current.BoundingRectangle.X +($ ObjectDragTo.Current.BoundingRectangle.Width/2))$ newY = [Int]($ ObjectDragTo.Current.BoundingRectangle.Y +($ ObjectDragTo.Current.BoundingRectangle.Height/2))#如果对象位于可折叠窗口内,或者位于屏幕外,则返回的像素为< 0,0>.#因此,我们将恢复为较旧的单击方法,因为它可以爬网控件并仍然获得该项目.if($ newX -eq 0-和$ newY -eq 0){$ ObjectDragTo.Mouse.LeftButtonClick()返回$ TRUE}[System.Windows.Forms.Cursor] :: Position =新对象System.Drawing.Point($ newX,$ newY)$ signature =@'[DllImport("user32.dll",CharSet = CharSet.Auto,CallingConvention = CallingConvention.StdCall)]公共静态外部void mouse_event(long dwFlags,long dx,long dy,long cButtons,long dwExtraInfo);'@$ SendMouseClick =添加类型-memberDefinition $ signature -name"Win32MouseEventNew"-命名空间Win32Functions -passThru尝试{$ SendMouseClick :: mouse_event(0x00000004,0,0,0,0);#鼠标左移返回$ TRUE}抓住{Write-Host(错误:在Click-DragControl中捕获了未处理的异常.原始错误:`n $ Global:Error [0]")返回$ FALSE} 

}

Contents

  • Question
  • Question Info
  • Background / Research
  • Code Block
  • resources


Question:

How do I Programmatic/Automatically upload an image to Artstation\Project-page using Powershell?

No human input to select files during upload. Only predefined media data. If it can be done with powershell's built-in functionality that is preferred.

(see web-page reference image 'ArtStation Upload Page' below)



Question Info:

Environment Context:

  • OS: Windows 10, V:1803, Build:17134.165
  • Platform: PC
  • Powershell: V:5.1.17134.165 (Desktop edition), Build:10.0.17134.165, (runas Admin, ExecutionPolicy RemoteSigned)
  • InternetExplorer11: V:11.165.17134.0, UpdateV:11.0.75(KB4339093)
  • Website: https://www.artstation.com/myartstation/projects/new


Artstation has a 'drag and drop' section with an 'upload button' in the center that opens a file browser. (see image ArtStation Upload Page).

I see a few options.

  1. Simulate a file drag into the drag area (seems the most simple)
  2. Pass the file browser the file to upload without using button.click()
  3. Button.click() Open the file browser use a separate powershell process to capture the file browser and navigate to and select the file to upload.
  4. Manualy create/add a new child 'Art-Work' element to the project page



Background - Research:

Hey, my first post.

I'm a new powershell user and new programmer. I was trying to right a quality of life application to upload an image to Artstation via powershell.

I've been trying to figure out how to do it for about two week now (80+ hours) looking at hundreds of fora and sites with no yield. Maybe I don't know what I'm looking for or not using queries that will land me close to an answer. So I thought it was time to cast a line and see if I could get some help. Please explain it to me like I'm an idiot, from square one.

I haven't found anything on how to upload an image via powershell yet. Or at least nothing I can understand.


So far everything I've looked at the I thought might work requires me to know where I'm sending the file. Invoke-WebRequest / Invoke-RestMethod, Copy-item -session, Drag-drop javaScript. The only problem is I don't know. And the only thing I have is a internetExplorer.application ComObject with variables for the 'drag and drop zone 'object and the 'file upload button' object. They both have methods and properties that I'm not sure how to set or how/what data structure they require.


Past Queries: (MFF, IE, and Chrome;)

(Word I've used over many sessions)
"powershell", v5, https, upload, image, file, artstation, datatransfer, onDropEvent, copy-item, html tag , html, javascript, drag&drop function, input function, definition, ondrop, object format, https file transfer, convert, image to bites, package, object, $ie.document.getelementId('image-input-upload').value=".\$myImage" , detect, catch, capture, track, find, new, sub, process, file explorer, browser, navigate, select file, assign, CTS, uploader, dllhost, sendkeys, AssemblyName, System.Windows.Forms, microsoft.VisualBasic, multiPartContent, set-clipboard, get-clipboard, fileAsBinaryString



Code Block:

Sorry if this is ugly or doesn't make sense. The simple answer for that is, I don't know what the heck I'm doing. I'm just scrapping something together that will hopefully work.

#< START_GLOBAL-VARIABLES >#

#< Secure Document >#
    #TODO: Clean up memory before setting to null
    #If Either list exists on script run set to null
    if($CredList.Keys){$CredList = $null}
    if($keyWord.Count){$keyWord = $null}

    $CredList = @{}
    #TODO: remove debug elements
    #Debug Variable 'easy select has key'
    $keyWord = @()

    #Pull and Parse Security Data from file
    $CredBody = Get-Content $CertFile
    $CredBody | ForEach-Object {
        $s = $_ -split ", "
        $keyWord += [REGEX]::Match($s[0], "(?<=www.).*?(?=.com)").groups[0].value
        $CredList.add($s[0],($s[1],$s[2]))
    }

#TODO: remove debug elements
#< Debug Option >#
    #Split security file data and repack in hashtable
    $keyWord = $keyWord.GetEnumerator() | Sort-Object
    $httpHost = ($CredList.Keys -imatch $keyWord[0])
    $ActiveKey = ($CredList[$CredList.Keys -imatch $keyWord[0]])

###< END_GLOBAL-VARIABLES >###


###< START_ARTSTATION >###


if($httpHost -imatch 'artstation')
{
    #Todo: Move this to a global scope to reuse for other art sites.
        #Or create once and use navigate? More/less secure?

    #< Create IE window and poit at Artstation >#
        $ie = New-Object -ComObject 'InternetExplorer.Application'
        $ie.visible=$true
        $ie.navigate($httpHost)

        while($ie.ReadyState -ne 4) {start-sleep -m 100}


    ##< START_LOGIN >##

    if($ie.Document.location.href -eq 'https://www.artstation.com/users/sign_in')
    {
        #Todo: Encrypt Data Source + pass information securly to webpage
            #Pass data through windows security window?

        #< Find Desired Cert Elements >#
            $forms = $ie.Document.forms | ForEach-Object { $_ | ForEach-Object { if($_.id -imatch 'email'-or $_.id -imatch 'password'){return $_ } } }

        # UserName
            $UserForm = $forms | Where-Object {$_.id -imatch 'email'}
            $UserForm[0].focus()
            $ie.Document.activeElement.value = $ActiveKey[0][0]

        # Password
            $PassForm = $forms | Where-Object {$_.id -imatch 'password'}
            $PassForm[0].focus()
            $ie.Document.activeElement.value = $ActiveKey[0][1]

        #Submit Form
            $submitForm = $ie.Document.forms[1].elements | Where-Object { $_.name -imatch 'button'}
            $submitForm.focus()
            $submitForm.click()

            while($ie.ReadyState -ne 4) {start-sleep -m 100}
    }

    ##< END_LOGIN >##

    #TODO: remove debug elements
    #< Debug Option >#
        #Navigate to an Existing or New project page
        $result = UserPrompt $ie 'Is this a new project?' 'Project Setup' 'Question' {$ie.navigate("https://www.artstation.com/myartstation/projects/new")} {$ie.navigate("https://www.artstation.com/marketplace/manage/products/new")} {$null}
        while($ie.ReadyState -ne 4) {start-sleep -m 100}


    ##< START_UPLOAD >##


    #"Drag & Drop Rect"
        #<div class="well drop-files text-center hidden-sm hidden-xs" id="dropzone"><label class="btn btn-default" for="upload-image-input"><i class="far fa-arrow-from-bottom fa-pad-right"></i>Upload your images</label><div class="separator-sm"></div><div class="text-muted">Upload or drag &amp; drop images</div></div>
    #Pictures:
        #<input accept="image/jpeg,image/png,image/gif" id="upload-image-input" multiple="multiple" name="asset[image][]" type="file">
    #Video:
        #<a class="btn btn-default" id="project-add-video-btn" data-toggle="modal" data-target="#add-video-modal" href="#"><i class="far fa-film fa-pad-right"></i>Add Video</a>
    #SketchFab
        #<a class="btn btn-default" id="project-add-3dmodel-btn" data-toggle="modal" data-target="#add-3dmodel-modal" href="#"><i class="far fa-cube fa-pad-right"></i>Add Sketchfab</a>
    #Marmoset
        #<input multiple="multiple" name="asset[image][]" type="file">
    #Pano
        #<a class="btn btn-default" id="project-add-pano-btn" href="#"><i class="far icon-pano fa-pad-right"></i>Add 360 Pano</a>
    #ProjectThumbnail
        #<label class="upload-thumbnail-placeholder" for="upload-thumbnail"><i class="far fa-image fa-2x"></i><div class="small">Upload or drag &amp; drop image</div></label>


    ##< START_POPULATE-FIELDS >##

        #< Art-Image >#
            #Image
            #Upload
            #Captions
            #ImageFitting

        #< Thumbnail-Image >#
            #Image
            #Upload

        #< VARIABLES >#
            $fielfToken = 'title','description', 'medium','Matter', 'adult','albmus','portfolio', 'software', 'Tags'
            $Values = 'This is my title',
                      'This painting was done for my Twitch stream! come stop on by some time.',
                      'digital 3d'

        #< TITLE >#
            #Text Field [a-z,0-9]
            $titleToken = $ie.Document.forms | ForEach-Object{ $_ | Where-Object {$_.id -imatch $fielfToken[0]} }
            $titleToken[0].value = $Values[0]

        #< DESCRIPTION >#
            #Text Field [a-z,0-9]
            $descriptionToken = $ie.Document.forms | ForEach-Object{ $_ | Where-Object {$_.id -imatch $fielfToken[1]} }
            $descriptionToken.value = $Values[1]

        #< MEDIUM >#
            #dropdown[v]
            #Pull dropdown choices
            $mediumToken = $ie.Document.forms | ForEach-Object{ $_ | Where-Object {$_.id -imatch $fielfToken[2]} }
            #Set medium dropdown to $mediumToken.tostring()

        #< SUBJECT-MATTERr >#
            #dropdown[v]
            #Pull dropdown choices
            #$subjectToken
            #$subjectToken

        #< ADULT-CONTENT >#
            #checkbox[x]
            $adultToken = $ie.Document.forms | ForEach-Object{ $_ | Where-Object {$_.id -imatch $fielfToken[4]} }
            $adultToken.click()

        #< SOFTWARE >#
            #Dropdown[v]
            #Pull software list
            #$softwareToken
            #$softwareToken

        #< START_TAGS >#
            #Option 1: Previous[] pr Previous[X]
            #Option 2:  'tag1' 'tag2' 'tag3'. . .

            #if Previous ticked checkbox[x]
            #$foundToken[1].click()

            #if extra Tags = @()
            #$foundToken[0].length

        #< END_TAGS >#

        #< ALBUMS >#
            #checkbox[x] list ( AlbumsA[], AlbumsB[], AlbumsC[] )
            #Get list of available albums
            $albumsToken = $ie.Document.forms | ForEach-Object{ $_ | Where-Object {$_.classname -imatch 'col-md-3'} }
            $albumsToken.click()

        #< START_PORTFOLIO >#

            #ArtStation.com checkbox[x]
            #$adultToken = $ie.Document.forms | ForEach-Object{ $_ | Where-Object {$_.id -imatch $fielfToken[4]} }
            #$adulToken.click()

            #MyWebsite checkbox[x]
            #$adultToken = $ie.Document.forms | ForEach-Object{ $_ | Where-Object {$_.id -imatch $fielfToken[4]} }
            #$adulToken.click()

        #< END_PORTFOLIO >#

        #< Review >#
            #click ok when done reviewing
            #Edit text
            #Re-upload media

        #< Publish >#
            #Save.click()
            #Publish.click()


    ##< END_POPULATE-FIELDS >##


    #< Logout >#

    #$signOut = $ie.Document.all | Where-Object {$_.classname -imatch 'far fa-sign-out fa-fw fa-pad-right-x2'}
    #$signOut.focus()
    #$signOut.click()

    ###< END_ARTSTATION >###
}



Resources:

Links:
* community.box.com/t5/Platform-and-Development-Forum/Upload-a-file-using-API-in-PowerShell/td-p/35660
* app.box.com/s/46hwgi48n31g42vuqjk67d01abceypij
* stackoverflow.com/questions/23059945/upload-a-file-to-box-com-using-powershell
* get-powershellblog.blogspot.com/2017/09/multipartform-data-support-for-invoke.html
* blog.majcica.com/2016/01/13/powershell-tips-and-tricks-multipartform-data-requests/
* blog.majcica.com/2016/01/15/uploading-xl-deploy-dar-package-via-powershell/
* github.com/react-dropzone/react-dropzone

解决方案

I know you posted that question a long time ago, but here's a possible approach that you can probably make use of in some way.

function Click-DragControl
{
Param(
    [Parameter(Position=0,Mandatory=$TRUE)]
    [UIAutomation.UiElement]
    $ObjectDragFrom,

    [Parameter(Position=1,Mandatory=$TRUE)]
    [UIAutomation.UiElement]
    $ObjectDragTo
    )

$newX=[Int]($ObjectDragFrom.Current.BoundingRectangle.X+($ObjectDragFrom.Current.BoundingRectangle.Width/2))
$newY=[Int]($ObjectDragFrom.Current.BoundingRectangle.Y+($ObjectDragFrom.Current.BoundingRectangle.Height/2))

# In the event the object is inside a collapsible window, or is otherwise off-screen, the pixels we get back will be <0,0>.
# So we'll revert to our older method of clicking, because it can crawl through the control and still obtain the item.
if ($newX -eq 0 -and $newY -eq 0)
{
    $ObjectDragFrom.Mouse.LeftButtonClick()
    return $true
}

[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($newX,$newY)
$signature=
@'
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
'@
$SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru
Try
{
    $SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0); # Left Mouse Down
}
Catch
{
    Write-Host("ERROR: Caught an Unhandled Exception in Click-Control. Originating Error:`n$Global:Error[0]")
    return $FALSE
}   

$newX=[Int]($ObjectDragTo.Current.BoundingRectangle.X+($ObjectDragTo.Current.BoundingRectangle.Width/2))
$newY=[Int]($ObjectDragTo.Current.BoundingRectangle.Y+($ObjectDragTo.Current.BoundingRectangle.Height/2))

# In the event the object is inside a collapsable window, or is otherwise off-screen, the pixels we get back will be <0,0>.
# So we'll revert to our older method of clicking, because it can crawl through the control and still obtain the item.
if($newX -eq 0 -and $newY -eq 0){
    $ObjectDragTo.Mouse.LeftButtonClick()
    return $TRUE
}

[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($newX,$newY)
$signature=
@'
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
'@
$SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru
Try
{
    $SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0); # Left Mouse Up
    return $TRUE
}
Catch
{
    Write-Host("ERROR: Caught an Unhandled Exception in Click-DragControl. Originating Error:`n$Global:Error[0]")
    return $FALSE
}

}

这篇关于Powershell将图像上传到https://www.artstation.com/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆