Passit Posted July 9, 2012 Share Posted July 9, 2012 Hello All, I have been viewing the site and reading some threads for a while now, and decided to register today as I would most greatly appreciate if someone can possibly fulfill my request. Here is the basics of the request: A would like a script which can mirror/duplicate the actions I preform on one half of my screen (can be either half), onto the other half of the screen, the actions i can talking about include mouse clicks, and keyboard inputs, after these actions have been preformed i would then like the mouse to go back to the previous program. I would also like this to be toggled on and off by pressing a combination on keys without having to restart the script (no real preference on which keys.) Finally, before preforming the action on the other half i would like the ability for a delay, for instance 0.5sec delay before the action is preformed on the other half of the screen. More detail about what/how it shall be used for: Basically, I shall have two programs open, and using windows 7 drag and drop, both shall be snapped half of the screen. Either side of the screen may be used, and the action preformed within that program needs to be duplicated into the other program. My thoughts of what should be done within the script: Get screen resolution Wait for mouse click or key press Check if toggle on or off, if off wait for key press If mouse click: Get and store mouse position Wait delay If mouse on left half add half of screen res x to mouse x, if mouse on right half take half of screen res x from mouse x Preform the action Move mouse back to start position Wait again If key press: Save key pressed Wait delay Alt + Tab (to switch to other program) Preform keys pressed Alt + Tab again (back to original program) Wait again This is just how i am thinking it would happen logically, i'm not good at programming or scripting so i have no idea if this would be the right way to do it, just hope it helps you understand what I would like Oh, and a last note, more than one action might happen in a short time period, i.e mouse click and a key press in very short space of time, so one action might occur while waiting in the delay for the previous action, is it possible to save and preform both? I don't know. I would really appreciate it if this can be done, it would make things a lot easier for me Thank you, Passit Quote Link to comment Share on other sites More sharing options...
LordJashin Posted July 9, 2012 Share Posted July 9, 2012 (edited) Hello All, I have been viewing the site and reading some threads for a while now, and decided to register today as I would most greatly appreciate if someone can possibly fulfill my request. Here is the basics of the request: A would like a script which can mirror/duplicate the actions I preform on one half of my screen (can be either half), onto the other half of the screen, the actions i can talking about include mouse clicks, and keyboard inputs, after these actions have been preformed i would then like the mouse to go back to the previous program. I would also like this to be toggled on and off by pressing a combination on keys without having to restart the script (no real preference on which keys.) Finally, before preforming the action on the other half i would like the ability for a delay, for instance 0.5sec delay before the action is preformed on the other half of the screen. More detail about what/how it shall be used for: Basically, I shall have two programs open, and using windows 7 drag and drop, both shall be snapped half of the screen. Either side of the screen may be used, and the action preformed within that program needs to be duplicated into the other program. My thoughts of what should be done within the script: Get screen resolution Wait for mouse click or key press Check if toggle on or off, if off wait for key press If mouse click: Get and store mouse position Wait delay If mouse on left half add half of screen res x to mouse x, if mouse on right half take half of screen res x from mouse x Preform the action Move mouse back to start position Wait again If key press: Save key pressed Wait delay Alt + Tab (to switch to other program) Preform keys pressed Alt + Tab again (back to original program) Wait again This is just how i am thinking it would happen logically, i'm not good at programming or scripting so i have no idea if this would be the right way to do it, just hope it helps you understand what I would like Oh, and a last note, more than one action might happen in a short time period, i.e mouse click and a key press in very short space of time, so one action might occur while waiting in the delay for the previous action, is it possible to save and preform both? I don't know. I would really appreciate it if this can be done, it would make things a lot easier for me Thank you, Passit Welcome, this is totally possible with SCAR. However let me go over this. 1. Get Screen Resolution - Possible, I should make a function for this in snippets. 2. Mouse, Keyboard, waits. All possible. Yes you can record the positions in variables, etc. SCAR uses Pascal Script syntax, which is kind of like Delphi syntax. You have a begin and a end.. Variables and constants have to be declared (what are they?) before you use them. And they can only be declared in certain sections of the script. When you make a procedure or function it cannot go in what we call the main loop or the begin end. block. Functions can return values. Form components are supported. Anyway, everything you need is a function/procedure already in SCAR. SCAR has a client targeting system. In 3.34, you can do SetDesktopAsClient;, then GetClientDimensions, and that will get the Width and Height of the desktop. (the resolution). In SCAR, CTRL+Space opens up the function list. And if you start typing MoveMouse( right after the right parenthesis you will have code completion tell you the variables that function/procedure needs. Functions return values. Procedure do not. Example: [sCAR] program JashinWasHere; var w, h, I: Integer; procedure WriteIT(Text: String); begin WriteLn(Text); end; begin WriteIT('Writes to the Debug Box (WriteLn does)'); SetDesktopAsClient; GetClientDimensions(w, h); WriteIT(w); WriteIT(h); MoveMouseSmooth(w div 2, h div 2); SendKeys('BOOOOOOM'); end. [/sCAR] Edit: If you wanted to RECORD, key presses. Timing all of this would be kind of hard. What you could do is make a transparent-clickthrough form to record them. Not sure if that would work though. (Forms have an OnMouseDown or OnClick event handler). Well you could always do, IsMouseDown, IsKeyDown. I guess that would work. You would have to check constantly though, so use a TTimer component (repeats the same procedure every x milliseconds). Check out the SCAR wiki, and tutorials section on here if you want to learn SCAR programming. NOTE: as far as I know, SCAR cannot record mouse movements. So replicating the same mouse moves would be hard. But it does know where you clicked at. Edited July 9, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
Passit Posted July 10, 2012 Author Share Posted July 10, 2012 Welcome, this is totally possible with SCAR. However let me go over this. 1. Get Screen Resolution - Possible, I should make a function for this in snippets. 2. Mouse, Keyboard, waits. All possible. Yes you can record the positions in variables, etc. SCAR uses Pascal Script syntax, which is kind of like Delphi syntax. You have a begin and a end.. Variables and constants have to be declared (what are they?) before you use them. And they can only be declared in certain sections of the script. When you make a procedure or function it cannot go in what we call the main loop or the begin end. block. Functions can return values. Form components are supported. Anyway, everything you need is a function/procedure already in SCAR. SCAR has a client targeting system. In 3.34, you can do SetDesktopAsClient;, then GetClientDimensions, and that will get the Width and Height of the desktop. (the resolution). In SCAR, CTRL+Space opens up the function list. And if you start typing MoveMouse( right after the right parenthesis you will have code completion tell you the variables that function/procedure needs. Functions return values. Procedure do not. Example: [sCAR] program JashinWasHere; var w, h, I: Integer; procedure WriteIT(Text: String); begin WriteLn(Text); end; begin WriteIT('Writes to the Debug Box (WriteLn does)'); SetDesktopAsClient; GetClientDimensions(w, h); WriteIT(w); WriteIT(h); MoveMouseSmooth(w div 2, h div 2); SendKeys('BOOOOOOM'); end. [/sCAR] Edit: If you wanted to RECORD, key presses. Timing all of this would be kind of hard. What you could do is make a transparent-clickthrough form to record them. Not sure if that would work though. (Forms have an OnMouseDown or OnClick event handler). Well you could always do, IsMouseDown, IsKeyDown. I guess that would work. You would have to check constantly though, so use a TTimer component (repeats the same procedure every x milliseconds). Check out the SCAR wiki, and tutorials section on here if you want to learn SCAR programming. NOTE: as far as I know, SCAR cannot record mouse movements. So replicating the same mouse moves would be hard. But it does know where you clicked at. Hello, Following your reply I then attempted to write the script, so far the scripts toggle works fine, i can turn it on and off, it also is checking for mouse clicks, and duplicating the action on the other half of the screen. However I have ran into a little issue, as the script is checking constantly if the mouse is down, it results in duplicating the action multiple times per second for one click. Is there a function which will return if the mouse has been lifted? I can not find one which does this, but it could be used to stop repeating the check until the mouse has been lifted, or something along those lines. As I said, i'm not very good at writing scripts/programming I just know the very basics, thanks for any help you can provide. Passit Quote Link to comment Share on other sites More sharing options...
LordJashin Posted July 10, 2012 Share Posted July 10, 2012 (edited) Hello, Following your reply I then attempted to write the script, so far the scripts toggle works fine, i can turn it on and off, it also is checking for mouse clicks, and duplicating the action on the other half of the screen. However I have ran into a little issue, as the script is checking constantly if the mouse is down, it results in duplicating the action multiple times per second for one click. Is there a function which will return if the mouse has been lifted? I can not find one which does this, but it could be used to stop repeating the check until the mouse has been lifted, or something along those lines. As I said, i'm not very good at writing scripts/programming I just know the very basics, thanks for any help you can provide. Passit You put a wait(1000); in the if then statement containing your IsMouseButtonDown; function. So if it was down, it would wait a second (1000 ms) then move the mouse / w/e. Use MoveMouseSmooth so the mouse doesn't move too fast (MoveMouse). Also if the problem, is the loop executing multiple times while the Mouse button is down, I thought you had a toggle? Nice progress though, I'd like to see your script. Edit: In order for this to work REALLY good, you need arrays, and some complicated looping. The idea, is to store where the user clicked, and in what order. So basically [WasTheMouseButton down if it was this is true, Where(Tpoint), WhatButton(left or right)]; [] are for arrays. But note this has to be a multidimensional array, make things easier I think that way too. Or you could do it that way, and just loop every four or something. It has to be in order though, otherwise your script has no idea what happened when. Edited July 10, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
MarkD Posted August 29, 2012 Share Posted August 29, 2012 The mouse could be recorded with GetMousePos() on initial location and again on final location. Substract the x and y and you have your movement. Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted August 29, 2012 Share Posted August 29, 2012 What an interesting idea. Play 2 copies of a game (or whatever) "live". Quote Link to comment Share on other sites More sharing options...