Jump to content

Looping And Reading Clipboard Text


Recommended Posts

I need autoit to read the text that I have copied ,add it to variable and if it contains text "152t34" to do action

and Repeat it Self Forever

all other comands have been made but I cant do those ones...

Edited by saio
Link to comment
Share on other sites

ClipGet?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Looks good. Is your problem solved now?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

If StringInStr($text, "152t34") > 0 Then
  ; Action 1
Else
  ; Action 2
EndIf

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Then the string "152t34" was not found in the clipboard.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Check While/WEnd.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Ok What I do Wrong The Text is there it goes to Action 2 on the if and it stays active and does not start again...

$i = 7
$lookfor = ("152t34")
ShellExecute ("C:Program FilesMozilla Firefoxfirefox.exe", "MyURL.com" )
Sleep(10000)
Send("{CTRLDOWN}")
Send("{A down}")
Send("{CTRLUP}")
Send("{A UP}")
Send("{CTRLDOWN}")
Send("{C down}")
Send("{CTRLUP}")
Send("{C UP}")
Local $text = ClipGet()
If StringInStr($text, $lookfor) > 0 Then
   ProcessClose ("C:Program FilesMozilla Firefoxfirefox.exe")
Else
Send("{CTRLDOWN}")
Send("{W down}")
Send("{CTRLUP}")
Send("{W UP}")
EndIf
Local $i = 0
While $i <= 10
   wend
Link to comment
Share on other sites

Haven't tested the code. Hit Escape to quit.

HotKeySet("{Esc}", "_Exit")

;$i = 7
$lookfor = ("152t34")
ShellExecute ("C:Program FilesMozilla Firefoxfirefox.exe", "MyURL.com" )
Sleep(10000)

While 1
    Send("^a")
    ;Send("{CTRLDOWN}")
    ;Send("{A down}")
    ;Send("{CTRLUP}")
    ;Send("{A UP}")
    
    Send("^c")
    ;Send("{CTRLDOWN}")
    ;Send("{C down}")
    ;Send("{CTRLUP}")
    ;Send("{C UP}")

    $text = ClipGet()
    If StringInStr($text, $lookfor) Then
       ProcessClose ("C:Program FilesMozilla Firefoxfirefox.exe")
       ExitLoop
   Else
        Send("^w")
        ;Send("{CTRLDOWN}")
        ;Send("{W down}")
        ;Send("{CTRLUP}")
        ;Send("{W UP}")
    EndIf
    Sleep(3000) ; Repeats action every three seconds.
;Local $i = 0
;While $i <= 10
WEnd

Func _Exit()
    Exit
EndFunc

I have slowed this script right down so you can see if it is really what you want. All it does for me is close all firefox tabs. You may wish to exit the script when all Firefox tabs have closed. Look at WinExisits in the help file.

Edited by czardas
Link to comment
Share on other sites

Haven't tested the code. Hit Escape to quit.

HotKeySet("{Esc}", "_Exit")

;$i = 7
$lookfor = ("152t34")
ShellExecute ("C:Program FilesMozilla Firefoxfirefox.exe", "MyURL.com" )
Sleep(10000)

While 1
    Send("^a")
    ;Send("{CTRLDOWN}")
    ;Send("{A down}")
    ;Send("{CTRLUP}")
    ;Send("{A UP}")
    
    Send("^c")
    ;Send("{CTRLDOWN}")
    ;Send("{C down}")
    ;Send("{CTRLUP}")
    ;Send("{C UP}")

    $text = ClipGet()
    If StringInStr($text, $lookfor) Then
       ProcessClose ("C:Program FilesMozilla Firefoxfirefox.exe")
       ExitLoop
   Else
        Send("^w")
        ;Send("{CTRLDOWN}")
        ;Send("{W down}")
        ;Send("{CTRLUP}")
        ;Send("{W UP}")
    EndIf
    Sleep(3000) ; Repeats action every three seconds.
;Local $i = 0
;While $i <= 10
WEnd

Func _Exit()
    Exit
EndFunc

I have slowed this script right down so you can see if it is really what you want. All it does for me is close all firefox tabs. You may wish to exit the script when all Firefox tabs have closed. Look at WinExisits in the help file.

Nop Same Result...
Link to comment
Share on other sites

Hmm, I don't get what you mean? The result is not the same. It either closes all firefox tabs one after the other, or it closes the current tab when the text 152t34 is encountered. This was the result of fixing most of the errors I found in your code. That is probably not what you want it to do, but I'm unable to guess that part.

Edited by czardas
Link to comment
Share on other sites

Okay I don't get it CTRL + W closes a tab in firefox. That was in the code you gave. Anyway you can test the loop is working like this. Run the code and then copy it to the clipboard again. See what happens.

HotKeySet("{Esc}", "_Exit")

ClipPut("") ; First empty the clipboard.
$lookfor = ("152t34")
$iLoopCount = 0
While 1
    $text = ClipGet()
    If StringInStr($text, $lookfor) Then
        ExitLoop
    Else
        $iLoopCount += 1
    EndIf
    Sleep(100) ; Repeats actions 10 times per second.
WEnd

MsgBox(0,"152t34", "Found after " & @LF & $iLoopCount & " loops")

Func _Exit()
    Exit
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...