Leaderboard
Popular Content
Showing content with the highest reputation on 06/04/2018 in all areas
-
Majority of users of AutoIt language likes it because it's easy to learn and very powerful when it comes to automating some basically very complicated stuff on windows. AutoIt often does it in just one line of code while doing it in other languages would be writing a full book of code. How to use AutoIt with other languages? One way would be to use AutoItX. Dll version of AutoIt. In this case you can access it through COM or exported functions. Downside surely is limited number of available functions and user rights for COM option. Other way is... no wait, there is no other way. But, what If I add some magic salt to the soup? Let's say I use some of the code from (thanks Manadar) and, yes you guessed AutoItObject, and make a simple (the most basic) COM server that exports almost the whole AutoIt functionality to anyone wanting to use it. AutoItObject 1.2.8.0 makes objects published to ROT (running object table) more accessible than ever. Accessing the object is as easy as GetObject(...) in any scripting language and CoGetObject() through Windows API. An example of VBS would be: Javascript could be: C# PowerShell (based on ptrex's example) Python (AdmiralAlkex) ...and so on. Server script is really minimalistic: All packed in ZIP: AccessAutoIt.zip What you'll find there is folder named AccessAutoIt. Unzip it somewhere and inside there will be five files: AutoItObject.au3 (1.2.8.0), AutoItServer.au3, Csharp.cs, JS.js and VBS.vbs. Run AutoItServer.au3 and then either vbs or js script or compile Csharp.cs and run resulting executable. I have chosen AutoIt.Application object moniker for no particular reason. Can be anything. Latest AutoItObject, if you want the whole thing, is here. AutoIt on your palm. edit: Added c# example. Don't mind about my usage of other languages. I'm not quite familiar with them.1 point
-
corrado33, Every ReDim slows down the script, so having none at all is bound to be faster. However, unless you are absolutely sure that you will never exceed the initial array size, I would suggest not hard coding the maximum size when declaring the array and using a dynamic resize as indicated in the example I showed you. M231 point
-
Func _updateSIRENpanel() ;updates SIREN panel if called out by updateControlPanel function ControlClick($diagnosticsWin, "", "[NAME:cmbCentralPort]", "primary", 1) Send('{DOWN} {ENTER}');selects SIREN _oneClickUp(199, 198) If GUICtrlRead($latestFw) <> 1 Then WinWait($selectFWfile) $SIRENpanelMessage = GUICreate("SIREN port panel", 549, 258, 266, 124) $SIRENportLable = GUICtrlCreateLabel("Which control panel type is plugged into the SIREN port?", 80, 40, 377, 18) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") $SIRENconsRotary = GUICtrlCreateButton("Console ROTARY", 120, 112, 131, 33) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") $SIRENconsPush = GUICtrlCreateButton("Console PUSH", 312, 112, 131, 33) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") $SIRENremPush = GUICtrlCreateButton("Remote PUSH", 24, 176, 123, 33) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") $SIRENremRotary = GUICtrlCreateButton("Remote ROTARY", 208, 176, 123, 33) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") $SIRENhandheld = GUICtrlCreateButton("HandHeld", 392, 176, 123, 33) GUICtrlSetFont(-1, 9, 800, 0, "Verdana") GUISetState() $handle = WinGetHandle( "SIREN port panel") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $SIRENconsRotary _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc") $SIRENpanelStatus = $status ExitLoop Case $SIRENconsPush _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc") $SIRENpanelStatus = $status ExitLoop Case $SIRENremPush _findFwFile('control_panels\', "CP_SO_RE_v02_*.enc") $SIRENpanelStatus = $status ExitLoop Case $SIRENremRotary _findFwFile('control_panels\', "CP_SO_RR_v01_*.enc") $SIRENpanelStatus = $status ExitLoop Case $SIRENhandheld _findFwFile('control_panels\', "CP_SO_HH_v02_*.enc") $SIRENpanelStatus = $status ExitLoop EndSwitch WEnd GUIDelete($handle) EndIf EndFunc Above is the code after I added the ExitLoop and it goes back to the main chunk of code again when its run, YAY! Thank you! My only other issue now is that I would like to have the child gui go away as soon as a button is selected. Any ideas on how to get that to work?1 point
-
GPinzone, I would almost guarantee that deleting all the entries and reloading will be faster than a loop reading the current entry, comparing it to the new value and then rewriting the entry. In this quick example script it is a factor of 10 times slower to do the compare: #include <GUIConstantsEx.au3> #include <GuiListView.au3> Global $aList[100] $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Data stored", 10, 10, 400, 400) For $i = 0 To 99 GUICtrlCreateListViewItem("Item " & $i, $cLV) $aList[$i] = $i Next $cAll = GUICtrlCreateButton("All delete", 10, 450, 80, 30) $cComp = GUICtrlCreateButton("Compare", 250, 450, 80, 30) GUISetState() ; Alter a single element $aList[9] = 100 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cAll $nBegin = TimerInit() _GUICtrlListView_DeleteAllItems($cLV) For $i = 0 To 99 GUICtrlCreateListViewItem("Item " & $i, $cLV) Next ConsoleWrite(TimerDiff($nBegin) & @CRLF) Case $cComp For $i = 0 To 99 If _GUICtrlListView_GetItemText($cLV, $i) <> "Item " & $aList[$i] Then _GUICtrlListView_SetItemText($cLV, $i, "Item " & $aList[$i]) EndIf Next ConsoleWrite(TimerDiff($nBegin) & @CRLF) EndSwitch WEnd M231 point
-
1 point
-
try to set TimeOut for HTTP session .1 point
-
Agreed this wording can easily be misinterptreted. My proposal: Within the same scope, redeclaring an array or a map† will erase its content and reset the dimensions to the new definition (in case of an array)†. Redeclaring a flat variable (not an array nor a map†) without reinitialization is a pointless no-op. † Since the future support of the Map datatype is uncertain (something VERY unfortunate) it may be wise to avoid mentionning it, just as it is missing in some other places of the help file.1 point
-
Hello all I found this function in the Internet It is to play audio files from the compiled script I did not understand just one thing on this function func play($name, $wait = 0) local Const $SND_RESOURCE = 0x00040004 local Const $SND_ASYNC = 1 ; Play the file - the script will pause as it sounds if $wait = 0 then DllCall("winmm.dll", "int", "PlaySound", "str", $name, "hwnd", 0, "int", BitOR($SND_RESOURCE, $SND_ASYNC)) else DllCall("winmm.dll", "int", "PlaySound", "str", $name, "hwnd", 0, "int", $SND_RESOURCE) endIf return 1 endFunc What I did not understand was this variable local Const $SND_RESOURCE = 0x00040004 I know that this variable is contains the resource name But what if I want to change the name of the resource what i'll do? can i do that? Thanks in advance1 point
-
Request a clarification in a function to play audio files from the compiled script
Earthshine reacted to TheXman for a topic
@nacerbaaziz $SND_RESOURCE does not contain the resource name. It is a named, magic number, constant that tells the PlaySound function that the value identifying the sound is a resource ID as opposed to an alias or a file name. Your questions don't seem to be related to AutoIt. If you want to know more about the Win32 API PlaySound() function, you can start here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd743680(v=vs.85).aspx Or Below is link to the help file for AutoIt's _WinAPI_PlaySound() function, which is a wrapper for the Win32 API PlaySound function. https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_PlaySound.htm If I'm wrong and your question is related to AutoIt, then please explain what it is, that relates to AutoIt, that you are having trouble understanding.1 point -
I think in this forum are about a dozen people that understand the power of your library and only a handfull that can write it . With your library and some others as mentioned before we could write in a more oo syntax then currently is possible. So keep up the great piece of work you made and offcourse credits to all people involved in AIO and objcreateinterface.1 point
-
appl3, Welcome to the AutoIt forum. Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked. See you soon with a legitimate question I hope. badcoder123, You might want to give those rules a quick look too - we do not like help being given to obviously illegal questions: M231 point
-
Using Wlanapi.dll in autoit
MrKris1224 reacted to Bilgus for a topic
The Wlan functions require you to hold an open handle to the dll when you use dllcall like above it opens the dll and then closes it Instead you need to use dllopen like so.. #RequireAdmin Global Enum $wlan_hosted_network_opcode_connection_settings = 0, _ $wlan_hosted_network_opcode_security_settings, _ $wlan_hosted_network_opcode_station_profile, _ $wlan_hosted_network_opcode_enable Global $hDll_Wlanapi Global $hWlan = WlanOpenHandle(2, $hDll_Wlanapi) MsgBox(0, "WlanOpenHandle", "handle: " & $hWlan) WlanSetMode($hWlan, False, $hDll_Wlanapi) If @error Then MsgBox(0, "WlanSetMode Error", "error: " & @error & " , extended: " & @extended) WlanCloseHandle($hWlan, $hDll_Wlanapi) Func WlanCloseHandle($hHandle, ByRef $hDll_Wlanapi) Local $aRet = DllCall($hDll_Wlanapi, 'dword', 'WlanCloseHandle', 'handle', $hHandle, 'ptr', Null) DllClose($hDll_Wlanapi) $hDll_Wlanapi = 0 If IsArray($aRet) Then If $aRet[0] = 0 Then Return True Else Return SetError(1, $aRet[0], False) EndIf Else Return SetError(2, 0, False) EndIf EndFunc ;==>WlanCloseHandle Func WlanOpenHandle($dwClientVersion, ByRef $hDll_Wlanapi) If Not $hDll_Wlanapi Then $hDll_Wlanapi = DllOpen("Wlanapi.dll") Local $aRet = DllCall($hDll_Wlanapi, 'dword', 'WlanOpenHandle', 'dword', $dwClientVersion, 'ptr', Null, 'dword*', 0, 'handle*', 0) If IsArray($aRet) Then If $aRet[0] = 0 Then Return $aRet[4] ;phClientHandle Else Return SetError(1, $aRet[0]) EndIf Else Return SetError(2) EndIf EndFunc ;==>WlanOpenHandle Func WlanSetMode($hHandle, $bAllow, $hDll_Wlanapi) ;Any user can call this function to set the Hosted Network properties. ;However, to set the wlan_hosted_network_opcode_enable flag requires elevated privileges Local $tEnable = DllStructCreate("bool bEnabled") DllStructSetData($tEnable, "bEnabled", $bAllow) Local $aRet = DllCall($hDll_Wlanapi, "dword", "WlanHostedNetworkSetProperty", _ "handle", $hHandle, _ "dword", $wlan_hosted_network_opcode_enable, _ "dword", DllStructGetSize($tEnable), _ "ptr", DllStructGetPtr($tEnable), _ "dword", 0, _ "ptr", Null) If IsArray($aRet) Then If $aRet[0] = 0 Then ;0 Means success Return SetError(0) Else ;https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx ;https://msdn.microsoft.com/en-us/library/windows/desktop/dd439506(v=vs.85).aspx Return SetError($aRet[0], $aRet[5]) EndIf Else Return SetError(2) EndIf EndFunc ;==>WlanSetMode Also this has been done already1 point -
Using Wlanapi.dll in autoit
MrKris1224 reacted to Bilgus for a topic
IIRC Bool is 4 Bytes So this would probably work as well but rather than guessing I'd prefer the way above... Func WlanSetMode($hHandle, $bAllow) ;Any user can call this function to set the Hosted Network properties. ;However, to set the wlan_hosted_network_opcode_enable flag requires elevated privileges Local $aRet = DllCall("Wlanapi.dll", "dword", "WlanHostedNetworkSetProperty", _ "handle", $hHandle, _ "dword", $wlan_hosted_network_opcode_enable, _ "dword", 4, _ "bool*", $bAllow, _ "dword", 0, _ "ptr", Null) If IsArray($aRet) Then If $aRet[0] = 0 Then ;0 Means success Return SetError(0) Else ;https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx ;https://msdn.microsoft.com/en-us/library/windows/desktop/dd439506(v=vs.85).aspx Return SetError($aRet[0], $aRet[5]) EndIf Else Return SetError(2) EndIf EndFunc ;==>WlanSetMode1 point -
Using Wlanapi.dll in autoit
MrKris1224 reacted to Bilgus for a topic
The function needs admin privileges to enable Wlan so either run scite as admin or use #RequireAdmin.. ;;#RequireAdmin Global Enum $wlan_hosted_network_opcode_connection_settings = 0, _ $wlan_hosted_network_opcode_security_settings, _ $wlan_hosted_network_opcode_station_profile, _ $wlan_hosted_network_opcode_enable $hWlan = WlanOpenHandle(2) Msgbox(0, "WlanOpenHandle", "handle: " & $hWlan) WlanSetMode($hWlan, False) If @error Then Msgbox(0,"WlanSetMode Error", "error: " & @error & " , extended: " & @extended) Func WlanOpenHandle($dwClientVersion) Local $aRet = DllCall('Wlanapi.dll', 'dword', 'WlanOpenHandle', 'dword', $dwClientVersion, 'ptr', Null, 'dword*', 0, 'handle*', 0) If IsArray($aRet) Then If $aRet[0] = 0 Then Return $aRet[4] ;phClientHandle Else Return SetError(1, $aRet[0]) EndIf Else Return SetError(2) EndIf EndFunc ;==>WlanOpenHandle Func WlanSetMode($hHandle, $bAllow) ;Any user can call this function to set the Hosted Network properties. ;However, to set the wlan_hosted_network_opcode_enable flag requires elevated privileges Local $tEnable = DllStructCreate("bool bEnabled") DllStructSetData($tEnable, "bEnabled", $bAllow) Local $aRet = DllCall("Wlanapi.dll", "dword", "WlanHostedNetworkSetProperty", _ "handle", $hHandle, _ "dword", $wlan_hosted_network_opcode_enable, _ "dword", DllStructGetSize($tEnable), _ ;Let AutoIt supply the size "ptr", DllStructGetPtr($tEnable), _ ;Pointer to the struct "dword", 0, _ "ptr", Null) If IsArray($aRet) Then If $aRet[0] = 0 Then ;0 Means success Return SetError(0) Else ;https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx ;https://msdn.microsoft.com/en-us/library/windows/desktop/dd439506(v=vs.85).aspx Return SetError($aRet[0], $aRet[5]) EndIf Else Return SetError(2) EndIf EndFunc ;==>WlanSetMode you also had your $aRet parameter off by 1 it goes $aRet = DllCall(dllname/handle, returntype($aRet0), FunctionName, Param1Type, $aRet[1], Param2Type, $aRet[2]............)1 point -
I tried, but all it did was eat my +1 mace, and slapped the dungeon master.1 point
-
Hi all, These come courtesy of Malkey (I am not smart enough to do this on my own ) ; Credit: Malkey ; Local $sFile = "C:\Program Files\Another Dir\AutoIt3\AutoIt3.chm" ; Drive letter - Example returns "C" Local $sDrive = StringRegExpReplace($sFile, ":.*$", "") ; Full Path with backslash - Example returns "C:\Program Files\Another Dir\AutoIt3\" Local $sPath = StringRegExpReplace($sFile, "(^.*\\)(.*)", "\1") ; Full Path without backslash - Example returns "C:\Program Files\Another Dir\AutoIt3" Local $sPathExDr = StringRegExpReplace($sFile, "(^.:)(\\.*\\)(.*$)", "\2") ; Full Path w/0 backslashes, nor drive letter - Example returns "\Program Files\Another Dir\AutoIt3\" Local $sPathExDrBSs = StringRegExpReplace($sFile, "(^.:\\)(.*)(\\.*$)", "\2") ; Path w/o backslash, not drive letter: - Example returns "Program Files\Another Dir\AutoIt3" Local $sPathExBS = StringRegExpReplace($sFile, "(^.*)\\(.*)", "\1") ; File name with ext - Example returns "AutoIt3.chm" Local $sFilName = StringRegExpReplace($sFile, "^.*\\", "") ; File name w/0 ext - Example returns "AutoIt3" Local $sFilenameExExt = StringRegExpReplace($sFile, "^.*\\|\..*$", "") ; Dot Extenstion - Example returns ".chm" Local $sDotExt = StringRegExpReplace($sFile, "^.*\.", ".$1") ; Extenstion - Example returns "chm" Local $sExt = StringRegExpReplace($sFile, "^.*\.", "") MsgBox(0, "Path File Name Parts", _ "Drive " & @TAB & $sDrive & @CRLF & _ "Path " & @TAB & $sPath & @CRLF & _ "Path w/o backslash" & @TAB & $sPathExBS & @CRLF & _ "Path w/o Drv: " & @TAB & $sPathExDr & @CRLF & _ "Path w/o Drv or \'s" & @TAB & $sPathExDrBSs & @CRLF & _ "File Name " & @TAB & $sFilName & @CRLF & _ "File Name w/o Ext " & @TAB & $sFilenameExExt & @CRLF & _ "Dot Extension " & @TAB & $sDotExt & @CRLF & _ "Extension " & @TAB & $sExt & @CRLF) Best path splitting tools I have ever seen - I use them all the time. M231 point