Jump to content

Recommended Posts

Posted (edited)

Like the Title says.

My goal is to change the default behaviour of Scite (move dragged text if you drag only with the mouse and copy the text if you press Ctrl while dragging), to that bahaviour that you copy the text if you only drag, and move the text if you press shift while dragging.

Why?

I created a Scite assist script that will do the following action:

- If you press the middle mouse button over a word in scite(marked or not), it will select the word and behave like you would normally drag the word with the left mouse button.

- While the middle mouse button is pressed, you can type any abbreviation ie. "cw" (Consolewrite)

and if you let go, it will insert that abbreviation and insert the dragged text into it.

You can imagine that pressing ctrl while holding the mouse button and typing in the abbrev letters is a bit of a problem and workflow killer, so it would be cool if it would copy the text by default.

I have read a bit in MSDN but this is a little over my horizon: http://msdn.microsoft.com/en-us/library/windows/desktop/ms692464%28v=vs.85%29.aspx

http://msdn.microsoft.com/en-us/library/ms693457%28VS.85%29.aspx

The other thing is that i dont know how to hook into the scite window messages or if this is possible after all.

Maybe it is possible to write a scite lua script to assist with that issue?

Im open for any hint.

Oh and here is my unfinished script. Its working like i want it to, but its a lot MouseClick and MouseDown and set switches to execute in mainloop and so on. I would appreciate a more efficient solution.

#Include <Array.au3>
#Include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Misc.au3>
;~ opt("MouseClickDragDelay",10)
Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo"
Dim $KeyChangedArr[256]
Dim $KeyPressedArr[256]
$XBut1 = 0
$XBut2 = 0
$MBut = ""
$charbuffer = ""
$Wheeltimer = TimerInit()
$ArrDis = 0
$SciteRecv = ""
Dim $MousePos[2]
Dim $VarSortArr[10][2]
;~ Opt("GUIOnEventMode", 1)
Opt("TrayAutoPause", 0)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown.
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "ExitF")

$SciteW_hwnd = WinGetHandle("[CLASS:SciTEWindow]")
$SciteWC_hwnd = ControlGetHandle("[CLASS:SciTEWindow]","","Scintilla1")
$Scite_hwnd = WinGetHandle("DirectorExtension")
$My_Hwnd = GUICreate("SciTE interface", 400, 600, 10, 10); For communication with Scite
GUIRegisterMsg($WM_COPYDATA, "MY_WM_COPYDATA"); For communication with Scite
HotKeySet("{ESC}", "ExitF")
OnAutoItExitRegister("ExitF")
; ### Register Mouse Hook ###
$hMouseProc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr")
$hMouseHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($hMouseProc), _WinAPI_GetModuleHandle(0))
; ###########################
; ### Register Keyboard Hook ###
$hKeyProc = DllCallbackRegister("_KeyProc", "long", "int;wparam;lparam")
$hKeyHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hKeyProc), _WinAPI_GetModuleHandle(0))
; ###########################

Func MouseEvent($wParam, $ptx, $pty, $mouseData, $flags)
;~  If not ($wParam = $WM_MOUSEMOVE) Then ConsoleWrite("Mevent: "&$wParam &", Data: "&$mouseData  & ", Flags: " &$flags  & @CRLF)
;~  Local $_blocked = 1; block mouse event by default if not explicit allowed in the case statement for this event
Local $_blocked = 0; allow mouse event by default if not explicit denied in the case statement for this event
if WinActive($SciteW_hwnd) and $flags = 0 Then
;~   if $flags then Return $_blocked
  Switch $wParam
   Case $WM_MOUSEWHEEL
    $Wheeltimer = TimerInit()
   case 0x020B ; Xbutton1 dwn
    If $mouseData = 65536 Then
     $XBut1 = 1
     $charbuffer = ""; to see if we type anything while pressed
    Elseif $mouseData = 131072 Then ; Xbutton2 dwn
     $XBut2 = 1
    EndIf
   case 0x020C ; Xbutton1 up
    If $mouseData = 65536 Then
     if $charbuffer = "" Then
      $l_sw = SendSciTE_GetInfo($My_Hwnd, $Scite_hwnd, "askproperty:CurrentSelection")
      if $l_sw = "" Then
       ControlSend($SciteW_hwnd,"","",'{ASC 34}{ASC 34}{LEFT}'); send: "" and put cursor in middle
      Else
       SendSciTE_Command($My_Hwnd, $Scite_hwnd, "insert:"&'"'&$l_sw&'"'); insert
;~      ControlSend($SciteW_hwnd,"","",'"'&$l_sw&'"')
      EndIf
;~     send('{ASC 34}') ; send: " (if we didnt type anything while pressed)
      $XBut1 = 0
     Else
      $XBut1 = "abbrevcheck"
     EndIf
    Elseif $mouseData = 131072 Then ; Xbutton2 up
     $XBut2 = 0
     send('{ASC 38}') ; send: &
    EndIf
   case 0x0207 ; $WM_MBUTTONDOWN
    $MBut = "pressed"
    $charbuffer = ""; to see if we type anything while pressed
    $MousePos = MouseGetPos()
    $MousePos = MouseGetPos()
   case 0x0208 ; $WM_MBUTTONUP
    If $MBut = "drag" or $MBut = "dragctrldown" Then

     ControlSend($SciteW_hwnd,"","","{ESC}"); Abort the Windows Drag&Drop
;~    send("{ESC down}")
;~    Sleep(100)
;~    send("{ESC up}")
     MouseUp("left")
;~    Send("{ASC 0xA3 up}")
     $MBut = "abbrevcheck"; Execute abbrev check in Main Loop
    ElseIf TimerDiff($Wheeltimer) > 200 Then
     send('{ASC 91}{ASC 93}{left}') ; send: [] and put cursor in middle
    EndIf

   Case $WM_MOUSEMOVE
    if $MBut = "pressed" Then
     $tMpos = MouseGetPos()
     If abs($MousePos[0] - $tMpos[0]) > 1 or  abs($MousePos[1] - $tMpos[1])  > 1 Then; If we draged with Middle Button 1 pixel
      MouseUp("middle")
;~     MouseClick("left")
;~     SendSciTE_Command($My_Hwnd, $Scite_hwnd,"extender:dostring editor:SetSel(editor:WordStartPosition(editor.CurrentPos, true),editor:WordEndPosition(editor.CurrentPos, true))")
;~     sleep(50)
      ; This is actually faster, but baby what a clickfest, and this inside a winproc function..
      MouseClick("left")
      MouseClick("left")
      MouseMove($tMpos[0]+5,$tMpos[1],0); Cant click 3 times with mouse on same spot, this would cause "select whole line", so move it a little
      MouseDown("left") ; Emulated Drag start
      $MBut = "drag"
     EndIf
    EndIf
    Case $WM_LBUTTONUP,$WM_RBUTTONUP
    Return $_blocked ; <--- Comment out to enable Array Live Display on Variable Click
    $Sciteword = SendSciTE_GetInfo($My_Hwnd, $Scite_hwnd, "askproperty:CurrentWord")
;~   ConsoleWrite($Sciteword & @CRLF)
    For $i = 0 To UBound($VarSortArr)-1
     $VarSortArr[$i][1] = round($VarSortArr[$i][1],1) ; to clear floating point errors
     if $VarSortArr[$i][1] then $VarSortArr[$i][1] -= 0.2 ; update frequency value
    next
    $isVarArr = StringRegExp($Sciteword,"A$w+?Z",3); only word
    if IsArray($isVarArr) Then
     $isVarArr = $isVarArr[0]
     ConsoleWrite($isVarArr & @CRLF)
     SortIntoArray($isVarArr)
     _AD($VarSortArr,"") ; Display the Recent Variables Array
    else
    EndIf

;~   Case $WM_LBUTTONUP
;~   Case $WM_RBUTTONDOWN
;~   Case $WM_RBUTTONUP
;~  Case Else
;~  ConsoleWrite("Mevent: "&$wParam &", Data: "&$mouseData  & ", Flags: " &$flags  & @CRLF)
;~  If $flags Then $_blocked = 0 ;-> proceed normal
  EndSwitch
EndIf
Return $_blocked
EndFunc

Func KeyEvent($keycode, $scancode, $flags, $char)
;~  Local $_blocked = 1; block key event by default if not explicit allowed in the case statement for this event
Local $_blocked = 0; allow key event by default if not explicit denied in the case statement for this event
Local $_UD = _Iif((BitAND($flags,128) = 0),"D",False)
Switch $KeyChangedArr[$keycode]
  Case $_UD,"G"
   $KeyChangedArr[$keycode] = False
   If $_UD = "D" Then $KeyChangedArr[$keycode] = "G"
  Case Else
   $KeyChangedArr[$keycode] = $_UD
EndSwitch
$KeyPressedArr[$keycode] = (BitAND($flags,128) = 0)
$chrchar = chr($char)
if number($char) = 0 then $chrchar = "NUL"
;~  ConsoleWrite("VK: 0x"& Hex($keycode,2) & ", SC: "&Hex($scancode,3)&@tab&", Char: "&$chrchar&"("& $char&")"&@tab&@tab&" " &@tab&" Changed: "&$KeyChangedArr[$keycode]&@tab&" Pressed: "&$KeyPressedArr[$keycode]& @CRLF)
;~  ConsoleWrite(@tab&"extended-key:" &@tab&@tab&BitAND($flags,$LLKHF_EXTENDED) &@crlf)
;~  ConsoleWrite(@tab&"injected flag:" &@tab&@tab&BitAND($flags,$LLKHF_INJECTED) &@crlf)
;~  ConsoleWrite(@tab&"context code(ALT DOWN):" &@tab&BitAND($flags,$LLKHF_ALTDOWN) &@crlf)
;~  ConsoleWrite(@tab&"transition state(UP):" &@tab&BitAND($flags,$LLKHF_UP) &@crlf)

#cs #### OnKey Switch Code #####
If WinActive($SciteW_hwnd) Then
  Switch $keycode
   Case 0x0D ; Enter
    if $KeyChangedArr[$keycode] Then; block any Enter event
;~    ConsoleWrite("oh mann" & @CRLF)
;~    $Sciteword = SendSciTE_Command($My_Hwnd, $Scite_hwnd, 'macrolist:Test Test1')
;~    $Sciteword = SendSciTE_Command($My_Hwnd, $Scite_hwnd,"extension:editor.GotoPos(184)")
;~    $Sciteword = SendSciTE_Command($My_Hwnd, $Scite_hwnd,"extender:dostring editor:SetSel(editor:WordStartPosition(editor.CurrentPos, true),editor:WordEndPosition(editor.CurrentPos, true))")
     $Sciteword = SendSciTE_GetInfo($My_Hwnd, $Scite_hwnd, "askproperty:CurrentWord")
     ConsoleWrite($Sciteword & @CRLF)
;~    $ArrDis = 1
     $_blocked = 1
     Return $_blocked
    EndIf
  EndSwitch
  If $KeyPressedArr[$keycode] Then; any key DOWN event
   if not BitAND($flags,$LLKHF_EXTENDED) and ($XBut1 or $MBut) Then
    $charbuffer &= chr($char)
    $_blocked = 1
   EndIf
  EndIf
EndIf
#ce
Return $_blocked
EndFunc
; ######## Main Loop ########
While 1
Sleep(10)
If $MBut = "abbrevcheck" Then
  $Sciteword = SendSciTE_GetInfo($My_Hwnd, $Scite_hwnd, "askproperty:CurrentSelection")
  MouseClick("left"); We sent ESC but then cursor will be on the start drag position, so click 1 time so reset cursor
  If $charbuffer Then ; did we type anything while button was pressed
   ConsoleWrite("M Open Abbrev Win.." & @CRLF)
   ControlSend($SciteW_hwnd,"","","^+{r}")
;~   SendSciTE_Command($My_Hwnd, $Scite_hwnd, "menucommand:247"); blocks execution of script :-
   While 1
    if WinExists("Insert Abbreviation") then ExitLoop
    Sleep(50)
   WEnd
   ControlSend($SciteW_hwnd,"","",$charbuffer&"{Enter}")
   $charbuffer = ""
   sleep(50)
  EndIf
;~   if $Sciteword then ControlSend($SciteW_hwnd,"","",$Sciteword)
  ; This is faster
  if $Sciteword then SendSciTE_Command($My_Hwnd, $Scite_hwnd, "insert:"&$Sciteword); insert Text
  $MBut = ""
EndIf
if $XBut1 = "abbrevcheck" and $charbuffer Then ; did we type anything while button was pressed
  ConsoleWrite("gi" & @CRLF)
  $Sciteword = SendSciTE_GetInfo($My_Hwnd, $Scite_hwnd, "askproperty:CurrentSelection")
  ConsoleWrite("X Open Abbrev Win.." & @CRLF)
  ControlSend($SciteW_hwnd,"","","^+{r}"); Open Abbrev Dialoge
;~   SendSciTE_Command($My_Hwnd, $Scite_hwnd, "menucommand:247"); not usable --> blocks execution of this script :-
  While 1
   if WinExists("Insert Abbreviation") then ExitLoop
   Sleep(50)
  WEnd
  ControlSend($SciteW_hwnd,"","",$charbuffer&"{Enter}")
  sleep(50)
  if $Sciteword = "" then SendSciTE_Command($My_Hwnd, $Scite_hwnd, "menucommand:205"); Paste
  $charbuffer = ""
  $XBut1 = 0
EndIf

If not $charbuffer Then; nothing wrote while button down
  If $MBut = "abbrevcheck" Then
   ConsoleWrite("MainLoop: ctrlup" & @CRLF)
   $MBut = ""
  ElseIf $MBut = "drag" Then
   ConsoleWrite("MainLoop: ctrldown" & @CRLF)
   $MBut = "dragctrldown"
  EndIf
EndIf
WEnd

Func _Mouse_Proc($nCode, $wParam, $lParam) ;function called for mouse events..
    If $nCode < 0 Then
  Return _WinAPI_CallNextHookEx($hMouseHook, $nCode, $wParam, $lParam)
    EndIf
Local $info, $ptx, $pty, $mouseData, $flags, $_blocked = 1
$info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) ;used to get all data in the struct ($lParam is the ptr)
$ptx = DllStructGetData($info, 1) ;see notes below..
$pty = DllStructGetData($info, 2)
$mouseData = DllStructGetData($info, 3)
$flags = DllStructGetData($info, 4)
If MouseEvent($wParam, $ptx, $pty, $mouseData, $flags) Then Return 1
    Return _WinAPI_CallNextHookEx($hMouseHook, $nCode, $wParam, $lParam)
EndFunc   ;==>_Mouse_Proc
Func _KeyProc($nCode, $wParam, $lParam) ;function called for Key events..
;~  ConsoleWrite("$nCode: "& $nCode & ", $wParam: "& $wParam& ", $lParam: "& $lParam & @CRLF)
    Local $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam)
    If $nCode < 0 Then ;must return if $nCode less than zero or return when not Activated and not the Toggle Key
        Return _WinAPI_CallNextHookEx($hKeyHook, $nCode, $wParam, $lParam)
    EndIf
;~ DllStructGetData($tKEYHOOKS, "scanCode")
    Local $tKbdState = DllStructCreate("byte[256];") ; A pointer to a 256-byte array that contains the current keyboard state.
    Local $aResult = DllCall("user32.dll", "int", "GetKeyboardState", "ptr", DllStructGetPtr($tKbdState))
    Local $tChar = DllStructCreate("WORD buff;")
    $aResult = DllCall("user32.dll", "int", "ToAscii", "uint", DllStructGetData($tKEYHOOKS, "VkCode"), "uint", DllStructGetData($tKEYHOOKS, "scanCode"), "ptr", DllStructGetPtr($tKbdState), "ptr", DllStructGetPtr($tChar), "uint", 0)
local $sData = ""
Switch  $aResult[0]
  Case 0 ; The specified virtual key has no translation for the current state of the keyboard.
;~  $sData = "No: "&DllStructGetData($tChar, "buff")&DllStructGetData($tChar, 1)
  Case 1 ; One character was copied to the buffer.
   If BitAND(DllStructGetData($tKEYHOOKS, "flags"),$LLKHF_ALTDOWN) Then
;~   $sData = DllStructGetData($tChar, 2)&DllStructGetData($tChar, 1)
   Else
    $sData = DllStructGetData($tChar, "buff")&""
   EndIf
  Case 2 ;  Two characters were copied to the buffer. This usually happens when a dead-key character (accent or diacritic) stored in the keyboard
;~    layout cannot be composed with the specified virtual key to form a single character.
;~  $sData = "Special: "&DllStructGetData($tChar, "buff")
  case Else
   $sData = "!ERROR return value from DllCall: "&$aResult[0]
EndSwitch
If KeyEvent(DllStructGetData($tKEYHOOKS, "VkCode"), DllStructGetData($tKEYHOOKS, "scanCode") , DllStructGetData($tKEYHOOKS, "flags"), $sData) Then Return 1
    Return _WinAPI_CallNextHookEx($hKeyHook, $nCode, $wParam, $lParam)
EndFunc   ;==>_KeyProc

; Send command to SciTE
Func SendSciTE_Command($My_Hwnd, $Scite_hwnd, $sCmd)
    ConsoleWrite('-->' & $sCmd & @lf )
;~   GUICtrlSetData($list,GUICtrlRead($list) & '-->' & $sCmd & @CRLF)
    Local $CmdStruct = DllStructCreate('Char[' & StringLen($sCmd) + 1 & ']')
    DllStructSetData($CmdStruct, 1, $sCmd)
    Local $COPYDATA = DllStructCreate('Ptr;DWord;Ptr')
    DllStructSetData($COPYDATA, 1, 1)
    DllStructSetData($COPYDATA, 2, StringLen($sCmd) + 1)
    DllStructSetData($COPYDATA, 3, DllStructGetPtr($CmdStruct))
    DllCall('User32.dll', 'None', 'SendMessage', 'HWnd', $Scite_hwnd, _
            'Int', $WM_COPYDATA, 'HWnd', $My_Hwnd, _
            'Ptr', DllStructGetPtr($COPYDATA))
EndFunc  ;==>SendSciTE_Command
;
;
Func SendSciTE_GetInfo($My_Hwnd, $Scite_hwnd, $sCmd)
    $My_Dec_Hwnd = Dec(StringTrimLeft($My_Hwnd, 2))
    $sCmd = ":" & $My_Dec_Hwnd & ":" & $sCmd
    $SciteRecv = ""
    $SaveSciTECmd = "xxxxx"
    SendSciTE_Command($My_Hwnd, $SciTE_hwnd,$sCmd)
    For $x = 1 To 10
        If $SciteRecv <> "" Then ExitLoop
        sleep(20)
    Next
    $SciteRecv = StringTrimLeft($SciteRecv,StringLen(":" & $My_Dec_Hwnd & ":"))
    $SciteRecv = StringReplace($SciteRecv,"macro:stringinfo:","")
ConsoleWrite('<--' & $SciteRecv & @lf )
    Return $SciteRecv
EndFunc

; Received Data from SciTE
Func MY_WM_COPYDATA($hWnd, $msg, $wParam, $lParam)
    Local $COPYDATA = DllStructCreate('Ptr;DWord;Ptr',$lparam)
    $bufLen = DllStructGetData($COPYDATA, 2)
    Local $CmdStruct = DllStructCreate('Char[4096]',DllStructGetData($COPYDATA, 3))
    $SciteRecv = Stringleft(DllStructGetData($CmdStruct, 1),$bufLen)
;~  ConsoleWrite('<--' & $SciteRecv & @CRLF)
;GUICtrlSetData($list,GUICtrlRead($list) & '<--' & $SciteRecv & @CRLF )
EndFunc  ;==>MY_WM_COPYDATA

Func SortIntoArray($_VarString)
For $i = 0 To UBound($VarSortArr)-1
  if $VarSortArr[$i][0] = $_VarString then
;~  ConsoleWrite("Found at: "&$i  & @CRLF)
;~  $VarSortArr[$i][1] += 1
   if $VarSortArr[$i][1] <= 9 then $VarSortArr[$i][1] += 1
   FastSortItemin2DArray($VarSortArr, $i, 1)
   $i = -1
   ExitLoop
  EndIf
next
If not ($i = -1) Then; No match found, this is a new value
  For $i = 0 To UBound($VarSortArr)-1
   if (not $VarSortArr[$i][0] and not $VarSortArr[$i][0]) Then ExitLoop; We found an empty row
   if $i = UBound($VarSortArr)-1 Then; we are at last index of array and no empty row was found
    ReDim $VarSortArr[UBound($VarSortArr)+10][2]; extend array
    $i += 1 ; set $i to the next free index
    ExitLoop
   EndIf
  next
  $VarSortArr[$i][0] = $_VarString
  $VarSortArr[$i][1] = 10
;~   ConsoleWrite("Empty row at: "&$i & @CRLF)
  FastSortItemin2DArray($VarSortArr, $i, 1)
EndIf

EndFunc
Func FastSortItemin2DArray(ByRef $a_Array, $_index, $_subitem)
If $_index > 0 then; If we not already on top
  For $_index2 = $_index-1 To 0 step -1
   if $a_Array[$_index2][$_subitem] > $a_Array[$_index-1][$_subitem] Then; search for the next higher value of the newly updated value
    _ArraySwap($a_Array[$_index2+1][0], $a_Array[$_index][0]); swap with one index lower (so that we are on top of all equal values)
    _ArraySwap($a_Array[$_index2+1][1], $a_Array[$_index][1])
    If $a_Array[$_index2][$_subitem] < $a_Array[$_index2+1][$_subitem] Then
     FastSortItemin2DArray($a_Array, $_index2+1, $_subitem); Recursive execution for every higher value
    EndIf
    ExitLoop
   EndIf
   if ($_index2 = 0 and $a_Array[0][$_subitem] <= $a_Array[$_index][$_subitem]) then; special case: if $_index2 = 0 we dont have any value that is higher, so we need this check here
    _ArraySwap($a_Array[$_index2][0], $a_Array[$_index][0]); swap if first item of array is equal or lower
    _ArraySwap($a_Array[$_index2][1], $a_Array[$_index][1])
    ExitLoop
   EndIf
  next

Else
;~   ConsoleWrite("Im #1 so why try harder" & @CRLF)
EndIf
EndFunc

Func ExitF()
;~  ConsoleWrite("Exit CTRL up" & @CRLF)
;~  Send("{RCTRL down}")
;~  Send("{RCTRL up}")
;~  Send("{LCTRL down}")
;~  Send("{LCTRL up}")
    _WinAPI_UnhookWindowsHookEx($hMouseHook)
    DllCallbackFree($hMouseProc)
    _WinAPI_UnhookWindowsHookEx($hKeyHook)
    DllCallbackFree($hKeyProc)
Exit
EndFunc

Func _AD(Const ByRef $avArray, $sTitle = "Array: ListView Display", $iItemLimit = -1, $iTranspose = 0, $sSeparator = "", $sReplace = "|")
If Not IsArray($avArray) Then
  If Not IsDeclared($ADUpdArr) Then
   Return SetError(1, 0, 0)
  Else
   $avArray = $ADUpdArr
  EndIf
EndIf
; Dimension checking
Local $iDimension = UBound($avArray, 0), $iUBound = UBound($avArray, 1) - 1, $iSubMax = UBound($avArray, 2) - 1
If $iDimension > 2 Then Return SetError(2, 0, 0)
; Separator handling
;~  If $sSeparator = "" Then $sSeparator = Chr(1)
If $sSeparator = "" Then $sSeparator = Chr(124)
; Declare variables
Local $i, $j, $vTmp, $aItem, $avArrayText, $sHeader = "Row", $iBuffer = 64
Local $iColLimit = 250, $iLVIAddUDFThreshold = 4000, $iWidth = 640, $iHeight = 480
Opt("GUIOnEventMode", 1)
;~  Local $iOnEventMode = Opt("GUIOnEventMode", 0)
Local $sDataSeparatorChar = Opt("GUIDataSeparatorChar", $sSeparator)
; Swap dimensions if transposing
If $iSubMax < 0 Then $iSubMax = 0
If $iTranspose Then
  $vTmp = $iUBound
  $iUBound = $iSubMax
  $iSubMax = $vTmp
EndIf
; Set limits for dimensions
If $iSubMax > $iColLimit Then $iSubMax = $iColLimit
If $iItemLimit = 1 Then $iItemLimit = $iLVIAddUDFThreshold
If $iItemLimit < 1 Then $iItemLimit = $iUBound
If $iUBound > $iItemLimit Then $iUBound = $iItemLimit
If $iLVIAddUDFThreshold > $iUBound Then $iLVIAddUDFThreshold = $iUBound
; Set header up
For $i = 0 To $iSubMax
  $sHeader &= $sSeparator & "Col " & $i
Next
; Convert array into text for listview
Local $avArrayText[$iUBound + 1]
For $i = 0 To $iUBound
  $avArrayText[$i] = "[" & $i & "]"
  For $j = 0 To $iSubMax
   ; Get current item
   If $iDimension = 1 Then
    If $iTranspose Then
     $vTmp = $avArray[$j]
    Else
     $vTmp = $avArray[$i]
    EndIf
   Else
    If $iTranspose Then
     $vTmp = $avArray[$j][$i]
    Else
     $vTmp = $avArray[$i][$j]
    EndIf
   EndIf
   ; Add to text array
   $vTmp = StringReplace($vTmp, $sSeparator, $sReplace, 0, 1)
   $avArrayText[$i] &= $sSeparator & $vTmp
   ; Set max buffer size
   $vTmp = StringLen($vTmp)
   If $vTmp > $iBuffer Then $iBuffer = $vTmp
  Next
Next
$iBuffer += 1
; GUI Constants
Local Const $_ARRAYCONSTANT_GUI_DOCKBORDERS = 0x66
Local Const $_ARRAYCONSTANT_GUI_DOCKBOTTOM = 0x40
Local Const $_ARRAYCONSTANT_GUI_DOCKHEIGHT = 0x0200
Local Const $_ARRAYCONSTANT_GUI_DOCKLEFT = 0x2
Local Const $_ARRAYCONSTANT_GUI_DOCKRIGHT = 0x4
Local Const $_ARRAYCONSTANT_GUI_EVENT_CLOSE = -3
Local Const $_ARRAYCONSTANT_LVIF_PARAM = 0x4
Local Const $_ARRAYCONSTANT_LVIF_TEXT = 0x1
Local Const $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH = (0x1000 + 29)
Local Const $_ARRAYCONSTANT_LVM_GETITEMCOUNT = (0x1000 + 4)
Local Const $_ARRAYCONSTANT_LVM_GETITEMSTATE = (0x1000 + 44)
Local Const $_ARRAYCONSTANT_LVM_INSERTITEMA = (0x1000 + 7)
Local Const $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54)
Local Const $_ARRAYCONSTANT_LVM_SETITEMA = (0x1000 + 6)
Local Const $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT = 0x20
Local Const $_ARRAYCONSTANT_LVS_EX_GRIDLINES = 0x1
Local Const $_ARRAYCONSTANT_LVS_SHOWSELALWAYS = 0x8
Local Const $_ARRAYCONSTANT_WS_EX_CLIENTEDGE = 0x0200
Local Const $_ARRAYCONSTANT_WS_MAXIMIZEBOX = 0x00010000
Local Const $_ARRAYCONSTANT_WS_MINIMIZEBOX = 0x00020000
Local Const $_ARRAYCONSTANT_WS_SIZEBOX = 0x00040000
Local Const $_ARRAYCONSTANT_tagLVITEM = "int Mask;int Item;int SubItem;int State;int StateMask;ptr Text;int TextMax;int Image;int Param;int Indent;int GroupID;int Columns;ptr pColumns"
Local $iAddMask = BitOR($_ARRAYCONSTANT_LVIF_TEXT, $_ARRAYCONSTANT_LVIF_PARAM)
Local $tBuffer = DllStructCreate("char Text[" & $iBuffer & "]"), $pBuffer = DllStructGetPtr($tBuffer)
Local $tItem = DllStructCreate($_ARRAYCONSTANT_tagLVITEM), $pItem = DllStructGetPtr($tItem)
DllStructSetData($tItem, "Param", 0)
DllStructSetData($tItem, "Text", $pBuffer)
DllStructSetData($tItem, "TextMax", $iBuffer)
; Set interface up
global $ADUpdArr = $avArray
If $ADUpdLV Then ; if already open, only update not create
  _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ADUpdLV))
  ; Fill listview
  For $i = 0 To $iLVIAddUDFThreshold
   GUICtrlCreateListViewItem($avArrayText[$i], $ADUpdLV)
  Next
  For $i = ($iLVIAddUDFThreshold + 1) To $iUBound
   $aItem = StringSplit($avArrayText[$i], $sSeparator)
   DllStructSetData($tBuffer, "Text", $aItem[1])
   ; Add listview item
   DllStructSetData($tItem, "Item", $i)
   DllStructSetData($tItem, "SubItem", 0)
   DllStructSetData($tItem, "Mask", $iAddMask)
   GUICtrlSendMsg($ADUpdLV, $_ARRAYCONSTANT_LVM_INSERTITEMA, 0, $pItem)
   ; Set listview subitem text
   DllStructSetData($tItem, "Mask", $_ARRAYCONSTANT_LVIF_TEXT)
   For $j = 2 To $aItem[0]
    DllStructSetData($tBuffer, "Text", $aItem[$j])
    DllStructSetData($tItem, "SubItem", $j - 1)
    GUICtrlSendMsg($ADUpdLV, $_ARRAYCONSTANT_LVM_SETITEMA, 0, $pItem)
   Next
  Next
  Return
EndIf
Local $hGUI = GUICreate($sTitle, $iWidth, $iHeight, Default, Default, BitOR($_ARRAYCONSTANT_WS_SIZEBOX, $_ARRAYCONSTANT_WS_MINIMIZEBOX, $_ARRAYCONSTANT_WS_MAXIMIZEBOX))
Local $aiGUISize = WinGetClientSize($hGUI)
Local $hListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - 26, $_ARRAYCONSTANT_LVS_SHOWSELALWAYS)
GUICtrlSetResizing($hListView, $_ARRAYCONSTANT_GUI_DOCKBORDERS)
$ADUpdLV = $hListView
Local $hCopy = GUICtrlCreateButton("Copy Selected", 3, $aiGUISize[1] - 23, $aiGUISize[0]/2 - 6, 20)
GUICtrlSetResizing($hCopy, 513+64)
Local $hUpd = GUICtrlCreateButton("Update", $aiGUISize[0]/2 + 6, $aiGUISize[1] - 23, $aiGUISize[0]/2 - 6, 20)
GUICtrlSetOnEvent($hUpd,"_ADDef")
GUICtrlSetResizing($hUpd, 513+64)
GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_GRIDLINES, $_ARRAYCONSTANT_LVS_EX_GRIDLINES)
GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT)
GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE)
; Fill listview
For $i = 0 To $iLVIAddUDFThreshold
  GUICtrlCreateListViewItem($avArrayText[$i], $hListView)
Next
For $i = ($iLVIAddUDFThreshold + 1) To $iUBound
  $aItem = StringSplit($avArrayText[$i], $sSeparator)
  DllStructSetData($tBuffer, "Text", $aItem[1])
  ; Add listview item
  DllStructSetData($tItem, "Item", $i)
  DllStructSetData($tItem, "SubItem", 0)
  DllStructSetData($tItem, "Mask", $iAddMask)
  GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_INSERTITEMA, 0, $pItem)
  ; Set listview subitem text
  DllStructSetData($tItem, "Mask", $_ARRAYCONSTANT_LVIF_TEXT)
  For $j = 2 To $aItem[0]
   DllStructSetData($tBuffer, "Text", $aItem[$j])
   DllStructSetData($tItem, "SubItem", $j - 1)
   GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETITEMA, 0, $pItem)
  Next
Next
; ajust window width
$iWidth = 0
For $i = 0 To $iSubMax + 1
  $iWidth += GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH, $i, 0)
Next
If $iWidth < 250 Then $iWidth = 230
WinMove($hGUI, "", Default, Default, $iWidth + 20)
; Show dialog
GUISetState(@SW_SHOW, $hGUI)
GUISetOnEvent(-3, "delADGUI", $hGUI)
Opt("GUIDataSeparatorChar", $sDataSeparatorChar)
Return 1
EndFunc   ;==>_ArrayDisplay
Func _ADDef()
_AD($ADUpdArr)
EndFunc
Func delADGUI()
;~  Exit
GUIDelete(@GUI_WinHandle)
Global $ADUpdLV = 0
Global $ADUpdArr = 0
EndFunc
#cs Scite Director interface Stuff
askfilename:                                Return the name of the file being edited.
askproperty:<key>                          Return the value of a property.
close:                                    Close the current file.
closing:                                    Director is closing - SciTE closes if it was started by the director.
currentmacro:<string>                      Set the current macro to name.
cwd:                                        Change the working directory.
enumproperties:dyn|local|user|base|embed    Enumerate all the properties in the argument set.
exportashtml:<path>                      Save the document in HTML format as the indicated file.
exportasrtf:<path>                        Save the document in RTF format as the indicated file.
exportaspdf:<path>                        Save the document in PDF format as the indicated file.
exportaslatex:<path>                        Save the document in LaTeX format as the indicated file.
exportasxml:<path>                        Save the document in XML format as the indicated file.
extender:<command>                        Call the extension interface with the given command.
find:<string>                              Search for a string, select and show it.
focus:<timeStamp>                          On GTK+ bring this SciTE window to the front. The timeStamp is from the window manager and ensures that windows are only activated because of a user command. Has no effect on Windows as applications on Windows can only donate focus, not take focus.
goto:<lineNumber>[,<columnNumber>]        Move caret to a particular line and make it visible.
                                            If there is a column number then select the word at that column number or move the caret there if no word is present.
identity:<hwndDirector>                  Sets the director window handle to which SciTE sends messages. The argument is in decimal.
insert:<value>                            Display the value in the editor pane replacing the selection.
loadsession:<path>                        Load a session as given by the indicated file.
macrocommand:<command>                    Execute a macro command. See the SciTE source code for the syntax of the command argument.
macroenable:<enable>                        If enable, display menu commands in SciTE for recording and playing macros.
macrolist:<list>                            Display a list for the user to choose from.
menucommand:<cmd>                          Execute a menu command based on numeric ID.
open:<path>                              Open the indicated file.
output:<value>                            Display the value in the output pane replacing the selection.
property:<key>=<value>                    Set a property to a value.
quit:                                      Shut down SciTE.
reloadproperties:                          Reload properties from files.
replaceall:<search>000<replace>         Replace all instances of he search string in the document with the replace string.
saveas:<path>                              Save the document as the indicated file.
savesession:<path>                        Save a session as given by the indicated file.
The actions sent by SciTE are:
closed:<path>                              SciTE has closed the indicated file.
closing:                                    SciTE is closing.
dyn|local|user|base|embed:<key>=<value>  Set a property in a set to a value.
filename:<path>                          The file being edited is path. This is the reply to the askfilename: command.
identity:<hwndSciTEReceiving>              SciTE indicates to the director the window handle to which it should send messages. The argument is in decimal.
macro:getlist                              Retrieve the list of available macros which will be returned by the macrolist command.
macro:record:<details>                    Start recording a macro. See the SciTE source code for the syntax of the details argument.
macro:run:<macroName>                      Run the named macro.
macro:stoprecord                            Stop recording a macro.
opened:<path>                              SciTE has opened the indicated file.
switched:<path>                          SciTE has switched buffers to the indicated file.
saved:<path>                                SciTE has saved the indicated file.
PROPERTYS:
        FilePath                            full path of the current file
        FileDir                          directory of the current file without a trailing slash
        FileName                            base name of the current file
        FileExt                          extension of the current file
        FileNameExt                      $(FileName).$(FileExt)
        Language                            name of the lexer used for the current file
        SessionPath                      full path of the current session
        CurrentSelection                    value of the currently selected text
        CurrentWord                      value of word which the caret is within or near
        Replacements                        number of replacements made by last Replace command
        SelectionStartColumn                column where selection starts
        SelectionStartLine                line where selection starts
        SelectionEndColumn                column where selection ends
        SelectionEndLine                    line where selection ends
        CurrentMessage                    most recently selected output pane message
        SciteDefaultHome                    directory in which the Global Options file is found
        SciteUserHome                      directory in which the User Options file is found
        SciteDirectoryHome                directory in which the Directory Options file is found
        APIPath                          list of full paths of API files from api.filepattern
        AbbrevPath                        full path of abbreviations file
#ce
#cs
Here are the other values that could be useful for you:
Go = 301
Compile = 302

Complete list from the SciTE source file scite.h
// Menu IDs.
// These are located 100 apart. No one will want more than 100 in each menu
#define IDM_MRUFILE 1000
#define IDM_TOOLS 1100
#define IDM_BUFFER 1200
#define IDM_IMPORT 1300
#define IDM_LANGUAGE 1400
// File
#define IDM_NEW 101
#define IDM_OPEN 102
#define IDM_OPENSELECTED 103
#define IDM_REVERT 104
#define IDM_CLOSE 105
#define IDM_SAVE 106
#define IDM_SAVEAS 110
#define IDM_SAVEASHTML 111
#define IDM_SAVEASRTF 112
#define IDM_SAVEASPDF 113
#define IDM_FILER 114
#define IDM_SAVEASTEX 115
#define IDM_SAVEACOPY 116
#define IDM_SAVEASXML 117
#define IDM_MRU_SEP 120
#define IDM_PRINTSETUP 130
#define IDM_PRINT 131
#define IDM_LOADSESSION 132
#define IDM_SAVESESSION 133
#define IDM_QUIT 140
#define IDM_ENCODING_DEFAULT 150
#define IDM_ENCODING_UCS2BE 151
#define IDM_ENCODING_UCS2LE 152
#define IDM_ENCODING_UTF8 153
#define IDM_ENCODING_UCOOKIE 154
#define MRU_START 16
#define IMPORT_START 19
#define TOOLS_START 3

// Edit
#define IDM_UNDO 201
#define IDM_REDO 202
#define IDM_CUT 203
#define IDM_COPY 204
#define IDM_PASTE 205
#define IDM_CLEAR 206
#define IDM_SELECTALL 207
#define IDM_PASTEANDDOWN 208
#define IDM_FIND 210
#define IDM_FINDNEXT 211
#define IDM_FINDNEXTBACK 212
#define IDM_FINDNEXTSEL 213
#define IDM_FINDNEXTBACKSEL 214
#define IDM_FINDINFILES 215
#define IDM_REPLACE 216
#define IDM_GOTO 220
#define IDM_BOOKMARK_NEXT 221
#define IDM_BOOKMARK_TOGGLE 222
#define IDM_BOOKMARK_PREV 223
#define IDM_BOOKMARK_CLEARALL 224
#define IDM_BOOKMARK_NEXT_SELECT 225
#define IDM_BOOKMARK_PREV_SELECT 226
#define IDM_MATCHBRACE 230
#define IDM_SELECTTOBRACE 231
#define IDM_SHOWCALLTIP 232
#define IDM_COMPLETE 233
#define IDM_COMPLETEWORD 234
#define IDM_EXPAND 235
#define IDM_TOGGLE_FOLDALL 236
#define IDM_TOGGLE_FOLDRECURSIVE 237
#define IDM_EXPAND_ENSURECHILDRENVISIBLE 238
#define IDM_UPRCASE 240
#define IDM_LWRCASE 241
#define IDM_ABBREV 242
#define IDM_BLOCK_COMMENT 243
#define IDM_STREAM_COMMENT 244
#define IDM_COPYASRTF 245
  #define IDM_BOX_COMMENT 246
    #define IDM_INS_ABBREV 247
    #define IDM_JOIN 248
    #define IDM_SPLIT 249
    #define IDM_DUPLICATE 250
    #define IDM_INCSEARCH 252
    #define IDM_ENTERSELECTION 256
#define IDC_INCFINDTEXT 253
#define IDC_INCFINDBTNOK 254
#define IDD_FIND2 255
#define IDC_EDIT1 1000
#define IDC_STATIC -1

#define IDM_PREVMATCHPPC 260
#define IDM_SELECTTOPREVMATCHPPC 261
#define IDM_NEXTMATCHPPC 262
#define IDM_SELECTTONEXTMATCHPPC 263
// Tools
#define IDM_COMPILE 301
#define IDM_BUILD 302
#define IDM_GO 303
#define IDM_STOPEXECUTE 304
#define IDM_FINISHEDEXECUTE 305
#define IDM_NEXTMSG 306
#define IDM_PREVMSG 307
#define IDM_MACRO_SEP 310
#define IDM_MACRORECORD 311
#define IDM_MACROSTOPRECORD 312
#define IDM_MACROPLAY 313
#define IDM_MACROLIST 314
#define IDM_ACTIVATE 320
#define IDM_SRCWIN 350
#define IDM_RUNWIN 351
#define IDM_TOOLWIN 352
#define IDM_STATUSWIN 353
#define IDM_TABWIN 354
// Options
#define IDM_SPLITVERTICAL 401
#define IDM_VIEWSPACE 402
#define IDM_VIEWEOL 403
#define IDM_VIEWGUIDES 404
#define IDM_SELMARGIN 405
#define IDM_FOLDMARGIN 406
#define IDM_LINENUMBERMARGIN 407
#define IDM_VIEWTOOLBAR 408
#define IDM_TOGGLEOUTPUT 409
#define IDM_VIEWTABBAR 410
#define IDM_VIEWSTATUSBAR 411
#define IDM_TOGGLEPARAMETERS 412
#define IDM_OPENFILESHERE 413
#define IDM_WRAP 414
#define IDM_WRAPOUTPUT 415
#define IDM_READONLY 416
#define IDM_CLEAROUTPUT 420
#define IDM_SWITCHPANE 421
#define IDM_EOL_CRLF 430
#define IDM_EOL_CR 431
#define IDM_EOL_LF 432
#define IDM_EOL_CONVERT 433
#define IDM_TABSIZE 440
#define IDM_MONOFONT 450
#define IDM_OPENLOCALPROPERTIES 460
#define IDM_OPENUSERPROPERTIES 461
#define IDM_OPENGLOBALPROPERTIES 462
#define IDM_OPENABBREVPROPERTIES 463
#define IDM_OPENLUAEXTERNALFILE 464
//#define IDM_SELECTIONMARGIN 490
//#define IDM_BUFFEREDDRAW 491
//#define IDM_USEPALETTE 492
// Buffers
#define IDM_PREVFILE 501
#define IDM_NEXTFILE 502
#define IDM_CLOSEALL 503
#define IDM_SAVEALL 504
#define IDM_BUFFERSEP 505
#define IDM_PREVFILESTACK 506
#define IDM_NEXTFILESTACK 507
// Help
#define IDM_HELP 901
#define IDM_ABOUT 902
#define IDM_HELP_SCITE 903
// Windows specific windowing options
#define IDM_ONTOP 960
#define IDM_FULLSCREEN 961
// Dialog control IDs
#define IDGOLINE 220
#define IDABOUTSCINTILLA 221
#define IDFINDWHAT 222
#define IDFILES 223
#define IDDIRECTORY 224
#define IDCURRLINE 225
#define IDLASTLINE 226
#define IDEXTEND 227
#define IDTABSIZE 228
#define IDINDENTSIZE 229
#define IDUSETABS 230
#define IDREPLACEWITH 231
#define IDWHOLEWORD 232
#define IDMATCHCASE 233
#define IDDIRECTIONUP 234
#define IDDIRECTIONDOWN 235
#define IDREPLACE 236
#define IDREPLACEALL 237
#define IDREPLACEINSEL 238
#define IDREGEXP 239
#define IDWRAP 240
#define IDUNSLASH 241
#define IDCMD 242
// id for the browse button in the grep dialog
#define IDBROWSE 243
#define IDABBREV 244
#define IDREPLACEINBUF 244
#define IDMARKALL 245
#define IDGOLINECHAR 246
#define IDCURRLINECHAR 247
#define IDREPLDONE 248
#define IDDOTDOT 249
#define IDFINDINSTYLE 250
#define IDFINDSTYLE 251
  #define IDPARAMSTART 300
// Dialog IDs
#define IDD_FIND 400
#define IDD_REPLACE 401
#define IDD_BUFFERS 402
#define IDD_FIND_ADV 403
#define IDD_REPLACE_ADV 404
#define IDR_CLOSEFILE 100
#ce

There are more functions included to assist scripting in Scite.

- nothing marked and middle mouse button (no drag) will insert [] and put cursor in middle

- nothing marked and Thumb Button 1 will insert "" and put cursor in middle

- Thumb Button 2 does '&'

- mark a word and press Thumb Button 1 it will put the selection in ""

- mark a word, press and hold Thumb Button 1. Now type in an abbreviation like 'cw' and let go. It will insert the abbreviation and inside the word.

and the function i have problems with:

- click on any word with middle mouse and drag it to somewhere else will copy it there. If you write an abbrev while dragging, it will put the word in the abbrev.

and there is a "fast access last used variables" list which is unfinished and now only a array, but you can make it visible if you uncomment line 152

If you have suggestions how to make other functions better, i would be very thankful :oops:

Edited by qsek
Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite
Posted

i found something that sounds perfect:

there are constants for those two events:

Global Const $EVENT_SYSTEM_DRAGDROPSTART = 0x000E ;An MSAA event indicating that an application is about to enter drag-and-drop mode.

Global Const $EVENT_SYSTEM_DRAGDROPEND = 0x000F ;An MSAA event indicating that an application is about to exit drag-and-drop mode.

so far so good, but i never get these events :oops:

not in scite not in the explorer not at any drag drop opeartion, also $EVENT_SYSTEM_SCROLLINGEND and $EVENT_SYSTEM_SCROLLINGSTART dont seem to work.

Anybody has a clue why they are not triggered?

Here is an example code:

#include <GuiMenu.au3>
#include <WindowsConstants.au3>
Global Const $WINEVENT_OUTOFCONTEXT = 0x0000
Global Const $WINEVENT_SKIPOWNTHREAD = 0x0001
Global Const $WINEVENT_SKIPOWNPROCESS = 0x0002
Global Const $WINEVENT_INCONTEXT = 0x0004
;Event Constants
;http://msdn.microsoft.com/en-us/library/ms697187.aspx
;http://msdn.microsoft.com/en-us/library/dd318066(VS.85).aspx
;http://mwinapi.sourceforge.net/doc/html/T_ManagedWinapi_Accessibility_AccessibleEventType.htm
; http://help.adobe.com/en_US/FlashPlatfor...nscript/3/mx/accessibility/Acc
Global Const $EVENT_SYSTEM_SOUND = 0x0001 ;An MSAA event indicating that a sound was played.
Global Const $EVENT_SYSTEM_ALERT = 0x0002 ;An MSAA event indicating that an alert was generated.
Global Const $EVENT_SYSTEM_FOREGROUND = 0x0003 ;An MSAA event indicating that the foreground window changed.
Global Const $EVENT_SYSTEM_MENUSTART = 0x0004 ;An MSAA event indicating that a menu item on the menu bar was selected.
Global Const $EVENT_SYSTEM_MENUEND = 0x0005 ;An MSAA event indicating that a menu from the menu bar was closed.
Global Const $EVENT_SYSTEM_MENUPOPUPSTART = 0x0006 ;An MSAA event indicating that a pop-up menu was displayed.
Global Const $EVENT_SYSTEM_MENUPOPUPEND = 0x0007 ;An MSAA event indicating that a pop-up menu was closed.
Global Const $EVENT_SYSTEM_CAPTURESTART = 0x0008 ;An MSAA event indicating that a window has received mouse capture.
Global Const $EVENT_SYSTEM_CAPTUREEND = 0x0009 ;An MSAA event indicating that a window has lost mouse capture.
Global Const $EVENT_SYSTEM_DIALOGSTART = 0x0010 ;An MSAA event indicating that a dialog box was displayed.
Global Const $EVENT_SYSTEM_DIALOGEND = 0x0011 ;An MSAA event indicating that a dialog box was closed.
Global Const $EVENT_SYSTEM_SCROLLINGSTART = 0x0012 ;An MSAA event indicating that scrolling has started on a scroll bar.
Global Const $EVENT_SYSTEM_SCROLLINGEND = 0x0013 ;An MSAA event indicating that scrolling has ended on a scroll bar.
Global Const $EVENT_SYSTEM_SWITCHSTART = 0x0014 ;An MSAA event indicating that the user pressed ALT+TAB, which activates the switch window.
Global Const $EVENT_SYSTEM_SWITCHEND = 0x0015 ;An MSAA event indicating that the user released ALT+TAB.
Global Const $EVENT_SYSTEM_MINIMIZESTART = 0x0016 ;An MSAA event indicating that a window object is about to be minimized or maximized.
Global Const $EVENT_SYSTEM_MINIMIZEEND = 0x0017 ;An MSAA event indicating that a window object was minimized or maximized.
Global Const $EVENT_SYSTEM_MOVESIZESTART = 0x000A ;An MSAA event indicating that a window is being moved or resized.
Global Const $EVENT_SYSTEM_MOVESIZEEND = 0x000B ;An MSAA event indicating that the movement or resizing of a window is finished.
Global Const $EVENT_SYSTEM_CONTEXTHELPSTART = 0x000C ;An MSAA event indicating that a window entered context-sensitive Help mode.
Global Const $EVENT_SYSTEM_CONTEXTHELPEND = 0x000D  ;An MSAA event indicating that a window exited context-sensitive Help mode.
Global Const $EVENT_SYSTEM_DRAGDROPSTART = 0x000E ;An MSAA event indicating that an application is about to enter drag-and-drop mode.
Global Const $EVENT_SYSTEM_DRAGDROPEND = 0x000F ;An MSAA event indicating that an application is about to exit drag-and-drop mode.
; EVENT_OBJECT events are triggered quite often, handle with care...
Global Const $EVENT_OBJECT_CREATE = 0x8000 ;An MSAA event indicating that an object was created.
Global Const $EVENT_OBJECT_DESTROY = 0x8001 ;An MSAA event indicating that an object was destroyed.
Global Const $EVENT_OBJECT_SHOW = 0x8002 ;An MSAA event indicating that a hidden object is being shown.
Global Const $EVENT_OBJECT_HIDE = 0x8003 ;An MSAA event indicating that an object is being hidden.
Global Const $EVENT_OBJECT_REORDER = 0x8004 ;An MSAA event indicating that a container object has added, removed, or reordered its children.
Global Const $EVENT_OBJECT_FOCUS = 0x8005 ;An MSAA event indicating that an object has received the keyboard focus.
Global Const $EVENT_OBJECT_SELECTION = 0x8006 ;An MSAA event indicating that the selection within a container object changed.
Global Const $EVENT_OBJECT_SELECTIONADD = 0x8007 ;An MSAA event indicating that an item within a container object was added to the selection.
Global Const $EVENT_OBJECT_SELECTIONREMOVE = 0x8008 ;An MSAA event indicating that an item within a container object was removed from the selection.
Global Const $EVENT_OBJECT_SELECTIONWITHIN = 0x8009 ;An MSAA event indicating that numerous selection changes occurred within a container object.
Global Const $EVENT_OBJECT_HELPCHANGE = 0x8010 ;An MSAA event indicating that an object's MSAA Help property changed.
Global Const $EVENT_OBJECT_DEFACTIONCHANGE = 0x8011 ;An MSAA event indicating that an object's MSAA DefaultAction property changed.
Global Const $EVENT_OBJECT_ACCELERATORCHANGE = 0x8012 ;An MSAA event indicating that an object's MSAA KeyboardShortcut property changed.
Global Const $EVENT_OBJECT_INVOKED = 0x8013 ;An MSAA event indicating that an object has been invoked; for example, the user has clicked a button.
Global Const $EVENT_OBJECT_TEXTSELECTIONCHANGED = 0x8014 ;An MSAA event indicating that an object's text selection has changed.
Global Const $EVENT_OBJECT_CONTENTSCROLLED = 0x8015 ;An MSAA event indicating that the scrolling of a window object has ended.
Global Const $EVENT_OBJECT_STATECHANGE = 0x800A ;An MSAA event indicating that an object's state has changed.
Global Const $EVENT_OBJECT_LOCATIONCHANGE = 0x800B ;An MSAA event indicating that an object has changed location, shape, or size.
Global Const $EVENT_OBJECT_NAMECHANGE = 0x800C ;An MSAA event indicating that an object's MSAA Name property changed.
Global Const $EVENT_OBJECT_DESCRIPTIONCHANGE = 0x800D ;An MSAA event indicating that an object's MSAA Description property changed.
Global Const $EVENT_OBJECT_VALUECHANGE = 0x800E ;An MSAA event indicating that an object's MSAA Value property changed.
Global Const $EVENT_OBJECT_PARENTCHANGE = 0x800F ;An MSAA event indicating that an object has a new parent object.
;minimum and maximum events
;to monitor one event type only use same event for min/max
Global Const $EVENT_MIN = 0x00000001
Global Const $EVENT_MAX = 0x7FFFFFFF


HotKeySet('{ESC}', '_EXIT')
If Not IsDeclared("WM_LBUTTONDOWN") Then Global Const $WM_LBUTTONDOWN = 0x0201
Global Const $tagMSLLHOOKSTRUCT = $tagPOINT & ";uint mouseData;uint flags;uint time;uint_ptr dwExtraInfo;"
Global $hHookFunc, $pFunc
Global $hWinHook
$hHookFunc = DllCallbackRegister('_WinEventProc', 'none', 'ptr;uint;hwnd;int;int;uint;uint')
$pFunc = DllCallbackGetPtr($hHookFunc)
$hWinHook = _SetWinEventHook(0x00000000, 0xFFFFFFFF, 0, $pFunc, 0, 0, _
                BitOR($WINEVENT_SKIPOWNPROCESS, $WINEVENT_OUTOFCONTEXT))
If $hWinHook = 0 Then Exit MsgBox(0x10, 'Error', 'Could not register callback procedure')
While 1
    Sleep(20)
WEnd

Func _WinEventProc($hHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iEventThread, $imsEventTime)
Switch $iEvent
;~   Case 0x800B,0x800C,0x8002,0x8003,0x800E ; some Object Events that are constantly triggered
  case 0x0008, 0x0009; $EVENT_SYSTEM_CAPTUREEND, $EVENT_SYSTEM_CAPTURESTART
   ConsoleWrite("MouseCapture: 0x"&hex($iEvent,8) & @CRLF)
   case 0x000E, 0x000F ; $EVENT_SYSTEM_DRAGDROPEND, $EVENT_SYSTEM_DRAGDROPSTART
    ConsoleWrite("Drag: 0x"&hex($iEvent,8) & @CRLF)
  Case Else
;~    ConsoleWrite("0x"&hex($iEvent,8) & @CRLF)
EndSwitch
EndFunc

Func _EXIT()
    Exit
EndFunc
Func OnAutoItExit()
    _UnhookWinEvent($hWinHook)
    DllCallbackFree($hHookFunc)
EndFunc

Func _SetWinEventHook($ieventMin, $ieventMax, $hMod, $pCallback, $iProcID, $iThreadID, $iFlags)
Local $aRet
$aRet = DllCall('user32.dll', 'ptr', 'SetWinEventHook', 'uint', $ieventMin, 'uint', $ieventMax, _
    'hwnd', $hMod, 'ptr', $pCallback, 'dword', $iProcID, 'dword', $iThreadID, 'uint', $iFlags)
If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
Return $aRet[0]
EndFunc
Func _UnhookWinEvent($hWinEventHook)
Local $aRet
$aRet = DllCall('user32.dll', 'int', 'UnhookWinEvent', 'ptr', $hWinEventHook)
If @error Or $aRet[0] = 0 Then Return SetError(1, 0, 0)
Return $aRet[0]
EndFunc
Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

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