JuanLopez Posted January 11, 2017 Share Posted January 11, 2017 Ive been trying all day to put something together, but something not clicking. This is what I have. #include <MsgBoxConstants.au3> If ProcessExists("chrome.exe") Then ; Check if the Notepad process is running. HotKeySet("{ESC}", "Main") HotKeySet("{PAUSE}", "Main1") Func Main() Send("!+{F4}",0) ;MsgBox($MB_SYSTEMMODAL, "", "Notepad is running") Func Main1() ControlClick ( [, button = "left" [, clicks = 3 [, 1629 [, 105]]]] ) Else MsgBox($MB_SYSTEMMODAL, "", "Notepad is not running") EndIf what I am trying to do is run a script that will only work when chrome is running and if the ESCAPE button gets pressed it will send the alt+f4 combo to terminate the program, or if the PAUSE button gets click it will click 3 clicks to a pre-determined spot on the webpage (1629,105). Ive been trying all day, and im at a stand still now, I think I have it right. PLease tell me im not that way off, that its some ; missing somewhere or soemthing lol. Link to comment Share on other sites More sharing options...
Subz Posted January 11, 2017 Share Posted January 11, 2017 You mean something like this? #include <AutoItConstants.au3> HotKeySet("{ESC}", "AltF4") HotKeySet("{PAUSE}", "Pause") While 1 Sleep(100) WEnd Func Pause() If WinActive('[CLASS:Chrome_WidgetWin_1]') Then MouseClick($MOUSE_CLICK_LEFT, 1629, 105, 3) EndFunc Func AltF4() If WinActive('[CLASS:Chrome_WidgetWin_1]') Then Send('!+{F4}') EndFunc Link to comment Share on other sites More sharing options...
JuanLopez Posted January 11, 2017 Author Share Posted January 11, 2017 3 minutes ago, Subz said: You mean something like this? #include <AutoItConstants.au3> HotKeySet("{ESC}", "AltF4") HotKeySet("{PAUSE}", "Pause") While 1 Sleep(100) WEnd Func Pause() If WinActive('[CLASS:Chrome_WidgetWin_1]') Then MouseClick($MOUSE_CLICK_LEFT, 1629, 105, 3) EndFunc Func AltF4() If WinActive('[CLASS:Chrome_WidgetWin_1]') Then Send('!+{F4}') EndFunc Yeah that worked perfectly, and is similar but different to what I tried. I guess with more expresience ill learn more different ways to accomplish the same thing. Thanks big time. Link to comment Share on other sites More sharing options...
spudw2k Posted January 11, 2017 Share Posted January 11, 2017 (edited) Just a couple comments. If you opt to use GUISetAccelerators instead of HotKeySet, you won't have to worry about the window being active or not. The "hotkey" function will only fire if the GUI is already active. Also, instead of sending the Alt+F4 keystrokes, you could use the WinClose function--more elegant and less room for human error. Edited January 12, 2017 by spudw2k strike-through, see next posts Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Subz Posted January 11, 2017 Share Posted January 11, 2017 @spudw2k - Don't quite follow with regards to using GUISetAccelerators over HotKeySet since the Window we're checking is active is "Google Chrome", Link to comment Share on other sites More sharing options...
spudw2k Posted January 12, 2017 Share Posted January 12, 2017 (edited) Doh, you are totally right. I glazed over the fact that the OP is not dealing with a GUI they made. Apologies. My second statement still stands....I think Edited January 12, 2017 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF 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