Jump to content

How to change MsgBox and CTRL+C action


Recommended Posts

Hello!

By default when a message box is popped up and you press CTRL+C it will copy everything that is displayed in that message box to the clipboard, including title, and the buttons. (btw, this feature is not mentioned in the manual under MsgBox)

How do one disable this feature or better yet how to change what its copy in clipboard?

If I assign a hotkey for CTRL+C it will only work AFTER message box is closed - its not acceptable..

Thank you.

Link to comment
Share on other sites

MsgBox() blocks the current thread, which means it will be hard to do anything from the same script while it's up.

You could consider using multiple scripts to simulate multi-threading, and have one of them simply trap clipboard data with ClipGet() and ClipPut().

Edited by evilertoaster
Link to comment
Share on other sites

...(btw, this feature is not mentioned in the manual under MsgBox)...

That is not an AutoIt feature. You can do that to any standard Windows MsgBox.

...How do one disable this feature or better yet how to change what its copy in clipboard?...

You could disable the clipboard within the Windows OS or monitor the contents - when it matches what came from the MsgBox, you could replace it with the info that you want. use your main script to launch a child script to perform this monitoring.

...

If I assign a hotkey for CTRL+C it will only work AFTER message box is closed - its not acceptable..

Perhaps you meant this "is not desired". You pretty much have to accept the way that it works or design a work-around to achieve your desired outcome.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Thanks guys for the information.

maybie this(?):

$clipboard = ClipGet ()
MsgBox(0, "Title", "Text goes here")
ClipPut ($clipboard)
This would kinda work, but only after the message box is closed.

That is not an AutoIt feature. You can do that to any standard Windows MsgBox.

DOH! didn't know that!

I guess the easiest way work around would be create GUI window that looks like a message box...

Edited by vanowm
Link to comment
Share on other sites

This will work as long as you don't need a return value from the message box

_Msgbox(0,"Title","Text")

For $i = 1 to 5
    ToolTip("The script is still running " & $i)
    Sleep(1000)
Next

ToolTip("")

Func _MsgBox($iType,$vTitle,$vText,$iDelay=0)
    
    If @compiled then 
        Run(FileGetShortName(@ScriptFullPath) & ' /AutoIt3ExecuteLine  "MsgBox(' & $iType & ', ''' & $vTitle & ''', '''& $vText &''',''' & $iDelay & ''')"')
    Else
        Run (FileGetShortName(@AutoItExe) & ' /AutoIt3ExecuteLine  "MsgBox(' & $iType & ', ''' & $vTitle & ''', '''& $vText &''',''' & $iDelay & ''')"')
    EndIf
    
EndFunc

Edit: This isn't doing anything with the clipboard but your main script is still running so you can do whatever else you like while the message is on screen

Edited by ChrisL
Link to comment
Share on other sites

This one wotks with keyboard hooking, you can set a Custom Text, but you don't need to:

CODE
;"MsgBoxCustCopy.au3"

; by Prog@ndy

#include-once

#include <Misc.au3>

$_MBCustomStrgC_KeyProc_struct = "DWORD vkCode;" _

&"DWORD scanCode;" _

&"DWORD flags;" _

&"DWORD time;" _

&"ULONG_PTR dwExtraInfo"

Global $_MBCustomCtrlC_hWinHook, $_MBCustomCtrlC_ClipText, $_MBCustomCtrlC_Title, $_MBCustomCtrlC_Text

; Author: Prog@ndy

; Parameters: like MsgBox, plus 6th parameter for Optional Copy-Text.

; YOU HAVE TO CALL ONLY THIS FUNCTION

Func _MBCustomStrgC($flag, $title, $text , $timeout=0 , $hwnd=0,$TextToPut="")

$_MBCustomCtrlC_ClipText = $TextToPut

$_MBCustomCtrlC_Title = $title

$_MBCustomCtrlC_Text = $text

$CallBackProc = _MBCustomStrgC_TogglePlugKeyBoard()

Local $return = MsgBox($flag, $title, $text , $timeout , $hwnd)

_MBCustomStrgC_TogglePlugKeyBoard($CallBackProc)

Return $return

EndFunc

; from autoitscript.com , don't know which thread anymore

Func _MBCustomStrgC_TogglePlugKeyBoard($hCallProc=0)

If IsArray($_MBCustomCtrlC_hWinHook) Then

DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $_MBCustomCtrlC_hWinHook[0])

DllCallbackFree($hCallProc)

$_MBCustomCtrlC_hWinHook = ""

Return 0

EndIf

Local Const $WH_KEYBOARD_LL = 13

Local $hKeyProc = DllCallbackRegister("_MBCustomStrgC_KeyProc", "int", "int;ptr;ptr")

Local $hMod = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)

$_MBCustomCtrlC_hWinHook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", _

"int", $WH_KEYBOARD_LL, _

"ptr", DllCallbackGetPtr($hKeyProc), _

"hwnd", $hMod[0], _

"dword", 0)

Return $hKeyProc

EndFunc

; from autoitscript.com , don't know which thread anymore, but Blocking for CTRL-C added.

Func _MBCustomStrgC_KeyProc($nCode, $wParam, $lParam)

If $nCode < 0 Then

Local $iRet = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $_MBCustomCtrlC_hWinHook[0], _

"int", $nCode, _

"ptr", $wParam, _

"ptr", $lParam)

Return $iRet[0]

EndIf

;Get Hotkey

$dllstruct = DllStructCreate($_MBCustomStrgC_KeyProc_struct,$lParam)

If DllStructGetData($dllstruct,1) = 67 And _IsPressed("11") And WinActive($_MBCustomCtrlC_Title,$_MBCustomCtrlC_Text) Then

ConsoleWrite("Custom CTRl-C on MsgBox" & @CRLF)

If $_MBCustomCtrlC_ClipText <> "" Then ClipPut($_MBCustomCtrlC_ClipText)

Return 1

EndIf

;~ ConsoleWrite(DllStructGetData($dllstruct,1) & @LF)

;End

Return 0

EndFunc

#include "MsgBoxCustCopy.au3"
;#########################
; ## EXAMPLE ##
_MBCustomStrgC(0,"Test mbox","Copy only this text",0,0,"Copy only this text")
_MBCustomStrgC(0,"Test mbox","Copy NO text")

;#########################

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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