Jump to content

Recommended Posts

Posted

Is there a better way than periodically monitor clipboard (using clipget or something?) to see if the clipboard contains certain string in it.

Thanks.

Posted (edited)

I don't know if this is what you want...

$String = "Test"; Change test to what your looking to find in the clipboard.
    $Result = StringInStr(ClipGet(), $String)
    
    If $Result > 0 Then
        MsgBox("", "Match", "Substring found.")
    Else
        MsgBox("", "No Match", "No substring found.")
    EndIf

Just modify it to your needs..

Edited by Sardith

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Posted

Yea that's what I'm using. Thanks.

My autoit script is taking about 5500 K in Task Manager -- does that sound a bit much?

If so, is there a way to bring it down? It's a standard GUI script that monitors clipboard every .1 seconds... maybe I can lower it to .5 seconds but I doubt it'll change anything. Right?

Thanks.

Posted

For changing RAM usage you might want to try to take out as much script as possible. For example if you use the GuiConstans.au3 take all the constants you need and place them in you actual code and take out the #include line...

I'm just making a logical assumption that less constants will use less RAM, correct me if I'm wrong!

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]
Posted (edited)

Can you post your actual script?

Or just the clipboard part your using in your script? That would help us out.

Edited by Sardith

[font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]

Posted

#include <GUIConstants.au3>

Global Const $WM_DRAWCLIPBOARD = 0x0308
Global Const $WM_CHANGECBCHAIN = 0x030D

Global $origHWND

$gui = GUICreate("Clip Hook",400,400,-1,-1,BitOR($WS_CAPTION,$WS_SYSMENU))

; remember last clip viewer in queue and set our GUI as first in queue
$origHWND = DLLCall("user32.dll","hwnd","SetClipboardViewer","hwnd",$gui)
$origHWND = $origHWND[0]

GUIRegisterMsg($WM_DRAWCLIPBOARD,"OnClipBoardChange")
GUIRegisterMsg($WM_CHANGECBCHAIN,"OnClipBoardViewerChange")

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

; send notification that we no longer will be in clipboard hook queue
DLLCall("user32.dll","int","ChangeClipboardChain","hwnd",$gui,"hwnd",$origHWND)
Exit

Func OnClipBoardChange($hWnd, $Msg, $wParam, $lParam)
    ; do what you need when clipboard changes
    ToolTip(ClipGet())
    Sleep(3000)
    ToolTip("")
        ; send notification about clipboard change to next clipviewer
    dllcall("user32.dll","int","SendMessage","hWnd",$origHWND,"int",$WM_DRAWCLIPBOARD,"int",$wParam,"int",$lParam)
EndFunc

Func OnClipBoardViewerChange($hWnd, $Msg, $wParam, $lParam)
    ; if our remembered previous clipviewer is removed then we must remember new next clipviewer
    ; else send notification about clipviewer change to next clipviewer
    If $wParam = $origHWND Then
        $origHWND = $lParam
    Else
        dllcall("user32.dll","int","SendMessage","hWnd",$origHWND,"int",$WM_CHANGECBCHAIN,"hwnd",$wParam,"hwnd",$lParam)
    EndIf
EndFunc

  • 4 years later...
Posted

Hey !! I added a Format Listener Instead of a ClipBoardViewer Windows

Its a bit less complicated coz there is no need of the maintenance of the Chains.....

Here is the code

#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.6.1
Author:         Zedna (Modified By Me)
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
; Script Start - Add your code below here
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

Global $origHWND,$lastCopied='',$WM_CLIPUPDATE=0x031D,$DefMsG='__•¯¯'
$gui = GUICreate("Clip Hook",400,400,-1,-1,BitOR($WS_CAPTION,$WS_SYSMENU))
Global $label=GUICtrlCreateLabel('Clipboard Contains',30,30,340,30)
Global $label1=GUICtrlCreateEdit('Clipboard Contains',30,80,340,210)
; remember last clip viewer in queue and set our GUI as first in queue
$origHWND = DLLCall("user32.dll","int","AddClipboardFormatListener","hwnd",$gui)
$origHWND = $origHWND[0]
GUIRegisterMsg($WM_CLIPUPDATE,"OnClipBoardChange")
WinSetOnTop($gui,'',1)
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
Exit
Func OnClipBoardChange($hWnd, $Msg, $wParam, $lParam)
    ; do what you need when clipboard changes
    _write(ClipGet())
EndFunc
Func _write($data)
If $data<>$lastCopied Then
  $lastCopied=$data
  Return GUICtrlSetData($label1,$data)
Else
  Return $DefMsG
EndIf
EndFunc

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Posted (edited)

Its even a good idea MortHawt

But even though there is no change in the clipboard , the function starts when the TIMER wents out.........

On registering the message we can get as and when the change ocuured ;)

Hope that this helps u out

Regards

Phoenix XL

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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
  • Recently Browsing   0 members

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