Bert Posted December 1, 2005 Share Posted December 1, 2005 Does anyone have a example of code that enables a HotKeySet only when a window is active? Let me explain a little further: Say for example you have a window that you want to set a Hotkey. You want to use F5 to do this. When this window is active, the key will do as you scripted. When the window is not active, any other application that normally use the F5 key, say for example Internet Explorer, will work normally for I.E. I wrote a application that uses 10 hot keys. (F1 thru F9, + the prnt scrn key) Works great. The problem is the hotkeys are now set to work with only the application I wrote, and it breaks the links to other applications tha use the same hotkeys. I like to fix this in my application before I release it for beta testing. (I can see this being a bug for some people) The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valuater Posted December 1, 2005 Share Posted December 1, 2005 if winactive("title") then hotkeyset(.....) 8) Link to comment Share on other sites More sharing options...
Bert Posted December 1, 2005 Author Share Posted December 1, 2005 I was driving home from work after I posted the question, and thought the same thing. I wondered, however would the Hotkey stay on once it got set when the window appeared and then closed? I was going to test it and see in a sample script. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
GaryFrost Posted December 1, 2005 Share Posted December 1, 2005 (edited) An example using a gui $G_SZVERSION = "My Application Title ver " & @AutoItVersion If WinExists($G_SZVERSION) Then Exit; It's already running AutoItWinSetTitle($G_SZVERSION) #include <GuiConstants.au3> GUICreate($G_SZVERSION, 392, 323) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else If WinActive($G_SZVERSION) Then HotKeySet("{F5}", "_F5_Func") Else HotKeySet("{F5}") EndIf EndSelect WEnd Exit Func _F5_Func() MsgBox(0, "test", "Pressed F5") EndFunc ;==>_F5_Func Example monitoring external window HotKeySet("{Esc}","_Exit") $Win_Title = "Untitled - Notepad" While 1 Sleep ( 100 ) If WinActive($Win_Title) Then HotKeySet("{F5}", "_F5_Func") Else HotKeySet("{F5}") EndIf WEnd Exit Func _F5_Func() MsgBox(0, "test", "Pressed F5") EndFunc ;==>_F5_Func Fun _Exit() Exit EndFun Edited December 2, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Bert Posted December 2, 2005 Author Share Posted December 2, 2005 Thanks! This should solve the problem. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted December 2, 2005 Author Share Posted December 2, 2005 I built a test script using what gafrost showed me. works like a champ. Thanks for the help The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valuater Posted December 2, 2005 Share Posted December 2, 2005 (edited) nevermind.... ( Dop!) 8) Edited December 2, 2005 by Valuater Link to comment Share on other sites More sharing options...
Bert Posted December 2, 2005 Author Share Posted December 2, 2005 I built the following script this morning, and it doesn't work. I get no errors, but the keys don't work. I have no clue what is causing the problem. I have a working version of the program, but the hotkeys are stuck on all the time. This script is suppossed to make it so the keys only work while the correct window is active. expandcollapse popup;Unicenter UNPlus tool .9_6 beta script ;written by Volly AutoItSetOption ("TrayIconDebug", 1) ;Startup splash screen $g_szVersion = "UNPlus.exe" If WinExists($g_szVersion) Then Exit; It's already running AutoItWinSetTitle($g_szVersion) Break(1);This fixes the icon in the systemtray. 1 is on, 0 is off SplashTextOn("Unicenter UNPlus", "Unicenter Plus Beta .9_6 for ServiceDesk 6.0.", 500, 40, -1, -1, 0, "", 18) sleep(1500) Splashoff() AutoItSetOption("WinTitleMatchMode", 2) ;Checks to see if Unicenter is loaded. If not ;it will start Unicenter IF WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") == 0 then run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://usdp/CAisd/pdmweb.exe", "") WinWaitActive("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") endif IF WinExists ("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe" )== 1 then WinActivate ( "Unicenter ServicePlus Service Desk" , "http://usdp/CAisd/pdmweb.exe" ) endif ;----------------------------------------------- ;These hotsetkeys will always be active. This is due to the nature of the function. dim $key6 dim $key10 $key6 = HotKeySet ("{F6}", "key6");QuickPaste $key10 = HotKeySet ("^!x", "key10") ;exit this script only - clrl + alt + x ;------------------------------------------------ While 1 ;This section monitors if Unicenter is open or closed $uni = WinExists("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") if $uni == 0 then $endunplus = msgbox (3+32+0, "Unicenter Service Desk was closed!", "Do you wish to restart Unicenter?" & @CRLF & "" & @CRLF & "Click YES to restart Unicenter."& @CRLF & "Click NO to close UNPlus."& @CRLF & "Click CANCEL to disreguard this message") if $endunplus == 2 then WinWaitActive("Unicenter ServicePlus Service Desk", "http://usdp/CAisd/pdmweb.exe") sleep(5000);IMPORTANT THAT THIS SLEEP STATEMENT STAYS HERE! endif if $endunplus == 7 then exit endif if $endunplus == 6 then run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new http://usdp/CAisd/pdmweb.exe","") endif ;end section ;----------- ;This section monitors if certain windows are open. ;If they are, the hotkeysets for those windows are active. ;<:::Keys for Request Detail:::> IF WinActive("Request Detail - Unicenter ServicePlus Service Desk", "") then HotKeySet("{F1}", "_F1A_Func");turns key on for help HotKeySet("{F5}", "_F5A_Func");turns key on for refresh ticket HotKeySet("{F7}", "_F7_Func");turns key on for close ticket HotKeySet("{F9}", "_F9_Func");turns key on for CTFS HotkeySet ("{PRINTSCREEN}", "key11") ; Print ticket Else HotKeySet("{F1}"); turns help off HotKeySet("{F5}"); turns refresh off HotKeySet("{F7}"); turns close ticket off HotKeySet("{F9}"); turns CTFS off HotkeySet ("{PRINTSCREEN}") ; Turns Print ticket off endif ;<:::Keys for Incident Detail:::> if winactive ("Incident Detail - Unicenter ServicePlus Service Desk", "") then HotKeySet("{F1}", "_F1B_Func");turns key on for help HotKeySet("{F5}", "_F5A_Func");turns key on for refresh ticket HotKeySet("{F7}", "_F7_Func");turns key on for close ticket HotKeySet("{F9}", "_F9_Func");turns key on for CTFS HotkeySet ("{PRINTSCREEN}", "key11") ; Print ticket else HotKeySet("{F1}"); turns help off HotKeySet("{F5}"); turns refresh off HotKeySet("{F7}"); turns close ticket off HotKeySet("{F9}"); turns CTFS off HotkeySet ("{PRINTSCREEN}") ; Turns Print ticket off endif ;<:::Keys for Problem Detail:::> if winactive ("Problem Detail - Unicenter ServicePlus Service Desk", "") then HotKeySet("{F1}", "_F1C_Func");turns key on for help HotKeySet("{F5}", "_F5A_Func");turns key on for refresh ticket HotKeySet("{F7}", "_F7_Func");turns key on for close ticket HotKeySet("{F9}", "_F9_Func");turns key on for CTFS HotkeySet ("{PRINTSCREEN}", "key11") ; Print ticket else HotKeySet("{F1}"); turns help off HotKeySet("{F5}"); turns refresh off HotKeySet("{F7}"); turns close ticket off HotKeySet("{F9}"); turns CTFS off HotkeySet ("{PRINTSCREEN}") ; Turns Print ticket off endif ;<:::Keys for Update Incident:::> if winactive ("Update Incident - Unicenter ServicePlus Service Desk", "") then HotKeySet("{F1}", "_F1D_Func");turns key on for help HotKeySet("{F3}", "_F3A_Func");turns key on for Resolution HotKeySet("{F4}", "_F4_Func");turns key on for TreePaste else HotKeySet("{F1}"); turns help off HotKeySet("{F3}"); turns close ticket off HotKeySet("{F4}"); turns CTFS off endif ;<:::Keys for Update Request:::> if winactive ("Update Request - Unicenter ServicePlus Service Desk", "") then HotKeySet("{F1}", "_F1E_Func");turns key on for help HotKeySet("{F3}", "_F3A_Func");turns key on for Resolution HotKeySet("{F4}", "_F4_Func");turns key on for TreePaste else HotKeySet("{F1}"); turns help off HotKeySet("{F3}"); turns close ticket off HotKeySet("{F4}"); turns CTFS off endif ;<:::Keys for Update Problem:::> if winactive ("Update Problem - Unicenter ServicePlus Service Desk", "") then HotKeySet("{F1}", "_F1F_Func");turns key on for help HotKeySet("{F3}", "_F3A_Func");turns key on for Resolution HotKeySet("{F4}", "_F4_Func");turns key on for TreePaste else HotKeySet("{F1}"); turns help off HotKeySet("{F3}"); turns close ticket off HotKeySet("{F4}"); turns CTFS off endif ;<:::Keys for Main Window:::> if winactive ("Update Problem - Unicenter ServicePlus Service Desk", "") then HotKeySet("{F1}", "_F1G_Func");turns key on for help HotKeySet("{F2}", "_F2_Func");turns key on for Search Request HotKeySet("{F3}", "_F3B_Func");turns key on for Search Request HotKeySet("{F5}", "_F5B_Func");turns key on Refresh current querry else HotKeySet("{F1}"); turns help off HotKeySet("{F3}"); turns close ticket off HotKeySet("{F4}"); turns CTFS off endif wend ;Functions------------------------------- ;F1 ; F1A: Help in Request Ticket view ; F1B: Help in Incident Ticket view ; F1C: Help in Problem Ticket view ; F1D: Help in Update Incident view ; F1E: Help in Update Request view ; F1F: Help in Update Problem view ; F1G: Help in Main Window view ;F2 ; F2: Search Request ;F3 ; F3A: Resolution field ; F3B: Search Incident ;F4 ; F4: TreePaste ;F5 ; F5B: Refresh ticket view ; F5B: Refresh Querry ;F6 ; F6: QuickPaste ;F7 ; F7: Close ticket ;F8 ; F8: Log out Unicenter ;F9 ; F9: CTFS ;--- ;F1 section Func _F1A_Func();Help in Request Ticket view If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else msgbox(0+64, "Help in Request Ticket view", "F1= Opens a help file showing the functions."& @CRLF _ & "F3= Resolution: This will change the view to the resolution field in edit mode."& @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired."& @CRLF _ & "F5= Refresh: This will refresh the current view."& @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields."& @CRLF _ & "F7= Close Ticket: This will change the status of a ticket to closed."& @CRLF _ & "F9= Close ticket function switch: This will allow you to turn on or off the close ticket function."& @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open"& @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") endif EndFunc Func _F1B_Func();Help in Incident Ticket view If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else msgbox(0+64, "Help in Incident Ticket view", "F1= Opens a help file showing the functions."& @CRLF _ & "F3= Resolution: This will change the view to the resolution field in edit mode."& @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired."& @CRLF _ & "F5= Refresh: This will refresh the current view."& @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields."& @CRLF _ & "F7= Close Ticket: This will change the status of a ticket to closed."& @CRLF _ & "F9= Close ticket function switch: This will allow you to turn on or off the close ticket function."& @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open"& @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") endif EndFunc Func _F1C_Func();Help in Problem Ticket view If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else msgbox(0+64, "Help in Problem Ticket view", "F1= Opens a help file showing the functions."& @CRLF _ & "F3= Resolution: This will change the view to the resolution field in edit mode."& @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired."& @CRLF _ & "F5= Refresh: This will refresh the current view."& @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields."& @CRLF _ & "F7= Close Ticket: This will change the status of a ticket to closed."& @CRLF _ & "F9= Close ticket function switch: This will allow you to turn on or off the close ticket function."& @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open"& @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") endif EndFunc Func _F1D_Func();Help in Incident Ticket view If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else msgbox(0+64, "Help in Update Incident view", "F1= Opens a help file showing the functions."& @CRLF _ & "F3= Resolution: This will change the view to the resolution field in edit mode."& @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired."& @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields."& @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open"& @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") endif EndFunc Func _F1E_Func();Help in Request Ticket view If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else msgbox(0+64, "Help in Update Request view", "F1= Opens a help file showing the functions."& @CRLF _ & "F3= Resolution: This will change the view to the resolution field."& @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired."& @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields."& @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open"& @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") endif EndFunc Func _F1F_Func();Help in Update Problem view If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else msgbox(0+64, "Help in Update Problem view", "F1= Opens a help file showing the functions."& @CRLF _ & "F3= Resolution: This will change the view to the resolution field."& @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired."& @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields."& @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open"& @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") endif EndFunc Func _F1G_Func();Help in main window view If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else msgbox(0+64, "Help in main window view", "F1= Opens a help file showing the functions."& @CRLF _ & "F2= Search Request: This will search for Request tickets in a predefined bucket."& @CRLF _ & "F3= Search Incident: This will search for Incidents tickets in a predefined bucket."& @CRLF _ & "F5= Refresh: This will refresh the current list of tickets that are listed."& @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields."& @CRLF _ & "F8= Logout: This will log you out of Unicenter") endif EndFunc ;F2 Section Func _F2_Func(); Search Request If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else BlockInput (1) Run ("request.exe", "") BlockInput (0) endif EndFunc ;F3 Section Func _F3A_Func(); Resolution field If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else BlockInput (1) send ("!d") WinWaitActive("Update Request - Unicenter ServicePlus Service Desk", "") send ("!9") BlockInput (0) endif EndFunc Func _F3B_Func(); Search Incident If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else BlockInput (1) Run ("incident.exe", "") BlockInput (0) endif EndFunc ;F4 Section Func _F4_Func(); TreePaste If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else BlockInput (1) Send("^a") sleep(50) Send("{DEL}") sleep(50) BlockInput (0) Runwait ("treepaste.exe", "") BlockInput (1) sleep(500) Send("^v") BlockInput (0) endif EndFunc ;F5 Section Func _F5A_Func(); Refresh Ticket If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else BlockInput (1) send ("!v") sleep(20) send ("!e") BlockInput (0) endif EndFunc Func _F5B_Func(); Refresh Querry If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else BlockInput (1) send ("!v") sleep(20) send ("!f") BlockInput (0) endif EndFunc ;F6 Section Func key6(); QuickPaste If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else Runwait ("quickpaste2_0.exe", "") endif EndFunc ;F7 Section Func _F7_Func(); Close Ticket If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else If fileExists ("ct.flg") then Runwait ("closeticket.exe", "") Else MsgBox(0+48,"Change ticket status to close", "This function is currently turned off. You will need to use the F9 key to enable this function") EndIf endif EndFunc ;F8 Section Func _F8_Func(); Close Unicenter and UNPlus If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else BlockInput (1) Send("!u") Send("!e") BlockInput (0) exit endif EndFunc ;F9 Section Func _F9_Func(); CTFS If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else runwait("switchF7.exe", "") endif EndFunc Func key10(); CTFS If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else exit endif EndFunc Func key11(); CTFS If WinExists ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.")Then WinActivate ("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") sleep(1000) Send("{ENTER}") else BlockInput (1) Run ("print.exe", "") BlockInput (0) endif EndFunc The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
GaryFrost Posted December 2, 2005 Share Posted December 2, 2005 give this a try expandcollapse popup;Unicenter UNPlus tool .9_6 beta script ;written by Volly AutoItSetOption("TrayIconDebug", 1) ;Startup splash screen $g_szVersion = "UNPlus.exe" If WinExists($g_szVersion) Then Exit; It's already running AutoItWinSetTitle($g_szVersion) Break(1);This fixes the icon in the systemtray. 1 is on, 0 is off SplashTextOn("Unicenter UNPlus", "Unicenter Plus Beta .9_6 for ServiceDesk 6.0.", 500, 40, -1, -1, 0, "", 18) Sleep(1500) SplashOff() AutoItSetOption("WinTitleMatchMode", 2) ;Checks to see if Unicenter is loaded. If not ;it will start Unicenter If WinExists("Unicenter ServicePlus Service Desk", "[url="http://usdp/CAisd/pdmweb.exe"]http://usdp/CAisd/pdmweb.exe[/url]") == 0 Then Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new [url="http://usdp/CAisd/pdmweb.exe"]http://usdp/CAisd/pdmweb.exe[/url]", "") WinWaitActive("Unicenter ServicePlus Service Desk", "[url="http://usdp/CAisd/pdmweb.exe"]http://usdp/CAisd/pdmweb.exe[/url]") EndIf If WinExists("Unicenter ServicePlus Service Desk", "[url="http://usdp/CAisd/pdmweb.exe"]http://usdp/CAisd/pdmweb.exe[/url]") == 1 Then WinActivate("Unicenter ServicePlus Service Desk", "[url="http://usdp/CAisd/pdmweb.exe"]http://usdp/CAisd/pdmweb.exe[/url]") EndIf ;----------------------------------------------- ;These hotsetkeys will always be active. This is due to the nature of the function. HotKeySet("{F6}", "key6");QuickPaste HotKeySet("^!x", "key10");exit this script only - clrl + alt + x ;------------------------------------------------ While 1 ;This section monitors if Unicenter is open or closed $uni = WinExists("Unicenter ServicePlus Service Desk", "[url="http://usdp/CAisd/pdmweb.exe"]http://usdp/CAisd/pdmweb.exe[/url]") If $uni == 0 Then $endunplus = MsgBox(3 + 32 + 0, "Unicenter Service Desk was closed!", "Do you wish to restart Unicenter?" & @CRLF & "" & @CRLF & "Click YES to restart Unicenter." & @CRLF & "Click NO to close UNPlus." & @CRLF & "Click CANCEL to disreguard this message") If $endunplus == 2 Then WinWaitActive("Unicenter ServicePlus Service Desk", "[url="http://usdp/CAisd/pdmweb.exe"]http://usdp/CAisd/pdmweb.exe[/url]") Sleep(5000);IMPORTANT THAT THIS SLEEP STATEMENT STAYS HERE! EndIf If $endunplus == 7 Then Exit EndIf If $endunplus == 6 Then Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new [url="http://usdp/CAisd/pdmweb.exe"]http://usdp/CAisd/pdmweb.exe[/url]", "") EndIf ;end section ;----------- ;This section monitors if certain windows are open. ;If they are, the hotkeysets for those windows are active. ;<:::Keys for Request Detail:::> If WinActive("Request Detail - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1A_Func");turns key on for help HotKeySet("{F5}", "_F5A_Func");turns key on for refresh ticket HotKeySet("{F7}", "_F7_Func");turns key on for close ticket HotKeySet("{F9}", "_F9_Func");turns key on for CTFS HotKeySet("{PRINTSCREEN}", "key11"); Print ticket Else HotKeySet("{F1}"); turns help off HotKeySet("{F5}"); turns refresh off HotKeySet("{F7}"); turns close ticket off HotKeySet("{F9}"); turns CTFS off HotKeySet("{PRINTSCREEN}"); Turns Print ticket off EndIf ;<:::Keys for Incident Detail:::> If WinActive("Incident Detail - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1B_Func");turns key on for help HotKeySet("{F5}", "_F5A_Func");turns key on for refresh ticket HotKeySet("{F7}", "_F7_Func");turns key on for close ticket HotKeySet("{F9}", "_F9_Func");turns key on for CTFS HotKeySet("{PRINTSCREEN}", "key11"); Print ticket Else HotKeySet("{F1}"); turns help off HotKeySet("{F5}"); turns refresh off HotKeySet("{F7}"); turns close ticket off HotKeySet("{F9}"); turns CTFS off HotKeySet("{PRINTSCREEN}"); Turns Print ticket off EndIf ;<:::Keys for Problem Detail:::> If WinActive("Problem Detail - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1C_Func");turns key on for help HotKeySet("{F5}", "_F5A_Func");turns key on for refresh ticket HotKeySet("{F7}", "_F7_Func");turns key on for close ticket HotKeySet("{F9}", "_F9_Func");turns key on for CTFS HotKeySet("{PRINTSCREEN}", "key11"); Print ticket Else HotKeySet("{F1}"); turns help off HotKeySet("{F5}"); turns refresh off HotKeySet("{F7}"); turns close ticket off HotKeySet("{F9}"); turns CTFS off HotKeySet("{PRINTSCREEN}"); Turns Print ticket off EndIf ;<:::Keys for Update Incident:::> If WinActive("Update Incident - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1D_Func");turns key on for help HotKeySet("{F3}", "_F3A_Func");turns key on for Resolution HotKeySet("{F4}", "_F4_Func");turns key on for TreePaste Else HotKeySet("{F1}"); turns help off HotKeySet("{F3}"); turns close ticket off HotKeySet("{F4}"); turns CTFS off EndIf ;<:::Keys for Update Request:::> If WinActive("Update Request - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1E_Func");turns key on for help HotKeySet("{F3}", "_F3A_Func");turns key on for Resolution HotKeySet("{F4}", "_F4_Func");turns key on for TreePaste Else HotKeySet("{F1}"); turns help off HotKeySet("{F3}"); turns close ticket off HotKeySet("{F4}"); turns CTFS off EndIf ;<:::Keys for Update Problem:::> If WinActive("Update Problem - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1F_Func");turns key on for help HotKeySet("{F3}", "_F3A_Func");turns key on for Resolution HotKeySet("{F4}", "_F4_Func");turns key on for TreePaste Else HotKeySet("{F1}"); turns help off HotKeySet("{F3}"); turns close ticket off HotKeySet("{F4}"); turns CTFS off EndIf ;<:::Keys for Main Window:::> If WinActive("Update Problem - Unicenter ServicePlus Service Desk") Then HotKeySet("{F1}", "_F1G_Func");turns key on for help HotKeySet("{F2}", "_F2_Func");turns key on for Search Request HotKeySet("{F3}", "_F3B_Func");turns key on for Search Request HotKeySet("{F5}", "_F5B_Func");turns key on Refresh current querry Else HotKeySet("{F1}"); turns help off HotKeySet("{F3}"); turns close ticket off HotKeySet("{F4}"); turns CTFS off EndIf WEnd ;Functions------------------------------- ;F1 ; F1A: Help in Request Ticket view ; F1B: Help in Incident Ticket view ; F1C: Help in Problem Ticket view ; F1D: Help in Update Incident view ; F1E: Help in Update Request view ; F1F: Help in Update Problem view ; F1G: Help in Main Window view ;F2 ; F2: Search Request ;F3 ; F3A: Resolution field ; F3B: Search Incident ;F4 ; F4: TreePaste ;F5 ; F5B: Refresh ticket view ; F5B: Refresh Querry ;F6 ; F6: QuickPaste ;F7 ; F7: Close ticket ;F8 ; F8: Log out Unicenter ;F9 ; F9: CTFS ;--- ;F1 section Func _F1A_Func();Help in Request Ticket view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else MsgBox(0 + 64, "Help in Request Ticket view", "F1= Opens a help file showing the functions." & @CRLF _ & "F3= Resolution: This will change the view to the resolution field in edit mode." & @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired." & @CRLF _ & "F5= Refresh: This will refresh the current view." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "F7= Close Ticket: This will change the status of a ticket to closed." & @CRLF _ & "F9= Close ticket function switch: This will allow you to turn on or off the close ticket function." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") EndIf EndFunc ;==>_F1A_Func Func _F1B_Func();Help in Incident Ticket view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else MsgBox(0 + 64, "Help in Incident Ticket view", "F1= Opens a help file showing the functions." & @CRLF _ & "F3= Resolution: This will change the view to the resolution field in edit mode." & @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired." & @CRLF _ & "F5= Refresh: This will refresh the current view." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "F7= Close Ticket: This will change the status of a ticket to closed." & @CRLF _ & "F9= Close ticket function switch: This will allow you to turn on or off the close ticket function." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") EndIf EndFunc ;==>_F1B_Func Func _F1C_Func();Help in Problem Ticket view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else MsgBox(0 + 64, "Help in Problem Ticket view", "F1= Opens a help file showing the functions." & @CRLF _ & "F3= Resolution: This will change the view to the resolution field in edit mode." & @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired." & @CRLF _ & "F5= Refresh: This will refresh the current view." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "F7= Close Ticket: This will change the status of a ticket to closed." & @CRLF _ & "F9= Close ticket function switch: This will allow you to turn on or off the close ticket function." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") EndIf EndFunc ;==>_F1C_Func Func _F1D_Func();Help in Incident Ticket view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else MsgBox(0 + 64, "Help in Update Incident view", "F1= Opens a help file showing the functions." & @CRLF _ & "F3= Resolution: This will change the view to the resolution field in edit mode." & @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") EndIf EndFunc ;==>_F1D_Func Func _F1E_Func();Help in Request Ticket view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else MsgBox(0 + 64, "Help in Update Request view", "F1= Opens a help file showing the functions." & @CRLF _ & "F3= Resolution: This will change the view to the resolution field." & @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") EndIf EndFunc ;==>_F1E_Func Func _F1F_Func();Help in Update Problem view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else MsgBox(0 + 64, "Help in Update Problem view", "F1= Opens a help file showing the functions." & @CRLF _ & "F3= Resolution: This will change the view to the resolution field." & @CRLF _ & "F4= TreePaste: This will open a GUI with a tree menu to allow the user to select the Configuration item desired." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "CTRL + ALT + X: Closes UNPlus, but leaves Unicenter ServiceDesk open" & @CRLF _ & "Print Scrn= Print Ticket: This will print your ticket to your default printer.") EndIf EndFunc ;==>_F1F_Func Func _F1G_Func();Help in main window view If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else MsgBox(0 + 64, "Help in main window view", "F1= Opens a help file showing the functions." & @CRLF _ & "F2= Search Request: This will search for Request tickets in a predefined bucket." & @CRLF _ & "F3= Search Incident: This will search for Incidents tickets in a predefined bucket." & @CRLF _ & "F5= Refresh: This will refresh the current list of tickets that are listed." & @CRLF _ & "F6= Quick Paste: This will paste pre-determined text of your choice to fields." & @CRLF _ & "F8= Logout: This will log you out of Unicenter") EndIf EndFunc ;==>_F1G_Func ;F2 Section Func _F2_Func(); Search Request If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else BlockInput(1) Run("request.exe", "") BlockInput(0) EndIf EndFunc ;==>_F2_Func ;F3 Section Func _F3A_Func(); Resolution field If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else BlockInput(1) Send("!d") WinWaitActive("Update Request - Unicenter ServicePlus Service Desk", "") Send("!9") BlockInput(0) EndIf EndFunc ;==>_F3A_Func Func _F3B_Func(); Search Incident If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else BlockInput(1) Run("incident.exe", "") BlockInput(0) EndIf EndFunc ;==>_F3B_Func ;F4 Section Func _F4_Func(); TreePaste If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else BlockInput(1) Send("^a") Sleep(50) Send("{DEL}") Sleep(50) BlockInput(0) RunWait("treepaste.exe", "") BlockInput(1) Sleep(500) Send("^v") BlockInput(0) EndIf EndFunc ;==>_F4_Func ;F5 Section Func _F5A_Func(); Refresh Ticket If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else BlockInput(1) Send("!v") Sleep(20) Send("!e") BlockInput(0) EndIf EndFunc ;==>_F5A_Func Func _F5B_Func(); Refresh Querry If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else BlockInput(1) Send("!v") Sleep(20) Send("!f") BlockInput(0) EndIf EndFunc ;==>_F5B_Func ;F6 Section Func key6(); QuickPaste If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else RunWait("quickpaste2_0.exe", "") EndIf EndFunc ;==>key6 ;F7 Section Func _F7_Func(); Close Ticket If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else If FileExists("ct.flg") Then RunWait("closeticket.exe", "") Else MsgBox(0 + 48, "Change ticket status to close", "This function is currently turned off. You will need to use the F9 key to enable this function") EndIf EndIf EndFunc ;==>_F7_Func ;F8 Section Func _F8_Func(); Close Unicenter and UNPlus If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else BlockInput(1) Send("!u") Send("!e") BlockInput(0) Exit EndIf EndFunc ;==>_F8_Func ;F9 Section Func _F9_Func(); CTFS If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else RunWait("switchF7.exe", "") EndIf EndFunc ;==>_F9_Func Func key10(); CTFS If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else Exit EndIf EndFunc ;==>key10 Func key11(); CTFS If WinExists("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Then WinActivate("Microsoft Internet Explorer", "[239] Sorry, your session has timed out.") Sleep(1000) Send("{ENTER}") Else BlockInput(1) Run("print.exe", "") BlockInput(0) EndIf EndFunc ;==>key11 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Bert Posted December 2, 2005 Author Share Posted December 2, 2005 I had to take out the lines that had /url and reset them to the way I had it before. They work fine. The problem is the hotkeysets. They still don't work. I wonder if it is because of the 64 key limit and I got it set as a loop. Any thoughts? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted December 3, 2005 Author Share Posted December 3, 2005 I was wondering, If you have a certain amount of hotkeyset commands in a loop, will this cause the 64 key limit to drop? I suspect this is the problem, but I'm not sure. Has anyone else ran into this problem? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Bert Posted December 3, 2005 Author Share Posted December 3, 2005 I think I found the problem. Take a look at the following test script: while 1 if winactive ("111.txt") then HotKeySet("{F1}", "_F1_Func");turns key on HotKeySet("{F2}", "_F2_Func");turns key on else HotKeySet("{F1}"); turns it back off HotKeySet("{F2}"); turns it back off endif ; if winactive ("222.txt") then ; HotKeySet("{F1}", "_F3_Func");turns key on ; else ; HotKeySet("{F1}"); turns it back off ; endif wend exit Func _F1_Func() MsgBox(0, "11111", "Pressed F1") EndFunc Func _F2_Func() MsgBox(0, "2222", "Pressed F2") EndFunc ; Func _F3_Func() ; MsgBox(0, "26543", "Pressed F2") ; EndFunc The script above was tested and works fine. It breaks if you release the comments for the other if statement, and the other Func statement, The second If statement will display the message, but the first one won't. Is this a bug? I tried to report it, but the forum is erroring out. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valuater Posted December 3, 2005 Share Posted December 3, 2005 (edited) the else's above keep killing the key set maybe like this ******** not tested *********** expandcollapse popupwhile 1 if winactive ("111.txt") then key_clean_1() HotKeySet("{F1}", "_F1_Func");turns key on HotKeySet("{F2}", "_F2_Func");turns key on endif if winactive ("222.txt") then key_clean_1() HotKeySet("{F1}", "_F3_Func");turns key on HotKeySet("{F2}", "_F4_Func");turns key on endif wend exit ; ----------- Key Functions ---------------------------- Func _F1_Func() MsgBox(0, "1111", "Pressed F1") EndFunc Func _F2_Func() MsgBox(0, "2222", "Pressed F2") EndFunc Func _F3_Func() MsgBox(0, "3333", "Pressed F3") EndFunc Func _F4_Func() MsgBox(0, "4444", "Pressed F4") EndFunc ; --------- Key Clean Functions ------------------ Func key_clean_1() HotKeySet("{F1}"); turns it back off HotKeySet("{F2}"); turns it back off EndFunc this would greatly reduce your original script use Func key_clean_2 Func key_clean_3 to clean the other sets of keys 8) Edited December 3, 2005 by Valuater Link to comment Share on other sites More sharing options...
Bert Posted December 3, 2005 Author Share Posted December 3, 2005 I'll give that a try. Thanks! The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
herewasplato Posted December 3, 2005 Share Posted December 3, 2005 This code does not constantly turn the hotkeys keys on and off: expandcollapse popupAutoItSetOption("WinTitleMatchMode", 2) AutoItSetOption("TrayIconDebug", 1) While 1 If WinActive("111.txt") Then _Window_111_Func() If WinActive("222.txt") Then _Window_222_Func() Sleep(10) WEnd Exit ; ----------- Key Functions ---------------------------- Func _F1_Func() MsgBox(0, "_F1_Func", "Pressed F1 for window 111.txt") EndFunc ;==>_F1_Func Func _F2_Func() MsgBox(0, "_F2_Func", "Pressed F2 for window 111.txt") EndFunc ;==>_F2_Func Func _F3_Func() MsgBox(0, "_F3_Func", "Pressed F1 for window 222.txt") EndFunc ;==>_F3_Func Func _F4_Func() MsgBox(0, "_F4_Func", "Pressed F2 for window 222.txt") EndFunc ;==>_F4_Func ; --------- Window Functions ------------------ Func _Window_111_Func() HotKeySet("{F1}", "_F1_Func");turns key on HotKeySet("{F2}", "_F2_Func");turns key on Do Sleep(50) Until Not WinActive("111.txt") HotKeySet("{F1}"); turns it back off HotKeySet("{F2}"); turns it back off EndFunc ;==>_Window_111_Func Func _Window_222_Func() HotKeySet("{F1}", "_F3_Func");turns key on HotKeySet("{F2}", "_F4_Func");turns key on Do Sleep(50) Until Not WinActive("222.txt") HotKeySet("{F1}"); turns it back off HotKeySet("{F2}"); turns it back off EndFunc ;==>_Window_222_FuncIt works for me... hope it works for you. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Valuater Posted December 3, 2005 Share Posted December 3, 2005 Yours may work but he has other levels.... anyway... i added a window # so it doent constantly reset the keys for that window expandcollapse popupDim $win_munber = 0 while 1 if winactive ("111.txt") And $win_munber <> 1 then key_clean_1() HotKeySet("{F1}", "_F1_Func");turns key on HotKeySet("{F2}", "_F2_Func");turns key on $win_munber = 1 endif if winactive ("222.txt") And $win_munber <> 2 then key_clean_1() HotKeySet("{F1}", "_F3_Func");turns key on HotKeySet("{F2}", "_F4_Func");turns key on $win_munber = 2 endif wend exit ; ----------- Key Functions ---------------------------- Func _F1_Func() MsgBox(0, "1111", "Pressed F1") EndFunc Func _F2_Func() MsgBox(0, "2222", "Pressed F2") EndFunc Func _F3_Func() MsgBox(0, "3333", "Pressed F3") EndFunc Func _F4_Func() MsgBox(0, "4444", "Pressed F4") EndFunc ; --------- Key Clean Functions ------------------ Func key_clean_1() HotKeySet("{F1}"); turns it back off HotKeySet("{F2}"); turns it back off EndFunc 8) Link to comment Share on other sites More sharing options...
herewasplato Posted December 3, 2005 Share Posted December 3, 2005 (edited) ...but he has other levels....Sorry, but I do not understand. What scenarios mentioned in the OPs code can you not achieve with the layout I mentioned? Here is a scenario for the code in your last post: Condition: 111.txt is active First time thru your loop: F1 is set. Condition: 111.txt is active Subsequent times thru your loop: no action Condition: Another application is brought up say notepad Condition: 111.txt is not active Subsequent times thru your loop: no action F1 will not work for notepad but will still cause _F1_Func() to run if pressed. In the layout that I mentioned, you can do other things within that do/until loop if need be (although I see no need to all scenarios should be handled within the main loop), but you might want F1 to be normal for all other apps. [Pardon my posts while I attempt to learn from a very patient Valuater. I usually pester Valuater via PM, but I thought the scenario above might be an important point for the OP.] @ Valuater thanks for your time. Edited December 3, 2005 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Bert Posted December 3, 2005 Author Share Posted December 3, 2005 This has been a very informative thread. Thanks to everyone who provided me input in solving my coding problem. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Valuater Posted December 3, 2005 Share Posted December 3, 2005 on your scenario above you are completely correct... if a window that was not in the I-if-active list was not active and no other in the list became active, the last set of "F" keys would remain and not function normaly for other apps. Your system is vary good... it has features that actaully check for this situation and return normal functions to the "F" keys when a window in the "list" is not active. I saw this program as a singular control of the the insurance/reporting application which actualy is started by the script. i did not consider the script continueing if the ins/report program was not active at all per original script by poster ;This section monitors if Unicenter is open or closed $uni = WinExists("Unicenter ServicePlus Service Desk", "[url="http://usdp/CAisd/pdmweb.exe"]http://usdp/CAisd/pdmweb.exe[/url]") If $uni == 0 Then $endunplus = MsgBox(3 + 32 + 0, "Unicenter Service Desk was closed!", "Do you wish to restart Unicenter?" & @CRLF & "" & @CRLF & "Click YES to restart Unicenter." & @CRLF & "Click NO to close UNPlus." & @CRLF & "Click CANCEL to disreguard this message") If $endunplus == 2 Then WinWaitActive("Unicenter ServicePlus Service Desk", "[url="http://usdp/CAisd/pdmweb.exe"]http://usdp/CAisd/pdmweb.exe[/url]") Sleep(5000);IMPORTANT THAT THIS SLEEP STATEMENT STAYS HERE! EndIf If $endunplus == 7 Then Exit EndIf If $endunplus == 6 Then Run( "C:\Program Files\Internet Explorer\IEXPLORE.EXE -new [url="http://usdp/CAisd/pdmweb.exe"]http://usdp/CAisd/pdmweb.exe[/url]", "") EndIf ;end section that is in the While/Wend loop Great Programming on your part and Recognition of possible problems with my script... but the actual use does not need normal "F" keys 8) Link to comment Share on other sites More sharing options...
gamerman2360 Posted December 3, 2005 Share Posted December 3, 2005 (edited) You could alwas have the hotkey on but do different things based on the window. HotKeySet("{F1}", "_F1_Func");turns key on HotKeySet("{F2}", "_F2_Func");turns key on ; ----------- Key Functions ---------------------------- Func _F1_Func() If WinActive ("111.txt") Then MsgBox(0, "1111", "Pressed F1") Else HotKeySet("{F1}") Send("{F1}") HotKeySet("{F1}", "_F1_Func") EndIf EndFunc Func _F2_Func() If WinActive ("222.txt") Then MsgBox(0, "2222", "Pressed F2") Else HotKeySet("{F2}") Send("{F2}") HotKeySet("{F2}", "_F2_Func") EndIf EndFuncShould have the same effect. Edited December 3, 2005 by gamerman2360 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