autohotkey mouse click selecting wrong place - loops

I made this code to copy and paste some data with autohotkey and according to the documentation I have done it correctly but the mouse click start from y=0 rather than the number i sat it before. the loop works fine it increments by 30px each time but I need to make it start from the number specified.
^j::
x_increment := 100
y_increment := 30
Loop, 15
{
clipboard := "" ; Start off empty to allow ClipWait to detect when the text has arrived.
y:= 175
y=y_offset
x:= 173
WinActivate, ahk_exe GoogleMapExtractor.exe
sleep 500
WinMaximize, ahk_exe GoogleMapExtractor.exe
Sleep, 500
MouseClick, left, x, y_offset, 1, 0, ,
Sleep, 100
MouseClick, left, x, y_offset, 1, 0, ,
Sleep, 100
MouseClick, left, x, y_offset, 1, 0, ,
Sleep, 500
Send ^a
sleep 500
Send ^c
sleep 500
;;;;;;;;;;;;;; EXCEL;;;;;;;;;;;;;;;;
WinActivate, ahk_exe Excel.exe
WinWaitActive, ahk_exe Excel.exe
Sleep 500
Send ^v
sleep 500
Send {Down}
sleep 500
y_offset+=y_increment
}
Return

The problem is with this line:
y=y_offset
Perhaps you meant to do this?
y += y_offset

Related

Is there a way to make a printing string literally in C, it has? [duplicate]

This question already has answers here:
How to escape the % (percent) sign in C's printf
(13 answers)
Closed 1 year ago.
fprintf(fptr, "#NoEnv SetWorkingDir %A_ScriptDir% CoordMode, Mouse, Window SendMode Input #SingleInstance Force SetTitleMatchMode 2 #WinActivateForce SetControlDelay 1 SetWinDelay 0 SetKeyDelay -1 SetMouseDelay -1 SetBatchLines -1 Loop { Sleep, 10 CoordMode, Pixel, Screen PixelSearch, FoundX, FoundY, 1324, 589, 1324, 589, 0x00786A, 0, RGB If ErrorLevel = 0 { Sleep, 1000 Click, 696, 728 Left, 1 Sleep, 10 Sleep, 300 Click, 775, 726 Left, 1 Sleep, 10 Sleep, 300 Click, 1273, 590 Left, 1 Sleep, 10 Return } else { sleep, 4000 Send {f5} sleep, 3000 Click, 1324, 589, 0 sleep, 10 }} Return")"");
Here is my code, not sure if it would work for what I'm doing, but it believes that the % and other stuff in the quotations are meant to be variables or whatever, how do I make it so it ignores all of that and just prints it?
fprintf stands for File Print Formatted.
In order to print unformatted, consider using fputs
You need to escape the %. You can do this by writing %% instead of %.

AutoHotKey SetTimer immediate 1st iterration

If i'm using:
SetTimer, T1, 5000
T1:
Send, {1 Down} {1 Up}
return
..it runs 1st iterration after 5 seconds.
Is there a way to start 1st iterration immediately?
No, but you can just Gosub(docs) to the label right before (or after) launching the timer:
Gosub, T1
SetTimer, T1, 5000
T1:
Send, {1 Down} {1 Up}
return
Or if you want to ditch the legacy AHK and use a function, you can just call the function first:
T1()
SetTimer, T1, 5000
T1()
{
Send, {1 Down} {1 Up}
}
Or even call it inline:
SetTimer, % ("T1", T1()), 5000
To add on to #0x464e 's answer, you can do the following to run it just once but immediately in a pseudo-thread.
SetTimer, T1, -1
or
SetTimer, T1, -0 ; this works, but I don't recommended it as it's not documented.
You can read more about AutoHotkey threading here:
https://www.autohotkey.com/docs/misc/Threads.htm

Redim'd array error in commodore 64 basic?

I am getting a redim'd array error in my commodore 64 basic project
I am not however re dimensioning my 2d array nor do I go through the line of code more than once!
Error is on line 1140
Can anyone help me out?
Thanks!
Code:
10 print "start"
20 rem: go to line 1100 in order to fill board with "."s because this is
30 rem: the board's initialization
40 gosub 1100
50 rem: looping from i to x allows for horizontal aspect of board to be printed
60 rem: x represents the width dimension of board, in this case, 8
70 for i = 1 to x
80 rem: looping from j to x allows for vertical aspect of board to be printed
90 rem: x represents the height dimension of board, in this case, 8
100 for j = 1 to x
110 rem: board initialized with "."s is printed
120 print b3$(i,j),
130 rem: end of first for loop, looping from i to x put on 130; , USED 4 TAB
140 next
150 print
160 rem: end of second for loop, looping from j to x
170 next
180 rem: checks what at the random number is equal to; places word vertically
190 rem: if rand is < 50 and places the word horizontally if rand is > 50
200 if r1 < 50 then gosub 1510
210 if r1 > 50 then print "no"
1000 rem: random num generator generates a random integer
1050 rem: between 0 and 100
1040 rem: values between 0 and 100, inclusive
1050 r1 = int(100*rnd(1))+1
1060 rem: Subroutine Fill
1070 rem: Purpose: read and data construct which fills b3$(x,x) with
1080 rem: either "."s or other random words depending on whether or not
1090 rem: the subroutine has been run before.
1100 x = 8
1110 rem: x represents the dimension for the board; in this case,8
1120 rem: took out
1130 rem: array b3 = board = specifications for width and height (8)
1140 dim b3$(x, x)
rem: i to x allows the horizontal aspect of board to be filled with "."s
1150 for i = 0 to x
1160 rem: j to x allows the vertical aspect of board to be filled with "."s
1170 for j = 0 to x
1180 rem: board filled with dots horizontally and vertically
1190 b3$(i, j) = "."
1200 rem: end of first nested for loop
1210 next
1220 rem: end of second nested for loop
1230 next
1240 return
You need an end statement before your subroutines. To make sure you don't interfere with anything else, something like:
1099 end
Otherwise, your program "completes," and then runs through all your subroutine code again just for fun.
It is because the line rem: i to x allows the horizontal aspect of board to be filled with "."s after the 1140 line doesn't have any number. To solve the problem, you can remove the line or put the number 1145 (for example) before.
Line 200 looks suspect, because line 1510 doesn't exist.
200 if r1 < 50 then gosub 1510

How do I count on picaxe?

I am trying to count the number of times a button is pressed at input pin C.4 on a picaxe 14M2. I would then like to have a 'mode' that sets b.4 high for 5 seconds then low. This 'mode' needs to repeat the number of times you press the button before hand.
If this makes any sense, how would I do this?
Here is what I have so far...
init:
let b0 = 0
main:
low B.1
low B.2
low B.3
low B.4
low B.5
if pinC.4 = 1
let b0 = b0 +1
goto mode
Endif
goto main
mode:
high B.4
wait 5
low B.4
goto main
If I understand your question you want to first count a number of button presses, then output that number of 5 second pulses. But how will your program decide that you've finished your series of button presses, and want it to carry on and generate the sequence of pulses?
Here's a possible solution, but you'll have to decide if it's suitable and adapt it if not:
b0 = 0 ' initialise counting variable
w1 = 0 ' initialise timing variable (a 2-byte word)
countpresses:
pause 10 ' wait for 10 ms
w1 = w1 + 1 ' increment the timing variable
if pinC.4 = 0 then countpresses ' loop until button pressed
wait_release:
pause 10
w1 = w1 + 1 ' increment the timing variable
if pinC.4 = 1 then wait_release ' loop until button released
b0 = b0 + 1 ' increment the counter
if w1 < 200 then countpresses ' keep counting until 4 seconds have elapsed
if b0 > 0 then
for b1 = 1 to b0
high B.4
pause 5000 ' take B.4 high for 5 seconds
low B.4
pause 1000 ' and low for 1 second between pulses
next b1
endif
This will count how many times you press the button in a 4 second period (200 x 20 ms), then output that number of pulses. The pause statements make sure that you don't count 'bounces' of the switch contacts that might occur in the few milliseconds after the button is pressed or released, and the second loop makes sure that you only count once for each press rather than incrementing as fast as the PICAXE can go for as long as you hold the button down! You didn't say how long B.4 should go low for in between the 5 second high pulses - in the code above I've made that 1 second.
If that's not exactly what you want then it shouldn't be hard to figure out how to modify it, for example to wait for a number of seconds after the last time you release the button.
I've used a word variable for the timing counter so that the maximum time to wait isn't limited to 255 counts - you could change the 200 in the code to any value up to 65535 if you wanted (but you should have a think about what might happen if it got near that value). If you're a PICAXE beginner then do read the section of the manual about how byte and word variables relate to each other, which might not be obvious.

How to make X11 window span multiple monitors

I'm trying to use XResizeWindow() to make a window which will span 2 monitors, but the ?window manager? is limiting it to one.
Is there a hint or property I can associate with the window to tell the WM not to limit it?
For my test case, I have two 1600x1200 monitors that nVidia is presenting as one 3200x1200 screen to KDE4. XDisplayWidth(display, 0); returns 3200 and XDisplayHeight(display, 0); returns 1200.
When I call
XCreateWindow(display, DefaultRootWindow(display),
220, 0, 1700, 930,
1, DefaultDepth(display,screen),
InputOutput, CopyFromParent,
CWCursor, &attributes);
for a window 1700x930 at 220,0 I get a window 1593x930 at 0,0, keeping it entirely on the left monitor. Any XResizeWindow larger than that gets shrunk to 1593. (I assume the 7 pixels are window decoration, which is fine.)
But, if I then XMoveWindow(display, win, 800, 0), it will move the window to span the screens, and I can then enlarge it up to 3200 wide (minus a few pixels).
Is there anything I can do to tell the window manager, or whoever is doing this, not to limit the window to a single monitor, and let me use the entire screen?
Thanks!
%xrandr -q --verbose
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 3200 x 1200, current 3200 x 1200, maximum 3200 x 1200
default connected 3200x1200+0+0 (0x161) normal (normal) 0mm x 0mm
Identifier: 0x160
Timestamp: 64409661
Subpixel: unknown
Clones:
CRTC: 0
CRTCs: 0
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
3200x1200 (0x161) 192.0MHz *current
h: width 3200 start 0 end 0 total 3200 skew 0 clock 60.0KHz
v: height 1200 start 0 end 0 total 1200 clock 50.0Hz
In general, an application should not try to rigidly control its window size and position, as WM is supposed to be smart and place the windows in the best possible fashion. If you want control anyway, try using XSizeHints like this:
XSizeHints sh;
sh.width = sh.min_width = 1700;
sh.height = sh.min_height = 930;
sh.h = 220;
sh.y = 0;
sh.flags = PSize | PMinSize | PPosition;
XSetWMNormalHints(dpy, win, &sh);
XMapWindow(dpy, win);
WMs will respect min_width and will not shrink the window smaller than this.
If you need a fullscreen window spanning multiple monitors, this is done differently, with _NET_WM_FULLSCREEN_MONITORS property. See here.

Resources