
photonblaster
Members-
Posts
12 -
Joined
-
Last visited
Everything posted 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!
-
subtleties of _Excel_Open
photonblaster replied to photonblaster's topic in AutoIt General Help and Support
Thanks for the all the feedback...these are subtleties that are hard to find for AutoIt novices . -
I am trying to make sure I completely understand how _Excel_Open works. The help file says "Connects to an existing Excel instance or creates a new one". So I would expect the following sequence to result in two open Excel, and $oExcel3=$oExcel1 (or maybe $oExcel2) Local $oExcel1 = ObjCreate("Excel.Application") Local $oExcel2 = _Excel_Open(Default, Default, Default, Default, True) Local $oExcel3 = _Excel_Open() Using the example from the help file as a starting point, I added the third opening of Excel. And some info displays. Now, when code is completed, there is still one Excel object open. If you comment out the lines for the second _Excel_Open (29-36) it reverts to the help file results, opening and then closing two instances of Excel. If I use the code below but change line 40 to close $oExcel3, NOTHING gets closed, not even $oExcel1 which is supposed to be forced close. Similar results if get rid of the $oExcel2 open line....$oExcel1 does not close. I either messed up my script and/or I really do not understand what is going on. Can you Please give me some guidance here...why do I not get what I expected? PS This is not totally random question... I came across this when I was trying to close all Excel previously opened prior to running the script...using Process list to see if there are instances of Excel open, and trying to use _Excel_Open to the get all the $oExcel so I can close them with _Excel_Close. I suspect after responses here I will eventually have to ask for help with that. #include <Excel.au3> #include <MsgBoxConstants.au3> ; Create application object Local $oExcel1 = ObjCreate("Excel.Application") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example", "Error creating the first Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Else Local $aProcesses = ProcessList("Excel.exe") $PID1 = $aProcesses[1][1] ToolTip("Fist PID= " & $PID1) _ArrayDisplay($aProcesses) ToolTip("") EndIf ; Open Excel application (force new instance) Local $oExcel2 = _Excel_Open(Default, Default, Default, Default, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example", "Error creating the second Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Else Local $aProcesses = ProcessList("Excel.exe") $PID2 = $aProcesses[2][1] ToolTip("Second Open Excel, PID's are: " & $PID1 & ", " & $PID2) _ArrayDisplay($aProcesses) ToolTip("") EndIf ;###### attach to one of open Excel (at least I think that is what is supposed to happen) Local $oExcel3 = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example", "Error creating the second Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) If $oExcel3 = 0 Then MsgBox($MB_SYSTEMMODAL, "Third Excel Open", "did not get object assigned") ToolTip("Third Excel_Open but should be two Excel, PID= " & $PID1 & ", " & $PID2) Local $aProcesses = ProcessList("Excel.exe") _ArrayDisplay($aProcesses) ToolTip("") ; Close the Excel instance opened by _Excel_Open _Excel_Close($oExcel2) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 2", "Error closing the Excel application." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Sleep(2000) $aProcesses = ProcessList("Excel.exe") ;MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 2", "Function ended successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instance(s) still running.") ToolTip("Should be only the first Excel PID= " & $PID1) $aProcesses = ProcessList("Excel.exe") _ArrayDisplay($aProcesses) ToolTip("") ; Force the Excel instance not opened by _Excel_Open ; without saving open workbooks _Excel_Close($oExcel1, Default, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 3", "Error closing the Excel application." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Sleep(2000) ToolTip("Supposed to be zero open Excel") $aProcesses = ProcessList("Excel.exe") ;MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 3", "Function ended successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instance(s) still running.") $aProcesses = ProcessList("Excel.exe") _ArrayDisplay($aProcesses)
-
Re-assigning values to an array - (Moved)
photonblaster replied to photonblaster's topic in AutoIt General Help and Support
THANKS! Especially the "hint" on using Dim for future assignments to literals so it preserves the original declared scope, not particularly obvious from the help files. Sorry about posting in wrong forum, I will try to do better. -
I am missing something here...I do not know why the second to last array assignment of this code snippet does not work Sorry if I am not using the correct "buzz" words to explain what I am intuitively expecting to be OK is not OK. Works of course-->: two arrays, same dimensions, different values, "A=B" works after the two arrays are declared and populated with Local statement . But "A=hard coded array" does not work even though "hard coded" array has same dimensions as the declared array and is the same as was assigned to array B in its declaration statement. As expected from searches, re-declaring the "A" array works to re-assign new array values, but it seems strange to me to have to redeclare an array when I just want to re-assign the values and not change its dimensions. Obviously not a burden to use "Local" again, but I do not see why this is needed. Worded differently.... IF Local ArrayA=an array of values Local ArrayB=an array of values Then Array A = B works if dimensions are the same. But A=[array of values of B in its declaration] does not work. I suspect, which is not clear in the help file for the arrays that I found, not only do you have to use Local/GLobal/Dim when you first declare an array, you must also use it whenever you want to re-assign values to an array other than with a variable (A=B). Of course you can also loop through the array using cell indices for all its cells, but this, to me is also cumbersome. #include <Array.au3> Local $aArray1D_Col[1][10] = [["AA", "BB", "CC",44,55,66,77,88,99,"JJ"]] _ArrayDisplay($aArray1D_Col) Local $aSecondArray1D_Col[1][10]=[["11", "22", "33",44,55,66,77,88,99,"TenthCOL"]] _ArrayDisplay( $aSecondArray1D_Col) $aArray1D_Col=$aSecondArray1D_Col ;works _ArrayDisplay($aArray1D_Col) ;Why does this assignment of values to the array not work? $aArray1D_Col=[["11", "22", "33",44,55,66,77,88,99,"JJ"]] ;But does if you re-initialize the array with LOCAL Local $aArray1D_Col[1][10]=[["11", "22", "33",44,55,66,77,88,99,"NEW TenthCOL"]] _ArrayDisplay($aArray1D_Col)
-
Windows 10 and ProcessSetPriority
photonblaster replied to photonblaster's topic in AutoIt General Help and Support
Thanks muchly, I will check these out. -
Windows 10 and ProcessSetPriority
photonblaster replied to photonblaster's topic in AutoIt General Help and Support
Thanks!!!!!!!! TheXman: Works for me too. argumentum, thanks for your comments. I am running speed tests to see if I need to go to real time, maybe "high" is good enough. Right now I get ~30% reduction in execution time using real time. I am trying different, dare I say more elegant, ways to speed it up of course since the priority is a hammer, but I need the absolute fastest analysis so I will always be using at least high priority. I have 8 core, 5GHZ CPU, and only two cores go to 85% utilization right now so real time does not seem to be a problem (yet, or that I see). I am working with Excel 2019 which is supposed to be optimized for multi-threading, but my data analysis is very linear, not much parallel processing algorithms available. I am guessing IPC is inter process communications? Can you steer me in the right direction to look into this? Isn't things like Autoit Excel functions to read, manipulate data inside AutoIT, write back answers basically IPC? MS says using the clipboard is one way to implement IPC, but this I think is usually very slow. Interprocess Communications - Win32 apps | Microsoft Docs I expect I will be posting later to get some pointers re speeding things up after I have pushed myself to the limit of my own devices. -
Back after ten years away, so please consider me a newbie. I researched this High Priority issue and came up with nothing to explain what I am seeing re ProcessSetPriority failing to set to "real time" I am running newest Windows 10, and MS Office 2019. I need to execute some code REALLY fast so I looked into ProcessSetPriority (besides trying for best practice for speed in the code itself). However , if I try to set priority to "real time" with ProcessSetPriority, it defaults back to "high", one level lower. Help file for ProcessSetPriority has no discussion about the pop-up window you see in Windows 10 if you manually try to set priority to real time. Manually you get a warning and have to agree to setting it real time. It does set to real time when you accept the warning. You can see my problem if you run the Help File example code for ProcessGetPriority, but change the third option to "real time" instead of "very high". See my modified version attached which checks to see if the actual priorities match the target. #include <MsgBoxConstants.au3> #include <Process.au3> Local $i_Priority_Level, $i_Notepad_PID, $i_ArrayItem Local $a_RunLevels[3] = [0, 4, 5] ;low, high, real time ; Get Priority Level of this instance of AutoIt Scripting Engine $i_Priority_Level = _ProcessGetPriority(@AutoItPID) MsgBox($MB_SYSTEMMODAL, "AutoIt Script", "Should be 2, IS: " & $i_Priority_Level) $i_Notepad_PID = Run(@ComSpec & ' /k notepad.exe', '', @SW_HIDE) For $i_ArrayItem = 0 To 2 ProcessSetPriority($i_Notepad_PID, $a_RunLevels[$i_ArrayItem]) $i_Priority_Level = _ProcessGetPriority($i_Notepad_PID) If $i_Priority_Level = $a_RunLevels[$i_ArrayItem] Then MsgBox($MB_SYSTEMMODAL, "Notepad Priority", "Should be " & $a_RunLevels[$i_ArrayItem] & @CRLF & " Matches, is : " & $i_Priority_Level) Else MsgBox($MB_SYSTEMMODAL, "Notepad Priority", "Should be " & $a_RunLevels[$i_ArrayItem] & @CRLF & " *DOES NOT MATCH* is: " & $i_Priority_Level) EndIf Next ProcessClose('notepad.exe') Am I doing something wrong? How can I set Priority to High other than brute force manually?
-
Error when moving code to Function
photonblaster replied to photonblaster's topic in AutoIt General Help and Support
Thank al lot, kylomas, and I will check out sciptomatic tool as well. ============================== Rats, can't get Scriptomatic to download through my firewall, will have to do a workaround to get it. BTW, you mentioned you added $Appkey to var def, but I did not see it in the revision you posted, and the script ran as you posted. -
I created this code to get number of physical cores("Cores") and logical cores ("Threads"), works OK on my PC. This is based on code posted on the forum, sorry I lost the reference to the origal author so cannot give that person credit. My goal is to get this function working in stand alone version and then incorporate it into larger project. I do not really know much about DLL calls, object calls, and am just using logic and trial and error to get this code to do what I want, the hard work like the $colitems equal.... statement was done by others and I have no clue what it does. For some reason when I try to include the code in this post the "#include" statement gets truncated, it should be "#include <CompInfo.au3>" Opt("MustDeclareVars", 1) #include Global $iCores = 1, $iThreads = 1 Local $hDll_ntdll = DllOpen("ntdll.dll") Local $hDll_winmm = DllOpen("winmm.dll") Local $colItems, $objWMIService, $objItem, $cI_Compname Dim $aProcessorInfo[1][10], $CoreInfo[2] Local $wbemFlagReturnImmediately, $wbemFlagForwardOnly, $i = 1 $objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $CoreInfo[0] = $i + 1 $CoreInfo[1] = $objItem.NumberOfLogicalProcessors $i += 1 Next $aProcessorInfo[0][0] = UBound($aProcessorInfo) - 1 If $aProcessorInfo[0][0] < 1 Then SetError(1, 1, 0) EndIf Else SetError(1, 2, 0) EndIf $iCores = $CoreInfo[0] $iThreads = $CoreInfo[1] If $iCores > $iThreads Then $iCores = $iThreads MsgBox(0, "core info", $iCores & " <--- Cores Threads -->" & $iThreads) DllClose($hDll_ntdll) DllClose($hDll_winmm) Exit I tried to move most of the code to a function, I get an this error message even though it compiles fine. E:\zzzMisc\AutoIT\CoresAndThreads.au3 (17) : ==> Variable must be of type "Object".: $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) $colItems = $objWMIService^ ERROR Opt("MustDeclareVars", 1) #include Global $iCores = 1, $iThreads = 1 GetCPU_INFO() MsgBox(0, "core info", $iCores & " <--- Cores Threads -->" & $iThreads) Exit Func GetCPU_INFO() Local $hDll_ntdll = DllOpen("ntdll.dll") Local $hDll_winmm = DllOpen("winmm.dll") Local $colItems, $objWMIService, $objItem, $cI_Compname Dim $aProcessorInfo[1][10], $CoreInfo[2] Local $wbemFlagReturnImmediately, $wbemFlagForwardOnly, $i = 1 $objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $CoreInfo[0] = $i + 1 $CoreInfo[1] = $objItem.NumberOfLogicalProcessors $i += 1 Next $aProcessorInfo[0][0] = UBound($aProcessorInfo) - 1 If $aProcessorInfo[0][0] < 1 Then SetError(1, 1, 0) EndIf Else SetError(1, 2, 0) EndIf $iCores = $CoreInfo[0] $iThreads = $CoreInfo[1] If $iCores > $iThreads Then $iCores = $iThreads DllClose($hDll_ntdll) DllClose($hDll_winmm) Return EndFunc ;==>GetCPU_INFO Please tell me why I get this error. Also I know the experts will "cringe" at some of my coding...eg I do not use seterror results so why carry this over from the original code example I worked from? And I do not need the EXIT and Return statements ?? but I feel more comfortable with them there. If someone wants to give constructive criticism besides telling me why the error occurs I promise to read it with a thick skin in place.
-
After 5 years absence from AutoIT, I forgot all about the SLEEP innacuracy problem. Finally figured this was what was causing me headachs, researched again SLEEP alternatives, and found that this solution worked very well for me. As coded, get as much as 3mSec average error on 1mSec accurate test time, but take the DLL call to set things up for accurate timing out of the loop and got this down to normally 50microsend accuracy, at least on my laptop. Did see some average errors up in the 100+microsecond range. considering a CPU clock cycle is more than a 100 thousand times smaller than these time intervals, as a scientist I think this still stinks, but is good enough for the engineering part of my brain. And yes, there are times when you want sleep to be accurate down in this time region, this time I am building a CPU stress program using a PWM type stress so I can automatically characterize PC CPU temp characteristics as a funtion of CPU stressing percentage and fan control parameters.
-
Logical Operators in AutoIt?
photonblaster replied to Encryption's topic in AutoIt General Help and Support
I decided to answer this question myself since I had problems getting NOT function info too. For me, I assumed that NOT was in AutoIt but wanted to make sure. In SCITe editor I typed NOT, saw the Scite indication it was part of the language, highlighted NOT, hit F1, and was not taken to the NOT function but the introduction to HELP files. Index list on left did not show NOT. Search term NOT did not find it. Looked at Function lists, expanded a few possible locations for NOT function, did not find it. Opened internet explorer, googled "autoit logical function NOT" and found this old posting. Finally did find it in the table I found when used help key word "operator" search. My problem is I was thinking of it as a function, not operator. My guess is that the search function in help can't handle the three letter search term well, and the NOT (and AND) links from Scite do not go to the right place.