Sign in to follow this  
Followers 0
simhabitton

Question about if function with copy/paste

2 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0