Windows 10 如何将包含clipget()参数的变量加载到单个字符数组中?

Windows 10 如何将包含clipget()参数的变量加载到单个字符数组中?,windows-10,copy-paste,autoit,Windows 10,Copy Paste,Autoit,我用AutoIt编写了一个程序,自动从剪贴板中找到的任何内容中删除http(/s)://(/www.) 现在我希望它删除URL的“页面”规范(结尾),只留下整个站点URL 我的第一个猜测是: ############################################################################ (a) put the value of the variable set to clipget() into an array of singl

我用AutoIt编写了一个程序,自动从剪贴板中找到的任何内容中删除
http(/s)://(/www.)

现在我希望它删除URL的“页面”规范(结尾),只留下整个站点URL

我的第一个猜测是:

############################################################################
    (a) put the value of the variable set to clipget() into an array of single characters 
        ###    here is my question: #### how do I do that?   ###;
############################################################################
    (b) point to the third backslash in the string;
    (c) set the value to null;
    (d) move to the next argument and do the same;
    (e) repeat until end of array;
    (f) write the values of the array to a variable;
    (g) clipput() the string;
    (h) exit 
我是新手

如何将包含clipget()参数的变量加载到数组中

非常感谢

这就是我到目前为止所拥有的:

这是一个我正在挣扎的例子。 “50”intiger文本需要替换为一个函数,该函数计算字符串从左到尾的第三个反斜杠之间存在的字符数

#include <MsgBoxConstants.au3>
Local $url = ClipGet()
;#########################################################################
;########################   that '50' needs to be a function   ###########
Local $url = StringTrimRight($url, 50) 
;#########################################################################
ClipPut($url)
$newurl = ClipGet()
MsgBox($MB_SYSTEMMODAL, "", $newurl)
#包括
本地$url=ClipGet()
;#########################################################################
;########################   “50”必须是一个函数###########
本地$url=StringTrimRight($url,50)
;#########################################################################
ClipPut($url)
$newurl=ClipGet()
MsgBox($MB_SYSTEMMODAL,“,$newurl)

下面是一个例子,说明我正在接近我想要的东西。 我得到的'整个网站'域语法本身。 现在我想CliptPut()[3]并删除MsgBox。 如何捕获[3]迭代

#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $url = CLipGet()
    Local $spliturl = StringSplit($url, '/')
    For $i = 1 To $spliturl[0] 
;#############################################################
;replace 'MsgBox()' with 'ClipPut()'    ######################
;i want to CliptPut() '[3]' only  
        MsgBox($MB_SYSTEMMODAL, "", "$spliturl[" & $i & "] - " & 
;somebody help me please    ##################################
;#############################################################
$spliturl[$i])
    Next
EndFunc
#包括
示例()
Func示例()
本地$url=CLipGet()
本地$spliturl=StringSplit($url,“/”)
对于$i=1到$spliturl[0]
;#############################################################
;将“MsgBox()”替换为“ClipPut()”######################
;我只想CliptPut()“[3]”
MsgBox($MB_SYSTEMMODAL,“,$spliturl[”&$i&“]-”和
有人帮帮我吗##################################
;#############################################################
$spliturl[$i])
下一个
EndFunc

更新

所以现在我有这个:

#include <MsgBoxConstants.au3>

; Press Esc to terminate script, Pause/Break to "pause"

Global $g_bPaused = False

HotKeySet("{PAUSE}", "HotKeyPressed")
HotKeySet("{ESC}", "HotKeyPressed")
HotKeySet("!d", "HotKeyPressed") ; alt-d
HotKeySet("!c", "HotKeyPressed") ; alt-c



While 1
    Sleep(100)
WEnd

Func HotKeyPressed()
    Switch @HotKeyPressed ; The last hotkey pressed.
        Case "{PAUSE}" ; String is the {PAUSE} hotkey.
            $g_bPaused = Not $g_bPaused
            While $g_bPaused
                Sleep(100)
                ToolTip('Script is "Paused"', 0, 0)
            WEnd
            ToolTip("")

        Case "{ESC}" ; String is the {ESC} hotkey.
            Exit

        Case "!d" ; String is the alt + d hotkey.
            ;####################################################
            ;####     this is my answer   #######################
            ;set url to the string in clipboard
            $url = CLipGet()

            ;split url into pieces divided by the '/' character
            $spliturl = StringSplit($url, '/')

            ;set $site to third value in '$spliturl'
            $site = $spliturl[3]

            ;export $site to clipboard
            ClipPut($site)
                ;####    looks like it does the trick    ##########
                ;#### does anyone have a better way?    ###########
                ;##################################################
        Case "!c" ; String is the alt + c
            $sData1 = ClipGet()
                ;"replace https://" with "" and write the result to clipboard
                $sString1 = StringReplace($sData1, "https://www.", Null)
                ClipPut($sString1)
                $sData1 = ClipGet()
            $sData2 = ClipGet()
                $sString2 = StringReplace($sData2, "https://", Null)
                ClipPut($sString2)
                $sData2 = ClipGet()
            $sData3 = ClipGet()
                ;"replace https://" with "" and write the result to clipboard
                $sString3 = StringReplace($sData3, "http://www.", Null)
                ClipPut($sString3)
                $sData3 = ClipGet()
            $sData4 = ClipGet()
                $sString4 = StringReplace($sData4, "http://", Null)
                ClipPut($sString4)
                $sData4 = ClipGet()

            ;##################################################

    EndSwitch
EndFunc   ;==>HotKeyPressed
#包括
; 按Esc键终止脚本,暂停/中断至“暂停”
全局$g_bPaused=False
热键集(“{PAUSE}”,“热键按下”)
热键集(“{ESC}”,“热键按下”)
热键集(“!d”,“热键按下”);alt-d
热键集(“!c”,“热键按下”);丙氨酸氨基转移酶
而1
睡眠(100)
温德
Func热键按下()
开关@热键按下;最后按下的热键。
案例“{PAUSE}”;字符串是{PAUSE}热键。
$g_bPaused=非$g_bPaused
而$g_b是
睡眠(100)
工具提示('脚本已“暂停”,0,0)
温德
工具提示(“”)
案例“{ESC}”;字符串是{ESC}热键。
出口
案例“!d”;字符串是alt+d热键。
;####################################################
;####     这是我的答案#######################
;将url设置为剪贴板中的字符串
$url=CLipGet()
;将url拆分为由“/”字符分隔的部分
$spliturl=StringSplit($url,'/'))
;将$site设置为“$spliturl”中的第三个值
$site=$spliturl[3]
;将$site导出到剪贴板
ClipPut($site)
;####    看来它成功了##########
;#### 有人有更好的方法吗###########
;##################################################
案例“!c”;字符串是alt+c
$sData1=ClipGet()
;将https://“替换为“”,并将结果写入剪贴板
$sString1=StringReplace($sData1,”https://www.“,空)
ClipPut($sString1)
$sData1=ClipGet()
$sData2=ClipGet()
$sString2=StringReplace($sData2,“https://”,Null)
ClipPut($sString2)
$sData2=ClipGet()
$sData3=ClipGet()
;将https://“替换为“”,并将结果写入剪贴板
$sString3=StringReplace($sData3,”http://www.“,空)
ClipPut($sString3)
$sData3=ClipGet()
$sData4=ClipGet()
$sString4=StringReplace($sData4,“http://”,Null)
ClipPut($sString4)
$sData4=ClipGet()
;##################################################
终端开关
EndFunc;==>热键
将变量设置为ClipGet() 示例:
Local$url=ClipGet()

使用StringSplit()拆分从ClipGet()返回的字符串 使用“/”作为StringSplit()的除味器 示例:
Local$spliturl=StringSplit($url,“/”)

将另一个变量设置为StringSplit($yourVariable,“/”)创建的数组中的第三个值 示例:
Local$site=$spliturl[3]

将该值发送回剪贴板 示例
ClipPut($site)

拍拍自己的肩膀,干得好

说明:在步骤b)中,您正在生成和排列子字符串。 在步骤c)中,从数组中选择所需的子字符串并将其放入变量中。 剩下的是蛋糕。

#包括
#include <array.au3>

$x = _ShortenUrl("https://stackoverflow.com/questions/59360429/how-do-i-load-a-variable-containing-the-arguments-of-clipget-into-an-array-of")
ConsoleWrite($x & @CRLF)

$x = _ShortenUrl("how do i load a variable containing the arguments of clipget into an array of ...")
ConsoleWrite($x & @CRLF)

Func _ShortenUrl($string)
    $url = StringRegExp($string, "(?i)(^https?://[^/]*)", 3)
    If Not @error Then $string = $url[0]
    Return $string
EndFunc   ;==>_ShortenUrl
$x=_ShortenUrl(“https://stackoverflow.com/questions/59360429/how-do-i-load-a-variable-containing-the-arguments-of-clipget-into-an-array-of") 控制台写入($x&@CRLF) $x=_ShortenUrl(“如何将包含clipget参数的变量加载到…”数组中) 控制台写入($x&@CRLF) Func_ShortenUrl($string) $url=StringRegExp($string,“(?i)(^https?://[^/]*)”,3) 如果不是@error,则$string=$url[0] 返回$string EndFunc;==>_短发
使用正则表达式获取所需字符串:
(?i)
不区分大小写
^
行的开头
https?://
http://
[^/]*
在下一个
/