Problem with clipboard not being detected for IF statement. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
wertbo
Posts: 3
Joined: 22 Mar 2018, 07:19

Problem with clipboard not being detected for IF statement.

22 Mar 2018, 09:01

Having problem with an IF statement not working properly.
I got a auto clicker/C&P which i use for work that i'm trying to make more effective by making it not do a bunch of commands when it doesn't get any data in the clipboard.

Code: Select all

...
Clipboard =   						;clear clipboard
Click 1080, 175 					;Service Contract nr. - Team		
Sleep, 25
Send {CTRLDOWN}a{CTRLUP} ;			;select all
Sleep, 25
Send {CTRLDOWN}c{CTRLUP} ; 			;copy 
Sleep, 25
if (Clipboard) 
	{ 	
		Click 2710, 502				;Press Service contract Checkbox - Mobigo
		Sleep, 25
		Click 2750, 525 			;Contract no. 
		Sleep, 25
		Send {CTRLDOWN}v{CTRLUP}
		Sleep, 25
		Clipboard =     			 
		Sleep, 25
		Click 2716, 550				;Check Contract start date Checkbox - Mobigo
		Sleep, 25
		Click 2716, 575				;Check contract end date Checkbox - Mobigo
	}
Sleep, 25
Click 1500, 300						;Number of visits/year - Team
Sleep, 25
Send {CTRLDOWN}a{CTRLUP} ; 			;select all
Sleep, 25
Send {CTRLDOWN}c{CTRLUP} ; 			;copy
...
However, it seems like it never recives the content of the clipboard, despite the fact that if i remove the IF statement the clicker works (meaning it is receiving the data to the clipboard).

Code: Select all

j::
Send {CTRLDOWN}c{CTRLUP}
if (Clipboard) 
	{ 	
		msgbox + %Clipboard%
	} 
msgbox test
Clipboard =  
So i made this code which is a scaled down version of the above one. And again it works great. It's only when i try to implement it in the clicker that it breaks :headwall: .

I have tried ClipWait in front of the statement, but that doesn't seem to work either.
As far as i managed to find so far the problem seems to be something with the clip not saving properly?
When i put a msgbox %Clipboard% AFTER pasting the box comes up empty despite the fact that i just used it?

What am i doing wrong???
Did i miss something while moving the code?

Entire code if needed
Spoiler
wertbo
Posts: 3
Joined: 22 Mar 2018, 07:19

Re: Problem with clipboard not being detected for IF statement.

22 Mar 2018, 09:58

I'm sorry, i'm not quite sure what i'm supposed to do with the code you provided?
MaxAstro
Posts: 557
Joined: 05 Oct 2016, 13:00

Re: Problem with clipboard not being detected for IF statement.  Topic is solved

22 Mar 2018, 10:57

My experience with sending key-down and key-up presses is that sometimes AHK gets "stuck" and doesn't release a key when it should; possibly that is happening here due to the multiple key-downs in a row? You might try just doing send ^c and see if that makes a difference.
wertbo
Posts: 3
Joined: 22 Mar 2018, 07:19

Re: Problem with clipboard not being detected for IF statement.

23 Mar 2018, 02:38

That seems to have solved it?
Changing all of the {CTRLDOWN}{CTRLUP} to ^ made the code work with the an IF statement.
Thank you.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, OrangeCat, ShatterCoder and 88 guests