Jump to content

All Activity

This stream auto-updates     

  1. Past hour
  2. The problem in your script is the func write. I don't understand why but after testing with little modification it runs: #include <guiconstantsex.au3> #include <buttonconstants.au3> #include <windowsconstants.au3> #include <guiedit.au3> ;-------------------------------------------------------------------------------------------------- const $form = guicreate('TypingError', 600, 400, default, default, bitor($gui_ss_default_gui,$ws_maximizebox,$ws_sizebox,$ws_thickframe,$ws_tabstop)) guisetbkcolor(0x400000) const $console = guictrlcreateedit('loading...', 10, 10, 581, 341, bitor($es_autovscroll,$es_readonly,$es_wantreturn,$ws_vscroll), 0) guictrlsetfont(default, 12, 800, 0, 'consolas') guictrlsetcolor(default, 0xffffff) guictrlsetbkcolor(default, 0x000000) guictrlsetresizing(default, bitor($gui_dockleft,$gui_dockright,$gui_docktop,$gui_dockbottom)) guictrlsetcursor (default, 3) const $user = guictrlcreateinput('', 10, 360, 521, 30, default, 0) guictrlsetfont(default, 14, 800, 0, 'consolas') guictrlsetcolor(default, 0xffffff) guictrlsetbkcolor(default, 0x000000) guictrlsetresizing(default, bitor($gui_dockleft,$gui_dockright,$gui_dockbottom,$gui_dockwidth,$gui_dockheight)) const $send = guictrlcreatebutton('send', 540, 360, 51, 31, bitor($es_uppercase,$bs_defpushbutton,$ws_disabled)) guictrlsetresizing(default, bitor($gui_dockright,$gui_dockbottom,$gui_dockwidth,$gui_dockheight)) guictrlsetcursor (default, 0) guisetstate(@sw_show) ;-------------------------------------------------------------------------------------------------- Global $clear = False func WRITE($message) if $clear then $clear = False ADD($message & @CRLF) else _guictrledit_appendtext($console, $message & @crlf) $clear = True ;can be deleted if no need for endif endfunc Func ADD($message) for $i = 1 to stringlen($message) sleep(50) _guictrledit_appendtext($console, stringmid($message, $i, 1)) next EndFunc func READ() guictrlsetstate($send, $gui_enable) while 1 switch guigetmsg() case $gui_event_close exit case $send guictrlsetstate($send, $gui_disable) local $answer = guictrlread($user) guictrlsetdata($user, '') return $answer endswitch wend endfunc HotKeySet('{esc}','quit') func QUIT() write("goodbye...") exit endfunc ;-------------------------------------------------------------------------------------------------- write('this a test of a string with the ' & @CRLF & 'character in it...') read() Sleep(1000) GUICtrlSetData($console, '') $clear = True write('this a test of qdfgdqfgqdfga string with the ' & @CRLF & 'character in it...');PROBLEM! $answer = read() write('this a test oqdgff a string with the ' & @CRLF & 'answer in it: ' & $answer) read() write('this a t... cbgfshf...e?' & @CRLF & 'character in it...') read() write('done')
  3. and the (simple) regex which fits nice... $txt = "text text tex text 123x 2x34 345" & @crlf & _ "text text tex text 123 23x4 3x45" & @crlf & _ "text text tex text 123 2x34 345" $res = StringRegExpReplace($txt, '(?m)^(.*?)\h{2,}.*', "$1") Msgbox(0,"", $res)
  4. Today
  5. Melba23, like your tag line. I'm in the mindset of "Old enough to know better, young enough to not worry"
  6. Actually as far as a Hotkey functionality with AutoIt I've done nothing as I don't seem to find anything helpful as a simple sample. The product I work with has default "Hotkeys" that allow the program to toggle between apps and also to trigger a VBA event that allows us to ingest data to pass on to the main program. The product and the connectivity tool they use are built as 32bit solutions and do not recognize 64 bit applications. The vendor has told me at this time they have no plans of implementing a 64bit connectivity module for Windows applications. As I said the problem is Windows 10 and bit-ness of desktop applications. If the application is 64bit the Hotkey simply posts to the window the actual key and not toggle windows or trigger the VBA event. My time constraints did not allow me much time, less than an hour to be honest, to resolve the problem. So when I found both AutoIt and another program that offer the HotKey element it was the fix I needed. AutoIt had both needs a HotKey and the ability to replace SendKeys in VBA, the other application seemed to only offer HotKey tooling. I quickly got AutoIt Dll working for the data return, found plenty of samples, but I could not find how to use AutoIt for the desktop hot key functionality the samples I found what seemed to be all kinds of things mostly too complex for my needs and difficult to break down with the time constraint. With the other hotkey app I found there was plenty on the desktop hotkey samples but nothing on VBA integration, it does not seem to be available. Now I have a bit of time, off the clock, to step back and try to figure out how to do the HotKey toggle and sending of keystrokes through AutoIt. The goal being to reduce long term support needs and overhead of multiple applications installed and running on a system. For simple reasons I'll use Chrome and Notepad++ as the 2 apps I'm toggling between and Notepad++ as the main app I want to send a keystroke to activate a Menu option in. Here is the other tools script that allows this to work. I removed obvious references to that hotkey program from the script. The script is loaded with the other app through Windows C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup folder entry. ;IF Numpad+ switch to Notepad++, push Ctrl{F1} to Notepad++ #ifwinactive class Chrome_WidgetWin_1 Numpadadd:: winactivate, class Notepad++ sendinput, ^{F1} return ;If = key toggle beween Chrome and Notepad++ #ifwinactive class Chrome_WidgetWin_1 =:: winactivate, class Notepad++ return #ifwinactive class Notepad++ =:: winactivate, class Chrome_WidgetWin_1 return Any help is most appreciated, thanks.
  7. MarkIT, As I posted when closing your completely unnecessary (although I know you were pointed there) Trac ticket - it is nothing to do with an AutoIt bug. If Symantec already agree it is a false positive then ask them to change their algorithm to prevent it being flagged - that has worked for me with other AV providers in the past. Thread locked. M23
  8. Your title is misleading, it has nothing to do with your question.
  9. Two remarks: When we ask for a reproducer script, that means that we should be able to run that on our own machine to be able to analyse what might be going wrong. What you posted is a mere "snippet" that doesn't do much, and certainly cannot run for hours, and doesnt help to study the problem. But... Since this part of your code allegedly does run for hours before the error occurs, I am guessing that you just keep creating new displays without ever cleaning up the old ones. So you simply run out of storage space for defining new displays. In the DigitalDisplay UDF, you can find the following above #endregion globals: ; list of specs per display unit Global $DigiDispSpecs[1000][10] $DigiDispSpecs[0][0]=0 #endregion Globals That number 1,000 defines 999 slots for such definitions (+1 for the total count), which should be plenty unless you would want to display over a thousand DigitalDislays at the same time on your screen. If you're going to keep defining new ones for hours on end, you'll need to clean up the old ones you're no longer using at some point, else you'll eventually run out of slots. If you study the UDF you'll see that calling _DD_Remove() clears one definition, but does not clear the slot in the list of DDs; for that you have to call _DD_RemoveAll(): Func _DigitalDisplay_Remove($displayID,$background=$GUI_Bk_Color) ; used slot is blanked, but remains in the queue until _DigitalDisplay_RemoveAll() ; otherwise all subsequent references would shift Of course, you could simply edit the $DigiDispSpecs array definition (in the previous code section I quoted) with a much higher number (up to about 16 million max), but that would merely defer the problem till a later time if your code runs for long enough. The proper way of handling this is to clean up the list often so it never reaches its ceiling.
  10. i was trying your script and im getting script paused problem please can you help me and i was traying to change the time to 3 min
  11. GUIGetMsg() returns pretty quickly. Just move your WinExists code into the while loop of your main script and use GUIGetMsg() as your Sleep(100). If you want you could put it into a Case $GUI_EVENT_NONE section but I don't think that is necessary. Another approach could be to use https://www.autoitscript.com/autoit3/docs/libfunctions/_Timer_SetTimer.htm but again: I would just copy your If and everything inside it into the while 1 loop in your main script.
  12. well, i will be very happy if you helped me i was trying all the scripts but im always having the script paused problem #include <Array.au3> #include <Timers.au3> #include <WinAPIProc.au3> Global $sProductFilePath = @WindowsDir Global $sProductFileName = "Notepad.exe" Global $sProductName = FileGetVersion($sProductFilePath & "\" & $sProductFileName, "ProductName") Global $hProcessWnd, $aProcessList, $idMsgBox Global $iTimerInit = TimerInit() Global $iIdleTime = _Timer_GetIdleTime() While 1 $aProcessList = ProcessList($sProductFileName) If $aProcessList[0][0] >= 2 Then $idMsgBox = MsgBox(48, $sProductName, "Multiple Licenses Detected" & @CRLF & @CRLF & "Due to license limitations only one copy of " & $sProductName & " is allowed." & @CRLF & @CRLF & "Please close additional copies of " & $sProductName) $iTimerInit = TimerInit() ContinueLoop EndIf $iProcessId = ProcessExists($sProductFileName) If $iProcessId Then $iIdleTime = _Timer_GetIdleTime() $hProcessWnd = _GetHwndFromPID($iProcessId) If WinActive($hProcessWnd ) Then $iTimerInit = TimerInit() EndIf ;~ If the timer is more than 40 minutes then send message to user and close the process, otherwise it closes within 5 minutes If TimerDiff($iTimerInit) >= 40 * 60 * 1000 Or $iIdleTime >= 40 * 60 * 1000 Then $idMsgBox = MsgBox(48, $sProductName, $sProductName & " has been idle for more than 40 minutes and will be closed in 5 minutes if no activity is detected.", 300) If $idMsgBox = -1 Then ProcessClose($sProductFileName) EndIf EndIf Sleep(100) WEnd ;Function for getting HWND from PID Func _GetHwndFromPID($_iProcessId) Local $_hProcessWnd Local $iWinList, $_aWinList = WinList() For $i = 1 To $_aWinList[0][0] If $_aWinList[$i][0] <> "" Then $iWinList = WinGetProcess($_aWinList[$i][1]) If $iWinList = $_iProcessId Then $_hProcessWnd = $_aWinList[$i][1] ExitLoop EndIf EndIf Next Return $_hProcessWnd EndFunc;==>_GetHwndFromPID
  13. Works great!! Ive changed $in = "text text tex text 123x 2x34 345@CRLF@" & _ "text text tex text 123 23x4 3x45@CRLF@" & _ "text text tex text 123 2x34 345" for $in = ClipGet() And its perfect THNKS!!
  14. Opt("ExpandVarStrings", 1) $in = "text text tex text 123x 2x34 345@CRLF@" & _ "text text tex text 123 23x4 3x45@CRLF@" & _ "text text tex text 123 2x34 345" $in = StringSplit(StringStripCR($in), @LF) $out = "" For $i = 1 To $in[0] $out &= StringLeft($in[$i], StringInStr($in[$i], ' ') + 0) & @LF Next ConsoleWrite($out) I would use StringSplit.
  15. I come from here: https://www.autoitscript.com/forum/topic/36064-string-delete-after-character/ Im trying to copy some multiline text like this from clipboard: text text tex text 123x 2x34 345 text text tex text 123 23x4 3x45 text text tex text 123 2x34 345 So I need to remove any character after "spaces" in every line and putit into clipboard with this format: text text tex text text text tex text text text tex text Im using StringLeft and I it's alright for one line. Is possible to make it multiline? $String = ClipGet() $OutPut = StringLeft($String, StringInStr($String, ' ') + 0) ClipPut ($OutPut) Thank you!
  16. ShellExecuteWait returns the exit code of the program. You know.. like the number between 0 and 255 that says if it errored or not. You read stdout like this: #include <AutoItConstants.au3> Opt("ExpandVarStrings", 1) Local $pid = Run("@ComSpec@ /C echo test", "", Default, $STDOUT_CHILD) ProcessWaitClose($pid) Local $out = StdoutRead($pid) StdioClose($pid) ConsoleWrite($out); test Check the docs for StdoutRead.
  17. Thanks, setting it in the capabilities did the trick. Fantastic. _WD_LoadWait, perfect. I overlooked it, sorry. It wasn't part of the listed helper functions on the readme 😃 I have a case where I fail to download the image with _WD_DownloadFile, might you know why? It displays fine in the browser. Here is the example: #include "wd_core.au3" #include "wd_helper.au3" $file = 'https://az534923.vo.msecnd.net/image.ashx?guid=59f690b7-0d5d-ef67-5389-9159e28f1034&w=-1&h=-1&rm=2&ac=10&mw=1024&mh=1024' _WD_DownloadFile($file, @ScriptDir & "\test.jpg") Instead of the image the function retrieves the "404 - File or directory not found" response. _InetGet works fine: #include <InetConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> $file = 'https://az534923.vo.msecnd.net/image.ashx?guid=59f690b7-0d5d-ef67-5389-9159e28f1034&w=-1&h=-1&rm=2&ac=10&mw=1024&mh=1024' Local $sFilePath = @ScriptDir & "\testInetGet.jpg" Local $hDownload = InetGet($file, $sFilePath, $INET_FORCERELOAD, $INET_DOWNLOADBACKGROUND) Do Sleep(250) Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE) Also a URL without https: in the URL returns an error, eg: #include "wd_core.au3" #include "wd_helper.au3" $file = '//az534923.vo.msecnd.net/image.ashx?guid=59f690b7-0d5d-ef67-5389-9159e28f1034&w=-1&h=-1&rm=2&ac=10&mw=1024&mh=1024' _WD_DownloadFile($file, @ScriptDir & "\test.jpg") This also works fine with _InetGet Thanks
  18. Hi All, I am very new to the autoit scripting and want to know how to created costume include script example #include "WinHttp.au3" when I am using above one I am getting below error can't open include file "WinHttp.au3".
  19. This is the program folder: As the code in cmd runs good with: I have changed the code to: $iC = 'C:\Program Files\ImageMagick-7.0.9-Q16\compare' instead \convert $iC = 'C:\Program Files\ImageMagick-7.0.9-Q16\compare' $Commandline = "C:\Users\CAIO\Downloads\x.bmp C:\Users\CAIO\Downloads\y.bmp -metric RMSE -subimage-search 2>diff.txt" $D = ShellExecuteWait($iC, $Commandline, "", "", @SW_HIDE) ConsoleWrite("D = "&$D&@CRLF) Now instead receive 1 on console i receive 2, what it means? @markyrocks if you could download imagemagick heres the link: Then just add two image same size on download folder and run the command in cmd "compare C:\Users\CAIO\Downloads\x.bmp C:\Users\CAIO\Downloads\y.bmp -metric RMSE -subimage-search" I have found this comment if it can help in something:
  20. Bc it reads the output file...I'm assuming that the output file is created by whatever program you're using. What does the screen look like? Maybe not do this with the window hidden until it works.
  21. I need run the code by command line to know the % between two images, based on % continue the rest of my code. I dont understand how this code you post could help.
  22. #include <File.au3> #include <Array.au3> _filereadtoarray($filepath,$sReturn) If isarray($sReturn) then  _arraydisplay($sReturn) Else  Exit Endif For $x=1 to ubound($sReturn)-1    if stringinstr($sReturn[$x],"whatever") then    ;do whatever    endif Next ....untested but it really doesn't get any easier than that edit sry edit edit...
  23. #RequireAdmin $iC = 'C:\Program Files\ImageMagick-7.0.9-Q16\convert.exe' $Commandline = "magick compare C:\Users\CAIO\Downloads\x.bmp C:\Users\CAIO\Downloads\y.bmp -metric RMSE -subimage-search 2>diff.tmp" $D = ShellExecuteWait($iC, $Commandline, "", "", @SW_HIDE) ConsoleWrite("D = "&$D&@CRLF) ;; MsgBox(0,"",$D) $Commandline2 = "magick compare C:\Users\CAIO\Downloads\x.bmp C:\Users\CAIO\Downloads\y.bmp -metric RMSE -subimage-search" $Z = RunWait(@ComSpec & " /C " & $iC & $Commandline2 & " > C:\output.txt") ConsoleWrite("Z = "&$Z&@CRLF) Console: D = 1 Z = 1 And i got a blank output.txt 😓
  24. So using _arraydisplay() I get only one instance of any program open. It seems to ignore the specified window title (Changed from [active]). If I focus Notepad 1 it shows the proper handle, then when I focus Notepad 2 it shows that handle as well. But not both instances like I presume it should. Global $aWinList = WinList(WinGetTitle("Notepad.exe")) _arraydisplay($aWinList) My guess is that you're right in the array being out of bounds because it does not find the 2nd one. Using some error checks and the IF ubounds statement it does not proceed through the code.
  25. why do you need to do the comparison in the command prompt can't you just do whatever comparison from the download folder and then do whatever you need to do in the cmd prompt after the fact? maybe this will help as well https://www.autoitscript.com/autoit3/docs/functions/StdoutRead.htm
  1. Load more activity
×
×
  • Create New...