Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/15/2018 in all areas

  1. I think so. No errors so far anyway.
    2 points
  2. @DynamicRookie The interesting question would be how you do that in W10 when AU3Inf is not recognizing the controls. You only can do it with the IUIAutomation library which details can be found thru FAQ31. So I assume @Earthshine (just like me) is interested how you would do it with native commands from AutoIt? The only thing I can quess you are saying is to use only sendkeys and not automating the clicks on the buttons itself which is basically the same as answerd in post 2 with controlsend.
    1 point
  3. So how did it fare, is your problem solved?
    1 point
  4. Hi, i searched the forum to communicate with a logitech G600 without using Shortcuts or Default Mouse Keys. the code below lets u use your sidekeys whenever you press down the ring key. before using the code you will have to unassign the keys in the logitech mouse driver software. The source of my code is a wacom usb script, wich was heavily modified to work. you might find some parts wierd, thats because this is my first attempt to communicate via raw hid. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <APISysConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIMisc.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #cs ; #include "CommMG.au3" $mgdebug = True Global $sportSetError $tset = _ComGetPortNames() for $i = 0 to UBound($tset) -1 if $tset[$i][1] = "Serielles USB-Gerät" Then $COMPort = StringTrimLeft($tset[$i][0],3) ConsoleWrite("Teensy an Port COM" & $COMPort & " gefunden!" & @CRLF) EndIf Next $resOpen = _CommSetPort($COMPort,$sportSetError,31250, 8,0,1,0,0,0) if $resOpen = 0 then ConsoleWrite($sportSetError & @LF) ;~ Exit EndIf #ce $atagRID_DEVICE_INFO_HID = 'struct;dword VendorId;dword ProductId;dword VersionNumber;ushort UsagePage;ushort Usage;endstruct' $atagRID_INFO_HID = 'dword Size;dword Type;' & $atagRID_DEVICE_INFO_HID & ';dword Unused[2]' Opt('TrayAutoPause', 0) ; Create GUI Global $g_hForm = GUICreate('G600', 100, 25, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK) DllStructSetData($tRID, 'hTarget', $g_hForm) DllStructSetData($tRID, 'UsagePage', 0x80) ; Logitech G600 DllStructSetData($tRID, 'Usage', 0x0A) ; _WinAPI_RegisterRawInputDevices($tRID) ; Now iterate to find other devices Local $tText, $aData = _WinAPI_EnumRawInputDevices() If IsArray($aData) Then ReDim $aData[$aData[0][0] + 1][3] $tText = DllStructCreate('wchar[256]') For $i = 1 To $aData[0][0] If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tText, 256, $RIDI_DEVICENAME) Then $aData[$i][2] = DllStructGetData($tText, 1) Else $aData[$i][2] = '' EndIf If $aData[$i][1] = $RIM_TYPEHID Then $devInf = DllStructCreate($atagRID_INFO_HID) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $devInf, DllStructGetSize($devInf), $RIDI_DEVICEINFO ) Then If DllStructGetData($devInf, 'VendorId') = 0x046D And DllStructGetData($devInf, 'ProductId') = 0xC24A then ; G600 VID & PID ConsoleWrite ("Device Info:-" & @CRLF) ConsoleWrite ('VendorId: ' & Hex(DllStructGetData($devInf, 'VendorId'),4) & @CRLF) ConsoleWrite ('ProductId: ' & Hex(DllStructGetData($devInf, 'ProductId'),4) & @CRLF) ConsoleWrite ('VersionNumber: ' & DllStructGetData($devInf, 'VersionNumber') & @CRLF) ConsoleWrite ('UsagePage: ' & Hex(DllStructGetData($devInf, 'UsagePage'),2) & @CRLF) ConsoleWrite ('Usage: ' & Hex(DllStructGetData($devInf, 'Usage'),2) & @CRLF) DllStructSetData($tRID, 'UsagePage', DllStructGetData($devInf, 'UsagePage')) DllStructSetData($tRID, 'Usage', DllStructGetData($devInf, 'Usage')) _WinAPI_RegisterRawInputDevices($tRID) EndIf EndIf EndIf Next EndIf ; Register WM_INPUT message GUIRegisterMsg($WM_INPUT, 'WM_INPUT') GUISetState(@SW_SHOW) Global $structHID_DATA = "struct;" & _ "dword Type;" & _ "dword Size;" & _ "handle hDevice;" & _ "wparam wParam;" & _ "dword dwSizeHid;" & _ "dword dwCount;" & _ "endstruct;" Global $structWACOM_PEN_DATA = "struct;" & _ "dword Type;" & _ "dword Size;" & _ "handle hDevice;" & _ "wparam wParam;" & _ "dword dwSizeHid;" & _ "dword dwCount;" & _ "ubyte bRawData00;" & _ "ubyte penvsEraser;" & _ "word x;" & _ "word y;" & _ "word proximity;" & _ "word pressure;" & _ "ubyte bRawData09;" & _ "ubyte bRawData10;" & _ "ubyte bRawData11;" & _ "ubyte bRawData12;" & _ "ubyte bRawData13;" & _ "ubyte bRawData14;" & _ "ubyte bRawData15;" & _ "ubyte bRawData16;" & _ "ubyte bRawData17;" & _ "ubyte bRawData18;" & _ "ubyte bRawData19;" & _ "ubyte bRawData20;" & _ "ubyte bRawData21;" & _ "ubyte bRawData22;" & _ "ubyte bRawData23;" & _ "ubyte bRawData24;" & _ "ubyte bRawData25;" & _ "ubyte bRawData26;" & _ "ubyte bRawData27;" & _ "ubyte bRawData28;" & _ "ubyte bRawData29;" & _ "ubyte bRawData30;" & _ "ubyte bRawData31;" & _ "ubyte bRawData32;" & _ "ubyte bRawData33;" & _ "ubyte tilt_ba;" & _ "ubyte bRawData35;" & _ "ubyte tilt_na;" & _ "ubyte bRawData37;" & _ "endstruct;" Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Switch $hWnd Case $g_hForm Local $tRIM = DllStructCreate($tagRAWINPUTHEADER) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_HEADER) Then ; Retrieves the raw input from the specified device $devType = DllStructGetData($tRIM, 'Type') $devSize = DllStructGetData($tRIM, 'Size') Else ConsoleWrite ("Device Header Retrieval Failed" & @CRLF) Return EndIf ; Now use the handle to the device to get it's name Local $tText = DllStructCreate('wchar[256]') If _WinAPI_GetRawInputDeviceInfo(DllStructGetData($tRIM, 'hDevice'), $tText, 256, $RIDI_DEVICENAME) Then $devName = DllStructGetData($tText, 1) Else ConsoleWrite ("Device Name Retrieval Failed" & @CRLF) EndIf if $devType = $RIM_TYPEHID Then $tRIM = DllStructCreate($structWACOM_PEN_DATA) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then if DllStructGetData($tRIM, 8) = 32 Then ; filter for ring key down (G-Mode) Switch DllStructGetData($tRIM, 9) ; if in g mode assign the Keys G9 to G20 to autoit functions. case 0 Return ; key released case 1 g1() case 2 g2() case 4 g3() case 8 g4() case 16 g5() case 32 g6() case 64 g7() case 128 g8() case 256 g9() case 512 g10() case 1024 g11() case 2048 g12() Case Else ;;; ConsoleWrite(DllStructGetData($tRIM, 9) & @CRLF) EndSwitch EndIf EndIf EndIf EndSwitch sleep(50) Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUT Func g1() ;~ Send("2") ConsoleWrite("g1" & @CRLF) ;~ _CommSendString("KEY_TAB" & @LF) ;~ Sleep(random(50,100,1)) ;~ _CommSendString("KEY_RELEASE_ALL" & @LF) ;~ Sleep(random(50,100,1)) ;~ _CommSendString("KEY_2" & @LF) ;~ Sleep(random(50,100,1)) ;~ _CommSendString("KEY_RELEASE_ALL" & @LF) EndFunc Func g2() ConsoleWrite("g2" & @CRLF) EndFunc Func g3() ConsoleWrite("g3" & @CRLF) EndFunc Func g4() ConsoleWrite("g4" & @CRLF) EndFunc Func g5() ConsoleWrite("g5" & @CRLF) EndFunc Func g6() ConsoleWrite("g6" & @CRLF) EndFunc Func g7() ConsoleWrite("g7" & @CRLF) EndFunc Func g8() ConsoleWrite("g8" & @CRLF) EndFunc Func g9() ConsoleWrite("g9" & @CRLF) EndFunc Func g10() ConsoleWrite("g10" & @CRLF) EndFunc Func g11() ConsoleWrite("g11" & @CRLF) EndFunc Func g12() ConsoleWrite("g12" & @CRLF) EndFunc
    1 point
  5. UEZ

    Colorization Custom Sliders

    Here an example for the 1st slider: ;coded by rover / Yashied / UEZ build 2017-06-28 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <SliderConstants.au3> #include <StructureConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global Const $tagNMCUSTOMDRAW = $tagNMHDR & ';dword DrawStage;handle hDC;long Rect[4];dword_ptr ItemSpec;uint ItemState;lparam ItemlParam' Global $hSlider, $hHBitmap, $hHBitmap2, $bmWidth = 8, $bmHeight = 25, $iWidth = 360, $iHeight = 15, $iXPos = 40 Example() Func Example() _GDIPlus_Startup() Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight), $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap), $hPen = _GDIPlus_PenCreate() _GDIPlus_GraphicsSetPixelOffsetMode($hGfx, 4) Local $h, $RGB For $h = 0 To $iWidth $RGB = HSLToRGB($h / 360, 1, 0.5) _GDIPlus_PenSetColor($hPen, 0xFF000000 + $RGB) _GDIPlus_GraphicsDrawLine($hGfx, $h, 0, $h, $iHeight, $hPen) Next $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_GraphicsDispose($hGfx) Local Const $hBitmap2 = _GDIPlus_BitmapCreateFromScan0($bmWidth, $bmHeight), $hGfx2 = _GDIPlus_ImageGetGraphicsContext($hBitmap), $hBrush = _GDIPlus_BrushCreateSolid() _GDIPlus_GraphicsFillRect($hGfx2, 0, 0, $bmWidth, $bmHeight, $hBrush) $hHBitmap2 = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap2,0xFF404040) ;slider thumb color _GDIPlus_PenDispose($hPen) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_GraphicsDispose($hGfx2) _GDIPlus_ImageDispose($hBitmap2) _GDIPlus_ImageDispose($hBitmap) _GDIPlus_Shutdown() GUICreate("HSL Slider", 450, 100) GUISetBkColor(0xFFFFFF) GUICtrlCreateLabel("HSL: ", 15, 18, 25, 20) Local $idSlider = GUICtrlCreateSlider($iXPos, 10, $iWidth + 30, 25, BitOR($TBS_NOTICKS, $TBS_FIXEDLENGTH, $WS_TABSTOP)) GUICtrlSetLimit(-1, 359, 0) ; change max/min value $hSlider = GUICtrlGetHandle($idSlider) GUICtrlSetCursor(-1, 0) GUICtrlSetBkColor(-1, 0xFFFFFF) _SendMessage($hSlider, $TBM_SETTHUMBLENGTH, 2 * $bmHeight - 1, 0) Local $idButton = GUICtrlCreateButton("RGB Value", 75, 70, 70, 20) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) GUICtrlSetData($idSlider, 0) ; set cursor ; Loop until the user exits. Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() _WinAPI_DeleteObject($hHBitmap) _WinAPI_DeleteObject($hHBitmap2) Exit Case $idButton MsgBox($MB_SYSTEMMODAL, "Slider", "RGB color in hex format: " & Hex(HSLToRGB(GUICtrlRead($idSlider) / 360, 1, 0.5), 6), 10) EndSwitch Until False EndFunc ;==>Example Func HSLToRGB($h, $s, $l) If Not $s Then Return BitShift(0xFF * $l, -16) + BitShift(0xFF * $l, -8) + BitShift(0xFF * $l, 0) Local Const $q = $l < 0.5 ? $l * (1 + $s) : $l + $s - $l * $s Local Const $p = 2 * $l - $q Return BitShift(0xFF * HUEtoRGB($p, $q, $h - 0.33333333), -16) + BitShift(0xFF * HUEtoRGB($p, $q, $h), -8) + BitShift(0xFF * HUEtoRGB($p, $q, $h + 0.33333333), 0) EndFunc Func HUEtoRGB($p, $q, $t) If($t < 0) Then $t += 1 If($t > 1) Then $t -= 1 If($t < 0.16666666) Then Return $p + ($q - $p) * 6 * $t If($t < 0.5) Then Return $q If($t < 0.66666666) Then Return $p + ($q - $p) * (0.66666666 - $t) * 6 Return $p EndFunc Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = DllStructGetData($tNMHDR, 'hWndFrom') Local $Code = DllStructGetData($tNMHDR, 'Code') Local $IDFrom = DllStructGetData($tNMHDR, 'IDFrom') Switch $hWndFrom Case $hSlider Switch $Code Case $NM_CUSTOMDRAW Local $tNMCD = DllStructCreate($tagNMCUSTOMDRAW, $lParam) Local $DrawStage = DllStructGetData($tNMCD, 'DrawStage') Local $ItemSpec = DllStructGetData($tNMCD, 'ItemSpec') Local $hDC, $hMemDC, $hPrev Switch $DrawStage Case $CDDS_PREPAINT DllStructSetData($tNMCD, 'ItemState', BitXOR(DllStructGetData($tNMCD, 'ItemState'), $CDIS_FOCUS)) ; Remove focus Rectangle Return $CDRF_NOTIFYITEMDRAW Case $CDDS_ITEMPREPAINT Local $nLeft = DllStructGetData($tNMCD, 'Rect', 1) Local $nTop = DllStructGetData($tNMCD, 'Rect', 2) Local $nRight = DllStructGetData($tNMCD, 'Rect', 3) Local $nBottom = DllStructGetData($tNMCD, 'Rect', 4) Local $nWidth = $nRight - $nLeft Local $nHeight = $nBottom - $nTop $hDC = DllStructGetData($tNMCD, 'hDC') Switch $ItemSpec Case $TBCD_TICS Return $CDRF_SKIPDEFAULT ; draw custom ticks from bitmap or remove tics ;Return $CDRF_DODEFAULT ; draw tics from current theme Case $TBCD_CHANNEL $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hPrev = _WinAPI_SelectObject($hMemDC, $hHBitmap) _WinAPI_BitBlt($hDC, $nLeft + 10, $nTop - 16, $iWidth - 20, $iHeight, $hMemDC, 0, 0, $MERGECOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return $CDRF_SKIPDEFAULT ;custom draw channel with bitmap or remove channel ;Return $CDRF_DODEFAULT ;draw channel from current theme Case $TBCD_THUMB If ($nWidth - $bmWidth) > 0 Then $nLeft += (($nWidth - $bmWidth) / 2) $nWidth = $bmWidth EndIf If ($nHeight - $bmHeight) > 0 Then $nTop += ($nHeight - $bmHeight) / 2 $nHeight = $bmHeight EndIf $hMemDC = _WinAPI_CreateCompatibleDC($hDC) $hPrev = _WinAPI_SelectObject($hMemDC, $hHBitmap2) _WinAPI_BitBlt($hDC, $nLeft, $nTop - 10, $nWidth, $nHeight, $hMemDC, 0, 0, $SRCCOPY) _WinAPI_SelectObject($hMemDC, $hPrev) _WinAPI_DeleteDC($hMemDC) Return $CDRF_SKIPDEFAULT ;custom draw thumb with bitmap EndSwitch EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY You have to do some adjustments in WM_NOTIFY function when you modify the slider settings!
    1 point
  6. It is not too difficult just do the following: Local $sCommand = 'Local $sMsg = "Hello", $Dummy = MsgBox(0,"Debug", $sMsg)' $sCommand = Stringreplace($sCommand,'"', '""') $sCommand = '"' & $sCommand & '"' Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & $sCommand) Jos
    1 point
×
×
  • Create New...