Locking window for screen scraping

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
albert27
Newbie
Posts: 3
Joined: Thu Dec 15, 2011 3:48 pm

Locking window for screen scraping

Post by albert27 » Wed Oct 31, 2012 5:49 pm

I've been running a script that screen scrapes a window and executes based on a matched screen scrape, and it's been running well for months.

The problem is when users close the window, or scroll down and the screen scrape doesn't work because the matching bitmap is no longer there.

Is there a way of preventing any user interaction with that window, preferably the user cannot click anywhere in that window (no closing, minimize or moves)?

Ideally I would also like a way of preventing users from closing my script through the taskbar or taskmanager

Thanks

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Oct 31, 2012 6:49 pm

If the user does not have to do any work at all during the process simply use BlockInput> to prevent all user interaction with the computer via the mouse or keyboard while your script is running. Just remember to turn it off before the script exits.

Code: Select all

//Turn on BlockInput
BlockInput>1

////////////Do stuff

//Turn off BlockInput
BlockInput>0

Exit>0
If the user has to interact while the script is running it gets a little more difficult but can probably be accomplished to some degree.

albert27
Newbie
Posts: 3
Joined: Thu Dec 15, 2011 3:48 pm

Post by albert27 » Thu Nov 01, 2012 3:09 am

Yes, the user needs to be able to work with other windows so blocking input isn't an option.

I saw this post for making the window refuse focus

http://www.mjtnet.com/forum/viewtopic.p ... bbd252e184

This could work, but I'm not sure if the user can just click the close button and close the window before focus.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Nov 01, 2012 1:55 pm

What function are you using for the screen scrape?

I have a thought that perhaps a dynamically created opaque dialog that hovers on top of your window preventing mouse contact with your window combined with an event handler that will decline focus from your window if the user did something like an ALT TAB to put focus on the window might work. Some get text functions can work even though the window is not focused. Those functions should work while your window is masked as I just described. If the function requires the window be focused, I haven't thought of any way other than to focus the window and blockinput during the screen scraping process.

I'm assuming you just need to protect against accidental interference with the window to be scraped so you're not trying to protect against a concerted effort to thwart the script.

idiot
Macro Veteran
Posts: 152
Joined: Thu Mar 01, 2007 9:21 am

Post by idiot » Tue Nov 27, 2012 7:19 am

heres a silly idea im guessing you dont want them to scroll down why not add a move mouse that keeps dragging the scroll bar back to top during the scrape thus preventing them from clicking anywhere else also you can also make the window stay on top check this link
http://www.mjtnet.com/blog/2010/09/16/m ... ay-on-top/
also they can use shorcuts liek alt f4 to close teh window you could remap those keys during the scrape and remap again after since you dont want to block input maybe redirecting the input can help kinda like how i made a mouse emulator using keyboard when wasd is pressed instead it would move the mouse so if they press alt it sends space key or if they send f4 it sends backspace or something liek that

but if they need to be able to interact with other windows this could cause a problem especially if your inputting to your window maybe you could use image recognition to detect the close /minimise/resize/move buttons on the scrape window and if they move mouse over them then it sends mouse to another point on the screen or you could just use image recogniton for the entire top bar and if mouse is over it then move the mouse you could also detect the mouse movements and if it goes to certain areas then its moved like make a box that if mouse moves within the box send it to another set point off the box

also windows can only set focus to 1 window at a time so if there using other windows you will need to refocus on your window to input to it
if idiots rule the world then im the king!!!!
i want a free t-shirt give me all of your rep!!!
please give me pro version of macro scheduler and appnavigator!!!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts