Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Block Input not working?


  • Please log in to reply
8 replies to this topic
MrZoud
  • Members
  • 4 posts
  • Last active: Apr 02 2014 11:25 PM
  • Joined: 08 Sep 2013

I'm in the middle of setting up a script that is essentially a master control panel for my desktop that allows me to have multiple different passwords for accounts over the internet while only needing to remember one password, as well as locking down any attempts to open windows or run certain processes.

The problem I've run into is that while everything else in my script is working as intended, the "BlockInput, On" is not working. While the script runs and is logging me into a website such as my email or facebook it is clicking and sending keystrokes that I'd like to avoid interrupting.

Below is just the part of the script for the automated log in process, but it's the only part of the script using "BlockInput, On". You can see that I have a "Sleep" after the "BlockInput, On" and during that it still allows me to move my mouse and click, as well as type out keystrokes, which I do not want to be allowed during that time. If anyone sees how I could resolve this please let me know:

 

[NOTE: Variables are in a different part of the script so don't worry, they're not empty strings.]
 

				Progress, B1 P1 X809 Y900, Allow the automation to finish ..., Automiatic Log In, %WindowTitle%
				CoordMode, Pixel, Screen
				CheckWindow = Gmail: Email from Google
				Progress, 10
				Run, http://www.gmail.com
				Progress, 20
				WinWait, %CheckWindow%,, 5
				WinMaximize, %CheckWindow%
				Progress, 30
				BlockInput, On
				Progress, 40
				Sleep, 2000
				ImageSearch, XSearchGmailLoginField, YSearchGmailLoginField, 1124, 167, 1461, 245, *35 %A_ScriptDir%\GmailLoginField.jpg
				if ErrorLevel = 2
				{
					Progress, Off
					MsgBox,0, %WindowTitle%, %WindowTitle% has encountered an error and could not open the file(s) needed.
				}else if ErrorLevel = 1
				{
                                        Progress, Off
					Gosub, Error1071
					Return
				}else{
					Progress, 60
					XClickGmailLoginField := XSearchGmailLoginField + 50
					YClickGmailLoginField := YSearchGmailLoginField + 100
					Click %XClickGmailLoginField% %YClickGmailLoginField%
					Progress, 70
					Sleep, 50
					Send, %Username1Gmail%
					Progress, 80
					Sleep, 50
					Send,{Tab}
					Sleep, 50
					Send, %Password1Gmail%
					Progress, 90
					Sleep, 50
					Send,{Enter}
				}
				Progress, 100, The automation has completed!, Automiatic Log In, %WindowTitle%
				Sleep, 2000
				Progress, Off
				BlockInput, Off
				Return


Sergio
  • Members
  • 516 posts
  • Last active: Dec 01 2017 04:46 PM
  • Joined: 16 Mar 2008

Have you tested the isolated script before putting it up?  

 

Blockinput works.


ahkFooter.png

IF YOU DO NOT GET ANSWERS HERE, TRY; HTTP://AHKSCRIPT.ORG/BOARDS


MrZoud
  • Members
  • 4 posts
  • Last active: Apr 02 2014 11:25 PM
  • Joined: 08 Sep 2013

Have you tested the isolated script before putting it up?  

 

Blockinput works.

Yes, and I've also made an even more simple script to test out if it was unique to the script I was working on or something else...
Here's the more simple script:

BlockInput, On
Sleep,100
Run,Notepad.exe
WinWait,Untitled - Notepad
WinActivate,Untitled - Notepad
Sleep,1000
Send,X
Sleep,1000
Send,{Tab}X
Sleep,1000
Send,{Tab}Y
Sleep,100
BlockInput, Off
Return
And while it is sleeping I press a couple of keys to test whether my keystrokes are being blocked, and I'm still able to input characters leaving me with "Xdasd Xasd Yasdasda" (because I was pressing "a", "s" and "d" while it ran).

Sergio
  • Members
  • 516 posts
  • Last active: Dec 01 2017 04:46 PM
  • Joined: 16 Mar 2008

Understood.  I needed to clarify because now we're asking a different set of questions.  It's not about analyzing your code if any/all blockinput do not work.  Instead we should be looking at the setup.  Which OS do you use?  Which version of AHK are you running?


ahkFooter.png

IF YOU DO NOT GET ANSWERS HERE, TRY; HTTP://AHKSCRIPT.ORG/BOARDS


AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012

The first and (generally only) question you should be asking when "BlockInput doesn't work" is... have you run the script as Administrator? AutoHotkey cannot block input if it's not running as Admin.



MrZoud
  • Members
  • 4 posts
  • Last active: Apr 02 2014 11:25 PM
  • Joined: 08 Sep 2013

The first and (generally only) question you should be asking when "BlockInput doesn't work" is... have you run the script as Administrator? AutoHotkey cannot block input if it's not running as Admin.

After running as Administrator it is now working properly, thank you. I was not aware that was a prerequisite.
I am now attempting to use "RunAs" to run the script (and when I reload it) but there's an issue. I am using the username/password of the admin account on my computer and it's giving me an error related to the "RunAs" command as soon as it reached the "Run" command to reload itself.

 

I used this to test the log in information: (file name: testload.ahk)

#SingleInstance, force
SetWorkingDir %A_ScriptDir%
 
MsgBox, This reloaded. ; This will pop up as expected.
RunAs, Zoud, mypassword
Run, %A_ScriptDir%\testload.ahk ; As soon as it reaches this, I get an error saying: [Error: Launch Error (Possibly related to RunAs).]
RunAs
MsgBox, This did not reload.
Return


MrZoud
  • Members
  • 4 posts
  • Last active: Apr 02 2014 11:25 PM
  • Joined: 08 Sep 2013

Bump



AfterLemon
  • Moderators
  • 237 posts
  • Connoisseur of Boobs
  • Last active: Jan 04 2016 11:12 PM
  • Joined: 09 Oct 2012

Let me explain this with an excerpt directly from the AHK Documents page for RunAs ( which you should have researched more thoroughly before bumping your post.)

-- While the RunAs feature is in effect, Run and RunWait will not able to launch documents, URLs, or system verbs. In other words, the file to be launched must be an executable file. --

Line 4 of the "Remarks" section.

 

This means ALL items "run" while RunAs is in effect, must be an executable (possibly only with .exe extension).



yrtsh
  • Members
  • 13 posts
  • Last active: Dec 17 2017 08:24 AM
  • Joined: 11 Feb 2015

please add to the blockinput page that it only work as admin