Jump to content

How do I run a script and use my computer at the same time?


Yeezus
 Share

Recommended Posts

Yes it is possible, but your script should not make any interaction with GUI.

For example I made script to interact with MSSQL and IE.
In such case user may manually work with they CRM program.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

  • Moderators

Threads merged. @Yeezus please do not double post in the future. Forum etiquette would be to wait 24 hours to allow people time to answer your question.

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Some scripts interfere with normal operations. A good example can be found in the help file under the function name _MouseTrap(). Run that example and try moving the mouse around the screen while the code is running. The hijacked mouse is released once you close the window. :phew:

Link to comment
Share on other sites

At the end of the day, it all depends on what your script is doing.

If it is not utilizing the mouse or relying on active windows or interacting in some way with what you are wanting to manually do etc, then it is usually no different to any other program you run on your PC, while doing something else ... memory issues aside of course.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

2 hours ago, Yeezus said:

czardas, when I minimize it, it still moves my mouse as if the window were still open

When I minimize the GUI, it releases the mouse for normal operation, so this ought to answer your question. Good to see your mouse still works anyway! :)

Edited by czardas
Link to comment
Share on other sites

I am listening to POWER right now =) Anyway, post the code you used.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

HotKeySet("{F1}", "start")
HotKeySet("{ESC}", "terminate")

#include <Misc.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 198, 62, -1130, 312)
$Button1 = GUICtrlCreateButton("Start", 16, 16, 75, 25)
$Button2 = GUICtrlCreateButton("Cancel", 104, 16, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

      Case $Button2
         Exit

      Case $Button1
         Start()
    EndSwitch
WEnd

Func terminate()
   Exit
EndFunc


Func start()
While 1
   $aCoords = WinGetPos("Notepad")
If Not @error Then
_MouseTrap($aCoords[0], $aCoords[1], $aCoords[0] + $aCoords[2], $aCoords[1] + $aCoords[3])
EndIf
MouseClick("right", $aCoords[2], $aCoords[3])
sleep(2500)
WEnd
EndFunc

I've been using this just as a test for now.

Link to comment
Share on other sites

You can move the mouse in other application because script is crashing:

--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
"C:\Users\Bert\AutoIt3.My\Test\jhgfddfgh.au3" (42) : ==> Subscript used on non-accessible variable.:
MouseClick("right", $aCoords[2], $aCoords[3])
MouseClick("right", $aCoords^ ERROR

Btw.: This script is in a never ending loop after clicking start the user can't interact with GUI.

If you wan't see the effect of _MouseTrap use origin example in the help.

Link to comment
Share on other sites

Basically all it does is click on random spots on the active window.

HotKeySet("{F4}", "EndClicker")

AutoItSetOption("MouseCoordMode",0)
AutoItSetOption("PixelCoordMode", 0)
AutoItSetOption("CaretCoordMode", 0)


#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Random Autoclicker", 491, 163, 188, 146)
$Checkbox1 = GUICtrlCreateCheckbox("Left Click", 200, 56, 65, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Right Click", 200, 80, 73, 17)
$Label1 = GUICtrlCreateLabel("Left", 16, 16, 22, 17)
$Label2 = GUICtrlCreateLabel("Right", 16, 40, 29, 17)
$Label3 = GUICtrlCreateLabel("Bottom", 16, 64, 37, 17)
$Label4 = GUICtrlCreateLabel("Top", 16, 88, 23, 17)
$Input1 = GUICtrlCreateInput("5", 72, 16, 57, 17)
$Input2 = GUICtrlCreateInput("516", 72, 40, 57, 17)
$Input3 = GUICtrlCreateInput("36", 72, 64, 57, 17)
$Input4 = GUICtrlCreateInput("369", 72, 88, 57, 17)
$Button1 = GUICtrlCreateButton("Start", 304, 120, 75, 25)
$Button2 = GUICtrlCreateButton("Cancel", 400, 120, 75, 25)
$Label5 = GUICtrlCreateLabel("Speed", 152, 16, 35, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Low", 200, 16, 49, 17)
$Checkbox4 = GUICtrlCreateCheckbox("Medium", 256, 16, 57, 17)
$Checkbox5 = GUICtrlCreateCheckbox("High", 328, 16, 41, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         Case $Button1
            Global $left = GUICtrlRead($Input1)
            Global $right = GUICtrlRead($Input2)
            Global $top = GUICtrlRead($Input3)
            Global $bottom = GUICtrlRead($Input4)
            Global $w = GUICtrlRead($checkbox1)
            If $w = $GUI_CHECKED Then $x = "left"
            Global $r = GUICtrlRead($checkbox2)
            If $r = $GUI_CHECKED Then $x = "right"

            $check1 = GUICtrlRead($checkbox3)
            If $check1 = $GUI_CHECKED Then $interval = random(300000, 600000, 1)
            $check2 = GUICtrlRead($checkbox4)
            If $check2 = $GUI_CHECKED Then $interval = random(10000, 60000, 1)
            $check3 = GUICtrlRead($checkbox5)
            If $check3 = $GUI_CHECKED Then $interval = random(1000, 5000, 1)
            start()

         Case $Button2
            Exit

    EndSwitch
 WEnd


Func start()
   While(1)
      sleep($interval)
      MouseClick($x, random($left, $right, 1), random($top, $bottom, 1), 1, random(8, 10, 1))
   WEnd
EndFunc

   Func EndClicker()
      Exit
   EndFunc

 

Link to comment
Share on other sites

Well, it is pretty safe to say, that because you are automatedly using your mouse to click with on a specific active window, that using your computer at the same time to do something else, is not really possible or a good idea.

The only exception, would be another program(s) that runs in the background and doesn't interact with your mouse or an active window, and was launched before your script was executed. And even in that scenario, if it shows an error dialog or any dialog really, then you are likely to have problems ... things getting clicked etc that shouldn't.

Look at it this way. You don't usually use you mouse simultaneously with two programs. In fact, you never do at the same instance in time. At best, processing is shared per millisecond ... but that is very advanced and clearly beyond your level of knowledge and thus understanding.

So the short answer to your topic, is you can't. The long answer depends on many factors ... like your script pausing and allowing you to manually etc do something. That last means, that either it provides opportunities or it looks out for certain external behavior or processes (i.e., the mouse just moved of its own volition).

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Can you explain the sence of random MouseClick's?

And no with your solution it is not possible to use the computer, the mouseclicks are alway's send to the active window. You can test this by using script while working at the computer. There are solutions possible, but: No further support of mine before question is answered and i understood the need of your random MouseClick's?

Edited by AutoBert
Link to comment
Share on other sites

Try using ControlClick() and ControlSend() instead of MouseClick() and Send(). 

One time I had a script that took a hour or 2 to complete it work. Way too much data to process. I changed MouseClick to ControlClick and I can easily play a game on monitor 1 while the script does work on monitor 2. 

 

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...