Unknown but thirsty for knowledge... Automatically executing

Hello all,
I´ve got a problem wich awnser seems to be find in c++, but I haven´t any knoledge about this language. Loops and other methods are well known from php and sql, but c is fishing in uncharted waters...

I would like to solve followings:
- Cyclically (not periodically) clicking the left mouse button auf on a defined section(random time lags)
- In regarding of clicking the button, check if a "variable" OR "an other section grafically" has been changed (in the way that it is hard to find this variable it would easier to compare the "old" and "new" grafically parts)
- If the "variable" has changed: Left mouse click on another section, after this clicking enter by the sleep method of c++ (this execute needs to repeat a few random times(that means 7-10) in random time lags(that means in 0,001-0,005 sec.))


And then, loop:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
enum SystemMetric{
  SM_CXSCREEN = 0,
  SM_CYSCREEN = 1,
}
 
[DllImport("user32.dll")]
static extern int GetSystemMetrics(SystemMetric smIndex);
 
int CalculateAbsoluteCoordinateX(int x){
  return (x * 65536) / GetSystemMetrics(SystemMetric.SM_CXSCREEN);
}
 
int CalculateAbsoluteCoordinateY(int y){
  return (y * 65536) / GetSystemMetrics(SystemMetric.SM_CYSCREEN);
}
 
public static void ClickLeftMouseButton(int x, int y){
  INPUT mouseInput = new INPUT();
  mouseInput.type = SendInputEventType.InputMouse;
  mouseInput.mkhi.mi.dx = CalculateAbsoluteCoordinateX(x);
  mouseInput.mkhi.mi.dy = CalculateAbsoluteCoordinateY(y);
  mouseInput.mkhi.mi.mouseData = 0;                    
  mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_MOVE |MouseEventFlags.MOUSEEVENTF_ABSOLUTE;
  SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
 
  mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_LEFTDOWN;
  SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));
 
  mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_LEFTUP;
  SendInput(1, ref mouseInput, Marshal.SizeOf(new INPUT()));            
}
 
 
int main(){
   for(int i = 0; i <= 5; ++i){
      $x=array($current, $new);
      foreach ($x as $value){
         if ($value != $current){
 
            UINT WINAPI SendInput(
            _In_  UINT nInputs,
            _In_  LPINPUT pInputs,
            _In_  int cbSize
            );
            int sub_main_a(){
               UINT WINAPI SendInput(VK_EXECUTE);
            Sleep(500);
            }
            int sub_main_b(){
               UINT WINAPI SendInput(VK_EXECUTE);
            Sleep(500);
            }
            // Left mouse click on another section, after this clicking enter by the sleep method of c++ (this execute needs to repeat a few random times(that means 7-10) in random time lags(that means in 0,001-0,005 sec.))
            $new = $current;
         }
      }
   }
Sleep(2000);
} 

The sleep function would helpful as random, too.

As I have told I´ve got no knowledge of c++. This is just an useless PHP-C++(sleep)code-mixo wich should exemplify what I want to do. A start/stop-function by clicking a hot key/shortcut is nessessary.


Need to get help for a startup. Thanks.
Topic archived. No new replies allowed.