Sign in to follow this  
Followers 0
8218

Need help with simple Autoit project

13 posts in this topic

I have worked with Autoit before a long time ago, and I am now returning and in the need of a script.

It would be running in the background, and every time something is copied (CTRL+C) it would use GetClip() to see if the copied string were formatted like a MAC-Address (XX-XX-XX-XX-XX-XX) and if it was, it would remove the hyphens (-) so it would be XXXXXXXXXXXX instead.

Is this possible?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

How do I identify the event of something being copied to the Clipboard then?

Edited by 8218

Share this post


Link to post
Share on other sites

How would you know whether it is possile or not, if you don't know how?

Share this post


Link to post
Share on other sites

Look in help file WM_CLIPBOARDUPDATE message.

1 person likes this

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Look in help file WM_CLIPBOARDUPDATE message.

Thanks, I will check it out ;)

Share this post


Link to post
Share on other sites

another option

#include <Misc.au3>

local $hDLL = DllOpen("user32.dll")

While 1
      If  _IsPressed("11",$hDLL) and _IsPressed("43",$hDLL) then
          Consolewrite("CTRL+C is PRESSED" & @crlf)
        ;here some Regular Expression to check MAC format

          EndIf



    Sleep(100)
WEnd

saludos


 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
Share on other sites

Since I never new Andreik's solution, I made quick basic example.

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $WM_CLIPBOARDUPDATE = 0x031D
    $mygui = GUICreate("GUI", 100, 100)
    DllCall("User32.dll", "bool", "AddClipboardFormatListener", "hwnd", $mygui)
    If @error Then
        Exit MsgBox(0, "Error", "DllCall")
    EndIf
    GUIRegisterMsg($WM_CLIPBOARDUPDATE, "MY_WM_CLIPBOARDUPDATE")
    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example


Func MY_WM_CLIPBOARDUPDATE($hWnd, $Msg, $wParam, $lParam)
    MsgBox(0, "Success", "Clipboard data changed")
EndFunc   ;==>MY_WM_CLIPBOARDUPDATE
1 person likes this

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Update.

Probably wise to remove listener.

#include <GUIConstantsEx.au3>

OnAutoItExitRegister("_Exit")

Global $mygui

Example()

Func Example()
    Local $WM_CLIPBOARDUPDATE = 0x031D
    $mygui = GUICreate("GUI", 100, 100)
    DllCall("User32.dll", "bool", "AddClipboardFormatListener", "hwnd", $mygui)
    If @error Then
        Exit MsgBox(0, "Error", "DllCall")
    EndIf
    GUIRegisterMsg($WM_CLIPBOARDUPDATE, "MY_WM_CLIPBOARDUPDATE")
    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
    WEnd
EndFunc   ;==>Example


Func MY_WM_CLIPBOARDUPDATE($hWnd, $Msg, $wParam, $lParam)
    MsgBox(0, "Success", "Clipboard data changed")
EndFunc   ;==>MY_WM_CLIPBOARDUPDATE

Func _Exit()
    DllCall("User32.dll", "bool", "RemoveClipboardFormatListener", "hwnd", $mygui)
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Thanks Andreik and JohnOne, I've created the script now, thanks a lot for the help.

Share this post


Link to post
Share on other sites

And the clipboard should be modified something like this:

Func MY_WM_CLIPBOARDUPDATE($hWnd, $Msg, $wParam, $lParam)
    Local $vData = ClipGet()
    If StringRegExp($vData,'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$',0) Then
        ClipPut(StringUpper(StringReplace($vData,'-','')))
    EndIf
EndFunc   ;==>MY_WM_CLIPBOARDUPDATE

When the words fail... music speaks

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