Jump to content

Input right click copy blocking?


Recommended Posts

I want to block right click on  Input2

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 799, 216)
$Input1 = GUICtrlCreateInput("", 72, 48, 641, 21)
$Input2 = GUICtrlCreateInput("",72, 88, 649, 21,2305);Input2 right click copy blocking
$Input3 = GUICtrlCreateInput("", 72, 128, 649, 21)
$Button1 = GUICtrlCreateButton("Button1", 72, 160, 75, 25)
$aCopy = GUICtrlCreateButton("C", 727, 86, 35, 25)
GUISetState(@SW_SHOW)
Local $input0
While 1
  $inputcontrol = GUICtrlRead($Input1)
  If $inputcontrol <> $input0 Then
    GUICtrlSetData($Input2,_GenerateID())
    $input0 = $inputcontrol
  EndIf
  $nMsg = GUIGetMsg()
  Switch $nMsg
    Case $GUI_EVENT_CLOSE
      Exit

      Case $Button1
                If guictrlread($input1) = "" or guictrlread($Input3) = "" Then
                MsgBox(0,"Error", "No entered",5)
                Else
                    MsgBox(48,"Ok","OK",5)
                EndIf

      Case $aCopy
          If guictrlread($input1) = "" Then
              MsgBox(48,"Error","No entered",5)
              Else
            ClipPut(GUICtrlRead($Input2))
ToolTip('Copied ok..')
            Sleep(500)
            ToolTip("")
EndIf
  EndSwitch
WEnd

Func _GenerateID()
    $Characters = StringSplit("ABCDEF0123456789", "")
    $Addrand = ""
    For $I = 1 To 15
            $Addrand &= $Characters[Random(1, 16, 1)]
    Next
    Return $Addrand
EndFunc

 

Link to comment
Share on other sites

I guess this is not a problem right?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIShellEx.au3>
$Form1 = GUICreate("Form1", 799, 216)
$Input1 = GUICtrlCreateInput("", 72, 48, 641, 21)

Local $Input2 = GUICtrlCreateInput("",72, 88, 649, 21,2305);Input2 right click copy blocking
Local $hMyedit = GUICtrlGetHandle( $Input2 )

$Input3 = GUICtrlCreateInput("", 72, 128, 649, 21)
$Button1 = GUICtrlCreateButton("Button1", 72, 160, 75, 25)
$aCopy = GUICtrlCreateButton("C", 727, 86, 35, 25)

  Local $pEditCallback = DllCallbackGetPtr( DllCallbackRegister( "EditCallback", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) )
  _WinAPI_SetWindowSubclass( $hMyedit, $pEditCallback, 1, 0 ) ; $iSubclassId = 1, $pData = 0

GUISetState(@SW_SHOW)
Local $input0
While 1
  $inputcontrol = GUICtrlRead($Input1)
  If $inputcontrol <> $input0 Then
    GUICtrlSetData($Input2,_GenerateID())
    $input0 = $inputcontrol
  EndIf
  $nMsg = GUIGetMsg()
  Switch $nMsg
    Case $GUI_EVENT_CLOSE
      Exit

      Case $Button1
                If guictrlread($input1) = "" or guictrlread($Input3) = "" Then
                MsgBox(0,"Error", "No entered",5)
                Else
                    MsgBox(48,"Ok","OK",5)
                EndIf

      Case $aCopy
          If guictrlread($input1) = "" Then
              MsgBox(48,"Error","No entered",5)
              Else
            ClipPut(GUICtrlRead($Input2))
ToolTip('Copied ok..')
            Sleep(500)
            ToolTip("")
EndIf
  EndSwitch
WEnd

Func _GenerateID()
    $Characters = StringSplit("ABCDEF0123456789", "")
    $Addrand = ""
    For $I = 1 To 15
            $Addrand &= $Characters[Random(1, 16, 1)]
    Next
    Return $Addrand
EndFunc

Func EditCallback( $hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData )
  ; If $iMsg <> $WM_RBUTTONUP then call next function in subclass chain (this forwards messages to Edit control)
  If $iMsg <> $WM_RBUTTONUP Then Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0]
  Return 0 ; If $iMsg = $WM_RBUTTONUP then cancel the message by returning 0
EndFunc

 

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