Jump to content

ClipGet


Recommended Posts

Hi guys

I've got a problem

Func AddText10()
    Send("^c")
        $SelectedText = ClipGet()
    $Replace=""
    $SelectedText=StringReplace($SelectedText, ' ',$Replace)
    $hFile = FileOpen("BanList.txt", 1)
        FileWriteLine($hFile, $slash&$banstring&" "&$SelectedText&" 10")
    FileClose($hFile)
EndFunc

My idea is that the person using the program should select a word and then press "1" and then a line "/ban word 10" should appear in banlist.txt

So here when 1 is pressed it sends ctrl+c and stuff gets put on clipboard.

this works on Windows 7 if run as an administrator but doesn't work on XP? Can anyone please give some advice on how to solve this problem or maybe achieve the same result using a different method?

Also

Although I've specified "/" as Ascii code, if a russian keyboard is turned on instead of english it just writes "|" instead. Anyway to solve this problem?

$slash= Chr ( 47 )
$banstring=String("ban")
FileWriteLine($hFile, $slash&$banstring&" "&$SelectedText&" 10")

so this comes out as |ban word 10 instead of /ban word 10

Any help would be appreciated - thanks!

Link to comment
Share on other sites

Put some error checking in to find out where things are going wrong.

msgbox or consolewrite after the clipget, to check it's copying.

Same after your white space strip [ have you seen StringStripWS btw?].

Also, is the file opening? Do you need the full path here? Chech with

If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
after the fileopen command.

Much of what I've learned over the last year or so is accompanied by commented-out msgboxes, arraydisplays etc where I've done some trial and error work!

William

Link to comment
Share on other sites

You should have also posted the part of your code where you set the hotkey so we could see if something was wrong there.

This seems to work fine for me.

HotKeySet("{1}", "AddText10")
HotKeySet("{Esc}", "_Quit")
While 1
    Sleep(5)
WEnd

Func AddText10()
    HotKeySet("{1}")
    Send("^c")
        $SelectedText = ClipGet()
    $Replace=""
    $SelectedText=StringReplace($SelectedText, ' ',$Replace)
    $hFile = FileOpen("BanList.txt", 1)
        FileWriteLine($hFile, $slash&$banstring&" "&$SelectedText&" 10")
    FileClose($hFile)
    HotKeySet("1", "addText10")
EndFunc

Func _Quit()
    HotKeySet("{1}") ;; These HotKeySet() Lines are for safety only
    HotKeySet("{Esc}")
    Exit
EndFunc
Are you sure you used some method to keep the script running until you wanted to close it. I used the While 1 loop to do that.

EDIT: Minor code change for consistency.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thanks for your replies guys

My script for Send("^c") works perfectly on windows 7, but on XP for some reason it doesn't. I will try using Send("^{c}") in the mean time and see what happens.

Could anyone else suggest a different method how i could copy selected text to clipboard?

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