Wooltown Posted March 9, 2006 Share Posted March 9, 2006 (edited) Hello ! Is there a way to check in which GUI Input controller you are in, I would in some input fields be able to go to the right and left, using the arrow-keys, but in some you would need to use the Tab-key. /Sven Edited March 9, 2006 by Wooltown Link to comment Share on other sites More sharing options...
Valuater Posted March 9, 2006 Share Posted March 9, 2006 how about using Control ID's 8) Link to comment Share on other sites More sharing options...
Wooltown Posted March 9, 2006 Author Share Posted March 9, 2006 Ok, I must try to make my question clearer: I am running my AutoIT scriptand have a lot of inpus fileds, how can my code check which ControlID i am currently writing in ? /Sven Link to comment Share on other sites More sharing options...
Valuater Posted March 9, 2006 Share Posted March 9, 2006 there are many ways... i do it all the time please post some code... maybe i can help 8) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2006 Moderators Share Posted March 9, 2006 (edited) In your GUI loop statement Example: While 1 ToolTip(ControlGetFocus($MainGUINameNotTheControlName)) Wend Edited March 9, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Wooltown Posted March 9, 2006 Author Share Posted March 9, 2006 Here comes an excerpt from my code, how can I trigger when I am in the Weekdays columns and then use the arrows to jump between fields ? expandcollapse popup#include <Array.au3> #include <GUIConstants.au3> Opt("WinTitleMatchMode", 1);1=start, 2=substring, 3=exact Opt("WinSearchChildren", 1) Opt("MouseCoordMode",0); 0=window, 1=screen Opt("PixelCoordMode",0) Opt("TrayIconDebug",1) Opt("MouseClickDelay",50) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt("GUICloseOnESC",1) GLOBAL $StaffActivityRow[25][12], $StaffActivityValue[25][12], $StaffActivitySumDay[8], $StaffActivitySumCol[8] $TimeReporterGUI = GUICreate("Test Time Manager",870,710) GUISetOnEvent($GUI_EVENT_CLOSE, "GUIExit") GUICtrlCreateLabel ("Staff Activity",10,85,70 ,-1) GUICtrlCreateLabel ("Track",220,85,70 ,-1) GUICtrlCreateLabel ("Test Area",370,85,70 ,-1) GUICtrlCreateLabel ("Mon Tue Wed Thu Fri Sat Sun Total",525,85,265,-1) $l_VertPos = 105 For $l_row = 0 to 24 ; ---------- Draw one row ---------- $StaffActivityRow[$l_row][1] = GUICtrlCreateCombo($StaffActivityValue[$l_row][1], 10,$l_VertPos,210,250,BitOr($GUI_SS_DEFAULT_COMBO,$CBS_DROPDOWNLIST)) GUICtrlSetData($StaffActivityRow[$l_row][1]," ") $StaffActivityRow[$l_row][2] = GUICtrlCreateCombo($StaffActivityValue[$l_row][2], 220,$l_VertPos,150,250,BitOr($GUI_SS_DEFAULT_COMBO,$CBS_DROPDOWNLIST)) GUICtrlSetData($StaffActivityRow[$l_row][2],"----------") $StaffActivityRow[$l_row][3] = GUICtrlCreateCombo($StaffActivityValue[$l_row][3], 370,$l_VertPos,150,250,BitOr($GUI_SS_DEFAULT_COMBO,$CBS_DROPDOWNLIST)) GUICtrlSetData($StaffActivityRow[$l_row][3],"----------") $StaffActivityRow[$l_row][4] = GUICtrlCreateInput($StaffActivityValue[$l_row][4], 525,$l_VertPos,25,20) $StaffActivityRow[$l_row][5] = GUICtrlCreateInput($StaffActivityValue[$l_row][5], 555,$l_VertPos,25,20) $StaffActivityRow[$l_row][6] = GUICtrlCreateInput($StaffActivityValue[$l_row][6], 585,$l_VertPos,25,20) $StaffActivityRow[$l_row][7] = GUICtrlCreateInput($StaffActivityValue[$l_row][7], 615,$l_VertPos,25,20) $StaffActivityRow[$l_row][8] = GUICtrlCreateInput($StaffActivityValue[$l_row][8], 645,$l_VertPos,25,20) $StaffActivityRow[$l_row][9] = GUICtrlCreateInput($StaffActivityValue[$l_row][9], 675,$l_VertPos,25,20) $StaffActivityRow[$l_row][10] = GUICtrlCreateInput($StaffActivityValue[$l_row][10], 705,$l_VertPos,25,20) $StaffActivityRow[$l_row][11] = GUICtrlCreateLabel($StaffActivityValue[$l_row][11], 740,$l_VertPos,35,20,$SS_SUNKEN,$WS_EX_CLIENTEDGE ) GUICtrlSetBkColor(-1,0xffffff) $l_VertPos = $l_VertPos + 20 Next ; ---------- Week Summary ---------- GUICtrlCreateLabel ("Totals:",470,612,40 ,-1) $StaffActivitySumCol[0] = GUICtrlCreateLabel($StaffActivitySumDay[0], 525,605,25,20,$SS_SUNKEN,$WS_EX_CLIENTEDGE ) GUICtrlSetBkColor(-1,0xffffff) $StaffActivitySumCol[1] = GUICtrlCreateLabel($StaffActivitySumDay[1], 555,605,25,20,$SS_SUNKEN,$WS_EX_CLIENTEDGE ) GUICtrlSetBkColor(-1,0xffffff) $StaffActivitySumCol[2] = GUICtrlCreateLabel($StaffActivitySumDay[2], 585,605,25,20,$SS_SUNKEN,$WS_EX_CLIENTEDGE ) GUICtrlSetBkColor(-1,0xffffff) $StaffActivitySumCol[3] = GUICtrlCreateLabel($StaffActivitySumDay[3], 615,605,25,20,$SS_SUNKEN,$WS_EX_CLIENTEDGE ) GUICtrlSetBkColor(-1,0xffffff) $StaffActivitySumCol[4] = GUICtrlCreateLabel($StaffActivitySumDay[4], 645,605,25,20,$SS_SUNKEN,$WS_EX_CLIENTEDGE ) GUICtrlSetBkColor(-1,0xffffff) $StaffActivitySumCol[5] = GUICtrlCreateLabel($StaffActivitySumDay[5], 675,605,25,20,$SS_SUNKEN,$WS_EX_CLIENTEDGE ) GUICtrlSetBkColor(-1,0xffffff) $StaffActivitySumCol[6] = GUICtrlCreateLabel($StaffActivitySumDay[6], 705,605,25,20,$SS_SUNKEN,$WS_EX_CLIENTEDGE ) GUICtrlSetBkColor(-1,0xffffff) $StaffActivitySumCol[7] = GUICtrlCreateLabel($StaffActivitySumDay[7], 740,605,35,20,$SS_SUNKEN,$WS_EX_CLIENTEDGE ) GUICtrlSetBkColor(-1,0xffffff) ; ---------- Buttons ---------- $StaffActivitySaveActivityButton = GUICtrlCreateButton ("Save",790,105,60,40) ; GUICtrlSetOnEvent($StaffActivitySaveActivityButton,"_SaveReport") $StaffActivitySubmitActivityButton = GUICtrlCreateButton ("Submit",790,165,60,40) ; GUICtrlSetOnEvent($StaffActivitySubmitActivityButton,"_SubmitReport") $StaffActivitySaveTemplateButton = GUICtrlCreateButton ("Save Temp",790,225,60,40) ; GUICtrlSetOnEvent($StaffActivitySaveTemplateButton,"_SaveTemplateToDatabase") $StaffActivityLoadTemplateButton = GUICtrlCreateButton ("Load Temp",790,285,60,40) ; GUICtrlSetOnEvent($StaffActivityLoadTemplateButton,"_LoadTemplateFromDatabase") GUICtrlCreateLabel ("Comment:",10,612,50 ,-1) $StaffActivityComment = GUICtrlCreateEdit("",10,630,360,50,BitOr($ES_WANTRETURN,$ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) GUISetState () While 1 Sleep (100) Wend Func GUIExit() Exit EndFunc Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2006 Moderators Share Posted March 9, 2006 What arrows on the WeekDay columns? Are you talking about the key board arrows? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted March 9, 2006 Share Posted March 9, 2006 (edited) ME AND MY BIG MOUTH.... how about this #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep (1) If _IsPressed("25", $dll) Then MsgBox(0,"_IsPressed", "Key Pressed") EndIf If _IsPressed("26", $dll) Then MsgBox(0,"_IsPressed", "Key Pressed") EndIf If _IsPressed("27", $dll) Then MsgBox(0,"_IsPressed", "Key Pressed") EndIf If _IsPressed("28", $dll) Then MsgBox(0,"_IsPressed", "Key Pressed") EndIf WEnd DllClose($dll) then use GUI-Ctrl-Set-Foucus 8) Edited March 9, 2006 by Valuater Link to comment Share on other sites More sharing options...
Wooltown Posted March 9, 2006 Author Share Posted March 9, 2006 SmOke_N: Yes I would like to navigate with my keyboard arrows in the weekday columns. How can I check if I am in those columns ? /Sven Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2006 Moderators Share Posted March 9, 2006 (edited) Blah... I need sleep:expandcollapse popupWhile 1 Sleep (10) If _IsPressed('25') And StringInStr(String(ControlGetFocus($TimeReporterGUI)), 'Edit') Then For $x = 2 To 175 If ControlGetFocus($TimeReporterGUI) = 'Edit' & $x Then ControlFocus($TimeReporterGUI, '', 'Edit' & ($x - 1)) ExitLoop EndIf Next Sleep(100) EndIf If _IsPressed('26') And StringInStr(String(ControlGetFocus($TimeReporterGUI)), 'Edit') Then For $x = 8 To 175 If ControlGetFocus($TimeReporterGUI) = 'Edit' & $x Then ControlFocus($TimeReporterGUI, '', 'Edit' & ($x - 7)) ExitLoop EndIf Next Sleep(100) EndIf If _IsPressed('27') And StringInStr(String(ControlGetFocus($TimeReporterGUI)), 'Edit') Then For $x = 1 To 174 If ControlGetFocus($TimeReporterGUI) = 'Edit' & $x Then ControlFocus($TimeReporterGUI, '', 'Edit' & ($x + 1)) ExitLoop EndIf Next Sleep(100) EndIf If _IsPressed('28') And StringInStr(String(ControlGetFocus($TimeReporterGUI)), 'Edit') Then For $x = 1 To 168 If ControlGetFocus($TimeReporterGUI) = 'Edit' & $x Then ControlFocus($TimeReporterGUI, '', 'Edit' & ($x + 7)) ExitLoop EndIf Next Sleep(100) EndIf Wend Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFuncEdit: Added the _IsPressed() Function there so you don't have to include the entire Misc.au3 file. Edit2: I had 1 To 175 on the Right Arrow ... Made it 1 to 174 since 175 is the last Edit Control. Edited March 9, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Wooltown Posted March 9, 2006 Author Share Posted March 9, 2006 Thank you very much for the help, I can see it works, just have to analyze the code and figure out how it works, will take some hours, but now I know how to continue. Regards Sven Link to comment Share on other sites More sharing options...
Valuater Posted March 9, 2006 Share Posted March 9, 2006 Sorry i didn't write the whole thing for you 8) Link to comment Share on other sites More sharing options...
Valuater Posted March 9, 2006 Share Posted March 9, 2006 (edited) another approach expandcollapse popup#include <GuiConstants.au3> Opt("GUIOnEventMode", 1) Dim $BTN_[40] Dim $x Dim $ver = "1.0.1" Dim $left = 0 Dim $top = 0 $key = StringSplit("1,2,3,4,5,6,7,8,9,0,Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M", ",") $gui = GUICreate("Key Magic by, Valuater v" & $ver, @DesktopWidth, @DesktopHeight - 60, -1, -1) $keybd = GUICtrlCreateButton("SHOW KEYBOARD", 100, @DesktopHeight - 150, 150, 40) GUICtrlCreateLabel("Presented by, QTasc ", @DesktopWidth - 170, @DesktopHeight - 120, 120, 15, $SS_SUNKEN) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState() $mainwindow = GUICreate("Keyboard - Enter Your PIN Number", 400, 200, 20, @DesktopHeight - 300, -1, "", $gui) ; BUTTONS For $i = 1 To 36 $BTN_[$i] = GUICtrlCreateButton($key[$i], $left, $top, 40, 40) GUICtrlSetOnEvent($BTN_[$i], "ButtonPressed") $left = $left + 40 If $i = 10 Or $i = 20 Or $i = 29 Then $top = $top + 40 If $i = 10 Then $left = 0 If $i = 20 Then $left = 20 If $i = 29 Then $left = 40 Next $BackSpace = GUICtrlCreateButton("<-", 320, 120, 40, 40) GUICtrlSetFont(-1, 10, 500) $Input = GUICtrlCreateInput("", 40, 170, 150, 20) GUICtrlSetFont(-1, 10) $Send = GUICtrlCreateButton("&ENTER", 205, 165, 150, 30) GUICtrlSetOnEvent($keybd, "Show_keys") GUICtrlSetOnEvent($BackSpace, "Back_Space") GUICtrlSetOnEvent($Send, "Send_it") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState(@SW_SHOW) WinSetOnTop("Keyboard", "", 1) While (1) Sleep(20) WEnd Func Show_keys() GUISetState(@SW_SHOW, $mainwindow) EndFunc ;==>Show_keys Func ButtonPressed() $i = @GUI_CtrlId - $BTN_[1] + 1 $info1 = GUICtrlRead($Input) GUICtrlSetData($Input, $info1 & $key[$i]) EndFunc ;==>ButtonPressed Func Back_Space() $info1 = GUICtrlRead($Input) $info1 = StringTrimRight($info1, 1) GUICtrlSetData($Input, $info1) EndFunc ;==>Back_Space Func CLOSEClicked() If @GUI_WinHandle = $mainwindow Then GUISetState(@SW_HIDE, $mainwindow) EndIf If @GUI_WinHandle = $gui Then Exit EndIf EndFunc ;==>CLOSEClicked Func Send_it() MsgBox(0,"", GUICtrlRead($Input)) EndFunc ;==>Send_it 8) Edited March 9, 2006 by Valuater Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2006 Moderators Share Posted March 9, 2006 another approach expandcollapse popup#include <GuiConstants.au3> Opt("GUIOnEventMode", 1) Dim $BTN_[40] Dim $x Dim $ver = "1.0.1" Dim $left = 0 Dim $top = 0 $key = StringSplit("1,2,3,4,5,6,7,8,9,0,Q,W,E,R,T,Y,U,I,O,P,A,S,D,F,G,H,J,K,L,Z,X,C,V,B,N,M", ",") $gui = GUICreate("Key Magic by, Valuater v" & $ver, @DesktopWidth, @DesktopHeight - 60, -1, -1) $keybd = GUICtrlCreateButton("SHOW KEYBOARD", 100, @DesktopHeight - 150, 150, 40) GUICtrlCreateLabel("Presented by, QTasc ", @DesktopWidth - 170, @DesktopHeight - 120, 120, 15, $SS_SUNKEN) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState() $mainwindow = GUICreate("Keyboard - Enter Your PIN Number", 400, 200, 20, @DesktopHeight - 300, -1, "", $gui) ; BUTTONS For $i = 1 To 36 $BTN_[$i] = GUICtrlCreateButton($key[$i], $left, $top, 40, 40) GUICtrlSetOnEvent($BTN_[$i], "ButtonPressed") $left = $left + 40 If $i = 10 Or $i = 20 Or $i = 29 Then $top = $top + 40 If $i = 10 Then $left = 0 If $i = 20 Then $left = 20 If $i = 29 Then $left = 40 Next $BackSpace = GUICtrlCreateButton("<-", 320, 120, 40, 40) GUICtrlSetFont(-1, 10, 500) $Input = GUICtrlCreateInput("", 40, 170, 150, 20) GUICtrlSetFont(-1, 10) $Send = GUICtrlCreateButton("&ENTER", 205, 165, 150, 30) GUICtrlSetOnEvent($keybd, "Show_keys") GUICtrlSetOnEvent($BackSpace, "Back_Space") GUICtrlSetOnEvent($Send, "Send_it") GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") GUISetState(@SW_SHOW) WinSetOnTop("Keyboard", "", 1) While (1) Sleep(20) WEnd Func Show_keys() GUISetState(@SW_SHOW, $mainwindow) EndFunc;==>Show_keys Func ButtonPressed() $i = @GUI_CtrlId - $BTN_[1] + 1 $info1 = GUICtrlRead($Input) GUICtrlSetData($Input, $info1 & $key[$i]) EndFunc;==>ButtonPressed Func Back_Space() $info1 = GUICtrlRead($Input) $info1 = StringTrimRight($info1, 1) GUICtrlSetData($Input, $info1) EndFunc;==>Back_Space Func CLOSEClicked() If @GUI_WinHandle = $mainwindow Then GUISetState(@SW_HIDE, $mainwindow) EndIf If @GUI_WinHandle = $gui Then Exit EndIf EndFunc;==>CLOSEClicked Func Send_it() MsgBox(0,"", GUICtrlRead($Input)) EndFunc;==>Send_it 8)He's using 2 dimensional Arrays... (I thought of that first... GUICtrlSetState() actually and then saw the arrays). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted March 9, 2006 Share Posted March 9, 2006 He's using 2 dimensional Arrays... (I thought of that first... GUICtrlSetState() actually and then saw the arrays).per help@GUI_CtrlId Last click GUI Control identifier. Only valid in an event Function.are you sure???doesn't mention the two diminsional arrays8) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 9, 2006 Moderators Share Posted March 9, 2006 per helpare you sure???doesn't mention the two diminsional arrays8)You may be right, I NEVER use OnEvent... so, I don't use those macros. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted March 9, 2006 Share Posted March 9, 2006 well ... at the least wooltown has some options 8) Link to comment Share on other sites More sharing options...
Wooltown Posted March 9, 2006 Author Share Posted March 9, 2006 Thank you for all your help, now I know how to do it, and I understand how the it works, I took SmOke_N's example. Everything is easy when you know how to do it. Thanks again Sven 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