-
Recently Browsing 0 members
No registered users viewing this page.
-
Similar Content
-
By noellarkin
This is the AutoIt script I'm using:
#include <AutoItConstants.au3> Local $Python = "C:\Program Files\Python38" Local $Script = "levenstein.py" Local $String1Path = @ScriptDir & "\string1.txt" Local $String2Path = @ScriptDir & "\string2.txt" Local $Arguments = '"' & $String1Path & '" "' & $String2Path & '"' Local $Concat = $Script & " " & $Arguments ConsoleWrite(@CRLF & $Concat) Local $RunIt = Run(@ComSpec & " /c " & $Concat, @ScriptDir, @SW_HIDE, $STDERR_MERGED) $Output = StdOutRead($RunIt) ConsoleWrite(@CRLF & "Output:" & $Output) It calls the following Python script (levenstein.py):
import re import sys import editdistance def main(): # Check if there are 2 command line arguments if len(sys.argv) != 3: print("Error: Two file paths must be provided") return # Read the contents of the files filepath1 = sys.argv[1] filepath2 = sys.argv[2] string1 = read_file_contents(filepath1) string2 = read_file_contents(filepath2) # Calculate and print the similarity between the two strings similarity = calculate_similarity(string1, string2) print(similarity) def read_file_contents(filepath): # Read the contents of a file into a string with open(filepath, 'r') as f: return f.read() def calculate_similarity(string1, string2): # Calculate the similarity between two strings return 100 - (100 * editdistance.eval(string1, string2) / max(len(string1), len(string2))) # Run the main function if __name__ == '__main__': main() It's working when I run it from cmd, but not when I use AutoIt.
My AutoIt console looks like this:
levenstein.py "C:\test\Autoit Python\string1.txt" "C:\test\Autoit Python\string2.txt" Output: Whereas when I run the exact same command in cmd levenstein.py "C:\test\Autoit Python\string1.txt" "C:\test\Autoit Python\string2.txt" I get an output that's more like 77.08934 which is what I would expect from the .py script.
I believe I must be making a mistake in the way I'm using the Run command.
Note: I'm using Python for Edit Distance because the files I'm comparing are rather large, and I'm not sure if the code snippets I found in the Autoit forum would be effective.
-
By photonblaster
I am looking for advice on next trouble shooting steps for my problem. I have researched this over the last three days and still not solved it. The main reason "run Scite works, exe doesnt" occurs seems to be duplicate names in executable files but I made sure I do not have that problem.
I have a "trivial" script that watches for a login window to pop up, inserts PW and enter/closes. It worked for a year then I experimented with #RequireAdmin on another problem and ran/compiled this one with RequireAdmin to check out what happens as a learning excercise. Now the compiled version MUST be run with admin rights, and I get the UAC approval window which I must avoid in my application, but the SciTe editor version runs from the tools menu (F5) just fine, no UAC. The correlation between using RequireAdmin for a while and the run problem is probably just a coincidence, but I am suspicious.
#include <MsgBoxConstants.au3> ;#RequireAdmin ;trying with and without #requireadmin Opt("SendCapslockMode", 0) ;make sure caps are off Send("{CapsLock off}") Local $myTitle = "User Login Dialog" Local $myPW = "password" & "{ENTER} ; Wait max 10 seconds for the Sign In window to appear. If Not (WinWait($myTitle, "", 10)) Then MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "Error", "LogIn window did not appear or is timed out") EndIf If WinActivate($myTitle) Then ControlSend($myTitle, "", "", $myPW ) ;alternate, also works in editor ;Send($myPW & "{ENTER}") ;MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "INFO", "SENT $myPW enter") Else MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "Error", "Sign In Window did not activate") EndIf Sleep(2000) If (WinExists($myTitle)) Then MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "Error", "LOGIN FAILED") EndIf More info that may be relevant, at least as background info: The LogIn window is from a custom addin to Excel, does not have control ID access to the user/pw entry locations, just the enter/cancel buttons are found by AU3Info. Thus I had to resort to Send, or ControlSend with just the default selection on popup of where the entries go. Fortunately the UserID area remains populated between uses and the PW entry "window" is automatically selected at window popup so I just enter PW text and {enter}.
I can run the compiled file as administrator, OK the UAC window "do you want to allow...", and it runs. (right click the file in file explorer, select "Run as Administrator".
Trying to accept this issue I tried ways to "bypass" the UAC window. I followed instructions on CNET to run the exe file as administrator automatically but the UAC window still comes up: Always run a program in administrator mode in Windows 10 - CNET
I tried to create a shortcut to the exe file through the scheduler following these instructions (other links give the same set of instructions), did not seem to run at all, could not track down any errors I might have made. Open any program as administrator without UAC prompt (winaero.com)
Is there any system settings permanently changed by RequireAdmin? What should I look at to have the exe file run without the UAC window?
Regards and stay healthy!
-
By nacerbaaziz
hello autoit team
is there any wey to check if any process run as admin or no?
i mean e.g if i want to restart any process, now i have the ability to get the process path and commands line
what i need is a wey to check if the process was runing as admin or no to restart it with the same state.
here is the part that am using it to restart the process
func _processRestart($i_pid, $s_ProcessPath) if not (ProcessExists($i_ProcessPid)) then return SetError(1, 0, -1) local $s_ProcessWorkDir = _WinAPI_GetProcessWorkingDirectory($i_ProcessPid) ProcessClose($i_ProcessPid) ProcessWaitClose($i_ProcessPid) ProcessWait(ShellExecute($i_pid,"", $s_ProcessWorkDir)) ProcessesGetList() return true endFunc thanks in advance
-
By shital
#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** RunAs(test", @ComputerName, "testinng",2,"wmic product where ""name= '%notepadexamples%'"" call uninstall", @SystemDir & "\wbem", @SW_MAXIMIZE) it not working
-
By KingOfNothing
This is for mac address spoofing.
Before a mod gives me the ban hammer for posting code such as this, id like to explain I recently had a necessity for it.
A lot of places use mac addresses to identify devices/machines and control internet permissions.
I myself love the xfinity wifi hotspots placed all around where I live as I can connect to them and save data usage instead of tethering my phone.
BUT! They use a captive portal with a webpage interface in javascript and (not too much to my surprise), wifey says some of her crap wont open that page.
I explained she can disable wifi on the device, use computer and spoof to the mac address of what she wants to use. Then sign into the portal as she would normally with computer.
Once connected, shut the computer down and enable wifi for that device again. Once enabled shes got net access. edit: Wife looked at me like I was speaking latin.....lol
; ; ; Function: Set_Mac() ; ; Parameter(s): $s_Desired_Mac = Need I really explain? ; $s_Target_Net_Adapter = Network adapter name (one can use the adapter index as well but thats less "user friendly" ; $b_Toggle_Device = For my wife cuz it needs full automation for her to stop bothering me ; ; Author(s): KingOfNothing credz to google & autoitscript.com members ; ; ;===================================================================== Opt('MustDeclareVars', 0) ;cause its late in the morning and im just gonna trust this should still fly #include <WinApi.au3> $MacAddressRegKey = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0007" ; ^^^ After making this I read online that this should be some "CurrentControlSet" ; key instead. However, I watched registry while changing things in adapter properties ; to see that key, which works fine on my 3 test machines.... ;easy example Set_Mac("Wireless Network Connection","",true) ;msgbox(0,"",Get_Mac()) Func Set_Mac($s_Targeted_Adapter, $s_Desired_Mac = "D20000000000", $b_Toggle_Device = true ) Local $sMac, $s_Tmp, $val, $sVar = "" $sMac = Get_Mac() while stringlen($s_Desired_Mac)< 12 and stringlen($s_Desired_Mac)> 0 ;this will append zeros if mac length is too short $s_Desired_Mac = $s_Desired_Mac & "0" wend if stringlen($s_Desired_Mac)> 12 then ;likewise if too many characters entered to function, then we should truincate some $s_Desired_Mac = StringLeft ($s_Desired_Mac,12) endif ;this creates a random mac address with very little actual thought behind it. ;Im sure theres some formal means to devising a valid mac address but this simple crap suits my needs atm.... if $s_Desired_Mac = "" then For $i = 1 To 10 $sVar= Chr(Random(48, 57, 1)) ;0-9 $s_Tmp = $s_Tmp & $sVar Next $s_Desired_Mac = "D2" & $s_Tmp $s_Desired_Mac = StringUpper($s_Desired_Mac) endif $val = RegWrite($MacAddressRegKey, "NetworkAddress", "REG_SZ", $s_Desired_Mac) if $val =0 then MsgBox(0,"Mac Address Changer ","Could not write to registry as needed to change your mac address!" & @CRLF & "Please restart this program with administrator rights!") Exit endif ;in order to benifit from changing the registry, one must disable/re-enable the adapter. ;This cmd line query to wmic prevents the need to do so in device manager manually if $b_Toggle_Device = true then ShellExecuteWait ("C:\Windows\System32\wbem\wmic.exe", "path win32_networkadapter where NetConnectionID=" & chr(34) & $s_Targeted_Adapter & chr(34) & " call disable" ,"",$SHEX_OPEN,@SW_HIDE) ShellExecuteWait ("C:\Windows\System32\wbem\wmic.exe","path win32_networkadapter where NetConnectionID=" & chr(34) & $s_Targeted_Adapter & chr(34) & " call enable" ,"",$SHEX_OPEN,@SW_HIDE) endif ;Would be smart to catch the return of the function there in some varible for error handling, but its too late for me to give a crap atm.... MsgBox(0,"Mac Address Changer", "Old Mac = " & $sMac & @crlf & "New Mac = " & $s_Desired_Mac) clipput($s_Desired_Mac) endfunc Func Get_Mac() Local $xRet $xRet= RegRead($MacAddressRegKey, "NetworkAddress") return $xRet EndFunc
Sorry bout the messy penmenship. Aint looked at the tidy thing yet....🧐
-
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now