Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/10/2019 in all areas

  1. Recently a user asked given two keyboards how to determine which keyboard was pressed this is the start of such functionality I was already given permission to post this example by a moderator before I bothered ;Bilgus 2018 ;Determine which keyboard was pressed #include <Array.au3> #include <WinAPISys.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global Const $HWND_MESSAGE = (-3) ;create a message-only window when set as Parent ;RAWINPUTDEVICE Constants Global Const $HID_USAGE_PAGE_GENERIC = 0x1 Global Const $HID_USAGE_GENERIC_KEYBOARD = 0x6 Global $ghSelectedDevice Global $gaKeyboards = EnumRawKeyboards("\HID") If IsArray($gaKeyboards) And $gaKeyboards[0][0] >= 1 Then $ghSelectedDevice = $gaKeyboards[1][0] ; hard coded change to suit _ArrayDisplay($gaKeyboards, '_WinAPI_EnumRawInputDevices', "", 0, Default, "Handle|Type|VID|Keys") ;Not Needed... Global $hTarget = GUICreate("main", 10, 10, Default, Default, Default, Default, $HWND_MESSAGE) ;Dummy window to recieve messages Register_RawInput($HID_USAGE_PAGE_GENERIC, $HID_USAGE_GENERIC_KEYBOARD, $RIDEV_INPUTSINK, $hTarget) ;$RIDEV_INPUTSINK recieves input when not foreground ; Register WM_INPUT message GUIRegisterMsg($WM_INPUT, 'WM_INPUT') HotKeySet("{ESC}", _Exit) While 1 Sleep(1000) WEnd Func Device_Pressed() ConsoleWrite("Device Pressed" & @CRLF) EndFunc ;==>Device_Pressed Func _Exit() Exit EndFunc ;==>_Exit Func Register_RawInput($iUsagePage, $iUsage, $iFlags, $hTargetHwnd) Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', $iUsagePage) DllStructSetData($tRID, 'Usage', $iUsage) DllStructSetData($tRID, 'Flags', $iFlags) DllStructSetData($tRID, 'hTarget', $hTargetHwnd) ; Register HID input to obtain info from devices _WinAPI_RegisterRawInputDevices($tRID) EndFunc ;==>Register_RawInput Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) ;Callback from RawInput #forceref $iMsg, $wParam ;'struct;dword Type;dword Size;handle hDevice;wparam wParam;endstruct' Local $tRIH = DllStructCreate($tagRAWINPUTHEADER) If _WinAPI_GetRawInputData($lParam, $tRIH, DllStructGetSize($tRIH), $RID_HEADER) And DllStructGetData($tRIH, "Type") = $RIM_TYPEKEYBOARD Then ConsoleWrite("0x" & Hex(DllStructGetData($tRIH, "hDevice")) & @CRLF) If $ghSelectedDevice = DllStructGetData($tRIH, "hDevice") Then Device_Pressed() Else ;Different Device ConsoleWrite("Different Device Pressed" & @CRLF) EndIf EndIf Return $GUI_RUNDEFMSG ;Pass on to default winproc EndFunc ;==>WM_INPUT Func EnumRawKeyboards($sDeviceNameMatch = "") ;Returns array of keyboard device IDs Local $tInfo, $aData = _WinAPI_EnumRawInputDevices() If IsArray($aData) Then Local $aKeyboards[$aData[0][0] + 1][4] ;'dword Size;dword Type;';'struct;dword KbType;dword KbSubType;dword KeyboardMode;dword NumberOfFunctionKeys;dword NumberOfIndicators;dword NumberOfKeysTotal;endstruc' Local $_tagRID_INFO_KEYBOARD = $tagRID_INFO_KEYBOARD If StringRight($_tagRID_INFO_KEYBOARD, 1) <> "t" Then $_tagRID_INFO_KEYBOARD &= "t" ; t is missing from endstruct Local $iCt = 0, $iSz Local $tInfo, $tDeviceName, $sDeviceName For $i = 1 To $aData[0][0] $tInfo = DllStructCreate($_tagRID_INFO_KEYBOARD) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tInfo, DllStructGetSize($tInfo), $RIDI_DEVICEINFO) And $aData[$i][1] = $RIM_TYPEKEYBOARD Then $iSz = _WinAPI_GetRawInputDeviceInfo($aData[$i][0], 0, 0, $RIDI_DEVICENAME) ;Get bytes needed $tDeviceName = DllStructCreate('wchar[' & $iSz + 1 & ']') ;Holds device name string If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tDeviceName, DllStructGetSize($tDeviceName), $RIDI_DEVICENAME) Then $sDeviceName = DllStructGetData($tDeviceName, 1) If $sDeviceNameMatch <> "" And Not StringInStr($sDeviceName, $sDeviceNameMatch) Then ContinueLoop $iCt += 1 $aKeyboards[$iCt][0] = $aData[$i][0] ;Handle $aKeyboards[$iCt][1] = $aData[$i][1] ;Type $aKeyboards[$iCt][2] = $sDeviceName $aKeyboards[$iCt][3] = DllStructGetData($tInfo, "NumberOfKeysTotal") EndIf EndIf Next $aKeyboards[0][0] = $iCt ; Write count of keyboard devices to array ReDim $aKeyboards[$iCt + 1][4] ;Resize array EndIf Return $aKeyboards EndFunc ;==>EnumRawKeyboards
    2 points
  2. careca

    MirrorDir

    Version 1.5.5

    815 downloads

    This is a folder backup tool, after i got tired of using tools made by others, that had either lack of functionality, or were overly complex, i decided to make my own, and this is it. MirrorDir mirrors dirs as the name says, simply select source and destination hit scan, review in the list if that's what you want it to do and press start copy. As this is a mirror sync tool, this means files that exist in destination but dont exist in source are marked for deletion. Other tools have other modes like the incrementing copy which does not delete anything, but i made this for me, only if there is a request i may think about adding features just for fun. Whats more? There's a save/load of profile and the profile is what contains the list of source and destination folders, these are kept in prefs.ini in folder MDir in local appdata. There are context menu's that allow for the removal of items from the profile list, either just for the list (in case you dont want to sync a specific folder, just this time) or delete from the list and the .ini . Best regards.
    1 point
  3. Hello Again. After a lot a reasearch here is a working example of the solution that I suggested here. @mLipok @LarsJ This is what I was talking about... #include "Variant.au3" #include "SafeArray.au3" Global Const $sIID_IModelSpace = "{E1E8DC11-DBAF-46E4-978B-06856A0FCF66}" Global $sTagIModelSpace = "" ;Build Dummy Interface Methods For $i = 1 To 47 $sTagIModelSpace &= "Method" & $i & " hresult();" Next ;Append AddPoint Method $sTagIModelSpace &= "AddPoint hresult(struct;ptr*);" Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Local $oAcad = ObjGet("", "AutoCAD.Application.20") If IsObj($oAcad) Then ConsoleWrite("IsObj($oAcad): " & IsObj($oAcad) & @CRLF) Local $oNewModelSpace = ObjCreateInterface($oAcad.ActiveDocument.Modelspace, $sIID_IModelSpace, $sTagIModelSpace) If IsObj($oNewModelSpace) Then ConsoleWrite("IsObj($oNewModelSpace): " & IsObj($oNewModelSpace) & @CRLF) Local $psa, $psaData ; Create safearray of doubles with 3 elements Local $tsaBound = DllStructCreate($tagSAFEARRAYBOUND) DllStructSetData($tsaBound, "cElements", 3) DllStructSetData($tsaBound, "lLbound", 0) $psa = SafeArrayCreate($VT_R8, 1, $tsaBound) Local $tSafeArray = DllStructCreate($tagSAFEARRAY, $psa) ;~ ; Store 5.0, 5.0, 0.0 in safearray SafeArrayAccessData($psa, $psaData) DllStructSetData(DllStructCreate("double", $psaData + 0), 1, 5.0) DllStructSetData(DllStructCreate("double", $psaData + 8), 1, 5.0) DllStructSetData(DllStructCreate("double", $psaData + 16), 1, 0.0) SafeArrayUnaccessData($psa) ; Store safearray in variant of type $VT_ARRAY + $VT_R8 Local $tVar = DllStructCreate($tagVARIANT) Local $pVar = DllStructGetPtr($tVar) DllCall("OleAut32.dll", "none", "VariantInit", "ptr", $pVar) Local $tvt = DllStructCreate("word", $pVar) DllStructSetData($tvt, 1, $VT_ARRAY + $VT_R8) Local $tData = DllStructCreate("ptr", $pVar + 8) DllStructSetData($tData, 1, $psa) Local $pIAcadPoint = 0 $oNewModelSpace.AddPoint($tVar, $pIAcadPoint) ConsoleWrite("$pIAcadPoint: " & $pIAcadPoint & @CRLF) EndIf EndIf Exit ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc A bunch of thanks to trancexx for helping me to solve this. Saludos
    1 point
  4. @PutinVV That's a good question Always from the Help file, you can see that the function WinList() returns a two dimensional array (rows and columns). If you want to obtain the handle of the i-element (i usually stands for Index of the row, used in the array), then you should do something like this: Global $arrWinList = WinList() For $i = 1 To $arrWinList[0][0] Step 1 ConsoleWrite("Window Title = " & $arrWinList[$i][0] & @CRLF & _ "Window Handle = " & $arrWinList[$i][1] & @CRLF) Next If you want to know more about arrays, then take a look at Arrays Wiki and/or at @TheDcoder tutorial
    1 point
  5. WinList('[CLASS:CalcFrame]') Loop through the returned array
    1 point
  6. Just in case if the original poster wanted to know why that extension was block(able). Some .chm(s) could have had malicious code, since it is a webpage and can access the internet. (example:BHO and so forth.) Question answered.
    1 point
  7. I am using this Metro UDF for the application, and I have duplicate the existing InputBox function just for the Password input. Func _Metro_InputPassword($Promt1, $Promt2, $Font_Size = 11, $DefaultText = "", $EnableEnterHotkey = True, $ParentGUI = "") Local $Metro_Input1, $Metro_Input2, $Metro_Input_GUI $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 400, 270, -1, -1, False, $ParentGUI) _Metro_SetGUIOption($Metro_Input_GUI, True) GUICtrlCreateLabel($Promt1, 15 * $gDPI, 20 * $gDPI, 370 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") GUICtrlSetColor(-1, $FontThemeColor) GUICtrlCreateLabel($Promt2, 15 * $gDPI, 95 * $gDPI, 370 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") GUICtrlSetColor(-1, $FontThemeColor) $Metro_Input1 = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 370 * $gDPI, 28 * $gDPI, 32) GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") $Metro_Input2 = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 150 * $gDPI, 370 * $gDPI, 28 * $gDPI, 32) GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") GUICtrlSetState($Metro_Input1, 256) GUICtrlSetState($Metro_Input2, 256) Local $cEnter = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 90, 215, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") GUICtrlSetState($Button_Continue, 512) Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 210, 215, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") GUISetState(@SW_SHOW) If $EnableEnterHotkey Then GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) EndIf If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode While 1 $input_nMsg = GUIGetMsg() Switch $input_nMsg Case -3, $Button_Cancel _Metro_GUIDelete($Metro_Input_GUI) If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode Return SetError(1, 0, "") Case $Button_Continue, $cEnter Local $User_Input1 = GUICtrlRead($Metro_Input1), $User_Input2 = GUICtrlRead($Metro_Input2) If ($User_Input1 <> $User_Input2) Then _Metro_GUIDelete($Metro_Input_GUI) Return SetError(2, 0, "Password Mismatch") ElseIf Not ($User_Input1 = "" Or $User_Input2 = "") Then _Metro_GUIDelete($Metro_Input_GUI) If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode Return $User_Input1 EndIf EndSwitch WEnd EndFunc ;==>_Metro_InputPassword So now I have 2 labels and 2 Inputs, but the cursor always focus on the 2nd one. How can I make it focus on the 1st input instead? Thanks.
    1 point
  8. Xandy

    SDL UDF

    @PedroWarlock My SDL Print function: SDL_Print.zip The example: "Print Test.au3" ; Print Test #include "Include/Print.au3" #include <GUIConstants.au3> OnAutoItExitRegister("_Exit") ; Unmarked Globals: screen, font Main() Func Main() Local $iSCR_W = 320, $iSCR_H = 200 $hGUI = GUICreate("", $iSCR_W, $iSCR_H) EnvSet("SDL_WINDOWID", $hGUI) ; Remark this to create AutoIt window and recieve error messages from AutoIt GUISetState() ; Font to load. This font is 9x9 pixels. $Font_Image_Path = @ScriptDir & "\Graphics\Fonts\qbasic_screen13.txt" ; Startup some SDL $winTitle = StringTrimRight(@ScriptName, 4) $SDL_STARTUP_FLAGS = BitOR($SDL_INIT_IMAGE, $SDL_INIT_SGE, $SDL_INIT_GFX, $SDL_INIT_SPRIG) SDL_Template_Init($iSCR_W, $iSCR_H, 32, $winTitle, $SDL_STARTUP_FLAGS, "", $Font_Image_Path) ; Print to screen ; Line 1 Local $x = 10, $y = 10 Local $r = 255, $g = 255, $b = 255 Local $scale_x = 2, $scale_y = 2 print("SDL_Print", $screen, $x, $y, $r, $g, $b, $scale_x, $scale_y) ; Line 2 $y += $font.iH * $scale_y + 5 Local $b = 0, $g = 0 print("Hello", $screen, $x, $y, $r, $g, $b) _SDL_Flip($screen) Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE EndFunc; Main ; Registered to be called at exit Func _Exit() ; If you don't do this script may hang in Scite after being stopped and not re-run until CTRL+BREAK If $__SDL_DLL <> -1 Then _SDL_Quit() If $__SDL_DLL_image <> -1 Then _SDL_Shutdown_image() If $__SDL_DLL_sge <> -1 Then _SDL_Shutdown_sge() If $__SDL_DLL_sprig <> -1 Then _SDL_Shutdown_sprig() ;) If $__SDL_DLL_GFX <> -1 Then _SDL_Shutdown_gfx() EndFunc ;==>_Exit Output: The font can be scaled in the print function, but it is always faster to have a default size. The file: Font/qbasic_screen13.png is 9x9. The file: Font/qbasic_screen_Scaled.png is 18x18. Load the better default for the current project and you can still scale on the fly from the default. PS: Freetype font and TTF are probably better. I wouldn't know.
    1 point
  9. I've revisited and modified a bit this funny toy. Added some ANSI color renditions (4, 8, 24 bit colors allowed), Added possibility to print big letters using Figlet-Fonts, and also added a script that allows you to quickly 'grab' ascii-arts, (copied from a web page for example) and past into your script in the form of a variable so that can be easily printed on the 'terminal'. (still presence of some flaws) The new stuff is in the vdt folder (I will port asap also the example from the first post to this zip) hope you have fun and ... happy new year everybody! vdt.zip
    1 point
  10. TV-Show-Manager is a small, easy to use application that manages all your favorite tv shows. It is a perfect program for you, if you like watching many tv-shows and need help with keeping track of the airdates and times. Features Manage all your favorite TV-Shows with a single program See all airing times of your shows and how many days/hours/minutes you have to wait for the next episode Don't get confused with all the time zones, TV-Show-Manager converts the airing times to your timezone TV-Schedule - See what shows will be airing in the next 48 hours in US an UK Windows 10 inspired user interface - Customize the user interface with different themes See if your favorit tv shows are canceled or renewed with colored status in your list. Download episodes with one click! (Warning: See notes in full description) Supports link collection for one-click hosters and torrents. (Warning: See notes in full description) Stream episodes with one click (Warning: See notes in full description) I have completely rewritten the program over the past months. It uses the latest version of my MetroGUI UDF and demonstrates what you can do with Autoit if you put in enough time You can download the script and the main program from sourceforge. I have removed all download link collection and other anti-bot-protection bypass features from the script that might be used to damage the site owners. So please don't ask for any of these functions on this forum. Images: Download Script and Main program: https://sourceforge.net/projects/tvshowcountdown/files/
    1 point
  11. Thanks guys. I was really struggling to follow even the simple examples, but after writing the main functionality of populating a form in C#, I was able to understand the Automation class a bit further -- without the abstraction of AutoIT. Then, I turned my attention back to AutoIT and with your guidance above and the C# experience, I wrote a simple UDF for my specific case. Not only do I appreciate the more AutoIT native syntax, the speed is now fully reasonable. The _UAI_SetVar and _UAI_Action methods (using the unaltered UIAWrappers.au3) takes ~4-seconds to enter a user name into a text field. The revised code below populates that field in ~20-milliseconds. Yeah! Thanks again for the guidance. Sample Code: #include "UIAutomation.au3" ; find parent element $hWindow = WinGetHandle('Sunlight MiniOmni') $aeParent = _getAeFromHandle($hWindow) ; find target element $aeTarget = _getAeFromCondition($aeParent, $UIA_AutomationIdPropertyId, 'txtUserName') ; set target element value _setAeValue($aeTarget, 'username here') My Simple UDF (UIAutomation.au3): #include "CUIAutomation2.au3" Global $aInterfaceObj _UIAutomationInit() Func _UIAutomationInit() $aInterfaceObj = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) Return IsObj($aInterfaceObj) ? $aInterfaceObj : False EndFunc ; _UIAutomationInit() Func _setAeValue($aeTarget, $valueStr) Local $patternPointer If Not IsObj($aeTarget) Then Return False $aeTarget.GetCurrentPattern($UIA_ValuePatternId, $patternPointer) $aePattern = ObjCreateInterface( $patternPointer, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern) $aePattern.SetValue($valueStr) EndFunc ;_setAeValue() Func _getAeFromCondition($aeParent, $propType, $propStr) Local $targetPointer, $propCondInterfaceObj If Not IsObj($aInterfaceObj) Then Return False If Not IsObj($aInterfaceObj) Then Return False If Not IsObj($aeParent) Then Return False $aInterfaceObj.createPropertyCondition( $propType, $propStr, $propCondInterfaceObj ) $aeParent.FindFirst( $TreeScope_Descendants, $propCondInterfaceObj, $targetPointer) $ae = ObjCreateInterface( $targetPointer, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) Return IsObj($ae) ? $ae : False EndFunc ; _getAeFromCondition() Func _getAeFromHandle($hWindow) Local $winPointer If Not WinExists($hWindow) Then Return False If Not IsObj($aInterfaceObj) Then Return False $aInterfaceObj.ElementFromHandle( $hWindow, $winPointer ) $ae = ObjCreateInterface( $winPointer, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) Return IsObj($ae) ? $ae : False EndFunc ; _getAeFromHandle()
    1 point
  12. Code Fixed: Mode 1: #include <File.au3> $file = "c:\yourfile.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) msgbox(0,'','the line ' & $i & ' is ' & $line) Next FileClose($file) Mode 2: #include <file.au3> $file = FileOpen("yourfile.txt", 0) While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop MsgBox(0,'',$line) WEnd FileClose($file) Mode 3: #include <Array.au3> #include <File.au3> Local $aInput $file = "yourfile.txt" _FileReadToArray($file, $aInput) For $i = 1 to UBound($aInput) -1 MsgBox (0,'',$aInput[$i]) Next all tested!
    1 point
×
×
  • Create New...