langthang084 Posted March 7, 2016 Share Posted March 7, 2016 Global $Paused HotKeySet("`", "TogglePause") HotKeySet("^q", "Terminate") opt("WinTitleMatchMode", 2) Local $TittleWindows[] = ['Firefox', 'Chrome'] While 1 send('`') Switch WinActive($TittleWindows) case 'Firefox' ; WinWaitActive($TittleWindows[0]) MsgBox(0, '', 'Firefox') case 'Chrome' ; WinWaitActive($TittleWindows[1]) MsgBox(0, '', 'Chrome') EndSwitch WEnd ;-------------------------------------------------------- Func TogglePause() $Paused = NOT $Paused While $Paused sleep(200) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Why It only run if Firefox is actived Link to comment Share on other sites More sharing options...
JohnOne Posted March 7, 2016 Share Posted March 7, 2016 It does not. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
AutoBert Posted March 7, 2016 Share Posted March 7, 2016 (edited) your script couldn't run as excpected: you use a array instead of a Title or Hwnd the return value is a Hwnd, but your switch argument is a string so logic say's wether firefox nor chrom will be activated. Edited March 7, 2016 by AutoBert Link to comment Share on other sites More sharing options...
careca Posted March 8, 2016 Share Posted March 8, 2016 (edited) Runs fine here, "`" unpauses the script and it shows "firefox" The tricky bit for me is that, "`" means shift+´ Edited March 8, 2016 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
langthang084 Posted March 8, 2016 Author Share Posted March 8, 2016 @AutoBert: I dont like use Hwnd because it will change each time application start. So how to solve my case with tittle?? @careca: I dont understand your trick very well Link to comment Share on other sites More sharing options...
careca Posted March 8, 2016 Share Posted March 8, 2016 Basically what i meant is that it works fine here, but the hotkey is tricky to press in my keyboard, requires shift. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
JohnOne Posted March 8, 2016 Share Posted March 8, 2016 It does not work at all because the switch condition is testing an array against a string. I have to say also that for a member of almost 8 years, the code is very poor and very speculative, that hotkey malarky with the send in the loop is quite disturbing. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 8, 2016 Share Posted March 8, 2016 (edited) 13 minutes ago, JohnOne said: It does not work at all because the switch condition is testing an array against a string. I have to say also that for a member of almost 8 years, the code is very poor and very speculative, that hotkey malarky with the send in the loop is quite disturbing. That and there's no micro-sleep in the loop so this code will be a processor hog. Perhaps that's what that toggle in the loop was for? Edited March 8, 2016 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
careca Posted March 8, 2016 Share Posted March 8, 2016 (edited) What do you think about this? I see now i made a mistake, when i said it worked, because it worked with firefox, and i didnt test with chrome. Apologies. HotKeySet("{F1}", "TogglePause") HotKeySet("{F2}", "Terminate") Opt("WinTitleMatchMode", 2) Local $Paused = 0 While 1 If $Paused = 0 Then If WinActive('Firefox') Then MsgBox(0, '', 'Firefox') If WinActive('Chrome') Then MsgBox(0, '', 'Chrome') Else ToolTip('Script is "Paused"', 0, 0) EndIf Sleep(500) WEnd Func TogglePause() If $Paused = 1 Then $Paused = 0 ToolTip("") Else $Paused = 1 ToolTip('Script is "Paused"', 0, 0) EndIf EndFunc ;==>TogglePause Func Terminate() Exit EndFunc ;==>Terminate Edited March 8, 2016 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
JohnOne Posted March 8, 2016 Share Posted March 8, 2016 (edited) My swift alteration. Global $Paused HotKeySet("`", "TogglePause") HotKeySet("^q", "Terminate") Opt("WinTitleMatchMode", 2) Local $TittleWindows[] = ['Firefox', 'Chrome'] While 1 ;send('`') Select Case WinActive($TittleWindows[0]) MsgBox(0, '', $TittleWindows[0]) Case WinActive($TittleWindows[1]) MsgBox(0, '', $TittleWindows[1]) EndSelect Sleep(100) WEnd ;-------------------------------------------------------- Func TogglePause() $Paused = Not $Paused While $Paused Sleep(200) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate But you cannot take OP word that the script works with firefox, because it does not, that was probably just a made up story. Edited March 8, 2016 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
careca Posted March 8, 2016 Share Posted March 8, 2016 It worked here, only i didn't test with chrome, did you test it? Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
JohnOne Posted March 8, 2016 Share Posted March 8, 2016 I did, it did nothing at all just as it should. Unless your window handle = 'firefox' or 'chrome' AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
careca Posted March 8, 2016 Share Posted March 8, 2016 You keep saying that, but from the way i see it: Opt("WinTitleMatchMode", 2) ;2=Match any substring $TittleWindows[] = ['Firefox', 'Chrome'] WinActive($TittleWindows) ;Equivalent to: WinActive('Firefox', 'Chrome') ;right? Where does the handle part comes from? Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
JohnOne Posted March 8, 2016 Share Posted March 8, 2016 WinActive takes 2 strings or a handle. Local $TittleWindows[] = ['Firefox', 'Chrome'] ConsoleWrite($TittleWindows & @LF) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
AutoBert Posted March 8, 2016 Share Posted March 8, 2016 @JohnOne: Meanwhile i have tested OP's script. It always show's firefox-MsgBox even firefox isn't running. Try ConsoleWrite(int(WinActive($TittleWindows))&@CRLF) and you know why. As careca uses If WinActive('Firefox') Then MsgBox(0, '', 'Firefox') If WinActive('Chrome') Then MsgBox(0, '', 'Chrome') his script works correct. I couldn't test with Chrome but sure it does this job also. Link to comment Share on other sites More sharing options...
JohnOne Posted March 8, 2016 Share Posted March 8, 2016 On 07/03/2016 at 4:21 PM, langthang084 said: It only run if Firefox is actived So that is wrong? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jdelaney Posted March 9, 2016 Share Posted March 9, 2016 2 hours ago, AutoBert said: @JohnOne: Meanwhile i have tested OP's script. It always show's firefox-MsgBox even firefox isn't running. Try ConsoleWrite(int(WinActive($TittleWindows))&@CRLF) and you know why. As careca uses If WinActive('Firefox') Then MsgBox(0, '', 'Firefox') If WinActive('Chrome') Then MsgBox(0, '', 'Chrome') his script works correct. I couldn't test with Chrome but sure it does this job also. Of course the OP's script provides a false positive EVERY time for Firefox. It's comparing an integer with a string...a string (not empty) will be true...winactive will almost always return a handle...I'm not aware of a situation where some window has no focus (but prove me wrong ). If the OP switched based on the active window's title, or class, it would have been fine...like: #include <WinAPI.au3> ConsoleWrite(_WinAPI_GetClassName(WinActive("[ACTIVE]")) & @CRLF) output when the scite window is open: SciTEWindow IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. 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