Jump to content

Question about if function with copy/paste


Recommended Posts

Hey :)

im pretty new to AutoIt and i have a question,

How can i do that the code will check if the clipboard is empty or with content

for example,

i built a program that has 10 buttons, each button relate to a text box that contain url addresses (of sports websites)

each button copy to clipboard the url that inside the textbox (1,2,3 etc)

some of them are empty sometimes (i edit them for testing or for updates)

Then it paste it to Url box address inside the software and press "Go".

the problem is, if it copied an empty textbox the program will give it an error and autoit wont continue

the is a solution that autoit will check if the clipboard is empty or with content?

something like:

If $clipboard <> "0" Then
MouseClick("Left",72,269) ;Continue to the next address
ElseIf $clipboard <> "1" Then
Send("{CTRLDOWN}v{CTRLUP}")
EndIf

I tried many ways but no success so far

There is anything like that?

Any solution would be welcome! 

Thanks!

Edited by simhabitton
Link to comment
Share on other sites

A tip:

easy/simple way...

Local $mClipBoard = ClipGet()
Switch @error
    Case 0 ; no error
        ConsoleWrite("$mClipBoard[ " & $mClipBoard & " ]" & @LF)
    Case 1
        ConsoleWrite("Clipboard is empty" & @LF)
    Case 2
        ConsoleWrite("Contains a non-text entry" & @LF)
    Case 3, 4
        ConsoleWrite("Cannot access the clipboard." & @LF)
    Case Else ; oh! this impossible!
        ConsoleWrite("unknow" & @LF)
EndSwitch

I like this way...

Local $mClipBoard = ClipGet()
If @error Then
    ; some error occurred
    Switch @error
        Case 1
            ConsoleWrite("Clipboard is empty" & @LF)
        Case 2
            ConsoleWrite("Contains a non-text entry" & @LF)
        Case 3, 4
            ConsoleWrite("Cannot access the clipboard." & @LF)
        Case Else ; oh! this impossible!
            ConsoleWrite("unknow" & @LF)
    EndSwitch
Else
    ; success
    ConsoleWrite("$mClipBoard[ " & $mClipBoard & " ]" & @LF)
EndIf
Edited by Detefon

Visit my repository

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...