Jump to content

kjpolker

Active Members
  • Posts

    203
  • Joined

  • Last visited

Everything posted by kjpolker

  1. Not too sure if this is the kind of feedback this thread is looking for but as of lately I have been getting Windows Defender to flag my executable. This is a exe I have been using for years written entirely by me of course, not even additional UDF's outside of the included functions. Trojan:Win32/Bearfoos.A!ml
  2. @Andreik Ahhh, I feel like a dummy. Thank you for clarifying! Can I still use @error to capture an incomplete or Windows defender issue of removing the file? Is there a built in timeout for a return of 0?
  3. @Andreik So is there an issue with the options? Force reloading source?
  4. Try this, just tested and can see the file get downloaded into temp directory. I kept the file structure similar for testing (.version) but it's just the au3 file itself. #include <MsgBoxConstants.au3> #include <InetConstants.au3> versionCheck() Func versionCheck() ShellExecute(@TempDir) $getVersion = InetGet("https://filebin.net/dtl7wvzrdd63wmfl/versiontest.au3", @TempDir & "\File.version") Do Until InetGetInfo($getVersion, 2) ;This is never satisfied and just locks up the program InetClose($getVersion) MsgBox(0, "", "Complete") EndFunc I am running Windows 10 and using AutoIt 3.3.14.5 EDIT: I just updated to 3.3.16.1
  5. I am attempting to fetch a download and wait until the download is complete but I never get past it downloading and I am not seeing much relating to this as it doesn't seem to ever be an issue. Func versionCheck() $getVersion = InetGet("URL/File", @TempDir & "\File", 1) Do ConsoleWrite($getVersion) & @CRLF) ;trying to troubleshoot Sleep(2000) Until InetGetInfo($getVersion, 2) ;This is never satisfied and just locks up the program InetClose($getVersion) MsgBox(0, "", "Complete") EndFunc I can see the file is successfully downloaded to the temp directory and I can open it. What's the deal?
  6. I am trying to work with and manage a GUICtrlCreateDate which is super annoying when opting for 12-Hour format due to the AM/PM issues. To alleviate this I was going to just apply a Regular Expression prior to managing the rest in order to strip the AM/PM but I can't get it to work and I am not sure why? \s([ap]m?)$ - Should be the expression (I have tested on RegExr) but it is not doing anything. Is my expression wrong? #include <GUIConstantsEx.au3> #include <DateTimeConstants.au3> GUICreate("test", 200, 100) $time = GUICtrlCreateDate("", 20, 10, 160, 20, $DTS_TIMEFORMAT) GUICtrlSendMsg($time, $DTM_SETFORMATW, 0, "h:mm tt") $button = GUICtrlCreateButton("check", 75, 40, 50, 20) $label = GUICtrlCreateLabel("", 80, 70, 50, 20) GUISetState() While 1 $nMsg = GUIGetMsg Switch $nMsg() Case $GUI_EVENT_CLOSE GUIDelete() Exit Case $button GUICtrlSetData($label, StringRegExpReplace(GUICtrlRead($time), "\s([ap]m?)$", "")) EndSwitch WEnd I know I could run it through StringReplace twice but I don't like that. StringReplace($time, " PM", "") ;Why can't we just use pipes to separate " PM| AM"... StringReplace($time, " AM", "")
  7. Wow I really appreciate it. I was loosing hair from scratching my head so much not sure how I missed the '$' not being required, probably because most links and help file don't use a literal string but rather a variable which does require the prefix. Also great to know about the array index being after Eval! I wasn't sure on that one and I kept flipping it around every time I tweaked it, not a ton of clarification available (at least provided by my search words).
  8. Is there a reason I cannot get my script to Evaluate a function with arrays? I have tried assigning the full function in a variable and evaluating that variable... #include <AutoItConstants.au3> #include <GUIConstants.au3> HotKeySet("^{NUMPAD1}", "test") HotKeySet("^{NUMPAD2}", "test") gui() Func gui() Global $hGUI = GUICreate("Test", 100, 100) GUISetState() While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd GUIDelete() EndFunc Func test() Local $test1[2] = ["Text 1", "Text 2"] Local $test2[2] = ["Text 3", "Text 4"] ConsoleWrite(Eval("$test" & StringRegExpReplace(@HotKeyPressed, "\D+", "")[0]) & @CRLF & Eval("$test" & StringRegExpReplace(@HotKeyPressed, "\D+", "")[1]) & @CRLF) EndFunc Note that the hotkeys are with CTRL. Regular expression is to extract the numeric value out of the @HotKeyPressed. I have tested the entire string and it is being built accurately, it just won't display the values. It simply closes, and with previous tweaking it was evaluating to an empty string.
  9. Disregard, I believe I understand it. Working with Work Area. Although I will say it seems to be a few pixels off a touch. Not a big deal. WinMove($hForm, _ $sText, _ Int($aData[1].Left), _ Int($aData[1].Bottom) - $aWinPos[3])
  10. Thank you! I am dissecting it now and understand most of it. Can you assist me in how I would change it to be lower left corner? WinMove($hForm, _ $sText, _ Int($aData[0].Left + $aWinPos[2]), _ Int($aData[0].Bottom) - $aWinPos[3] - WinGetClientSize("[CLASS:Shell_TrayWnd]")) ;Attempt to account for tasbar height I tried the above and apparently I am not understanding it like I thought.
  11. I am looking for a way to get the screen resolution from mouse point which I am having a hard time figuring out. I also would like to identify where the monitor sits. This is so I can "snap" my gui to the correct monitor in the correct location. For example position 1 will snap the gui to the lower left corner of the screen that the mouse is on. I have been playing with Windows API functions but I can't seem to get what I need. Here is an example best I can come up with but doesn't work obviously. #include <WinAPI.au3> #include <WindowsConstants.au3> Local $aMousePos = MouseGetPos() ; Get the current mouse position Local $hMonitor = _WinAPI_MonitorFromPoint($aMousePos[0], $aMousePos[1]) ; Get the handle of the monitor containing the mouse position Local $tMonitorInfo = _WinAPI_GetMonitorInfo($hMonitor) ; Get the monitor information ; Retrieve the monitor resolution Local $iMonitorWidth = DllStructGetData($tMonitorInfo, "Monitor.Right") - DllStructGetData($tMonitorInfo, "Monitor.Left") Local $iMonitorHeight = DllStructGetData($tMonitorInfo, "Monitor.Bottom") - DllStructGetData($tMonitorInfo, "Monitor.Top") ConsoleWrite("Monitor Resolution: " & $iMonitorWidth & "x" & $iMonitorHeight & @CRLF) I have 4 monitors for reference. 3 are 1920x1080 and the middle one is 2560x1440 in the following layout:
  12. Is there a way to check if a hotkey is currently registered within AutoIt? Looking for a way to Pause a hotkey so I can bypass AutoIt and temporarily utilize the key until I decide to resume. Something like: HotKeySet("{PAUSE}", "Pause") Func Pause() If HotKeyRegistered("{F1}") Then HotKeySet("{F1}") Else HotKeySet("{F1}", "Toggle") EndIf EndFunc Yes I am being lazy, but also curious because I did not find anything relatable. I know I could probably set a variable indicating it's on or off.
  13. Interesting approach. I suppose that would work well. Although I was hoping for something a bit more robust but that is simple and efficient.
  14. Right, I just didn't want to click anything as that has an actual consequence. The coordinates may be fine but lets say the client size or layout gets changed in the future, it may be clicking on something else or not at all. I was hoping for another approach to simulate activity in a foreground app, but maybe it is not do-able outside of a controlClick?
  15. I wasn't too excited about performing an actual click as that could in theory select anything depending on the window size and layout. Meaning if I just choose some an arbitrary click location in the middle of the client, it may actually do something.
  16. Understandable. I am not clear on this either to be honest. I know just activating the window works, but since that is not a practical function as I would prefer it to be done in the background then I would assume a simulation of moving the mouse should work. I suppose I was looking for some guidance on if I am on the right track of doing a Windows Message or if there are alternate ways to simulate focusing a window or interaction on a background process. I don't mind doing the research but could use a nudge in the right direction and assistance on working out the syntax (if WM_MOUSEMOVE is the right fit).
  17. I understand that. I definitely get how using this function could prevent a computer from going idle as well as bypass a built-in function, but wouldn't all Window Messages through AutoIt have the same effect? Like using WM_MOUSEMOVE. This is for me and does not violate any work rules. Essentially when idle, calls do not forward to me as I appear away. There are no issues with being idle while on the job but for the sake of keeping my status available for calls without constantly activating Teams I was looking for help.
  18. As the title suggests, I am looking for a way to keep Microsoft Teams (or any window for that matter) from going idle without intrusively activating it. Is there something that can be done without attempting a ControlClick to the window (initial thought but I am searching for alternative approaches)? I don't even know if a ControlClick would suffice. I am looking for a backend option utilizing the handle, maybe a Windows Message? Just to clear confusion, this is not meant to keep the computer from going idle. Specifically in this situation, Teams has to be active in order to prevent status going idle regardless of being in another window. If I am in the zone or working in another app and I don't activate Teams then I go idle after 5 minutes. It's very annoying.
  19. A bit silly, but my intention was for it to be a bit of an easter egg. A way to access back end information, but I admit the idea was more of a learning opportunity for me to get creative and I took advantage of the idea to improve my understanding of code. The actual script I am looking to implement it on is a glorified mouse clicker with a bunch of handy tools for interacting with Windows. This! I was looking down the right path but fell short. I was able to find WM_MENUSELECT and that was not working as desired. This is exactly what I was looking for and would not have been able to piece it together without help. I have zero understanding of how that Function is working which gives me a chance to read up
  20. I am looking for a way to have a switch recognize when I left click vs. right click on a submenu option. I can perform this task on controls within the GUI but I can't figure it out within Menu Options. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Global $GUI, $menu, $subMenu $GUI = GUICreate("Example GUI", 300, 200) $menu = GUICtrlCreateMenu("&File") $subMenu = GUICtrlCreateMenuItem("Options", $menu) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_SECONDARYUP $mCur = GUIGetCursorInfo($GUI) If IsArray($mCur) Then If $mCur[4] = $subMenu Then MsgBox(0, "Test", "Right Clicked") EndIf Case $subMenu MsgBox(0, "Test", "Left Clicked") EndSwitch WEnd
  21. #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> $Form1 = GUICreate("Output", 618, 290, 192, 124) $Edit1 = _GUICtrlRichEdit_Create($Form1, "", 0, 0, 617, 289, BitOR($ES_AUTOVSCROLL,$WS_VSCROLL,$ES_MULTILINE,$ES_WANTRETURN)) GUICtrlSetData(-1, "") WinSetOnTop($Form1, "", 1) GUISetState(@SW_SHOW) HotKeySet("{F5}","stream") ;Call function to get stream $handle = "" Run("cmd.exe") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func stream() $aWinList = WinList("[REGEXPTITLE:(?i)(.*cmd.*)]") ;find first handle of cmd window If UBound($aWinList) = 0 Then Return Else $handle = $aWinList[1][1] ;obtain handle of first cmd.exe window $apid = WinGetProcess($handle) ;obtain PID of handle _GUICtrlRichEdit_AppendText($Edit1, "Handle: " & $handle & @CRLF) ;write handle to RichEdit _GUICtrlRichEdit_AppendText($Edit1, "PID: " & $apid & @CRLF) ;write PID to RichEdit StdinWrite($apid, "Ping 127.0.0.1") ;Writes to console or executes? $timer = TimerInit() ;begin timer Local $output = "" Do Sleep(100) $output = StdoutRead($apid) _GUICtrlRichEdit_AppendText($Edit1, @CRLF & $output) ;write stream to RichEdit Until TimerDiff($timer) > 5000 ;read stream until 5 seconds has passed EndIf EndFunc I know there are other ways to test but I had the majority of this available from previous tests so I changed it up to simply launch a console window and attempt to write/read. I get empty lines as a result. Is this what you had in mind and you expected it to fail as per your last sentence?
  22. I am not certain what this statement is referencing but it sounds like the right track. Essentially my tests have been to open up Command prompt window and interact with it (write to the console) while seeing if I can capture the output in a RichEdit GUI window. I get no results and I am certain I am attaching it to the correct PID, at least of the cmd.exe process running as I have referenced it to the task manager. That is where my small understanding comes into play of the console being a graphic display of input/output and is not the actual stream. The real world use I have is a dedicated server that shows input output of the status/backups/etc in a standard Command Window. Hope this helps. P.S. I have not tried writing to the console via AutoIt, only Read what is already there.
  23. I am familiar with those functions but to my understanding, and testing you must relay the $STDIN_CHILD parameter with the run function in order to capture the steam and write to it. If the process was not called via AutoIt then you cannot intercept the STDIN/OUT of the child process (command window).
  24. Thank you for the post! Although I am unfamiliar with C++ that looks very interesting and maybe I can learn from it and get myself into C++ with the example provided.
  25. Appreciate the response! There is a lot going on in that for me to digest. All that is needed to continue the functionality of the command console?
×
×
  • Create New...