Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/17/2020 in all areas

  1. ClipPut(FileGetVersion("\\path\file.exe"))
    2 points
  2. TheAutomator, There is no automatic alert for bugs, but we check Trac regularly. And I have amended the thread title as you requested. I can certainly reproduce the problem and I am trying to see if I can find a pattern to what actually triggers the freezing - at the moment the script seems to be waiting at the Sleep(50) line but I cannot understand why this should occur. There also appears to be little pattern to the makeup of the string preceding the @CRLF as I can get the same symptoms using other character combinations - so the particular string you used does not appear to be "magic" in any particular way. I did wonder if the actual location of the @CRLF within the string was critical, but again it does not seem to be the case from my tests so far. I will keep plugging away and see if I can come up with something. M23
    2 points
  3. LarsJ

    UI Automation Events

    UI Automation Events In standard Windows GUI code, you can respond to Windows messages by registering and implementing a message handler function. A WM_NOTIFY message handler is registered and implemented in this way: ; Registration GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) ; Implementation Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) ; Code EndFunc The WM_NOTIFY function is a callback function. In UI Automation code, you can respond to UI Automation events by registering and implementing an event handler object. A FocusChangedEventHandler object is registered and implemented in this way: ; Registration UIAEH_FocusChangedEventHandlerCreate() $oUIAutomation.AddFocusChangedEventHandler( 0, $oUIAEH_FocusChangedEventHandler ) ; Implementation ; This is the function that receives events Func UIAEH_FocusChangedEventHandler_HandleFocusChangedEvent( $pSelf, $pSender ) ; Code EndFunc $oUIAEH_FocusChangedEventHandler is the event handler object. It's a callback object. This thread is about how to respond to UI Automation events by registering, implementing and using event handler objects. User Defined Functions Registering and implementing the event handler object in the code above is very simple. To make it that simple, it's necessary to include a few functions in a UDF. The zip-file at bottom of post contains a UIAEH_FocusChangedEventHandler.au3 UDF that allows the registration and implementation of the event handler object as simple as shown above. UIAEH_FocusChangedEventHandlerCreate() is a function in this UDF. The function creates the $oUIAEH_FocusChangedEventHandler object. Because this is a callback object it must be implemented through ObjectFromTag() (coded in ObjectFromTag.au3 in zip-file) function by trancexx and not through the usual ObjCreateInterface() which is used to create other UI Automation objects. (The warning at top of the help text is much more an error in the help text than an error in the function. Thousands of examples show that ObjCreateInterface() works flawlessly.) You don't need to use ObjectFromTag() in your own code. This function is completely handled in the UDFs. UIAEH_FocusChangedEventHandler_HandleFocusChangedEvent() is the function that receives events. This function is coded but commented out in UIAEH_FocusChangedEventHandler.au3. Copy this function to your own code. See FocusChangedEventHandler example below. UIA Event Handlers The first version of Microsoft's UI Automation code (the Windows 7 version that works on Windows XP, Windows Vista, Windows 7 and all later versions) implements four different event handler objects. In addition to the FocusChangedEventHandler object, it's the AutomationEventHandler, PropertyChangedEventHandler and StructureChangedEventHandler objects. The zip-file at the bottom contains the corresponding three event handler UDFs. By the way, these four event handlers are implemented in AutoIt several years ago in this and the following posts. FocusChangedEventHandler exposes a method to handle events that are raised when the keyboard focus moves to another UI Automation element. AutomationEventHandler exposes a method to handle Microsoft UI Automation events. These events include MenuOpened ($UIA_MenuOpenedEventId) and Window_WindowOpened ($UIA_Window_WindowOpenedEventId) events. See module UIA_EventIds in UIA_Constants.au3 for a complete list. Note that EventIds that belong to Windows 8 or later cannot be used in this version of the event handler. But they can be used after code updates over the coming weeks. 2019-12-15 If you select Desktop, AutomationEvent and all Events (Event Ids) in UI Automation Event Monitor below and click Start, you'll see the following output in SciTE console: $oUIAEH_AutomationEventHandler OK Desktop: AddAutomationEventHandler() = AsyncContentLoaded OK Desktop: AddAutomationEventHandler() = AutomationFocusChanged ERR Desktop: AddAutomationEventHandler() = AutomationPropertyChanged OK Desktop: AddAutomationEventHandler() = InputDiscarded OK Desktop: AddAutomationEventHandler() = InputReachedOtherElement OK Desktop: AddAutomationEventHandler() = InputReachedTarget OK Desktop: AddAutomationEventHandler() = Invoke_Invoked OK Desktop: AddAutomationEventHandler() = LayoutInvalidated OK Desktop: AddAutomationEventHandler() = MenuClosed OK Desktop: AddAutomationEventHandler() = MenuModeEnd OK Desktop: AddAutomationEventHandler() = MenuModeStart OK Desktop: AddAutomationEventHandler() = MenuOpened OK Desktop: AddAutomationEventHandler() = Selection_Invalidated OK Desktop: AddAutomationEventHandler() = SelectionItem_ElementAddedToSelection OK Desktop: AddAutomationEventHandler() = SelectionItem_ElementRemovedFromSelection OK Desktop: AddAutomationEventHandler() = SelectionItem_ElementSelected OK Desktop: AddAutomationEventHandler() = StructureChanged OK Desktop: AddAutomationEventHandler() = Text_TextChanged OK Desktop: AddAutomationEventHandler() = Text_TextSelectionChanged OK Desktop: AddAutomationEventHandler() = ToolTipClosed OK Desktop: AddAutomationEventHandler() = ToolTipOpened OK Desktop: AddAutomationEventHandler() = Window_WindowClosed OK Desktop: AddAutomationEventHandler() = Window_WindowOpened OK Note the error for the AutomationFocusChanged event handler (at the top of the list). I've found that there is an error, but so far have no explanation for it. PropertyChangedEventHandler exposes a method to handle Microsoft UI Automation events that occur when a property is changed. These events include Name ($UIA_NamePropertyId) and ValueValue ($UIA_ValueValuePropertyId) changes. See module UIA_PropertyIds in UIA_Constants.au3 for a complete list. Note that PropertyIds that belong to Windows 8 or later cannot be used in this version of the event handler. But they can be used after code updates over the coming weeks. StructureChangedEventHandler exposes a method to handle events that occur when the Microsoft UI Automation tree structure is changed. This event handler seems to be more valuable in eg. screen readers than in usual UI Automation code. NotificationEventHandler exposes a method to handle Microsoft UI Automation notification events. See this post. FocusChangedEventHandler example This is full code in Examples\FocusChangedEventHandlerEx.au3. Run the code in SciTE with F5. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;#AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include "..\Includes\UIAEH_FocusChangedEventHandler.au3" Example() Func Example() UIAEH_FocusChangedEventHandlerCreate() If Not IsObj( $oUIAEH_FocusChangedEventHandler ) Then Return ConsoleWrite( "$oUIAEH_FocusChangedEventHandler ERR" & @CRLF ) ConsoleWrite( "$oUIAEH_FocusChangedEventHandler OK" & @CRLF ) Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) Local $iError = $oUIAutomation.AddFocusChangedEventHandler( 0, $oUIAEH_FocusChangedEventHandler ) If $iError Then Return ConsoleWrite( "AddFocusChangedEventHandler() ERR" & @CRLF ) ConsoleWrite( "AddFocusChangedEventHandler() OK" & @CRLF ) HotKeySet( "{ESC}", "Quit" ) While Sleep(10) WEnd EndFunc Func Quit() UIAEH_FocusChangedEventHandlerDelete() Exit EndFunc ; This is the function that receives events Func UIAEH_FocusChangedEventHandler_HandleFocusChangedEvent( $pSelf, $pSender ) ; Ret: long Par: ptr ConsoleWrite( @CRLF & "UIAEH_FocusChangedEventHandler_HandleFocusChangedEvent: " & $pSender & @CRLF ) Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) $oSender.AddRef() ConsoleWrite( "Title = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NamePropertyId ) & @CRLF & _ "Class = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ClassNamePropertyId ) & @CRLF & _ "Ctrl type = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ControlTypePropertyId ) & @CRLF & _ "Ctrl name = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _ "Handle = " & "0x" & Hex( UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & _ "Value = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ValueValuePropertyId ) & @CRLF ) Return 0x00000000 ; $S_OK #forceref $pSelf EndFunc ; Auxiliary function (for simple properties only) ; There must be only one instance of this function Func UIAEH_GetCurrentPropertyValue( $oSender, $iPropertyId ) Local $vPropertyValue $oSender.GetCurrentPropertyValue( $iPropertyId, $vPropertyValue ) Return $vPropertyValue EndFunc Test the code by opening the Desktop context menu and move the mouse over the menu items. When the mouse hovers over a menu item it gets focus. Exit with Esc. AutomationEventHandlerEx.au3 Test the example by opening some windows, menus and tooltips. PropertyChangedEventHandlerEx.au3 Open Windows Task Manager (Ctrl+Shift+Esc) and you'll get a whole bunch of property changed events. Note that to access Windows Task Manager (and other programs) on Windows 10, use #RequireAdmin in the script and run SciTE as administrator. StructureChangedEventHandlerEx.au3 Clicking on a folder in File/Windows Explorer treeview generates a lot of structure changed events. New examples will be added over the coming weeks. UI Automation Event Monitor UI Automation Event Monitor is a tool to detect UI Automation events. The first group of toolbar buttons is used to set up the UI Automation event handler. The images have a PropertyChangedEventHandler set up to monitor Name ($UIA_NamePropertyId) and ValueValue ($UIA_ValueValuePropertyId) property changes in Windows Task Manager. Note that to access Windows Task Manager (and other programs) on Windows 10, use #RequireAdmin in the script (UIAEHEvents.au3) and run SciTE as administrator. These four toolbar buttons are hot-track enabled with the technique used in this example. The buttons open four listviews to set up the event handler. All listviews have multiple selections enabled. Select multiple items at once and check a single item in/out to check all selected items in/out. Use mouse or Space key to check an item in/out. In the first image, the mouse hovers over the Top Windows button so that it's selected. In the second image, the Top Windows button is clicked so that the listview is opened. Moving the mouse over the next three buttons automatically opens the corresponding listviews due to hot-tracking. Click the toolbar button again to close the listview or move the mouse above the title bar. Windows Task Manager is checked in the Top Windows listview. The Event Handlers listview is enabled when a Top Window is checked. The Event Ids listview is enabled when the AutomationEvent event handler is checked. The Property Ids listview is enabled when the PropertyChanged event handler is checked. In Event Ids and Property Ids listview you can select an item by pressing the first letter on the keyboard. The second group of toolbar buttons is used to Start/Stop the event handler (or multiple event handlers), Pause/Continue updating the Events listview, and Clear the listview. Note that the Pause button only stops updating the listview. Events are still detected and stored in $aEvents array. All new events are added at the bottom of the listview when you click Continue or Stop. The Pause Main Loop button is used to stop the GUI main loop, which significantly increases the performance of the Events listview. When the GUI main loop is paused you can only click the Continue Main Loop button (same button as Pause Main Loop) and you can close the GUI. Events listview The Events listview is a virtual listview because of performance and to make it easy to constantly add new rows to the bottom of the listview. Nevertheless, there can still be performance issues when a lot of events are generated. To remedy these issues, it's possible to stop the GUI main loop with the Pause Main Loop button. This significantly increases the performance of the Events listview. When there are a large number of events (when many new rows are added quickly at the bottom of the listview), this procedure must be followed to stop the event handler (or multiple event handlers): Make sure the GUI main loop isn't paused. Click the Pause button (second toolbar group) to pause Events listview updates. Click the Stop button to stop the event handler. When there are a small number of events you can immediately click the Stop button. To test the UI Automation Event Monitor, try performing the four examples (in Examples\, briefly described above) through the monitor GUI. There'll probably be some GUI updates in the coming weeks. UIA Menu, Tooltip and Window Events Monitor is a simpler version of UI Automation Event Monitor that detects only MenuOpened, ToolTipOpened and Window_WindowOpened events (AutomationEvents). Updates Windows 8, Windows 8.1 and Windows 10 updates Threads UI Automation UDFs contains all include files. UIASpy - UI Automation Spy Tool is a GUI tool that provides information about windows and controls and their interconnection and provides functionality to generate sample code. UIASpy is essential for creating UI Automation code. In Using UI Automation Code in AutoIt you can find and download examples and read information about using UIA code. IUIAutomation MS framework automate chrome, FF, IE, .... created by junkew August 2013 is the first AutoIt thread on UIA code. Zip-file The zip contains source files for GUIs and examples. Note that UI Automation UDFs must be installed in the Includes folder. You need AutoIt 3.3.12 or later. Tested on Windows 7 and Windows 10. Note that under Windows 7 and earlier versions, only the original four event handlers (AutomationEventHandler, FocusChangedEventHandler, PropertyChangedEventHandler, StructureChangedEventHandler) introduced in Windows 7 can be used. Comments are welcome. Let me know if there are any issues. UIAEHEvents.7z
    1 point
  4. @Dion07 Yes, just tried it. it works ^.^
    1 point
  5. Or maybe this ? Local $sVersion = FileGetVersion("\\path\file.exe") If Not DirCreate (".\" & $sVersion) Then Exit MsgBox (0,"Error","Unable to create folder")
    1 point
  6. 1 point
  7. Local $File_Version = FileGetVersion("file.exe") Hello there, i think you should start by putting that file version in a variable so you can use it later to create your folder
    1 point
  8. Trueeeeeeeee ! it worked also, that's nice I prefer Hex too.
    1 point
  9. If you got multiple colors to search, you could also make it in a loop (with a Const $array) instead of using embedded IF. Would make it more compact and readable.
    1 point
  10. Could you show the DOM area of the object "bloodrain" ? Beside it is just a warning not an error ! Use this : Local $oIE = _IECreate($sUrl) ConsoleWrite (Povtor("bloodrain") & @CRLF) Func Povtor($sDivId) Local $Count = 0 While True Sleep(100) Local $oDiv = _IEGetObjById($oIE, $sDivId) If IsObj($oDiv) Then _IEAction($oDiv, "click") _IELoadWait($oIE) Return True Else $Count += 1 if $Count > 500 then return False EndIf WEnd EndFunc
    1 point
  11. Something like this : Local $x = 100, $y = 100 Local $aCoord = PixelSearch($x , $y , $x+150 , $y+150 , 0xFF0000) If Not @error Then MsgBox ($MB_SYSTEMMODAL,"","Pure Red found at " & $aCoord[0] & "/" & $aCoord[1]) Else $aCoord = PixelSearch($x , $y , $x+150 , $y+150 , 0x00FF00) If Not @error Then MsgBox ($MB_SYSTEMMODAL,"","Pure Green found at " & $aCoord[0] & "/" & $aCoord[1]) Else $aCoord = PixelSearch($x , $y , $x+150 , $y+150 , 0x0000FF) If Not @error Then MsgBox ($MB_SYSTEMMODAL,"","Pure Blue found at " & $aCoord[0] & "/" & $aCoord[1]) Else MsgBox ($MB_SYSTEMMODAL,"","No color found") EndIf EndIf EndIf If you only want to search for a single pixel, use PixelGetColor () instead...
    1 point
  12. The tool takes a "snapshot" of your system. Then you scroll through the pages of information like a book. Its broken down into sections heaps, modules, threads and processes. The only limitation is it only has the same rights as the user so if you're running as a base level user you're not going to get as much info as a person running as admin. Also you can only obtain information about the modules loaded into the memory of the calling process. This is pretty standard across all calls for module information. As you can clearly see from the example a user needs to use the CreateToolhelp32Snapshot_onit at the beginning of their code. It builds all the structs and sets the size of the struct to the first value of the structure. Then call xxxx32first() to initiatialize the group then every subsequent call is made to xxxx32next(). The displays are exactly that displays to demonstrate its working. How you harvest and use the information is up to you. The sample is just a sample the main functions that make it work live in the 32Snapshot.AU3 that is attached. Last but not least what makes this useful vs the built in calls for processlist(), _winapi_Enummodule() etc is that this returns more information. Instead of just the name and pid of a process it returns information about the base address, parent processes, how many threads all types of stuff. UPDATE v1.0 There were issues i just found with the modules part of the script. Should be fixed now Update: Its all fixed up seems to be operating correctly let me know otherwise. If you are using any of the 32W functions let me know how theyr working. I couldn't test those. But ever edit that was made to their counterpart were made to the 32W UPDATE Edit edit there was a logic issue in the newly posted sample script $bool[0][0] will never be false if its an array. needs to be $bool[0][1]<>0 Its fixed in the latest sample as of the time i press this button. UPDATE!!!!!!!!!!!!!!!!!!! wasnt able to get information on the processes and I was wondering if autoit.exe was set to run as admin even tho the script was set to require admin.... the fact that the autoit.exe was not set to run as admin i wasn't getting all the info. . New file uploaded. Should be perfect this time . This is my wrapper on the Toolhelp32snapshot functions available on the kernel32.dll. I'm super stoked on it. Probably the best thing I've ever written. Looking for some testers. I'd also like to note if you're not getting the expected results it is possible that it's a bug in the script it is also possible that you have virus protection running or not running scite as admin or some other privileges issue. That's about as far as I can go on that subject. https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/ ;~ ============================================================================================================================================================================================================================= ;~ Title Description Author:$MarkyRocks!! ;~ ========================================================================================================================================================================================================================================== ;~ CreateToolhelp32Snapshot($Flags,$ProcessID ) Takes a snapshot of the specified processes, as well as the heaps, modules, and threads used by these processes. ;~ ======================================================================================================================================================================================================================================== ;~ Heap32First($hSnapShot) Retrieves information about the first block of a heap that has been allocated by a process. ;~ ================================================================================================================================================================================================================================================ ;~ ===================================================================================================================================================================================================================================================== ;~ Heap32Next($hSnapShot) Retrieves information about the next block of a heap that has been allocated by a process. ;~ ================================================================================================================================================================================================================================================== ;~ Module32First($hSnapShot) Retrieves information about the first module associated with a process. ;~ ======================================================================================================================================================================================================================================================== ;~ Module32FirstW($hSnapShot) Retrieves information about the first module associated with a process. ;~ ================================================================================================================================================================================================================================================== ;~ Module32Next($hSnapShot) Retrieves information about the next module associated with a process or thread. ;~ ================================================================================================================================================================================================================================================== ;~ Module32NextW($hSnapShot) Retrieves information about the next module associated with a process or thread. ;~ ================================================================================================================================================================================================================================================== ;~ Process32First($hSnapShot) Retrieves information about the first process encountered in a system snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Process32FirstW($hSnapShot) Retrieves information about the first process encountered in a system snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Process32Next($hSnapShot) Retrieves information about the next process recorded in a system snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Process32NextW($hSnapShot) Retrieves information about the next process recorded in a system snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Thread32First($hSnapShot) Retrieves information about the first thread of any process encountered in a system snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Thread32Next($hSnapShot) Retrieves information about the next thread of any process encountered in the system memory snapshot. ;~ ================================================================================================================================================================================================================================================== ;~ Toolhelp32ReadProcessMemory($th32ProcessID,$lpBaseAddress,$lpBuffer,$cbRead,$lpNumberOfBytesRead) Copies memory allocated to another process into an application-supplied buffer. ;~ ================================================================================================================================================================================================================================================== ;~ CreateToolHelp32Snapshot_OnInit() Builds the structs gets things ready !!!!!!!!!!Must Be Ran on Start of your code ;~ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;~ CreateToolHelp32Snapshot_OnExit() Release Memory resources SHOULD Be automatic but it can't hurt to run it anyways ;===================================================================================================================================================================================================================================================== ;~ CreateToolhelp32Snapshot($flags,$iPID) Takes a snapshot of the specified processes, as well as the heaps, modules, and threads used by these processes. ;~ ;~ Returns a Handle to the Snapshot of the system or Exit on fail Markyrocks ;~====================================================================================================================================================================================================================================================== just a sample of how it works. The include is attached for download 32Snapshot.au3
    1 point
  13. Take a look at this snippet, it blocks all user inputs for a single window, but still allows programmatic manipulations : #include <Constants.au3> #include <GUIConstants.au3> #include <WinAPISys.au3> Opt ("MustDeclareVars", 1) Local $Form1 = GUICreate("Enable Window", 362, 190, 192, 124) Local $Label1 = GUICtrlCreateLabel("Test of Window Enable", 56, 40, 115, 17) Local $Input1 = GUICtrlCreateInput("Input1", 192, 38, 145, 21) Local $Button1 = GUICtrlCreateButton("OK", 128, 104, 89, 33) _WinAPI_EnableWindow ($Form1,False) GUISetState(@SW_SHOW) Sleep (1000) GUICtrlSetData ($Input1, "Test") ControlClick ($Form1, "", $Button1) Local $t = TimerInit () While 1 If TimerDiff ($t) > 10000 Then _WinAPI_EnableWindow ($Form1,True) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 ConsoleWrite ("Button1 was pressed" & @CRLF) EndSwitch WEnd
    1 point
  14. @topgundcp: the function used doesn't seem to be the good one : _GUICtrlListView_GetItemSelected() As the title thread & the picture you posted indicate a list box (not a listview) then this instruction should be used instead : _GUICtrlListBox_GetCurSel($listEdition)
    1 point
  15. @topgundcp You would help us in making a runable snippet of your code instead of showing us only a small part of the script. You would get much more help that way. Help us to help you...
    1 point
  16. Welcome to the forums. I'm afraid you cannot expect much help on this unless you post a short test script that reproduces the error, so we can have a look at what might be the issue. If/when yo udo, please use the "code tags" button (looks like this: <>) above the text window to post your code. Thanks.
    1 point
  17. @MarkIT please open a ticket here: https://www.autoitscript.com/trac/autoit/timeline
    1 point
  18. i dont see where you define $editionArray your comment says editionArray contains the total count of items, but i dont see in your script where you tell it that.
    1 point
  19. 1 point
  20. Are you using UPX program compression? #AutoIt3Wrapper_UseUpx=Y
    1 point
  21. The challenge with .NET CLR and AutoIT is that the data type conversion between the 2 is not working out well in some cases.... Better approach is to use the PS AUTOMATION Object that works in 100% of the cases. Because the type conversion is done outside of the CLR host. Example : (Dont forget to change the database connection details) #AutoIt3Wrapper_UseX64=y #include "CLR.Au3" Local $PS_Script = "CLS" & @LF $PS_Script &= "" & @LF $PS_Script &= "$QueryStr = 'Select * From TableX'" & @LF $PS_Script &= "" & @LF $PS_Script &= "$SqlConnection = New-Object System.Data.SqlClient.SqlConnection" & @LF $PS_Script &= "" & @LF $PS_Script &= "$SqlConnection.ConnectionString = 'Server=serverip;Database=dbname;UID=user;PWD=aaaa;'" & @LF $PS_Script &= "" & @LF $PS_Script &= "$SqlCmd = New-Object System.Data.SqlClient.SqlCommand" & @LF $PS_Script &= "$SqlCmd.CommandText = $QueryStr" & @LF $PS_Script &= "" & @LF $PS_Script &= "$SqlCmd.Connection = $SqlConnection" & @LF $PS_Script &= "" & @LF $PS_Script &= "$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter" & @LF $PS_Script &= "$SqlAdapter.SelectCommand = $SqlCmd" & @LF $PS_Script &= "" & @LF $PS_Script &= "$DataSet = New-Object System.Data.DataSet" & @LF $PS_Script &= "$SqlAdapter.Fill($DataSet) " & @LF $PS_Script &= "" & @LF $PS_Script &= "'Rows # : ' + $DataSet.tables.rows.count" & @LF $PS_Script &= "$DataSet.tables.rows | Out-GridView -Title AutoIT # Export-CSV " & @LF $PS_Script &= "" & @LF $PS_Script &= "$SqlConnection.Close() " & @LF $PS_Script &= "" & @LF _Run_PSHost_Script($PS_Script) Func _Run_PSHost_Script($PSScript) Local $oAssembly = _CLR_LoadLibrary("System.Management.Automation") ConsoleWrite("!$oAssembly: " & IsObj($oAssembly) & @CRLF) ; Create Object Local $pAssemblyType = 0 $oAssembly.GetType_2("System.Management.Automation.PowerShell", $pAssemblyType) ConsoleWrite("$pAssemblyType = " & Ptr($pAssemblyType) & @CRLF) Local $oActivatorType = ObjCreateInterface($pAssemblyType, $sIID_IType, $sTag_IType) ConsoleWrite("IsObj( $oAssemblyType ) = " & IsObj($oActivatorType) & @TAB & @CRLF) ; Create Object Local $pObjectPS = 0 $oActivatorType.InvokeMember_3("Create", 0x158, 0, 0, 0, $pObjectPS) ConsoleWrite("IsObject: " & IsObj($pObjectPS) & @TAB & "$pObject: " & ObjName($pObjectPS) & @CRLF) ; <<<<<<<<<<<<<<<<<<< PS COMMAND HERE >>>>>>>>>>>>>>>>>>>> $pObjectPS.AddScript($PSScript) ; Add Script here ;~ ConsoleWrite($PSScript & @CRLF) $objAsync = $pObjectPS.BeginInvoke ; (2); ($oActivatorType,$oActivatorType) While $objAsync.IsCompleted = False ;~ ConsoleWrite($objAsync.IsCompleted & @CRLF) ContinueLoop WEnd ConsoleWrite("Completed : " & $objAsync.IsCompleted & @CRLF) $objPsCollection = $pObjectPS.EndInvoke($objAsync) ;~ ConsoleWrite("$objPsCollection: " & IsObj($objPsCollection) & @TAB & "$objPsCollection: " & ObjName($objPsCollection) & " - " & ObjName($objPsCollection,6) & " - " & ObjName($objPsCollection,3) & @CRLF) $Whnd = WinGetHandle("AutoIT") ConsoleWrite($Whnd & @CRLF) WinWaitClose($Whnd) ConsoleWrite("closed !" & @CRLF) EndFunc Enjoy !
    1 point
  22. Does a certificate really guarantee your app won't get flagged? We have a client that says our app was getting quarantined, so we signed it with Entrust CA. Apparently Windows Defender is still flagging it, but now at least he gets an option to run it anyway. There's a little bit of an English issue, but we're going to set up a laptop here with the same version of MS Windows Defender and see if we can duplicate it in-house.
    1 point
  23. Yashied

    How to clear the console?

    ControlSetText('', '', 'Scintilla2', '')?
    1 point
×
×
  • Create New...