Sparhawk Posted September 19, 2010 Posted September 19, 2010 (edited) Hi, I just started using autoit, but I have problem... My script looks like this: hotkeyset ("{F9}", "hide") hotkeyset ("{F10}", "show") AutoItSetOption("WinTitleMatchMode", 4) Global $handle = WinGetHandle("classname=xxx") while 1 sleep(1000) WEnd func hide() Global $Show = 0 WinSetState ($handle, "", @SW_MINIMIZE ) ;~ WinSetState ($handle, "", @SW_HIDE ) If @error Then MsgBox(0, "Error", "Couldn't find xxx") Else While 1 ControlSend($handle, "", "", "1") Sleep(1000) If $Show > 0 Then ExitLoop Wend EndIf endfunc func show() Global $Show = 1 ;~ WinSetstate ($handle, "", @SW_SHOW ) WinSetState ($handle, "", @SW_MAXIMIZE ) WinActivate ($handle, "") endfunc Purpose of this script is, when u press F9, program will Be minimized and pressing "1" at loop with 1s looptime.. However I cant make this work, cause I have problem with sending that "1" key, cause I using diferent keyboard layout = not ENGLISH = instead of "1" it sending "+" key... can some1 help me? I think I must define some keyboard layout to eng in script.. if Im wrong, just tell me... Thanks for your help P.S. Another problem is, that it randomly sending Shift key to windows and I rly dont know why Edited September 19, 2010 by Sparhawk
seandisanti Posted September 19, 2010 Posted September 19, 2010 (edited) hotkeyset ("{F9}", "hide") hotkeyset ("{F10}", "show") AutoItSetOption("WinTitleMatchMode", 4) Global $handle = WinGetHandle("classname=xxx") while 1 sleep(1000) WEnd func hide() Global $Show = 0;don't declare globally inside of a function, it defeats the purpose WinSetState ($handle, "", @SW_MINIMIZE ) ;~ WinSetState ($handle, "", @SW_HIDE ) If @error Then MsgBox(0, "Error", "Couldn't find xxx") Else While 1 ControlSend($handle, "", "", "1");you're using controlsend but not sending to a control, check out Send() Sleep(1000) If $Show > 0 Then ExitLoop Wend EndIf endfunc func show() Global $Show = 1;definitely don't declare 1 variable globally in 2 functions ;~ WinSetstate ($handle, "", @SW_SHOW ) WinSetState ($handle, "", @SW_MAXIMIZE ) WinActivate ($handle, "") endfunc I've added a couple of comments... also, when you list code, use [ autoit] and [ /autoit] tags ***edit*** ps, try using "{NUMPAD1}" instead of 1, and your errant Shifting is probably because the + you're actually sending is being interpreted as a shift key Edited September 19, 2010 by cameronsdad
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