Jump to content

Need help with simple Autoit project


8218
 Share

Recommended Posts

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?

Link to comment
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

Link to comment
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

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

Monkey's are, like, natures humans.

Link to comment
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.

Link to comment
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.

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