litlmike Posted January 3, 2007 Posted January 3, 2007 Happy New Year!Conditions for Desired Script:1) Want to have a HotKeySet function differently depending on the active window.2) If the active window is "Eudora", then Click Here3) If the active window is "Eudora", and the HotKeySet is Pressed twice then Activate_ACT()4) Would prefer that when HotKeySet is Pressed twice that the MouseClick would not activate first, but is this is impossible, no worries.5) If any other window is active then Activate_ACT()Thanks in advance, here is what I have so far.HotKeySet("^1", "Select_ACT_NotesHistory") While 1 Sleep (1000) WEnd Func Select_ACT_NotesHistory () If WinActive ("ACT") Then Send("+{F9}") ElseIf WinActive ("Eudora") Then If $Act_Counter > 1 Then Activate_ACT() Else Opt ("MouseCoordMode", 0) $current_x_y = MouseGetPos () MouseClick ( "left", 30, 940) MouseMove ( $current_x_y [0], $current_x_y [1]) $Act_Counter += 1 EndIf Else Activate_ACT() EndIf $Act_Counter = 0 EndFunc Func Activate_ACT() Opt("WinTitleMatchMode",1) $title = WinGetTitle("") WinWait("ACT!","") If Not WinActive("ACT!","") Then WinActivate("ACT!","") WinWaitActive("ACT!","") EndFunc _ArrayPermute()_ArrayUnique()Excel.au3 UDF
Bert Posted January 3, 2007 Posted January 3, 2007 If I remember right, you have that all in one script that runs everything on your PC, and everything is ran with hotsetkeys? The Vollatran project My blog: http://www.vollysinterestingshit.com/
litlmike Posted January 3, 2007 Author Posted January 3, 2007 If I remember right, you have that all in one script that runs everything on your PC, and everything is ran with hotsetkeys?Correct-a-mundo _ArrayPermute()_ArrayUnique()Excel.au3 UDF
dandymcgee Posted January 3, 2007 Posted January 3, 2007 (edited) 3) If the active window is "Eudora", and the HotKeySet is Pressed twice then Activate_ACT()4) Would prefer that when HotKeySet is Pressed twice that the MouseClick would not activate first, but is this is impossible, no worries.Do you mean that when you press the hotkey twice in a row (rather than you press it once, it does one thing, every time you press it after than it does something else) you want it so that if you press it, it does one thing, and if you press it twice quickly (say within 2 seconds of each other) it does something else? You would have to reset the hotkey to a second function for a certain time (would have to use a timer to have it reset the hoetkey back to the original function after two seconds or so, so that it would just alternate between functions each time it was pressed if you understand what I mean?). Please verify this is what you want, and I will help you if you need help. Edited January 3, 2007 by dandymcgee - Dan [Website]
litlmike Posted January 3, 2007 Author Posted January 3, 2007 Do you mean that when you press the hotkey twice in a row (rather than you press it once, it does one thing, every time you press it after than it does something else) you want it so that if you press it, it does one thing, and if you press it twice quickly (say within 2 seconds of each other) it does something else? You would have to reset the hotkey to a second function for a certain time (would have to use a timer to have it reset the hoetkey back to the original function after two seconds or so, so that it would just alternate between functions each time it was pressed if you understand what I mean?). Please verify this is what you want, and I will help you if you need help.That is correct, that is what I am looking for. I was thinking I could accomplish it by using a counter, it sounds like you are saying it must be done another way. I am all ears.Thanks _ArrayPermute()_ArrayUnique()Excel.au3 UDF
litlmike Posted January 4, 2007 Author Posted January 4, 2007 How do I "reset the hotkey to a second function"?And use a timer to have it reset the hoetkey back to the original function? Does that just mean make it sleep? _ArrayPermute()_ArrayUnique()Excel.au3 UDF
dandymcgee Posted January 4, 2007 Posted January 4, 2007 Wrote example function for having a double hotkey: Hotkeyset("{Esc}", "FirstFunc") Global $HotKeyPresses = 0 While 1 Sleep(100) WEnd ;blah code here blah Func FirstFunc() Global $HotKeyPresses = 1 HotKeySet("{Esc}", "SecondFunc") Sleep(200) HotKeySet("{Esc}", "FirstFunc") If $HotKeyPresses = 1 Then ;Hotkey only pressed once do this <--- PUT CODE HERE ElseIf $HotKeyPresses = 2 Then ;Hotkey pressed twice do this <--- PUT CODE HERE EndIf Global $HotKeyPresses = 0 EndFunc Func SecondFunc() Global $HotKeyPresses = 2 EndFunc Wow, this is really neat... could prove useful to somebody else, I'll definately keep this function around. Hope this helps you out with what you want to do. - Dan [Website]
litlmike Posted January 4, 2007 Author Posted January 4, 2007 Wrote example function for having a double hotkey: Wow, this is really neat... could prove useful to somebody else, I'll definately keep this function around. Hope this helps you out with what you want to do. Awesome! Thanks a ton. You're right it is really neat. Here is my final modification to your code. I had to increase the sleep to allow time for the second press of the HotKey HotKeySet("^1", "Select_ACT_NotesHistory") Global $HotKeyPresses = 0 Func Select_ACT_NotesHistory () ; If HotKey is pressed once then it goes to one-thing, if pressed twice in 1 second it does other-thing. Global $HotKeyPresses = 1 HotKeySet("^1", "SecondFunc") Sleep(800) HotKeySet("^1", "Select_ACT_NotesHistory") If WinActive ("ACT") Then Send("+{F9}") ElseIf WinActive ("Eudora") Then If $HotKeyPresses = 1 Then ;Hotkey only pressed once do this <--- PUT CODE HERE Opt ("MouseCoordMode", 0) $current_x_y = MouseGetPos () MouseClick ( "left", 30, 940) MouseMove ( $current_x_y [0], $current_x_y [1]) ElseIf $HotKeyPresses = 2 Then ;Hotkey pressed twice do this <--- PUT CODE HERE Activate_ACT() EndIf Else Activate_ACT() EndIf Global $HotKeyPresses = 0 EndFunc Func SecondFunc() Global $HotKeyPresses = 2 EndFunc _ArrayPermute()_ArrayUnique()Excel.au3 UDF
dandymcgee Posted January 4, 2007 Posted January 4, 2007 ;Hotkey only pressed once do this <--- PUT CODE HERE Lol feel free to remove this looks kinda silly now that it's not just an example. I'm glad I could help you out, I've been quite bored with AutoIt for the last month with not ideas of what to do, so I've pretty much been browsing the forums and helping who I see needs help and seems worthy of help (some of these people don't deserve to own computers in my opinion...). Please feel free to PM me if you find anything else you need help with (that goes for anyone reading this), I always get really excited when I check my email and see "New Personal Message ( AutoIt Forums )". Well time to eat dinner, maybe play some Diablo and browser AutoIt forums. Of course I can't miss Walker Texas Ranger from 7:00 to 9:00. Chuck Norris is awesome (I'm not just saying this because of the recent group of people that are completely obsessed with him, I don't know what's up with that it's annoying as hell). I've liked Chuck Norris ever since I can remember watching TV for the first time. Although it was only like 6 months ago I was reading about him online and found out he is actually a black belt and really does know karate much better then the majority of other people, he won World Championships Middle-Weight I think 8 years undefeated (not facts just what I remember I don't remember exactly times he won and such). Anyways time for dinner. - Dan [Website]
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