ChronoStriker1 Posted July 27, 2007 Share Posted July 27, 2007 What I want to do is press a keyboard button to move the mouse, click a button so I can zoom in a medical program, then move back to the original position. I also want it to only happen while the program is running. This is a test script for what I want to do. I'm using firefox as the program cause I don't have the medical program on my laptop. #RequireAdmin #Include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep(10) If _IsPressed("7B", $dll) Then If ProcessExists("firefox.exe") Then ;change when I find out process name $origpos = MouseGetPos() MouseClick("left", 0, 0, 1, 10) ;change 10 to 1 so its instant MouseMove($origpos[0], $origpos[1], 10) ;same as above EndIf EndIf WEnd DllClose($dll) Is this the best way to do this and is there anyway to map it to the "?" button, I didn't see hex for it. Link to comment Share on other sites More sharing options...
qazwsx Posted July 27, 2007 Share Posted July 27, 2007 I think you want a hotkey. If that is true then #RequireAdmin #Include <Misc.au3> $dll = DllOpen("user32.dll") Hotkeyset ("your key", "_zoom" Func _zoom () ;your program here Endfunc While 1 Sleep (1000) Wend Link to comment Share on other sites More sharing options...
Leighwyn Posted July 27, 2007 Share Posted July 27, 2007 (edited) You'd be better off using a hotkey probably. Look up HotKeySet() in the helpful. Your code will turn into something like: HotKeySet("yourkey","yourfunction") HotKeySet("exitkey","Terminate") Func yourfunction() ;mouse moving and clicking code goes here EndFunc Func Terminate() exit 0 EndFunc While 1 sleep(10) WEnd To use "?" as your hotkey, you can simply put "?" or "+/" since they're equivalent. Edited July 27, 2007 by Leighwyn Link to comment Share on other sites More sharing options...
DW1 Posted July 27, 2007 Share Posted July 27, 2007 (edited) _IsPressed should work you can clean up your code if you used ControlClick (no mouse movement) Put it in a function EDIT: Hotkey will work fine, but unless you see the FAQ and tweak the example a bit, whatever key you use for your hotkey will no longer be able to be used. In other words, if "?" is your hotkey then you would not be able to type a "?" into any other program (without seeing the FAQ) Edited July 27, 2007 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
ChronoStriker1 Posted July 27, 2007 Author Share Posted July 27, 2007 I originally used HotKeySet but it ran regardless of the process being found or not. Link to comment Share on other sites More sharing options...
DW1 Posted July 27, 2007 Share Posted July 27, 2007 (edited) then put the If processexists into the function EDIT: Please see above comments about HotKeySet Edited July 27, 2007 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now