Jump to content

dgm5555

Active Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by dgm5555

  1. DUH of course. mikell in a reply to another post of mine noted there are typos in the autoit WinAPISys.au3 core code. This of course causes the script to fail as DllStructCreate doesn't work properly. This was actually pretty obvious when I checked as $i_devInf (sizeOf) was always 0. (endstruct constructs are missing their final t) this hack works (and I've contracted it slightly) #include <APISysConstants.au3> #include <Array.au3> #include <WinAPISys.au3> ; fix this first in WinAPISys.au3 ; Global Const $tagRID_DEVICE_INFO_HID = 'struct;dword VendorId;dword ProductId;dword VersionNumber;ushort UsagePage;ushort Usage;endstruc' <<< add trailing "t" ; ConsoleWrite($tagRID_INFO_HID) ; dword Size;dword Type;struct;dword VendorId;dword ProductId;dword VersionNumber;ushort UsagePage;ushort Usage;endstruct;dword Unused[2] ; NB The following tags are a hack due to typos in the autoit core code (in WinAPISys.au3) $atagRID_DEVICE_INFO_MOUSE = 'struct;dword Id;dword NumberOfButtons;dword SampleRate;int HasHorizontalWheel;endstruct' $atagRID_DEVICE_INFO_KEYBOARD = 'struct;dword KbType;dword KbSubType;dword KeyboardMode;dword NumberOfFunctionKeys;dword NumberOfIndicators;dword NumberOfKeysTotal;endstruct' $atagRID_DEVICE_INFO_HID = 'struct;dword VendorId;dword ProductId;dword VersionNumber;ushort UsagePage;ushort Usage;endstruct' $atagRID_INFO_MOUSE = 'dword Size;dword Type;' & $atagRID_DEVICE_INFO_MOUSE & ';dword Unused[2];' $atagRID_INFO_KEYBOARD = 'dword Size;dword Type;' & $atagRID_DEVICE_INFO_KEYBOARD $atagRID_INFO_HID = 'dword Size;dword Type;' & $atagRID_DEVICE_INFO_HID & ';dword Unused[2]' 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) ConsoleWrite ($aData[$i][2] & @CRLF) Else $aData[$i][2] = '' EndIf If $aData[$i][1] = $RIM_TYPEMOUSE Then $devInf = DllStructCreate($atagRID_INFO_MOUSE) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $devInf, DllStructGetSize($devInf), $RIDI_DEVICEINFO ) Then ConsoleWrite ("Mouse Info:-" & @CRLF) ConsoleWrite ('Id: ' & DllStructGetData($devInf, 'Id') & @CRLF) ConsoleWrite ('NumberOfButtons: ' & DllStructGetData($devInf, 'NumberOfButtons') & @CRLF) ConsoleWrite ('SampleRate: ' & DllStructGetData($devInf, 'SampleRate') & @CRLF) ConsoleWrite ('HasHorizontalWheel: ' & DllStructGetData($devInf, 'HasHorizontalWheel') & @CRLF) EndIf EndIf If $aData[$i][1] = $RIM_TYPEKEYBOARD Then $devInf = DllStructCreate($atagRID_INFO_KEYBOARD) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $devInf, DllStructGetSize($devInf), $RIDI_DEVICEINFO ) Then ConsoleWrite ("Keyboard Info:-" & @CRLF) ConsoleWrite ('KbType: ' & DllStructGetData($devInf, 'KbType') & @CRLF) ConsoleWrite ('KbSubType: ' & DllStructGetData($devInf, 'KbSubType') & @CRLF) ConsoleWrite ('KeyboardMode: ' & DllStructGetData($devInf, 'KeyboardMode') & @CRLF) ConsoleWrite ('NumberOfFunctionKeys: ' & DllStructGetData($devInf, 'NumberOfFunctionKeys') & @CRLF) EndIf 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 ConsoleWrite ("Device Info:-" & @CRLF) ; see http://www.usb.org/developers/hidpage/Hut1_12v2.pdf for UsagePage and UsageID 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) EndIf EndIf Next EndIf ;_ArrayDisplay($aData, '_WinAPI_EnumRawInputDevices')
  2. @careca: I only mentioned because I was initially searching for the text and it didn't highlight. HOWEVER:- @mikell THANKS!!!!!! you were right, the errors in the autoit core code were the cause of my problems in my other HID post (which cost me quite a few wasted hours trying various mutations of code!! @jchd thanks for the explanation, I think I might have to read around a bit more about memory allocation, as I wouldn't have expected padding to be required in the middle of a data packet.
  3. No, unfortunately I still get the same list of 0s (although your code restricts it to the HID type device and skips the mouse/keyboard). For testing I added the following in case the failure was HID-type device specific to see if it would list mouse or keyboard info (and to enable testing on systems without other HID devices) but it doesn't work either. #include <APISysConstants.au3> #include <Array.au3> #include <WinAPISys.au3> ; fix this first in WinAPISys.au3 ; Global Const $tagRID_DEVICE_INFO_HID = 'struct;dword VendorId;dword ProductId;dword VersionNumber;ushort UsagePage;ushort Usage;endstruc' <<< add trailing "t" ; ConsoleWrite($tagRID_INFO_HID) ; dword Size;dword Type;struct;dword VendorId;dword ProductId;dword VersionNumber;ushort UsagePage;ushort Usage;endstruct;dword Unused[2] 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) ConsoleWrite ($aData[$i][2] & @CRLF) Else $aData[$i][2] = '' EndIf If $aData[$i][1] = $RIM_TYPEMOUSE Then $devInf = DllStructCreate($tagRID_INFO_MOUSE) $p_devInf = DllStructGetPtr($devInf) $i_devInf = DllStructGetSize($devInf) DllStructSetData($devInf , 'Size', $i_devInf) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $p_devInf, $i_devInf, $RIDI_DEVICEINFO ) Then ConsoleWrite ("Device Info:-" & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'Id') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'NumberOfButtons') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'SampleRate') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'HasHorizontalWheel') & @CRLF) EndIf EndIf If $aData[$i][1] = $RIM_TYPEKEYBOARD Then $devInf = DllStructCreate($tagRID_INFO_KEYBOARD) $p_devInf = DllStructGetPtr($devInf) $i_devInf = DllStructGetSize($devInf) DllStructSetData($devInf , 'Size', $i_devInf) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $p_devInf, $i_devInf, $RIDI_DEVICEINFO ) Then ConsoleWrite ("Device Info:-" & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'KbType') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'KbSubType') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'KeyboardMode') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'NumberOfFunctionKeys') & @CRLF) EndIf EndIf If $aData[$i][1] = $RIM_TYPEHID Then $devInf = DllStructCreate($tagRID_INFO_HID) $p_devInf = DllStructGetPtr($devInf) $i_devInf = DllStructGetSize($devInf) DllStructSetData($devInf , 'Size', $i_devInf) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $p_devInf, $i_devInf, $RIDI_DEVICEINFO ) Then ConsoleWrite ("Device Info:-" & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'VendorId') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'ProductId') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'VersionNumber') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'UsagePage') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'Usage') & @CRLF) EndIf EndIf Next EndIf _ArrayDisplay($aData, '_WinAPI_EnumRawInputDevices') Also I'm not sure why you are setting up a pointer to $devInf as shouldn't this already be a pointer? (I did try converting the GetRawInputDeviceInfo call back to $devInf but keeping $i_devInf for size, but that didn't work either)
  4. I'm trying to modify the example code to actually get the HID device info (rather than just the name), but I can't make it work (all I get is zeros). Can anyone help? #include <APISysConstants.au3> #include <Array.au3> #include <WinAPISys.au3> Local $tText, $aData = _WinAPI_EnumRawInputDevices() ;ConsoleWrite($tagRID_DEVICE_INFO_HID) ; struct;dword VendorId;dword ProductId;dword VersionNumber;ushort UsagePage;ushort Usage;endstruc If IsArray($aData) Then ReDim $aData[$aData[0][0] + 1][3] $tText = DllStructCreate('wchar[256]') $devInf = DllStructCreate($tagRID_DEVICE_INFO_HID) For $i = 1 To $aData[0][0] If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tText, 256, $RIDI_DEVICENAME) Then $aData[$i][2] = DllStructGetData($tText, 1) ConsoleWrite ($aData[$i][2] & @CRLF) Else $aData[$i][2] = '' EndIf If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $devInf, DllStructGetSize($devInf), $RIDI_DEVICEINFO ) Then ConsoleWrite ("Device Info:-" & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'VendorId') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'ProductId') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'VersionNumber') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'UsagePage') & @CRLF) ConsoleWrite (DllStructGetData($devInf, 'Usage') & @CRLF) EndIf Next EndIf _ArrayDisplay($aData, '_WinAPI_EnumRawInputDevices')
  5. Just looking at the raw input functions If I do this:- ConsoleWrite($tagRAWINPUTMOUSE & @CRLF) I get: ; struct;dword Type;dword Size;handle hDevice;wparam wParam;endstruct;ushort Flags;ushort Alignment;ushort ButtonFlags;ushort ButtonData;ulong RawButtons;long LastX;long LastY;ulong ExtraInformation; I don't understand why "endstruct" isn't at the end? (although I presume it's correct as its the same in the help file) The relevant code in WinAPISys.au3 is:- #region Global Variables and Constants ; #CONSTANTS# =================================================================================================================== Global Const $tagOSVERSIONINFOEX = $tagOSVERSIONINFO & ';ushort ServicePackMajor;ushort ServicePackMinor;ushort SuiteMask;byte ProductType;byte Reserved' Global Const $tagRAWINPUTDEVICE = 'struct;ushort UsagePage;ushort Usage;dword Flags;hwnd hTarget;endstruct' Global Const $tagRAWINPUTHEADER = 'struct;dword Type;dword Size;handle hDevice;wparam wParam;endstruct' Global Const $tagRAWMOUSE = 'ushort Flags;ushort Alignment;ushort ButtonFlags;ushort ButtonData;ulong RawButtons;long LastX;long LastY;ulong ExtraInformation;' Global Const $tagRAWKEYBOARD = 'ushort MakeCode;ushort Flags;ushort Reserved;ushort VKey;ushort;uint Message;ulong ExtraInformation;' Global Const $tagRAWHID = 'dword SizeHid;dword Count;' ; & 'byte RawData[n];' Global Const $tagRAWINPUTMOUSE = $tagRAWINPUTHEADER & ';' & $tagRAWMOUSE Global Const $tagRAWINPUTKEYBOARD = $tagRAWINPUTHEADER & ';' & $tagRAWKEYBOARD Also incidentally I think there is a typo in the APISysConstants.au3: ; _WinAPI_*RowInput*() should read RawInput
  6. I'm trying to use AutoIt to monitor outputs from a Wacom digitizer tablet. Running the _WinAPI_EnumRawInputDevices demo produces the following output relevant to the tablet (I think this will be mouse, pen, eraser, touchpad, +??) \\?\HID#VID_056A&PID_0314&Col01#6&1a48d70e&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd} \\?\HID#VID_056A&PID_0314&Col05#6&1a48d70e&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030} \\?\HID#VID_056A&PID_0314&Col04#6&1a48d70e&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030} \\?\HID#VID_056A&PID_0314&Col03#6&1a48d70e&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} \\?\HID#VID_056A&PID_0314&Col02#6&1a48d70e&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} Attached is a file with linux wacom driver info which would seem like a good start for constants etc http://www.usb.org/developers/hidpage/Hut1_12v2.pdf page 103 lists the Digitiser page for HID devices as 0D, with various devices, but I can't figure out which is relevant to the tablet. (I also looked at (HID) Human Interface Device Communications in XP but this was a post from 2009 and seems to have been superseded by updates to AutoIt, and basically just does the same as the _WinAPI_EnumRawInputDevices demo) This is my most current code which registers HID devices and consoleWrites out the raw input information. There are still some problems - 1. It doesn't label all the extracted raw data 2. Some of the information from the Tablet can be seen using HIDTrace.exe, but I can't extract it with this current code (eg the touchring and hotkeys):- #include <APISysConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIMisc.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> ; NB The following tags are a hack due to typos in the autoit core code (in WinAPISys.au3) $atagRID_DEVICE_INFO_MOUSE = 'struct;dword Id;dword NumberOfButtons;dword SampleRate;int HasHorizontalWheel;endstruct' $atagRID_DEVICE_INFO_KEYBOARD = 'struct;dword KbType;dword KbSubType;dword KeyboardMode;dword NumberOfFunctionKeys;dword NumberOfIndicators;dword NumberOfKeysTotal;endstruct' $atagRID_DEVICE_INFO_HID = 'struct;dword VendorId;dword ProductId;dword VersionNumber;ushort UsagePage;ushort Usage;endstruct' $atagRID_INFO_MOUSE = 'dword Size;dword Type;' & $atagRID_DEVICE_INFO_MOUSE & ';dword Unused[2];' $atagRID_INFO_KEYBOARD = 'dword Size;dword Type;' & $atagRID_DEVICE_INFO_KEYBOARD $atagRID_INFO_HID = 'dword Size;dword Type;' & $atagRID_DEVICE_INFO_HID & ';dword Unused[2]' Opt('TrayAutoPause', 0) ;RID = Raw Input Data ; Create GUI Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 212, @DesktopWidth - 179, @DesktopHeight - 283, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_TOPMOST) ;ConsoleWrite($tagRAWINPUTDEVICE & @CRLF) ; struct;ushort UsagePage;ushort Usage;dword Flags;hwnd hTarget;endstruct ; Digitizer pen works correctly ; Now iterate through all HID devices and register them ; To obtain the values of "UsagePage" and "Usage" members of this structure read HID Usage Tables documentation ; www.usb.org/developers/hidpage/Hut1_12v2.pdf Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK) DllStructSetData($tRID, 'hTarget', $g_hForm) #cs \\?\HID#VID_056A&PID_0314&Col05#6&1a48d70e&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030} Device Info:- VendorId: 056A ProductId: 0314 VersionNumber: 256 UsagePage: 00 Usage: 0B \\?\HID#VID_056A&PID_0314&Col04#6&1a48d70e&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030} Device Info:- VendorId: 056A ProductId: 0314 VersionNumber: 256 UsagePage: 0D Usage: 01 \\?\HID#VID_056A&PID_0314&Col03#6&1a48d70e&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030} Device Info:- VendorId: 056A ProductId: 0314 VersionNumber: 256 UsagePage: 0D Usage: 02 \\?\HID#VID_056A&PID_0314&Col02#6&1a48d70e&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030} Device Info:- VendorId: 056A ProductId: 0314 VersionNumber: 256 UsagePage: 00 Usage: 0A \\?\HID#VID_056A&PID_0314&Col01#6&1a48d70e&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd} Mouse Info:- Id: 256 NumberOfButtons: 5 SampleRate: 0 HasHorizontalWheel: 0 #ce ; Register tablet mouse DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls DllStructSetData($tRID, 'Usage', 0x02) ; Mouse _WinAPI_RegisterRawInputDevices($tRID) ; Register keyboard DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls DllStructSetData($tRID, 'Usage', 0x06) ; Keyboard _WinAPI_RegisterRawInputDevices($tRID) ; Register tablet digitizer DllStructSetData($tRID, 'UsagePage', 0x0D) ; Digitizers DllStructSetData($tRID, 'Usage', 0x01) ; Digitizer _WinAPI_RegisterRawInputDevices($tRID) ; Register tablet ?? DllStructSetData($tRID, 'UsagePage', 0x00) ; Undefined DllStructSetData($tRID, 'Usage', 0x0B) ; ?? _WinAPI_RegisterRawInputDevices($tRID) ; Register tablet pen DllStructSetData($tRID, 'UsagePage', 0x0D) ; Digitizers DllStructSetData($tRID, 'Usage', 0x02) ; Pen _WinAPI_RegisterRawInputDevices($tRID) ; Register tablet ?? DllStructSetData($tRID, 'UsagePage', 0x00) ; Undefined DllStructSetData($tRID, 'Usage', 0x0A) ; _WinAPI_RegisterRawInputDevices($tRID) #cs ; 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) ConsoleWrite ($aData[$i][2] & @CRLF) 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') = 0x056A And DllStructGetData($devInf, 'ProductId') = 0x0314 then ConsoleWrite ("Device Info:-" & @CRLF) ; see http://www.usb.org/developers/hidpage/Hut1_12v2.pdf for UsagePage and UsageID 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 #ce ; Register WM_INPUT message GUIRegisterMsg($WM_INPUT, 'WM_INPUT') GUISetState(@SW_SHOW) ; ConsoleWrite($structWACOM_HID_DATA & @CRLF) ; ConsoleWrite("W" & @CRLF) ; ConsoleWrite($hWnd & @CRLF) ; ConsoleWrite($iMsg & @CRLF) ; ConsoleWrite($wParam & @CRLF) ; ConsoleWrite($lParam & @CRLF) ;lParam has the handle to the RAWINPUT structure, not a pointer to it. To get the raw data, use the handle in the call to GetRawInputData. ; ConsoleWrite($tagRAWINPUTMOUSE & @CRLF) ; struct;dword Type;dword Size;handle hDevice;wparam wParam;endstruct;ushort Flags;ushort Alignment;ushort ButtonFlags;ushort ButtonData;ulong RawButtons;long LastX;long LastY;ulong ExtraInformation; ; ConsoleWrite($tagRAWINPUTHID & @CRLF) ; struct;dword Type;dword Size;handle hDevice;wparam wParam;endstruct;dword SizeHid;dword Count; ; from https://raw.githubusercontent.com/torvalds/linux/master/drivers/hid/wacom_wac.c ;static const struct wacom_features wacom_features_0x314 = { "Wacom Intuos Pro S", 31496, 19685, 2047, 63, INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16, .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; ; from https://raw.githubusercontent.com/torvalds/linux/master/drivers/hid/wacom_wac.h Global $nameArr[45] $nameArr[1] = "dword Type; (mouse=0,keyboard=1,HID=2)" $nameArr[2] = "dword Size; (entire packet bytes, incl headers)" $nameArr[3] = "handle hDevice;" $nameArr[4] = "wparam wParam;" $nameArr[5] = "dword dwSizeHid (in bytes);" $nameArr[6] = "dword dwCount; (num of HID inputs for device)" for $i = 0 to 37 $nameArr[$i+7] = $i Next ;local $nameArr[35] = ["", "dword Type; (mouse=0,keyboard=1,HID=2)", "dword Size; (entire packet bytes, incl headers)", "handle hDevice;", "wparam wParam;", "dword dwSizeHid (in bytes);", "dword dwCount; (num of HID inputs for device)", "ubyte bRawData; (as arr of bytes)", "SHORT inputmode;", "SHORT inputmode_index;", "BOOL sense_state;", "BOOL inrange_state;", "BOOL invert_state;", "BOOL tipswitch;", "INT x;", "INT y;", "INT pressure;", "INT width;", "INT height;", "INT id;", "INT cc_report;", "INT cc_index;", "INT cc_value_index;", "INT last_slot_field;", "INT num_expected;", "INT num_received;", "INT bat_status;", "INT battery_capacity;", "INT bat_charging;", "INT bat_connected;", "INT ps_connected;", "BOOL pad_input_event_flag;" ] $nameArr[8] = "penvsEraser: 30+p=2,e=6 pen=32,bl=33,bs=35,Eraser=36,bl=44,bs=46" $nameArr[9] = "x (5080lpi, 6.2 inches = 32768 = 15 bits)" $nameArr[10] = "y (5080lpi, 3.9 inches)" $nameArr[11] = "proximity (1024)" $nameArr[12] = "pressure (2048)" $nameArr[34] = "tilt(buttonaxis) [+/- 60]" $nameArr[36] = "tilt(noaxis) [+/- 60]" 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;" ;Global $tRIM = DllStructCreate($structWACOM_PEN_DATA) ; Local $tRIM = DllStructCreate($structRAW_HID_DATA) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Switch $hWnd Case $g_hForm ConsoleWrite("*** New WM_INPUT Recieved ***" & @CRLF) ; Retrieve the device header information 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 ; The tablet seems to spoof the keyboard or the mouse for some of it's functions, in which case there is no device name available Local $tText = DllStructCreate('wchar[256]') If _WinAPI_GetRawInputDeviceInfo(DllStructGetData($tRIM, 'hDevice'), $tText, 256, $RIDI_DEVICENAME) Then $devName = DllStructGetData($tText, 1) ConsoleWrite ($devName & @CRLF) Else ConsoleWrite ("Device Name Retrieval Failed" & @CRLF) EndIf ConsoleWrite ('Raw Input Device Type: ' & $devType & @CRLF) ConsoleWrite ('Input Packet Size (bytes): ' & $devSize & @CRLF) if $devType = $RIM_TYPEMOUSE Then ;$tagRAWINPUTMOUSE = 'struct;dword Type;dword Size;handle hDevice;wparam wParam;endstruct;ushort Flags;ushort Alignment;ushort ButtonFlags;ushort ButtonData;ulong RawButtons;long LastX;long LastY;ulong ExtraInformation;' Local $tRIM = DllStructCreate($tagRAWINPUTMOUSE) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then ; Retrieves the raw input from the specified device ConsoleWrite ("Mouse Info:-" & @CRLF) ConsoleWrite ('Flags: ' & DllStructGetData($tRIM, 'Flags') & @CRLF) ConsoleWrite ('Alignment: ' & DllStructGetData($tRIM, 'Alignment') & @CRLF) ConsoleWrite ('ButtonFlags: ' & DllStructGetData($tRIM, 'ButtonFlags') & @CRLF) ConsoleWrite ('ButtonData: ' & DllStructGetData($tRIM, 'ButtonData') & @CRLF) ConsoleWrite ('RawButtons: ' & DllStructGetData($tRIM, 'RawButtons') & @CRLF) ConsoleWrite ('LastX: ' & DllStructGetData($tRIM, 'LastX') & @CRLF) ConsoleWrite ('LastY: ' & DllStructGetData($tRIM, 'LastY') & @CRLF) ConsoleWrite ('ExtraInformation: ' & DllStructGetData($tRIM, 'ExtraInformation') & @CRLF) EndIf EndIf if $devType = $RIM_TYPEKEYBOARD Then ;$tagRAWINPUTMOUSE = 'struct;dword Type;dword Size;handle hDevice;wparam wParam;endstruct;ushort MakeCode;ushort Flags;ushort Reserved;ushort VKey;ushort;uint Message;ulong ExtraInformation;' Local $tRIM = DllStructCreate($tagRAWINPUTKEYBOARD) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then ; Retrieves the raw input from the specified device ConsoleWrite ("Keyboard Info:-" & @CRLF) ConsoleWrite ('MakeCode: ' & DllStructGetData($tRIM, 'MakeCode') & " MakeCode = The scan code from the key depression." & @CRLF) ConsoleWrite ('Flags: ' & DllStructGetData($tRIM, 'Flags') & @CRLF) ConsoleWrite ('VKey: ' & DllStructGetData($tRIM, 'VKey') & " VKey = Windows message compatible virtual-key code." & @CRLF) ConsoleWrite ('Message: ' & DllStructGetData($tRIM, 'Message') & @CRLF) ConsoleWrite ('ExtraInformation: ' & DllStructGetData($tRIM, 'ExtraInformation') & @CRLF) EndIf EndIf if $devType = $RIM_TYPEHID Then $tRIM = DllStructCreate($structWACOM_PEN_DATA) ; If _WinAPI_GetRawInputDeviceInfo($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then ; Retrieves the raw input from the specified device If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then ; Retrieves the raw input from the specified device ConsoleWrite ("HID Info:-" & @CRLF) ; Print out all possible variables ; for $i = 1 to UBound($nameArr)-1 ; ConsoleWrite($i & ":" & $nameArr[$i] & ": " & DllStructGetData($tRIM, $i) & " @@@: " & @error & @CRLF) ; Next ; Print out identified variables For $i = 8 to 12 ConsoleWrite($i & ":" & $nameArr[$i] & ": " & DllStructGetData($tRIM, $i) & @CRLF) Next ConsoleWrite(34 & ":" & $nameArr[34] & ": " & DllStructGetData($tRIM, 34) & @CRLF) ConsoleWrite(36 & ":" & $nameArr[36] & ": " & DllStructGetData($tRIM, 36) & @CRLF) EndIf EndIf EndSwitch sleep(500) Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUT wacom_wac.c
  7. I do apologise after "fixing" the code posting as per mLipok I pasted my current func which included a return which bypassed it completely (I've now removed the immediate return call) I've added the edits and integrated your suggestion into my logging system (which will save it to text file), but if I don't get the error in the next hour before I leave work (it's caused by a particular automatic popup window which I can't manually trigger), so I'll post the results here next week. Thanks for the super-prompt suggestions.
  8. code posting corrected the "if winExists" line in the code is checking for existence of window:
  9. I also get this error regularly with the code (and I am checking for existence): Func cancelGillickQuestionWindow() ;logMSG("cancelQuestionWindow") ; Close the do you want to switch to open (viewing documents) window $win1Title = "[TITLE:Question]" If WinExists($win1Title) Then $winPos = WinGetPos($win1Title) If $winPos[0] = 106 And _ $winPos[1] = 327 And _ $winPos[2] = 737 And _ $winPos[3] = 369 Then WinActivate($win1Title) Send ( "{ALTDOWN}d{ALTUP}") ; Defer decision EndIf EndIf EndFunc
  10. Looks likes Gimerly has created a dropbox authenticator, as well as an uploader Unfortunately the authenticator doesn't work for me yet. It produced the some of the required tokens, as a debug message in the SciTE console then crashed, but I'm working on it. The uploader - is included in the above post, but reckon I'm 90% there with that (hopefully it will work when the tokens are correct: I've posted my current code anyway ; Original code posted by Gimerly:- ; https://www.autoitscript.com/forum/files/file/290-dropbox-authenticator/ ; https://www.autoitscript.com/forum/topic/161633-uploading-a-file-to-http-server/ ; Modified by David Mckenzie 19/07/2015 #include <File.au3> #include <WinHttp.au3> #include <Date.au3> #include <Array.au3> #include <String.au3> ; set the dropbox tokens If $App_Key = "" Then $File = "" $App_Key = "" $App_secret = "" $Oauth_access_token = "" $Oauth_access_token_secret = "" ; this the personal Oauth2 Generated access token $App_folder = "autoitUploader" ; this is (probably) the name of your app - it's not currently needed in this code EndIf getAuth($App_Key, $App_secret) upload($App_Key, $App_secret, $Oauth_access_token, $Oauth_access_token_secret, $File) Func upload($App_Key, $App_secret, $Oauth_access_token, $Oauth_access_token_secret, $File="") ; trayseticon("C:\Program Files\AutoIt3\Icons\cute panda.ico", -1) ; Get the file to upload Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = "" local $time= CurrentTime() local $Random = Random(0,32767,1) ; if a filename isn't passed to the function, then ask the user for one If $File = "" Then $File = fileopendialog("Pick something to upload", @desktopdir, "All (*.*)|Text files (*.txt)" ) EndIf ;ConsoleWriteTS($File) ; Now open the file and load the data into memory local $array = _PathSplit($File,$sDrive, $sDir, $sFilename, $sExtension) ; get the file name and extension Local $i = UBound($array) - 1 local $sFile = fileopen($File,16) Local $data = fileread($sFile) local $size = @extended FileClose($File) ;set up the dropbox upload URL ;to get the dropbox tokens, browse to https://www.dropbox.com/developers/apply?cont=/developers/apps and create a new app ;$array[$i-1] is the file name of the file the user wants to upload and $array[$i] is the extension Local $sUrl = ("https://api-content.dropbox.com/1/files_put/dropbox" & "/" & $array[$i-1] & $array[$i] & _ "?oauth_consumer_key=" & $App_Key & _ "&oauth_token=" & $Oauth_access_token & _ "&oauth_signature_method=PLAINTEXT" & _ "&oauth_signature=" & $App_secret & "&" & $Oauth_access_token_secret & _ "&oauth_timestamp=" & $time & _ "&oauth_nonce=" & $RANDOM) ConsoleWriteTS("URL: " & $sUrl) ; now attempt to upload the file with the generated dropbox URL Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1") $obj.Open("PUT", $sURL, False) ConsoleWriteTS("Open PUT") If @error Then ConsoleWriteTS("@1:unable to open PUT" & " " &$array[$i-1] & $array[$i]) else ConsoleWriteTS("request opened") $obj.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0") ;$obj.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $obj.SetRequestHeader("Content-Length", $size) ; if _FindNetwork() = "xavier" Then ; $obj.SetProxy(2, "number") ; endif ConsoleWriteTS("@2:" & $sFile) $obj.Send($data) ; send the file to uploaded $oReceived = $obj.ResponseText $oStatusCode = $obj.Status If $obj.Status <> $HTTP_STATUS_OK Then $FindError = FindError($oStatusCode) ConsoleWriteTS($oReceived) ConsoleWriteTS("@3:" & $oStatusCode & ":" & $FindError & " :unable to upload " & $array[$i-1] & $array[$i]) else ConsoleWriteTS("uploaded " & $array[$i-1] & $array[$i]) endif ; trayseticon("C:\Program Files\AutoIt3\Icons\panda.ico", -1) endif EndFunc Func CurrentTime() return _DateDiff('s', "1970/01/01 00:00:00", _NowCalc()) EndFunc Func FindError($apple) switch 1 case $apple = 400 return "Bad input parameter" case $apple = 401 return "Bad or expired token." case $apple = 403 return "Bad OAuth request (wrong consumer key, bad nonce, expired timestamp...). " case $apple = 404 return "File or folder not found at the specified path." case $apple = 405 return "Request method not expected (generally should be GET or POST)." case $apple = 429 return "Your app is making too many requests and is being rate limited" case $apple = 503 return "OAuth 1.0 app is being rate limited. " case $apple = 507 return "User is over Dropbox storage quota." case $apple = 5&"xx" return "server error" endswitch EndFunc Func ConsoleWriteTS($pea) ; consolewrite writes whatever value you want to the stdout stream ConsoleWrite(@Mday&"/"&@mon&" "&@hour&":"&@min&":"&@sec&" --> " & $pea & @CRLF) EndFunc Exit ;********************* Dropbox authenticator ******************** DirCreate(@desktopdir & "\Dropbox authenticator") ;fileinstall("C:\Users\jcampbell\Desktop\AutoIT\tokens.txt", @desktopdir & "\Dropbox authenticator\tokens.txt") ;fileinstall("C:\Users\jcampbell\Desktop\AutoIT\url.txt", @desktopdir & "\Dropbox authenticator\url.txt") Func getAuth($App_Key="", $App_secret="") ConsoleWriteTS("starting Func GetToken") If $App_Key = "" Then Msgbox(0,"Welcome", "This was created to make getting your oauth_token and secret easier. When you first run this program it will create an empty folder on your desktop (please leave it as it needs to be on the desktop). As your progress though the program text files will be created as they are needed. make sure not to click ok on the ConsoleWriteTSbox without reading as it is vitial each step be complete before going onto the next.") $App_Key = inputbox("App key", "Please enter your app key" & @CRLF & "To get the initial dropbox tokens, browse to https://www.dropbox.com/developers/apply?cont=/developers/apps and create a new app", "https://www.dropbox.com/developers/apply?cont=/developers/apps" ) $App_Secret = inputbox("App secret", "Please enter your app secret") EndIf Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1") local $time=currenttime() local $Random = Random(0,32767,1) ; using my fucntion _FindNetwork I can determine whether or not I need to set a proxy. This is so the user doesn't have to do anything and is all automated. ;if _FindNetwork() = "xavier" Then $obj.SetProxy(2, "proxy.school:3128") ;$obj.SetTimeouts(30000,60000,30000,400000) ;wait a max of 6.6 minutes for request to timeout Local $sUrl = ("https://api.dropbox.com/1/oauth/request_token" & _ "?oauth_consumer_key=" & $App_Key & _ "&oauth_token=" & $Oauth_access_token & _ "&oauth_signature_method=PLAINTEXT" & _ "&oauth_signature=" & $App_secret & "&" & _ "&oauth_timestamp=" & $time & _ "&oauth_nonce=" & $RANDOM) ConsoleWriteTS("URL: " & $sUrl) $obj.Open("POST", $sURL , False) ConsoleWriteTS("Open POST") $obj.Send($sUrl) local $status = $obj.Status local $Recieved = $obj.ResponseText local $FindError = FindError($status) If $obj.Status <> 200 Then $FindError = FindError($status) ConsoleWriteTS($FindError) Exit else ConsoleWriteTS($obj.ResponseText) ConsoleWriteTS($Recieved) $secret = GetSecret($Recieved) ConsoleWriteTS("secret:" & " "&$secret) $token = GetToken1($Recieved) ConsoleWriteTS("token:" & " "&$token) authorize($secret, $token) ;pause(100) local $url = "https://www.dropbox.com/1/oauth/authorize"&"?oauth_consumer_key="&$App_Key&"&oauth_token="&$token&"&oauth_signature="&$App_Secret&"&"&$secret&"&oauth_signature_method=PLAINTEXT" ConsoleWriteTS("Copy and paste the following url into your browser and click the ok button when you have accepted authorization" & @CRLF & $url & @CRLF) InputBox("Instructions", "Copy and paste the following url into your browser and click the ok button when you have accepted authorization", $url) AccessToken($secret, $token) endif EndFunc Func AccessToken($secret, $token) ConsoleWriteTS("starting Func AccessToken") Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1") local $time = currenttime() local $Random = Random(0,32767,1) ;ConsoleWriteTS("App key" & " " & $App_Key) ConsoleWriteTS($token) Local $sUrl = ("https://api.dropbox.com/1/oauth/access_token" & _ "?oauth_consumer_key=" & $App_Key & _ "&oauth_token=" & $token & _ "&oauth_signature_method=PLAINTEXT" & _ "&oauth_signature=" & $App_secret & "&" & $secret & _ "&oauth_timestamp=" & $time & _ "&oauth_nonce=" & $RANDOM) ConsoleWriteTS("URL: " & $sUrl) ;$size = stringlen($token) $obj.Open("POST", $sUrl , False) ConsoleWriteTS("Open POST") ;$obj.SetResponseHeaders("content-length", $size) ;$obj.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0") $obj.send($sUrl) local $Recieved = $obj.ResponseText If $obj.Status <> 200 Then ConsoleWriteTS($obj.status) ConsoleWriteTS($obj.ResponseText) MsgBox(0, "Error", "Unable to retrieve your Oauth_token and secret at this time") else ;iniwrite(@scriptdir & "/ ;ConsoleWriteTS($Recieved) ;$oauth_token_secret = GetSecret1($Recieved) ;$oauth_token = GetOauth($Recieved) msgbox(0, "Success", "Go to the dropbox authenticator folder, open tokens.txt and the last line has your most recent Oauth_token and secret") local $sFile = fileopen(@desktopdir & "\Dropbox authenticator\tokens.txt",1) filewrite($sFile, $Recieved) fileclose($sFile) endif EndFunc Func GetOauth($data) local $array = _StringBetween($data, "oauth_token=","&") return $array[0] EndFunc Func GetSecret1($data) local $array = _StringBetween($data, "oauth_token_secret=", "&") return $array[0] EndFunc Func authorize($token_secret, $access_token) local $time=currenttime() local $Random = Random(0,32767,1) local $url = "https://www.dropbox.com/1/oauth/authorize"&"?oauth_consumer_key="&$App_Key&"&oauth_token="&$access_token&"&oauth_signature="&$App_Secret&"&"&$token_secret&"&oauth_signature_method=PLAINTEXT"&"&oauth_timestamp="&$time&"&oauth_nonce="&$RANDOM local $Random = Random(0,32767,1) ConsoleWriteTS("url is " & " "&$url) Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1") $obj.Open("GET", $url , False) ;if _FindNetwork() = "xavier" Then $obj.SetProxy(2, "proxy.school:3128") ;ConsoleWriteTS($url) local $size = stringlen($url) $obj.SetResponseHeaders("content-length", $size) $obj.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0") $obj.Send($url) local $status = $obj.Status local $Recieved = $obj.ResponseText If $obj.Status <> 200 Then local $FindError = FindError($status) ConsoleWriteTS($FindError) else ConsoleWriteTS($obj.Status) endif EndFunc Func GetToken1($str) Local $pie = _StringBetween($str, "oauth_token=","") ; gets the text starting from oauth_token to the end of the file if $pie = 1 then ConsoleWriteTS("error") else return $pie[0] endif EndFunc Func GetSecret($str) local $pie = _StringBetween($str,"oauth_token_secret=","&") if $pie = 1 then ConsoleWriteTS(@error) else ConsoleWriteTS("pie is" & " " &$pie[0]) return $pie[0] endif EndFunc
  11. Sorry about the delay. @Jon you script seems to be timing how long before I press OK for the msgbox. Was that your intention? I modified the script a bit (including the missing reference too) to the following which repeats the loop changing variables and averages the time: Let me know though if I busted it from your intended purpose? #include <WinAPI.au3> Global Const $HWND_BROADCAST = 0xFFFF Global Const $WM_SETTINGCHANGE = 0x001A Global Const $SMTO_BLOCK = 0x0001 Global Const $SMTO_NORMAL = 0x0000 Global Const $SMTO_ABORTIFHUNG = 0x0002 $time1=0 $time2=0 $time3=0 for $i = 1 to 100 $time = TimerInit() _WinAPI_SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, 0, "Environment", 5000, $SMTO_NORMAL) $time1 = $time1 + TimerDiff($time) $time = TimerInit() _WinAPI_SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, 0, "Environment", 5000, $SMTO_BLOCK+$SMTO_ABORTIFHUNG) $time2 = $time2 + TimerDiff($time) $time = TimerInit() _WinAPI_SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, 0, "Environment", 250, $SMTO_NORMAL) $time3 = $time3 + TimerDiff($time) Next ConsoleWrite(@CRLF & "Script1" & @CRLF) ConsoleWrite("Script time: " & Round($time1 / 1000/100, 2) & @CRLF) ConsoleWrite(@CRLF & "Script2" & @CRLF) ConsoleWrite("Script time: " & Round($time2 / 1000/100, 2) & @CRLF) ConsoleWrite(@CRLF & "Script3" & @CRLF) ConsoleWrite("Script time: " & Round($time3 / 1000/100, 2) & @CRLF) Func _WinAPI_SendMessageTimeout($hWnd, $iMsg, $wParam = 0, $lParam = 0, $iTimeout = 1000, $iFlags = 0) Local $aRet = DllCall('user32.dll', 'lresult', 'SendMessageTimeoutW', 'hwnd', $hWnd, 'uint', $iMsg, 'wparam', $wParam, _ 'lparam', $lParam, 'uint', $iFlags, 'uint', $iTimeout, 'dword_ptr*', 0) If @error Then Return SetError(@error, @extended, -1) If Not $aRet[0] Then Return SetError(10, _WinAPI_GetLastError(), -1) Return $aRet[7] EndFunc ;==>_WinAPI_SendMessageTimeoutThe entire SciTe console output was: >"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\dgm55\OneDrive\Documents\Scripts\test1.au3" /UserParams +>08:49:57 Starting AutoIt3Wrapper v.15.503.1200.1 SciTE v.3.5.4.0 Keyboard:00000809 OS:WIN_81/ CPU:X64 OS:X64 Environment(Language:0809) +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\dgm55\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\dgm55\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.0) from:C:\Program Files (x86)\AutoIt3 input:C:\Users\dgm55\OneDrive\Documents\Scripts\test1.au3 +>08:49:57 AU3Check ended.rc:0 >Running:(3.3.14.0):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\dgm55\OneDrive\Documents\Scripts\test1.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop Script1 Script time: 0.13 Script2 Script time: 0.13 Script3 Script time: 0.12 +>08:50:35 AutoIt3.exe ended.rc:0 +>08:50:35 AutoIt3Wrapper Finished. >Exit code: 0 Time: 38.5
  12. I'd like to create a dropbox uploader (and downloader) to provide a simple file sync without using the dropbox app. The following is my current code (cadged and modified from other posts and websites), but I can't even figure out how to get initial authorization. Can anyone help? NB I would be quite happy to use the oauth2 Generated access token if it bypassed a lot of this, but I'm not sure how to do this. (If you can't guess, I know virtually nothing about http calls) Alternatively if there is a working autoit dropbox up/downloader, I'm more than happy not to write my own (but couldn't find one) Thanks #include "WinHttp.au3" ; set the dropbox tokens ;to get the dropbox app_key and app_secret tokens, browse to https://www.dropbox.com/developers/apply?cont=/developers/apps and create a new app If $App_Key = "" Then $File = "" $App_Key = "" $App_secret = "" $Oauth_access_token = "" $Oauth_access_token_secret = "" ; this could possibly the personal Oauth2 Generated access token $App_folder = "" ; this is the name of your app - it's not currently needed in this code ; the folder where the uploaded file will be stored is: Dropbox/Apps/$App_folder EndIf Local $sURL = "https://api.dropbox.com/1/oauth/request_token " & _ "Authorization: OAuth oauth_version=""1.0"", oauth_signature_method=""PLAINTEXT"", " & _ "oauth_consumer_key=""" & $App_Key & """, " & _ "oauth_signature=""" & $App_secret & "&""" $hOpen = _WinHttpOpen() $FileHandle = FileOpen($File) $hConnect = _WinHttpConnect($hOpen, $sURL) $hRequest = _WinHttpOpenRequest($hConnect, "POST") _WinHttpReceiveResponse($hRequest) $sResult = "" Do $sResult &= _WinHttpReadData($hRequest) Until @error ;MsgBox(0, "", $sResult) ConsoleWrite($sResult & @CRLF) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; response should be: ;oauth_token=<request-token>&oauth_token_secret=<request-token-secret> ;user will have to browse to the following and authorise the app ;https://www.dropbox.com/1/oauth/authorize?oauth_token=<request-token> ; you now need to generate an access token ; POST https://api.dropbox.com/1/oauth/access_token ; Header will be: ;Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="<app-key>", oauth_token="<request-token>", oauth_signature="<app-secret>&<request-token-secret>" ;reponse will be: ;oauth_token=<access-token>&oauth_token_secret=<access-token-secret>&uid=<user-id> ;now you can access the account and undertake actions ;eg get account info: ;GET https://api.dropbox.com/1/account/info ;Header: ;Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="<app-key>", oauth_token="<access-token>", oauth_signature="<app-secret>&<access-token-secret>" ; this function doesn't work, it will need to be modified to allow upload func upload($App_Key, $App_secret, $Oauth_access_token, $Oauth_access_token_secret, $File="") trayseticon("C:\Program Files\AutoIt3\Icons\cute panda.ico", -1) ; Get the file to upload Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = "" local $time=@HOUR & ":" & @MIN & ":" & @SEC local $Random = Random(0,32767,1) ; if a filename isn't passed to the function, then ask the user for one If $File = "" Then $File = fileopendialog("Pick something to upload", @desktopdir, "All (*.*)|Text files (*.txt)" ) EndIf ;message($File) ; Now open the file and load the data into memory local $array = _PathSplit($File,$sDrive, $sDir, $sFilename, $sExtension) ; get the file name and extension Local $i = UBound($array) - 1 local $sFile = fileopen($File,16) Local $data = fileread($sFile) local $size = @extended FileClose($File) ;set up the dropbox upload URL ;to get the dropbox tokens, browse to https://www.dropbox.com/developers/apply?cont=/developers/apps and create a new app ;$array[$i-1] is the file name of the file the user wants to upload and $array[$i] is the extension Local $sUrl = ("https://api-content.dropbox.com/1/files_put/dropbox"&"/"& $array[$i-1] & $array[$i] & _ '?oauth_consumer_key=' & $App_Key & _ " & oauth_token=" & $Oauth_access_token & _ " & oauth_signature_method=PLAINTEXT & oauth_signature=" & $App_secret & "%26" & $Oauth_access_token_secret & _ " & oauth_timestamp=" & $time & _ " & oauth_nonce=" & $RANDOM) ;Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", ;oauth_consumer_key="<app-key>", oauth_token="<access-token>", ;oauth_signature="<app-secret>&<access-token-secret>" msgbox(1,"URL",$sUrl) ; now attempt to upload the file with the generated dropbox URL Local $obj = ObjCreate("WinHttp.WinHttpRequest.5.1") ;message("here") $obj.Open("PUT", $sURL, False) If @error Then MsgBox(1,"ERROR","@1unable to upload" & " " &$array[$i-1] & $array[$i]) else ; message("request opened") $obj.SetRequestHeader("User-Agent", "User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0") ;$obj.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $obj.SetRequestHeader("Content-Length", $size) ; if _FindNetwork() = "xavier" Then ; $obj.SetProxy(2, "number") ; endif ; message($sFile) $obj.Send($data) ; send the file to uploaded $oReceived = $obj.ResponseText $oStatusCode = $obj.Status If $obj.Status <> $HTTP_STATUS_OK Then ; local $FindError = FindError($oStatusCode) ; message($oReceived) msgbox(0 , "Error", "@2" & $oStatusCode & " :unable to upload " & $array[$i-1] & $array[$i]) else msgbox(0 , "success", "uploaded " & $array[$i-1] & $array[$i]) endif trayseticon("C:\Program Files\AutoIt3\Icons\panda.ico", -1) endif endfunc
  13. The SciTE4 installation also hangs for a minute at "Tell Windows to Update Environment". Given the rest of the installation (and almost every other installation I've tried) takes 15-20 seconds on my system, this seems to me a significant glitch.
  14. Installation appeared to hang for 2-3 minutes with the message "Target was appended to PSModulePath" I was about to kill it when it restarted. (Installing 64bit version of v3.3.14.0 on Windows10 beta)
  15. @Seeker: I found this code helped (I tried UnstickKeys2, but it didn't work well) if you put a short sleep in to give you time to release the key it may also help... [del the logMSG line - the forum text editors won't allow me to edit the code to remove it] ; sometimes autoit causes keys to get stuck down, UnstickKeys can help and needs $user32dll and $keys. $user32dll = DllOpen("C:\Windows\System32\user32.dll") ;0xa0=LSHIFT; 0xa1=RSHIFT; 0xa2=LCTRL; 0xa3=RCTRL; 0xa4=LALT; 0xa5=RALT; 0x5b=LWIN; 0x5c=RWIN Global Const $keys[8] = [0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0x5b, 0x5c] Func UnstickKeys() logMSG("UnstickKeys") ; also a 'sleep()' call may help: Good News! I have determined that inserting a "sleep()" command before the "send()" command will also reliably resolve the stuck-key problem. On slow computers, a "send(300)" was required, while on fast machines, a "send(100)" was enough. Most importantly, this experiment showed that the problem occurs BECAUSE the "send()" action starts before the hotkey detection function completes. When the "send()" action starts too soon, it seems to cause the detection function to silently error out and fail to finish it's normal cleanup after each use (speculation). For $vkvalue in $keys DllCall($user32dll,"int","keybd_event","int",$vkvalue,"int",0,"long",2,"long",0) ;Release each key Next EndFunc func UnstickKeys2() logMSG("UnstickKeys2") send("{CTRLUP}{SHIFTUP}{ALTUP}{LWINUP}{RWINUP}") EndFunc
  16. I keep getting the atached error. It seems to occur randomly and can happen even an some hour or more after starting. Also I get the same bug as remin. I'm finding that the hotstrings randomly seem to stop responding, although the script is still running, and normal hotkeys still work perfectly. I had thought it was due to a function logger I added at the same time, but doesn't seem to be. I got around it by automatically regularly restarting my script. Both errors have started recently and since an upgrade from XP to Win7. If you have any error code you want me to add and send you logs, I'm happy to do so. I'm running hotstrings approx 8hrs/weekday, so could help to pick up intermittent bugs. David
  17. Over the past year of use, I've made a few mods (but not much), and core code is unchanged. I discovered that the function got slower over time, and was cursing windows until I realised my font data file had been bloated horrifically with logging of unrecognised characters. I thus added a cleaner function to remove them. I've also slightly altered the default options, with defaults for initial training (when logging is useful) and another set once usage is stable (when it probably isn't) which also stops asking for user input. I thus thought an update was in order. I'll claim much of the kudos offerred by dmob, as civilcalc's code and subsequent discussion was only a stub, but did give me an idea of how to start with screen OCR (which is why my post appeared under hers in the first place - I was hoping for a bit of constructive input, but it never eventuated). Hopefully the 700 downloads so far of my code mean at least someone other than me is using it. Cheers David OCR.au3_PixelGetColor.au3
  18. EDIT: THE CODE HAS BEEN UPDATED AND IMPROVED, SEE MY POST ON 12/11/13 I've updated the code quite a bit since my 29/10/12 post. There are a few more options able to be selected, and I ultimately decided to get rid of the colourmatchblack/white but go with a threshold routine which is nearly as fast. I'd still consider it a 'beta' (so I've left much of the debugging code in but commented out) The instructions/description etc are at the top of the OCR file. Cheers David OCR.au3 _PixelGetColor.au3
  19. Is there any way of detecting if a window is somewhat obscured by eg tooltips, menus, or other popups which it has opened. I can't find anything relevant in the forums, and would like a more elegant/faster solution than doing a pixelsearch for colours (which would not always work anyway due to lack of distinctive colours sometimes. I have an OCR function I've written, which monitors in the background and updates other windows, but it intermittently gets caught out by these popups. Thanks David
  20. Am I doing/expecting something wrong? Hex division is producing incorrect values Running from SciTE - AutoIt3Wrapper v.2.1.0.33 (oops: autoit version is 3.3.8.1255) ConsoleWrite(0xFF0000/0xFFFF & @CRLF) ; expect 0xFF or 255 ; actual output is 255.003891050584 = INCORRECT[/autoit] (ignore the bitshift bit of the title, I figured that out) Thanks to anyone who can help David
  21. Hi jchd, Does your system of categorising/indexing characters by columns mean it can self-learn characters? In any case I'd be interested in seeing your code as mine doesn't have any form of character index - just loads the entire database and uses stringInstr to look for character matches, but my database is currently only 10kb, so not currently big enough that this is too slow. Did you have the same problem as me that the screen grab/conversion time is the bottle-neck? If not how did you get around it? I'm currently wondering about converting my script to FreeBasic so hopefully it would run faster, but if you had any ways you did things faster would be great (and I have no idea how to make such a program integrate with AutoIt scripts, so that's probably just random musing). You noted it recognised any style. How did you manage italics/strikethough/underline? Cheers David
  22. I've just uploaed this native autoit screen OCR (working reasonably well, but still not totally bug-free):- Also this can search for a pixel pattern (eg a word), but doesn't return the actual text: May be useful. David
  23. Maybe this:
  24. I needed a system for checking if a particular pixel pattern (eg an icon) was present in a defined area, so wrote this script. Hope it's useful to someone else too. David patternFind.au3
×
×
  • Create New...