AutoHotkey Community

It is currently May 26th, 2012, 10:12 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: issue with missed clicks
PostPosted: October 21st, 2009, 7:32 pm 
Offline

Joined: October 21st, 2009, 7:27 pm
Posts: 4
I am in the process of writing a script to fully run malware bytes, and remove items found. The script works perfectly on my windows 7 64bit pc, it is fully compatible with XP also. My screen resolution changes dont seem to affect my coordinates, but when i run this on another pc some of the clicks are missed, yet using the windows spy shows on my computer the same coordinates that i have scripted. On the XP computer i see different coordinates.

My question is do different screen resolutions affect clicking, and what might my problem be. Script below, please guys this is my first autohotkey script so bear with me.

Code:
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Malwarebytes' Anti-Malware, terminateie, 00000001         ; sets program options
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Malwarebytes' Anti-Malware, autosavelog, 00000001         ; sets program options
;RunAs, Administrator, passwordhere
Run, "C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe"          ; opens malwarebyes
Sleep, 5000          ; pauses script for 5s
WinWait Malwarebytes' Anti-Malware          ; waits for application to start fully
WinActivate                                 ; sets focus to the program, uses last found window referenced by WinWait

IFWinExist Malwarebytes' Anti-Malware       ; test that program is open

SetControlDelay, 1000          ; sets mouse clicks to 1s between clicks

{
     Click 183, 128         ; clicks update tab
     Sleep, 1000
     Click 108, 329         ; clicks Check for Updates
}

WinWaitActive ahk_class #32770        ; waits for this class window to appear, it appears for updates and no updates
Sleep, 1000

IfWinActive,,You have the latest database version          ; no updates found

{
     Click 248, 133
}

else

{
     Click 416, 133         ; Clicks ok on update window          ; updates found
}

Sleep, 2000

{
     Click 51, 130          ; clicks Scanner Tab
     Sleep, 1000
}

{
     Click 31, 268          ; clicks Perform quick scan   340          ; clicks Perform Full Scan button
     Sleep, 1000
     Click 87, 424          ; clicks Scan button
}

WinWaitNotActive ahk_class ThunderRT6FormDC          ; waits till the scan form isnt active, it wont be active when the next message

appears

IfWinNotActive ahk_class #32770
WinActivate

IfWinActive,,No malicious items were detected          ; checks for window that means no spyware

{
     Click 418, 133         ; clicks OK that no spyware was found
     Sleep, 1000
     WinWaitActive ahk_class Notepad          ; waits for log to display
     WinKill ahk_class Notepad                ; closes the logfile displayed in notepad
     WinActivate ahk_class ThunderRT6FormDC   ; sets focus back to malware bytes main window
     Sleep, 1000
     Click 705, 562         ; nothing to remove, close the program
}

else

IfWinActive,,Show Results          ; checks for Show Results text meaning spyware was found

{
     Click 408, 133          ; clicks OK on the found dialoge
     Sleep, 1000
     Click 680, 512          ; clicks Show Results
     Sleep, 1000
     Click 96, 514          ; clicks Remove Selected
}

WinWaitActive ahk_class Notepad          ; waits for log to display
WinKill ahk_class Notepad                ; closes the logfile displayed in notepad
WinActivate ahk_class #32770             ; sets focus back to the reboot prompt
WinWaitActive,,All selected items removed successfully

Sleep, 1500

{
     Click 332, 134          ; clicks Yes to restart
}

ExitApp


[Moved from Scripts & Functions forum. ~jaco0646]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2009, 8:30 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Instead of relying on clicks try to send either letters (sometimes you can type alt-letter to active a checkbox or button) or use the various control commands http://www.autohotkey.com/docs/commands.htm to click buttons, active checkbox etc this will work regardless of screenres. You can find the ahk_class with the window spy (right click the AHK icon in your systray)

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2009, 5:43 pm 
Offline

Joined: October 21st, 2009, 7:27 pm
Posts: 4
Thanks HugoV, that worked for me, Below is my newest script for this program. I think its done, just a little more testing to do.

RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Malwarebytes' Anti-Malware, terminateie, 00000001 ; sets program options
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Malwarebytes' Anti-Malware, autosavelog, 00000001 ; sets program options
Run, "C:\Program Files\Malwarebytes' Anti-Malware\mbam.exe" ; opens malwarebyes
Sleep, 5000 ; pauses script for 5s
WinWait Malwarebytes' Anti-Malware ; waits for application to start fully
;WinActivate ; sets focus to the program, uses last found window referenced by WinWait

IFWinExist Malwarebytes' Anti-Malware ; test that program is open

;SetControlDelay, 1000 ; sets mouse clicks to 1s between clicks

ControlClick, Check for Updates, ahk_class ThunderRT6FormDC ; clicks Check for Updates,note this is on another tab
WinWaitActive ahk_class #32770 ; waits for this class window to appear, shows for updates and no updates
Sleep, 1000

IfWinActive,,You have the latest database version ; no updates found
ControlClick, OK, Malwarebytes' Anti-Malware ; clicks OK that no updates were found

else

ControlClick, OK, ahk_class #32770 ; updates found
Sleep, 1000

ControlClick, Perform full scan, Malwarebytes' Anti-Malware ; clicks Perform Full Scan Option
Sleep, 1000
ControlClick, Scan, Malwarebytes' Anti-Malware
Sleep, 1500
ControlClick, Start Scan, Perform full scan ; clicks Start Scan with default selections

WinWaitNotActive ahk_class ThunderRT6FormDC ; waits till the scan form isnt active,wont be active when the next message appears
IfWinNotActive ahk_class #32770
WinActivate

IfWinActive,,No malicious items were detected ; checks for window that means no spyware

{
ControlClick, OK, ahk_class #32770 ; clicks OK that no spyware was found
Sleep, 1000
WinWaitActive ahk_class Notepad ; waits for log to display
WinKill ahk_class Notepad ; closes the logfile displayed in notepad
WinActivate ahk_class ThunderRT6FormDC ; sets focus back to malware bytes main window
Sleep, 1000
ControlClick, Exit, Malwarebytes' Anti-Malware ; nothing to remove, close the program
}

else

IfWinActive,,Show Results ; checks for Show Results text meaning spyware was found

{
ControlClick, OK, ahk_class #32770 ; clicks OK on the found dialoge
Sleep, 1000
ControlClick, Show Results, ahk_class ThunderRT6FormDC ; clicks Show Results
Sleep, 1000
ControlClick, Remove Selected, ahk_class ThunderRT6FormDC ; clicks Remove Selected
}

WinWaitActive ahk_class Notepad ; waits for log to display
WinKill ahk_class Notepad ; closes the logfile displayed in notepad
WinActivate ahk_class #32770 ; sets focus back to the reboot prompt
WinWaitActive,,All selected items removed successfully

Sleep, 1500
ControlClick, Yes, ahk_class #32770 ; clicks yes to restart after spyware removal

ExitApp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2009, 8:50 pm 
Offline

Joined: October 21st, 2009, 7:27 pm
Posts: 4
NOTE: This script is intended for home use only.

ALso, the next to last line of code reads
ControlClick, Yes, ahk_class #32770 ; clicks yes to restart after spyware removal

Change to

ControlClick, &Yes, ahk_class #32770 ; clicks yes to restart after spyware removal

THis is working great on home computers ;)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: hyper_, JSLover, Leef_me, oldbrother, patgenn123 and 63 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