We help IT Professionals succeed at work.

Assign the location for the clicks in an Autohotkey script when script starts

greggstar
greggstar asked
on
Hi, I have an Autohotkey script I use to do several actions in BMC Remedy. Problem is that if someone else wants to use this script or I change the position of the Remedy window, the clicks won't be in the right position. Is there any way to create some GUI or something similar that when the script starts will ask you first to assign the position of all the clicks ? This is the code I have :
^!v:: 
MouseClick, left,  391,  383
Sleep, 100
WinWait, BMC Remedy User - [Incident (Modify)], 
IfWinNotActive, BMC Remedy User - [Incident (Modify)], , WinActivate, BMC Remedy User - [Incident (Modify)], 
WinWaitActive, BMC Remedy User - [Incident (Modify)], 
MouseClick, left,  371,  500
Sleep, 100
Send, {SHIFTDOWN}i{SHIFTUP}nstall
MouseClick, left,  437,  382
Sleep, 100
MouseClick, left,  257,  621
Sleep, 100
WinWait, Create Task (link.link.link.net), 
IfWinNotActive, Create Task (link.link.link.net), , WinActivate, Create Task (link.link.link.net), 
WinWaitActive, Create Task (link.link.link.net), 
Send, New license purchase request{TAB}Please buy new licence for application Application ID. After the purchase has been finished, please provide us with the Purchase order number and the License key.{SPACE}For detailed information please check related incident.{TAB}Requested{SPACE}application{SPACE}{SPACE}{SPACE}Application{SPACE}ID{SPACE}PC{SPACE}Netbios{SPACE}name{SPACE}{SPACE}{SPACE}Requestor{SPACE}name{SPACE}{SPACE}{SPACE}Requestor{SPACE}PRID{SPACE}{SPACE}Location{SPACE}{SPACE}{SPACE}Cost{SPACE}centre{SPACE}{ENTER}
MouseClick, left,  160,  218
Sleep, 100
MouseClick, left,  420,  276
Sleep, 100
MouseClick, left,  444,  230
Sleep, 100
MouseClick, left,  417,  303
Sleep, 100
MouseClick, left,  471,  237
Sleep, 100
MouseClick, left,  416,  334
Sleep, 100
MouseClick, left,  462,  311
Sleep, 100
MouseClick, left,  840,  269
Sleep, 100
WinWait, Field "Scheduled Start Date+", 
IfWinNotActive, Field "Scheduled Start Date+", , WinActivate, Field "Scheduled Start Date+", 
WinWaitActive, Field "Scheduled Start Date+", 
MouseClick, left,  154,  341
Sleep, 100
WinWait, Create Task (link.link.link.net), 
IfWinNotActive, Create Task (link.link.link.net), , WinActivate, Create Task (link.link.link.net), 
WinWaitActive, Create Task (link.link.link.net), 
MouseClick, left,  834,  298
Sleep, 100
WinWait, Field "Scheduled End Date+", 
IfWinNotActive, Field "Scheduled End Date+", , WinActivate, Field "Scheduled End Date+", 
WinWaitActive, Field "Scheduled End Date+", 
MouseClick, left,  223,  75
Sleep, 100
MouseClick, left,  153,  352
Sleep, 100

!^b::
MouseClick, left,  509,  385
Sleep, 100
WinWait, BMC Remedy User - [Incident (Modify)], 
IfWinNotActive, BMC Remedy User - [Incident (Modify)], , WinActivate, BMC Remedy User - [Incident (Modify)], 
WinWaitActive, BMC Remedy User - [Incident (Modify)], 
MouseClick, left,  559,  451
Sleep, 100
MouseClick, left,  622,  616
Sleep, 100
MouseClick, left,  558,  474
Sleep, 100
MouseClick, left,  708,  648
Sleep, 100

Open in new window

Comment
Watch Question

You could write a wrapper and pass in the values.  Or maybe just always have it "full screen" the app at the start.  Another thing might be to use AutoIT which when I checked a while back was usually more appropriate than autohotkey for this type of thing.
Commented:
I'm not familiar with autohotkey as I use AutoIT. I'd suggest you have a look at AutoIT, it is able to send clicks and keystroke to a specific control (Could be a button in a window). You can use AutoIT Window Info tool to look up the specific control ID.

Author

Commented:
Hi, I just installed AutoIT and trying now to use it. I liked autohotkey because it has the record function which helps a lot since my programming skills are close to nothing. I'll let you know how AutoIT works out. Thank you.

Commented:
If you download SciTE, the AutoIT script editor, you can record by going to Tools/AU3Recorder. Don't know if this will help you though as it probable only records mouseclicks by coords
If it can get a "handle" for what you click on, it will show that, otherwise it will show just the coords.  This should be a major improvement over autohotkey.

Commented:
Yes, in SciTE, use the Tools/AutoitMacroGenerator (Not AU3Recorder like I mentioned before), AutoitMacroGenerator uses controlclick rather than coords.

Commented:
Bytheway, sciTE can be downloaded here: http://www.autoitscript.com/autoit3/downloads.shtml, it's called: AutoIt Script Editor.

Author

Commented:
Hi, I downloaded scite also, tried the macro generator but I get this comment in the script ";AutoIt supports no Popup menus and Special menus". AU3Recorder only records coordinates so I think I will try to do it with the coordinates. Could you please give me a few details about the wrapper please ? I'm a total noob and I don't know how to do it.

Commented:
Try AutoitMacroGenerator instead of AU3Recorder.
Yep, try AutoitMacroGenerator, and if it still doesn't work, then coords will have to do.  As far as a wrapper, you say:
"script starts will ask you first to assign the position of all the clicks "
Do you mean the user starts the script and it asks them for the position of the window?  buttons?  This would be just as much a hastle as if they clicked.  What about full screen?  

Author

Commented:
HI, I looked more into AutoIT and I think I will use that, I will build some kind of GUI which would really be more useful for further projects also. So thank you all, I replaced autohotkey with AutoIT and I think it will work better.