Sign in to follow this  
Followers 0
Sparhawk

Keyboard problem

2 posts in this topic

#1 ·  Posted (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 by Sparhawk

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0