Leaderboard
Popular Content
Showing content with the highest reputation on 08/07/2015 in all areas
-
LAST VERSION - 1.0 07-Mar-10 This is my very simple and small UDF. Allows you to restart the script from any location with full restoration of the original command line parameters. I use this library in several of my programs, and I was not disappointed. I hope this UDF will be useful for many as for me. I will be glad to any feedback and suggestions. Restart UDF Library v1.0 Previous downloads: 943 Restart.au3 Example #NoTrayIcon #Include <Misc.au3> #Include <Restart.au3> _Singleton('MyProgram') If MsgBox(36, 'Restarting...', 'Press OK to restart this script.') = 6 Then _ScriptRestart() EndIf1 point
-
Modular JS
jaberwacky reacted to guinness for a topic
If you're like me and think the playlist is a little long, then set the speed to 2 times to cut the duration in half.1 point -
Lets say 2001, when IE 6 was initially released. http://blog.html5test.com/2015/07/a-eulogy-for-internet-explorer-1995-2015/ << Quite a funny video, but also informative that Microsoft did pave the way for a lot of standards e.g. XMLHttpRequest, which is what we now use for Ajax =)1 point
-
As JLogan3o13 says It still work. Look This alternative. ;~ Sound Global Const $MicrosoftSound="Microsoft.Sound" Global Const $GUID_MicrosoftSound="{F2DDFC82-8F12-4CDD-B7DC-D4FE1425AA4D}" ;~ Supported OS: Windows 7, Windows 8, Windows 8.1 Global Const $sCLSID_OpenControlPanel = "{06622D85-6856-4460-8DE1-A81921B41C4B}" Global Const $sIID_IOpenControlPanel = "{D11AD862-66DE-4DF4-BF6C-1F5621996AF1}" Global Const $sTagIOpenControlPanel= "Open hresult(wstr;wstr;ptr);GetPath hresult(wstr;wstr;uint);GetCurrentView hresult(int*)" Local $oOpenControlPanel = ObjCreateInterface($sCLSID_OpenControlPanel, $sIID_IOpenControlPanel, $sTagIOpenControlPanel) ;~ open Playback tab $oOpenControlPanel.Open($MicrosoftSound,"",Null) ;~ open Recording tab $oOpenControlPanel.Open($MicrosoftSound,"1",Null) $oOpenControlPanel=0;Free Saludos1 point
-
I was getting 0x00000 before winactive - and a result after it was activated. In hindsight it was the sleep(1000) that made it work.1 point
-
Why would the Window need to be active to get its handle ? This is working fine for me so what do you get?: ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : WinGetHandle("Untitled - Paint") = ' & WinGetHandle("Untitled - Paint") & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug ConsoleJos1 point
-
For #1: I think you may not have the window activated. Try this to get the handle and see if it works for you ... run("mspaint.exe") sleep(1000) WinActivate("Untitled - Paint") $paintHandle=WinGetHandle("Untitled - Paint") ConsoleWrite(@CRLF&$paintHandle&@CRLF)I think the new paint may have ribbon-like controls that are harder to individually identify. The IUIAutomation MS framework referenced here: https://www.autoitscript.com/forum/topic/153520-iuiautomation-ms-framework-automate-chrome-ff-ie/ may help. On the last issue, if you can't identify the individual properly the send won't take. Try regular send instead of controlsend.1 point
-
check with the iuiAutomation thread in examples section and try if simplespy can reach your control (logically it should as its using the uiautomationcore.dll) most likely the iuiAutomation stuff will have a property of the control if its active yes/no and as such no need to check based on the color.1 point
-
Are you trying to prevent anybody from modifying the EXE or something else? There is always the option to check the hash of the ran program, but of course that check can be updated as well Jos1 point
-
Windows 10 - How To
jvanegmond reacted to guinness for a topic
So you would say it's not at the "cutting edge" of technology! Hahahahaha1 point -
Try using the font name MLW-TTREVATHI, the font packs I've found that list it as ML-TTREVATHI actually have the font name with the W in it.1 point
-
Something like this ? Local $reg = '(?i).*<a\s+href="([^"]+)' Local $text = '<a href="link=1">1</a> <b>2</b> <a href="link=3">3</a> | <a href="link=2">Previous</a> | <a href="link=3">Next</a>' $aData = StringRegExp($text, $reg, 1) ConsoleWrite($aData[0]&@LF)1 point
-
To get the right process icons you have to use a system image list and you have to use PIDLs to get the icons. You can continue with this. Eg. determine which icon you want to use if $icon = 0. #include <GuiListView.au3> #include <GuiImageList.au3> #include <WinAPIProc.au3> #include <WinAPICom.au3> #include <WinAPIShellEx.au3> _WinAPI_CoInitialize() $iStylesEx = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES) $mainForm = GUICreate("test", 500, 500) $List = _GUICtrlListView_Create($mainForm, "Process Name|PID", 0, 0, 500, 500, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) _GUICtrlListView_SetExtendedListViewStyle($List, $iStylesEx) GUISetState(@SW_SHOW) $aProcess = ProcessList() $hImage = GetSystemImageList() _GUICtrlListView_SetImageList($List, $hImage, 1) ;create an image list to pick images from, fill none icon images with an icon from some where else to make shure the images in the image list match the processlist, or images will be wrongly asignet(srry my english xD) For $i = 0 To $aProcess[0][0] $CurIcon = _WinAPI_GetProcessFileName($aProcess[$i][1]) ;ConsoleWrite( "$CurIcon = " & $CurIcon & @CRLF ) ;$icon = _GUIImageList_AddIcon($hImage, $CurIcon,0) $icon = GetIconIndex( $CurIcon ) ;ConsoleWrite( "$icon = " & $icon & @CRLF ) ;if exe does not have an icon extract an icon from shell32 or some where else ;if $icon = -1 then _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 0);using 0 but 2 is exe icon probably not the right one, you will need to correct this one _GUICtrlListView_AddItem($List, $aProcess[$i][0], $icon) ; add items and pick the image position (in $hImage) to show for the exe with $i _GUICtrlListView_AddSubItem($List, $i, $aProcess[$i][1], 1 ) Next GUISetState() While 1 Switch GUIGetMsg() Case -3 Exit EndSwitch WEnd _WinAPI_CoUninitialize() Func GetSystemImageList( $bLargeIcons = False ) Local $tSHFILEINFO = DllStructCreate( $tagSHFILEINFO ) Local $dwFlags = BitOR( $SHGFI_USEFILEATTRIBUTES, $SHGFI_SYSICONINDEX ) If Not $bLargeIcons Then $dwFlags = BitOR( $dwFlags, $SHGFI_SMALLICON ) Local $hIml = _WinAPI_ShellGetFileInfo( ".txt", $dwFlags, $FILE_ATTRIBUTE_NORMAL, $tSHFILEINFO ) If @error Then Return SetError( @error, 0, 0 ) Return $hIml EndFunc Func GetIconIndex( $sFileName ) Local $pPIDL = _WinAPI_ShellILCreateFromPath( $sFileName ) Local $tSHFILEINFO = DllStructCreate( $tagSHFILEINFO ) Local $iFlags = BitOr( $SHGFI_PIDL, $SHGFI_SYSICONINDEX ) ShellGetFileInfo( $pPIDL, $iFlags, 0, $tSHFILEINFO ) Local $iIcon = DllStructGetData( $tSHFILEINFO, "iIcon" ) _WinAPI_CoTaskMemFree( $pPIDL ) Return $iIcon EndFunc Func ShellGetFileInfo($pPIDL, $iFlags, $iAttributes, ByRef $tSHFILEINFO) Local $aRet = DllCall('shell32.dll', 'dword_ptr', 'SHGetFileInfoW', 'ptr', $pPIDL, 'dword', $iAttributes, 'struct*', $tSHFILEINFO, 'uint', DllStructGetSize($tSHFILEINFO), 'uint', $iFlags) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc1 point
-
1 point
-
i know but it's the only way to make money without charging users1 point
-
1 point
-
Probably you don't have the permission on remote system or WMI is not running properly. You can try to provide login credentials (found in my WMI snippets folder): Global Const $oErrorHandler = ObjEvent("AutoIt.Error", "ObjErrorHandler") Global $aNetInfo = WMI_GetInfoFromActiveNetworkCard() Global $fCDriveFreeSpace = WMI_GetCDriveFreeSpace() MsgBox(0, "Test", "Adapter:" & @TAB & $aNetInfo[0] & @CRLF & _ "MAC:" & @TAB & $aNetInfo[1] & @CRLF & _ "IP:" & @TAB & $aNetInfo[2] & @CRLF & _ "Subnet:" & @TAB & $aNetInfo[3] & @CRLF & _ "Gateway:" & @TAB & $aNetInfo[4] & @CRLF & @CRLF & _ "Free space on C drive: " & $fCDriveFreeSpace & " GB") Func WMI_GetInfoFromActiveNetworkCard($sHost = @ComputerName, $sUserID = "", $sPWD = "") Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") If @error Then Return SetError(1, 0, 0) Local $objWMIService = $objWMILocator.ConnectServer($sHost, "\root\cimv2", $sUserID, $sPWD, "", "", 0x80) If @error Then Return SetError(2, 0, 0) Local $iInterfaceIndex, $objItem, $colItems2, $objItem2 Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_IP4RouteTable WHERE Destination='0.0.0.0'", "WQL", 0x30) If IsObj($colItems) Then Local $aActiveNetworkAdapter[5] For $objItem in $colItems $colItems2 = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE InterfaceIndex = " & $objItem.InterfaceIndex, "WQL", 0x30) For $objItem2 in $colItems2 $aActiveNetworkAdapter[0] = $objItem2.Description $aActiveNetworkAdapter[1] = $objItem2.MACAddress $aActiveNetworkAdapter[2] = $objItem2.IPAddress[0] $aActiveNetworkAdapter[3] = $objItem2.IPSubnet[0] $aActiveNetworkAdapter[4] = $objItem2.DefaultIPGateway[0] Return $aActiveNetworkAdapter Next Next Else Return SetError(3, 0, 0) EndIf EndFunc Func WMI_GetInfoFromActiveNetworkCard2($sHost = @ComputerName) Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sHost & "\root\cimv2") If @error Then Return SetError(1, 0, 0) Local $iInterfaceIndex, $objItem, $colItems2, $objItem2 Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_IP4RouteTable WHERE Destination='0.0.0.0'", "WQL", 0x30) If IsObj($colItems) Then Local $aActiveNetworkAdapter[5] For $objItem in $colItems $colItems2 = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE InterfaceIndex = " & $objItem.InterfaceIndex, "WQL", 0x30) For $objItem2 in $colItems2 $aActiveNetworkAdapter[0] = $objItem2.Description $aActiveNetworkAdapter[1] = $objItem2.MACAddress $aActiveNetworkAdapter[2] = $objItem2.IPAddress[0] $aActiveNetworkAdapter[3] = $objItem2.IPSubnet[0] $aActiveNetworkAdapter[4] = $objItem2.DefaultIPGateway[0] Return $aActiveNetworkAdapter Next Next Else Return SetError(2, 0, 0) EndIf EndFunc Func WMI_GetCDriveFreeSpace($sHost = @ComputerName, $sUserID = "", $sPWD = "") Local $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") If @error Then Return SetError(1, 0, 0) Local $objWMIService = $objWMILocator.ConnectServer($sHost, "\root\cimv2", $sUserID, $sPWD, "", "", 0x80) If @error Then Return SetError(2, 0, 0) Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfDisk_LogicalDisk WHERE Name = 'C:'", "WQL", 0x30), $objItem If IsObj($colItems) Then For $objItem in $colItems Return Round($objItem.FreeMegabytes / 1024, 2) Next Else Return SetError(2, 0, 0) EndIf EndFunc Func WMI_GetCDriveFreeSpace2($sHost = @ComputerName) Local $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sHost & "\root\cimv2") If @error Then Return SetError(1, 0, 0) Local $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfDisk_LogicalDisk WHERE Name = 'C:'", "WQL", 0x30), $objItem If IsObj($colItems) Then For $objItem in $colItems Return Round($objItem.FreeMegabytes / 1024, 2) Next Else Return SetError(2, 0, 0) EndIf EndFunc Func ObjErrorHandler() ConsoleWrite( "A COM Error has occured!" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oErrorHandler.description & @CRLF & _ "err.windescription:" & @TAB & $oErrorHandler & @CRLF & _ "err.number is: " & @TAB & Hex($oErrorHandler.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oErrorHandler.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oErrorHandler.scriptline & @CRLF & _ "err.source is: " & @TAB & $oErrorHandler.source & @CRLF & _ "err.helpfile is: " & @TAB & $oErrorHandler.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oErrorHandler.helpcontext & @CRLF _ ) EndFunc1 point
-
Create Classes Fast And Easy
TheAutomator reacted to xroot for a topic
Lots of us have used the "ScriptControl" object in Autoit to create simple classes using jScript, vbScript. For example, I created a simple Car class in jScript. #include "jsFunc.au3" jsc('function Car(make,color,year){') ;Car class jsc('this.make = make;') ;property jsc('this.color = color;') jsc('this.year = year;') jsc('this.Info = function(){return this.year + " " + this.color + " " + this.make;}}') $js.AddCode($jsCode) ;add code to the global module ;MsgBox(0,"jScript",$jscode) ;debug local $car = $js.Eval('new Car("Jaguar F-Type","Black",2015);') ;car class object msgbox(64,"New Car Class 1",$car.Info(),2) ;show car class properties ;change car properties $car.make = "Porsche Speedster" $car.color = "Red" $car.year = 1955 msgbox(64,"New Car Class 2",$car.Info(),2) ;show car class properties The Car class is not very useful. I needed the ability to create classes that makes Autoit more functional and easy to produce with the power of Autoit. The VARIANT class is more interesting and functional, showing todays long date. Of course using vbScript's "FormatDateTime" to show long date in one line is simpler. I'am just trying to show how easy it is too create and use meaningful classes. #include "jsFunc.au3" jsc('function VARIANT(){') ;VARIANT class jsc('this.vt = 0;') ;property jsc('this.union = 0;') jsc('this.Now = new Date().toString();') ;string date object jsc('this.api = new ActiveXObject("Apidll.ApidllC");') ;api class object jsc('this.Ptr = this.api.CallApi("kernel32","GlobalAlloc",64,16);') ;VARIANT structure Ptr jsc('this.StrPtr = this.api.CallApi("kernel32","GlobalAlloc",64,32);') ;VARIANT string Ptr jsc('this.class_Set = function(){') jsc('this.api.Set_Data(this.Ptr ,this.vt ,2);') ;vt_type jsc('this.api.Set_Data(this.Ptr+8,this.union,this.vt);}') ;vt_data ;formats a variant containing named date and time information into a string jsc('this.VarFormatDateTime = function(pvarIn,iNamedFormat,dwFlags,pbstrOut){') jsc('return this.api.CallApi("oleaut32","VarFormatDateTime",pvarIn,iNamedFormat,dwFlags,pbstrOut);}') jsc('this.class_Terminate = function(){') jsc('this.api.CallApi("kernel32","GlobalFree",this.Ptr);') jsc('this.api.CallApi("kernel32","GlobalFree",this.StrPtr);}}') $js.AddCode($jsCode) ;add code to the global module ;MsgBox(0,"jScript",$jscode) ;debug local $longdate = 1 local $dwflags = 0 local $VT_LPWSTR = 31 local $varnt = $js.Eval("new VARIANT();") ;variant class object ; set date variant $varnt.vt = 7 ;vt_type date $varnt.union = (@YEAR-1900)*365+@YDAY+29 ;vt_date data $varnt.class_Set() ;update class variant ;get long date $varnt.VarFormatDateTime($varnt.Ptr, $longdate, $dwflags, $varnt.StrPtr) Msgbox(64,$varnt.Now, $varnt.api.Get_Data($varnt.StrPtr, $VT_LPWSTR)) ;cleanup $varnt.class_Terminate() $varnt = 0 I Created "Apidll.ApidllC", an Activex Class that dynamically calls a function in any dll. This class is simple with a few methods, for more information see the Apidll.chm file. This gives jScript, and vbScript the ability to call the Api and do pointers, and giving Autoit the ability to create classes on the fly. ApiDll.zip1 point