Sign in to follow this  
Followers 0
Merlin

HowTo two funcions() at the same time?

27 posts in this topic

#1 ·  Posted (edited)

Howto execute two functions at the same time ? (sry topic title is wrong maybe some can correct that?!pls thx)

is something like this possible ? :

Opt("MouseCoordMode", 0)
Opt("MouseClickDownDelay", 1000)

;bind two "functions" to Hotkey
HotKeySet("{BACKSPACE}","click"+"move")
While 1                            
 Sleep(1)                            
Wend                            

;this makes some of clicks with the clickdowntime from MouseClickDowndelay
;or i can use Sleep()´s ... we´ll see

Func click()
  MouseClick("left")
  MouseClick("left")
  MouseClick("left")
  MouseClick("left")
  MouseClick("left")
  MouseClick("left")
EndFunc


;and this should move the mouse with its own timing

Func move()
 $pos = MouseGetPos()
 MouseMove($pos[0],$pos[1]+10,5)
EndFunc

This example doesnt work... oh wonder lol ... its from me hehe. it has an error where i try to bind 2 funcs to a key...

BUT BOTH AT THE SAME TIME !! HOW???

it should move the mouse AND click at the same time 6 times for example on its way.

maybe something like?:

Opt("MouseCoordMode", 0)
Opt("MouseClickDownDelay", 1000)

;bind "combine" to Hotkey
HotKeySet("{BACKSPACE}","combine")
While 1                            
 Sleep(1)                            
Wend                            

;combine both "functions"
Func combine()
 click()
 move()
EndFunc

;this makes some of clicks with the clickdowntime from MouseClickDowndelay
;or i can use Sleep()´s ... we´ll see
Func click()
  MouseClick("left")
  MouseClick("left")
  MouseClick("left")
  MouseClick("left")
  MouseClick("left")
  MouseClick("left")
EndFunc


;and this should move the mouse with its own timing

Func move()
 $pos = MouseGetPos()
 MouseMove($pos[0],$pos[1]+10,5)
EndFunc

the above example also executes click and move AFTER EACH OTHER not at the same time ... argh i get insane ... i think include will do the same...

s..t what can i do?

I know about clickdrag but that has the wrong timing and just clicks one time... with wrong timing i mean : it starts to click and then it stays still for 50-90miliseconds THEN it starts movin... i need it immediatly ... and best would be with not just one click (i think i could resolve this "only one long click"problem) but not the bad timing... it should click and start movin at the same time!!!!

Edited by Merlin

Share this post


Link to post
Share on other sites



maybe 2 seperate scripts running simultaneously?

i know what you mean though, sometimes i want to do 2 things at once also.

makes things tricky


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites

can i call 2 scripts with one hotkey? i guess no ?!

can i call 2 scripts with "include" from another script which contains for example Hotkey and the include ? so then one key calls these two functions at the same time?!

-EDIT: i updatet my post above with another idea (the second code) what do u think? its about buildin a combine function which contains BOTH functions i wanna execute simultanuesly (man what a word rofl)

EDIT 2: i tried the above idea with no success ... if it could work then my syntax is wrong...

PS:i´ll try now playin around with include (i hope there is something like that...

this is such a powerfull software - it cant be limited to "batchrules" - i mean this "step by step" one function after another ... i think there should be a possibility to execute/call more functions at the same time

thx in Advance folks 4 ur fast replys !!

Share this post


Link to post
Share on other sites

I haven't tried this so I don't know if it will work but

try making one of the functions, then place an adlibenable inside of that function to refer to diff function. Then adlibdisable at the end of the original function.

or

spawn another script with the second function you want within the original script when the function is run.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

;):D:):):(

type slowly im german hehe

I haven't tried this so I don't know if it will work but

try making one of the functions, then place an adlibenable inside of that function to refer to diff function.  Then adlibdisable at the end of the original function.

or

spawn another script with the second function you want within the original script when the function is run.

<{POST_SNAPBACK}>

im a totally noob to this... maybe u can post some code ? (example?)

which funtions to use?

what is adlibenable & adlibdisable ? (i´ll look at the docu now but maybe u could explain a bit? i would be happy to get some advice)

thx mate !

EDIT: i checked for ´adlibenable & adlibdisable´ but how should that help ?!

-maybe i can store both functions in a variable and execute the variable?

Edited by Merlin

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

example

hotkeyset("^1","myfunc")
While 1
   Sleep(2147483647)
WEnd

Func myfunc()
   adlibenable("myotherfunc",250)
   do stuff
   adlibdisable()
EndFunc

Func myotherfunc()
   do other stuff
EndFunc
Edited by KnowledgeSponge

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

It is possible, if you explain to us what you want.

Do you want to click (multiple times) and then move the mouse or

move the mouse and then click (multiple times)?

Edited by SlimShady

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Howto execute two functions at the same time ? (sry topic title is wrong maybe some can correct that?!pls thx)

<{POST_SNAPBACK}>

i want two functions AT THE SAME TIME not AFTER EACH OTHER...

i want to click the mouse multiple times WHILE movin

(i know similar can be MouseClickDrag but that only clicks once and isnt good to configure

I want someling like

;bind two "functions" to Hotkey which should call them AT THE SAME TIME!!
HotKeySet("{BACKSPACE}","click"+"move")
While 1                            
Sleep(1)                            
Wend

;this makes some of clicks with the timing controlled by Sleep´s
Func click()
 MouseClick("left")
Sleep(65)
 MouseClick("left")
Sleep(25)
 MouseClick("left")
 MouseClick("left")
Sleep(50)
 MouseClick("left")
 MouseClick("left")
EndFunc


;and this should move the mouse with its own timing

Func move()
$pos = MouseGetPos()
MouseMove($pos[0],$pos[1]+10,5)
EndFunc

but that doesnt work

Edited by Merlin

Share this post


Link to post
Share on other sites

What you're saying doesn't make sense.

You can't click and move at the same time.

BUT you can click first (once or multiple times) and then move the mouse.

Here's an example that makes sense:

;bind two "functions" to Hotkey which should call them AT THE SAME TIME!!
HotKeySet("{BACKSPACE}","RunThis")
While 1                            
   Sleep(100)                            
Wend

;this makes some of clicks with the timing controlled by sleeps
Func MouseClickNow()
   MouseClick("left")
   Sleep(65)
   MouseClick("left")
   Sleep(25)
   MouseClick("left")
   MouseClick("left")
   Sleep(50)
   MouseClick("left")
   MouseClick("left")
EndFunc


;and this should move the mouse with its own timing

Func MoveMouseNow()
   $pos = MouseGetPos()
   MouseMove($pos[0],$pos[1]+10,5)
EndFunc

Func RunThis()
   MouseClickNow()
   MoveMouseNow()
EndFunc

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

nah it makes sense but maybe this isnt possible to do with simple scripting like we do here ... i have to think about it..

EXAMPLE:

I just want to move the mouse -lets say 500pixel downwards with a speed of 25pixel/second. (its called [,speed] in AutoIT i´ll have to figure out which speed fits my needs)

AND WHILE THE MOUSE MOVES it should click more then one time (not clickdrag!) - just a click -lets say every second/25pixel or whatever i´ll enter in the Sleep() between the:

MouseClick("left")

Sleep(50)

MouseClick("left")

----------------------

heres another idea how maybe it could work:

scriptC.au3 -binds hotkey[c] to 2 other Hotkeys[a + b] (something like that possible? i know syntax is wrong its just to show what i mean...):

basicscripts:

scriptA.au3:

HotKeySet("{F1}","move")
While 1                            
 Sleep(1)                            
Wend

Func move()
  $pos = MouseGetPos()
  MouseMove($pos[0],$pos[1]+10,5)
EndFunc

scriptB.au3:

HotKeySet("{F2}","click")
While 1                            
 Sleep(1)                            
Wend

;this makes some of clicks with the timing controlled by sleeps
Func click()
  MouseClick("left")
  Sleep(65)
  MouseClick("left")
  Sleep(25)
  MouseClick("left")
  MouseClick("left")
  Sleep(50)
  MouseClick("left")
  MouseClick("left")
EndFunc

ideas for the scriptC.au3:

1:

HotKeySet("{BACKSPACE}","{F1}+{F2}")
While 1                            
 Sleep(1)                            
Wend

or

(workin with variables?!)

2:

HotKeySet("{BACKSPACE}","combine")
While 1                            
 Sleep(1)                            
Wend

func combine()
 $myvar = ({F1}+{F2})
 execute=($myvar)
EndFunc

REMEMBER I KNOW THIS IS WRONG SYNTAX ITS ONLY TO SHOW WHAT I MEAN !!!

i hope u can tell me a solution to this...

or binding 2 scripts to 1 Hotkey?! (in that case there wouldnt be any hotkey setteing in script A+B...just simple funtioncalls)

HotKeySet("{BACKSPACE}","{scriptA.au3}+{scriptB.au3}")
While 1                            
 Sleep(1)                            
Wend
Edited by Merlin

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Listen I understand what you are wanting... you are wanting a mouse to keep moving in a direction while it is clicking.. why cant you send a move for 25 pixels... send a click and do that in a loop until it has ended up where you want it? Would that not work?

Edit: I havent worked much with mouseclick()'s yet. I plan on it in the near future. I have a project that needs it. I will let you know if I dig up something new. What I said above will work.

JS

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

i need the clicks WHILE movin not one after another ... i understand what u mean but if u think about mousemovement u will understand that i need clickDOWNandHOLD for specific time WHILE movin because it has to drag stuff around... (mouseclickdrag doesnt fit my needs ... i need a long move down and some clicks in it ...)

maybe LARRY can say how he made his clickdrag because maybe theres a way to configure it to do what i want?!

I would be interested in his opinion about this whole problem .. if this doesnt work (execute 2 or more whatever functions AT THE SAME TIME) because maybe this is something he should think about for the next version or just an update/plugin whatever ... im not a procoder...

LAAAAAAAARRYYYY we need ur help !

Edited by Merlin

Share this post


Link to post
Share on other sites

sorry im german ..i dont understand this:

(maybe someone can explain and check if this would combine two scripts?!)

Dim / Global / Local

--------------------------------------------------------------------------------

Declare a variable or create an array.

Dim $variable

Dim $array[subscript 1]...[subscript n]

Parameters

$variable The name of the variable to declare.

subscript The number of elements to create for the array dimension, indexed 0 to n-1.

Remarks

The Dim/Local/Global keywords perform a similar function.

1. Declare a variable before you use it (similar to VBScript)

2. Create an array

Note: In AutoIt you can create a variable simply by assigning a value ($myvar = 0) but many people like to explicitly declare them.

You can also declare multiple variables on a single line:

Dim $a, $b, $c

And pre-initialize, if variable is not an array:

Dim $a = 2, $b, $c = 20

The difference between Dim/Local/Global is the scope in which they are created:

Dim = Local scope if the variable name doesn't already exist globally (in which case it reuses the global variable!)

Global = Forces creation of the variable in the Global scope

Local = Forces creation of the variable in the Local/Function scope

When using variables the local scope is checked first and then the global scope second.

When creating arrays you are limited to up to 64 dimensions and/or a total of 16 million elements. (Technical: The internal table of 4 bytes per element is allocated at the time of creation, but the actual memory for each element is ONLY allocated on that elements first use).

A unique feature is the ability to copy arrays like this:

$mycopy = $myarray

In this case $mycopy will be an exact copy of $myarray and will have the same dimensions - no Dim statement is required first. If the variable $mycopy was already an array or value it will be erased before the copy takes place.

To erase an array (maybe because it is a large global array and you want to free the memory), simply assign a single value to it:

$array = 0

This will free the array and convert it back to the single value of 0.

Dim for the same variable name will erase and reset the dimensions to the new definition.

Related

UBound, ReDim

Example

; Example 1 - Declaring variables

Dim $x, $y = 23, $z

Global $PI = 3.14159, $RADIUS

Local $daysWorking = 5

; Example 2 - Declaring arrays

Dim $weeklyWorkSchedule[$daysWorking]

Global $chessBoard[8][8]

Local $mouseCoordinates[2], $windowStats[4]

Share this post


Link to post
Share on other sites

Dude, just separate the two functions into separate scripts and spawn the second from the original when the hotkey is pressed...

Share this post


Link to post
Share on other sites

I's not sure, but isn't it possible to set a hotkey so that you can press it once to run a function, twice to pause a funciton, and a third time to stop a function? If this is true, then you can effective set it up in two scripts, either

A) pause the function until the second has started, or

:) on the first script, set it to open the second and start it, but not activate itself till it checks if ProcessExists().

Share this post


Link to post
Share on other sites

Good luck. Just have it check to see if the second process (script) is running, then if it is, then start your first script. That will make them go at the same time =)

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

HotKeySet("^1","myfunc")

While 1
   Sleep(2147483647)
WEnd

Func myfunc()
   Run("myotherscript.exe","C:\myotherscriptsfolder\")
   do some stuff
   ProcessClose("myotherscript.exe")
EndFunc

Why does this have to be done separately anyways? You realize that if you coded it in one script like others have stated it would be the same either way?

Edited by KnowledgeSponge

Share this post


Link to post
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
Sign in to follow this  
Followers 0