AutoHotkey Community

It is currently May 27th, 2012, 12:50 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: December 25th, 2009, 12:06 pm 
Offline

Joined: December 25th, 2009, 11:16 am
Posts: 5
I'm attempting to emulate the 5 consecutive SHIFT keypresses used to activate the windows Stickykeys function and not having any success.

If I press the 5x Shift shortcut myself the PC beeps and the sethc.exe file in win\system32\ will run both before or after login (regardless of it's content) but I cannot seem to get AHK to automate this particular key sequence successfully.

I've tried
Code:
Send {Shift}{Shift}{Shift}{Shift}{Shift}

and
Code:
Send {Shift}
Sleep <various intervals>
x5

also
Code:
Send , {LShift Down}
Sleep <various intervals>
Send , {LShift Up}
Sleep <various intervals>

All to no avail... Any tips on how to do this? Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 25th, 2009, 3:16 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Well it looks like your 1st idea was correct. You could have also written it like this:
Code:
Send, {Shift 5}
The problem is not the script, the problem is that sethc.exe cannot be run manually or from ahk (afaict).

I have not been able to do it myself here.

I will try to see if I can get it to run and post my findings if any..

btw this also does not work

Code:
Loop, 6
{
   Send, {SHIFTDOWN}{SHIFTUP}
   Sleep, 300
}

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 25th, 2009, 4:14 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Ok heres a long workaround.

Pressing F1 will toggle sticky keys on <> off. It does not take into consideration settings you may want to make.
Code:
F1::

DetectHiddenWindows, On
Run, access.cpl, % A_WinDir "\system32"
   WinWait, Accessibility Options,
   WinHide, Accessibility Options ; Can be omitted if you need to make setting changes.
   Control, TabLeft, 5, SysTabControl321, Accessibility Options

   Loop
   {
      ControlGet, tabNum, Tab,, SysTabControl321, Accessibility Options
      If tabNum != 1
         {
         Control, TabLeft, 5, SysTabControl321, Accessibility Options
         Break
         }
      Else
         Break
   }

btnOrder = Button2,Button13,Button11
   StringSplit, btnOrder, btnOrder, `,,

Loop, 3
   ControlClick, % btnOrder%A_Index%, Accessibility Options
Return

Works on XP. I'm about to test it on Vista and win7.

This can also be achieved (probably with one line) by using DllCall().

hth



edit:

Yea does not work on Vista or Win7 because theres no access.cpl
Attempting a workaround..

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 26th, 2009, 3:13 am 
Offline

Joined: December 25th, 2009, 11:16 am
Posts: 5
Thanks for your reply TLM.

Have learned a few new things from your code which will come in handy in future. Am still very new to this program - finding it so much easier (and faster!) then AutoIT which I had done some experimentation with previously.

[preamble]
Am looking at using it to increase productivity at work as I'm employed in a call centre and a lot of time is spent doing tedious tasks like naming files according to a formula and navigating to specific areas of shared drives whilst trying to avoid too much "dead air".

Not a big fan of smalltalk and wasting time and so far I think this little script I've put together is going to blow them away after Xmas break. Shaving a good 30 seconds off the performance of common tasks definately will add up to a better service to callers, more cost effectiveness to the company and most importantly less RSI for me :)

The company's security policy seems to block a lot of the usual shortcuts (i.e. disabled access to a folder by typing it's location into an address bar, must manually navigate and such) so automating user input seems to be the way to go.
[/preamble]

Was particularly looking at emulating the shortcut that calls stickykeys only since I've replaced the sethc.exe that the shortcut calls with a cmd.exe

Was attempting a workaround of having a compiled script run as a service thru SrvAny.exe in order to automate login so their clunky PC's would login at a set time and have the many applications required loaded and ready to go and then lock the PC with the apps running. (don't like having to rock up too early to do them manually).

I'd noticed as per other forum posts that AHK doesn't like to interact with the XP Login process, however if I use my Stickykeys backdoor to open a command prompt as system (still at the pre-login stage) then activate a compiled script that does the WinWaitActive "Log On To Windows" and sends login info that AHK will send the required info to the XP login dialog and login successfully.

This still required me to be at the computer and do the 5x shift to bring up the command prompt and launch the compiled script. Was thinking that if the AutoHotKey doesn't do the trick as planned with one script when ran as a service at bootup that I could perhaps have two scripts, one as a service that just hits SHIFT all the time and launches the cmd.exe backdoor and call the 2nd script as if I had launched it myself - at which point the second script which when called manually seems to have no trouble with the windows login would run.

This seems to not be possible as keypresses entered by AHK seem to somehow not be interpreted the same way as the ones I punch myself only for the purposes of that 5x shift stickykeys shortcut. Quite interesting.

Thinking about it now it's probably a bit of an odd way to even attempt that XP Login workaround.

I guess since I have obtained admin access on my workstation the more elegant way to do this trick will be to use scheduling for timed bootup and registry settings to allow for automatic login to my account, and then from there normal AutoHotKey scripts to activate all the programs I require before locking the computer to await my arrival.

I'm guessing that even if I could emulate the 5x shift keys in a script that it may not have worked as planned since it appears that even when running as a service that the programmes/scripts seem to put themselves on hold until Windows Logon has been performed. So even then it might not automatically do anything. (Could be wrong about that though... other services may continue to perform their usual function pre-login - perhaps it's only those that interact with the desktop that must wait for login?)

My using the sethc.exe backdoor manually was probably interrupting that process of waiting until logged in before running my AutoHotKey scripts so attempting to automate it might be like trying to pick up the chair you're sitting in so to say.

Got a bit more time on my hands so will try a bit more experimentation with running a compiled script as a service that just writes timestamps to a textfile every two seconds and that also notes the current logged in user to see just whether or not my AutoHotKey scripts are performing their functions before login or only after.

I know I could have had this all running functionally yesterday if I wasn't so hung up (anal retentive?) about doing it all through AutoHotKey and not being "defeated" and having to use other methods.

Many thanks for your response. Soz about the wall of text. Will re-post if I have any success.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 19th, 2010, 3:30 pm 
Offline

Joined: January 19th, 2010, 11:39 am
Posts: 12
Location: Philippines
Did you ever figure out how to do an auto login of Windows? I spent about 18 hours straight on this just a couple of weeks ago and finally gave up <sigh>.

Thanks for any help you can give. And yes I read the part about "WinWaitActive "Log On To Windows" and sends login info that AHK" ... Am getting ready to do some digging based on this new information. This little piece has given me further encouragement to pick up the battle again :-)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], Ohnitiel, WillTroll, XstatyK and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group