Jump to content
Sign in to follow this  
MikahS

Parent child problem; Child case in while loop running before called

Recommended Posts

MikahS

I am having problem. I have script that has a main GUI window that allows you to select which kind of encryption you'd like to use. When I go to start the script, for some reason the case statement for the:

$iSubmit
button for the child GUI runs right away and tried to read the data from the input on the child window, which hasn't been created yet, and then pops up the MsgBox.

 

I have been scouring the forums for something of similar nature, but unsuccessful. I have checked helpfile and it seems I am doing this correct. Here is my script:

; includes
 
#include <GUIConstantsEx.au3>
#include <Crypt.au3>
 
; vars
Local $hGUI, $msg = 0, $hInput, $iButton, $hDecode, $dButton
Local $aChkBx[8], $cValue, $iChild, $iMsg, $iPswd, $iMsgBox
Local $iPswdBox, $iSubmit
;main line
 
GUI()
 
While 1
    $msg = GUIGetMsg(1)
    Switch $msg[1]
        Case $hGUI
            Switch $msg[0]
                Case $GUI_EVENT_CLOSE
                    Quit()
                Case $iButton
                    getCheckbox()
                    inputChild()
                    ;Crypt(, $cValue)
                Case $dButton
                    getCheckbox()
             EndSwitch
        Case $iChild
            Switch $msg[0]
                  Case $GUI_EVENT_CLOSE
                      GUIDelete($iChild)
                  Case $iSubmit
                      $iMsg = GUICtrlRead($iMsgBox)
                      $iPswd = GUICtrlRead($iPswdBox)
                      MsgBox(0, "title", "msg:" & $iMsg & " paswrd:" & $iPswd)
            EndSwitch
    EndSwitch
WEnd
 
;functions
 
Func GUI()
    $hGUI = GUICreate("Short-Order Encrypter", 300, 200)
    GUICtrlCreateLabel("Encrypt a Message!", 95, 15)
    GUICtrlCreateLabel("This is a simple input and output encryption program.", 25, 35)
    GUICtrlCreateLabel("You will select which method of encryption, then", 30, 48)
    GUICtrlCreateLabel("input your text by pressing the Input button,", 40, 61)
    GUICtrlCreateLabel("or you will press the Decode button to", 55, 74)
    GUICtrlCreateLabel("decode an encrypted message.", 65, 87)
    $iButton = GUICtrlCreateButton("Input", 50, 160, 70, 30)
    $dButton = GUICtrlCreateButton("Decode", 160, 160, 70, 30)
    $aChkBx[0] = GUICtrlCreateCheckbox("Text", 15, 105)
    $aChkBx[1] = GUICtrlCreateCheckbox("3DES", 67, 105)
    $aChkBx[2] = GUICtrlCreateCheckbox("AES (128bit)", 122, 105)
    $aChkBx[3] = GUICtrlCreateCheckbox("AES (192bit)", 208, 105)
    $aChkBx[4] = GUICtrlCreateCheckbox("AES (256bit)", 32, 130)
    $aChkBx[5] = GUICtrlCreateCheckbox("DES", 121, 130)
    $aChkBx[6] = GUICtrlCreateCheckbox("RC2", 172, 130)
    $aChkBx[7] = GUICtrlCreateCheckbox("RC4", 224, 130)
    GUISetState(@SW_SHOW)
EndFunc ;==>GUI
 
Func getCheckbox()
    Local $i, $readArray, $cCounter = 0
    For $i = 0 To UBound($aChkBx) - 1 Step 1
        $readArray = GUICtrlRead($aChkBx[$i])
        If $readArray = 1 Then
             $cCounter += 1
             $cValue &= $i
        EndIf
    Next
    If $cCounter > 1 Then
        MsgBox(0, "Encryption Type", "Could not specify encryption type due to multiple selections. Please make sure you have only selected on type of encryption")
        $cValue = ""
        Return
    ElseIf $cCounter = 0 Then
         MsgBox(0, "Encryption Type", "You must select an encryption type in the Short-Order Encrypter window")
         Return
    EndIf
EndFunc ;==>getCheckbox
 
Func inputChild()
    If $cValue = "" Then
         Return
    EndIf
    $iChild = GUICreate("Input Message", 386, 120, -1, -1, -1, -1, $hGUI)
    GUICtrlCreateLabel("Message", 5, 10)
    GUICtrlCreateLabel("Password", 200, 10)
    $iMsgBox = GUICtrlCreateInput("", 5, 25, 180, 60)
    $iPswdBox = GUICtrlCreateInput("", 200, 25, 180, 60)
    $iSubmit = GUICtrlCreateButton("Encrypt", 172, 90)
    GUISetState()
EndFunc ;==>inputChild
 
#cs
Func Crypt($iMsg, $iPass, $iflag)
    Local $mFlag[8]
    $mFlag[0] = "TEXT"
    $mFlag[1] = $CALG_3DES
    $mFlag[2] = $CALG_AES_128
    $mFlag[3] = $CALG_AES_192
    $mFlag[4] = $CALG_AES_256
    $mFlag[5] = $CALG_DES
    $mFlag[6] = $CALG_RC2
    $mFlag[7] = $CALG_RC4
EndFunc ;==>Crypt
#ce
 
Func Quit()
    GUIDelete($hGUI)
    Exit
EndFunc ;==>Quit

 


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
careca

This works for me.

; includes

#include <GUIConstantsEx.au3>
#include <Crypt.au3>
Opt("TrayMenuMode", 1)
Opt("TrayIconHide", 0)
Opt("GUICoordMode", 1)
Opt("GUIResizeMode", 1)
Opt("TrayIconDebug", 1)
Opt("TrayAutoPause", 0)
Opt("MouseCoordMode", 2)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)
Opt("GUIEventOptions", 0)
Opt("TrayOnEventMode", 1)
Opt("ExpandEnvStrings", 1)
Opt("WinDetectHiddenText", 1)
; vars
Local $hGUI, $msg = 0, $hInput, $iButton, $hDecode, $dButton
Local $aChkBx[8], $cValue, $iChild, $iMsg, $iPswd, $iMsgBox
Local $iPswdBox, $iSubmit
;main line

GUI()

;functions

Func GUI()
    $hGUI = GUICreate("Short-Order Encrypter", 300, 200)
    GUICtrlCreateLabel("Encrypt a Message!", 95, 15)
    GUICtrlCreateLabel("This is a simple input and output encryption program.", 25, 35)
    GUICtrlCreateLabel("You will select which method of encryption, then", 30, 48)
    GUICtrlCreateLabel("input your text by pressing the Input button,", 40, 61)
    GUICtrlCreateLabel("or you will press the Decode button to", 55, 74)
    GUICtrlCreateLabel("decode an encrypted message.", 65, 87)
    $iButton = GUICtrlCreateButton("Input", 50, 160, 70, 30)
    GUICtrlSetOnEvent(-1, "iButton")
    $dButton = GUICtrlCreateButton("Decode", 160, 160, 70, 30)
    GUICtrlSetOnEvent(-1, "getCheckbox")
    $aChkBx[0] = GUICtrlCreateCheckbox("Text", 15, 105)
    $aChkBx[1] = GUICtrlCreateCheckbox("3DES", 67, 105)
    $aChkBx[2] = GUICtrlCreateCheckbox("AES (128bit)", 122, 105)
    $aChkBx[3] = GUICtrlCreateCheckbox("AES (192bit)", 208, 105)
    $aChkBx[4] = GUICtrlCreateCheckbox("AES (256bit)", 32, 130)
    $aChkBx[5] = GUICtrlCreateCheckbox("DES", 121, 130)
    $aChkBx[6] = GUICtrlCreateCheckbox("RC2", 172, 130)
    $aChkBx[7] = GUICtrlCreateCheckbox("RC4", 224, 130)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
    GUISetState(@SW_SHOW)
EndFunc ;==>GUI

Func iButton()
    getCheckbox()
    inputChild()
EndFunc

Func getCheckbox()
    Local $i, $readArray, $cCounter = 0
    For $i = 0 To UBound($aChkBx) - 1 Step 1
        $readArray = GUICtrlRead($aChkBx[$i])
        If $readArray = 1 Then
             $cCounter += 1
             $cValue &= $i
        EndIf
    Next
    If $cCounter > 1 Then
        MsgBox(0, "Encryption Type", "Could not specify encryption type due to multiple selections. Please make sure you have only selected on type of encryption")
        $cValue = ""
        Return
    ElseIf $cCounter = 0 Then
         MsgBox(0, "Encryption Type", "You must select an encryption type in the Short-Order Encrypter window")
         Return
    EndIf
EndFunc ;==>getCheckbox

Func inputChild()
    If $cValue = "" Then
         Return
    EndIf
    $iChild = GUICreate("Input Message", 386, 120, -1, -1, -1, -1, $hGUI)
    GUICtrlCreateLabel("Message", 5, 10)
    GUICtrlCreateLabel("Password", 200, 10)
    $iMsgBox = GUICtrlCreateInput("", 5, 25, 180, 60)
    $iPswdBox = GUICtrlCreateInput("", 200, 25, 180, 60)
    $iSubmit = GUICtrlCreateButton("Encrypt", 172, 90)
    GUICtrlSetOnEvent($iSubmit, "Encrypt")
    GUISetOnEvent($GUI_EVENT_CLOSE, "QuitChild")
    GUISetState()
EndFunc ;==>inputChild

#cs
Func Crypt($iMsg, $iPass, $iflag)
    Local $mFlag[8]
    $mFlag[0] = "TEXT"
    $mFlag[1] = $CALG_3DES
    $mFlag[2] = $CALG_AES_128
    $mFlag[3] = $CALG_AES_192
    $mFlag[4] = $CALG_AES_256
    $mFlag[5] = $CALG_DES
    $mFlag[6] = $CALG_RC2
    $mFlag[7] = $CALG_RC4
EndFunc ;==>Crypt
#ce

Func Quit()
    GUIDelete($hGUI)
    Exit
EndFunc ;==>Quit

Func QuitChild()
    GUIDelete($iChild)
EndFunc ;==>Quit

Func Encrypt()
    $iMsg = GUICtrlRead($iMsgBox)
    $iPswd = GUICtrlRead($iPswdBox)
    MsgBox(0, "title", "msg:" & $iMsg & " paswrd:" & $iPswd)
EndFunc

While 1
Sleep(100)
WEnd

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
BrewManNH

All you need to do is change your declarations for the child gui and the controls on it.

; vars
Local $hGUI, $msg = 0, $hInput, $iButton, $hDecode, $dButton
Local $aChkBx[8], $cValue, $iChild=9999, $iMsg, $iPswd, $iMsgBox ; <<<<<<<<<<<<<<<<<<<<<<
Local $iPswdBox, $iSubmit=9999 ; <<<<<<<<<<<<<<<<<<<<<<<<
;main line

Because you haven't created the child GUI yet, the gui handle and all controls will equal zero. In a MessageLoop, GUIGetMsg returns 0 whenever nothing is happening in the GUI, so the child GUI handle will match and the $iSubmit id will match because both are zero. Set them to something that probably won't be a control ID, 9999 in my example above, and this won't happen. When the controls and the GUI are created, the default 9999 will be overwritten.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
MikahS

@careca Thank you for that solution, as it's something to think about :)

@BrewManNH Thank you, I really wanted to figure out what was going on and not change around the way I poll for events on the GUI. With this solution (tested) it worked :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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  

  • Similar Content

    • UEZ
      By UEZ
      Following script shows a parent GUI with a child GUI initialized as MDICHILD.
      #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiReBar.au3> #include <GuiScrollBars.au3> #include <GuiToolbar.au3> #include <ScreenCapture.au3> #include <ScrollBarConstants.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Enum $idNew = 1000, $idOpen, $idSave, $idHelper Global Const $iImageW = @DesktopWidth, $iImageH = @DesktopHeight Global Const $hBMP_ScreenCapture = _ScreenCapture_Capture("", 0, 0, $iImageW, $iImageH, False) Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP_ScreenCapture) Sleep(50) Global Const $iW = 1500, $iH = 700, $SC_DRAGMOVE = 0xF012 Global Const $hGUI = GUICreate("Move child GUI within GUI", $iW, $iH) Global Const $hToolbar = _GUICtrlToolbar_Create($hGUI) Global Const $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS)) Global Const $height_delta = 37 Global Const $idPic = GUICtrlCreatePic("", 0, $height_delta + 2, $iW, $iH) Global $hBitmap_tmp, $hHBitmap_tmp $hBitmap_tmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Global $hGfx_Context = _GDIPlus_ImageGetGraphicsContext($hBitmap_tmp) _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($hToolbar) _GUICtrlToolbar_AddButton($hToolbar, $idHelper, $STD_HELP) _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0) Global Const $iVSscroll = _WinAPI_GetSystemMetrics(2) Global Const $iHSscroll = _WinAPI_GetSystemMetrics(3) Global Const $iYCaption = _WinAPI_GetSystemMetrics(4) Global Const $iYFixedFrame = _WinAPI_GetSystemMetrics(8) Global Const $iXFixedFrame = _WinAPI_GetSystemMetrics(7) Global Const $iMetricsSumX = $iVSscroll + $iXFixedFrame * 2 Global Const $iMetricsSumY = $iHSscroll + $iYCaption + $iYFixedFrame _GUIScrollBars_Init($hGUI) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $iImageW - $iW + 61 + $iMetricsSumX) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_VERT, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $iImageH - $iH + $iMetricsSumY + $height_delta - 1) GUISetState(@SW_SHOW, $hGUI) Global Const $STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBMP_ScreenCapture)) Global $IE_offset_x = 0, $IE_offset_y = 0 DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL_IE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL_IE") Global $iPosX_Crop = 0, $iPosY_Crop = 0, $iW_crop = 200, $iH_crop = 200, $bMove_Crop = True Global $hGUI_IE_Crop = GUICreate("", $iW_crop, $iH_crop, $iPosX_Crop, $iPosY_Crop) GUISetStyle(BitOR($WS_BORDER, $WS_POPUP), $WS_EX_MDICHILD) _WinAPI_SetParent($hGUI_IE_Crop, $hGUI) WinSetTrans($hGUI_IE_Crop, "", 0xA0) Global $iLable_CropMove = GUICtrlCreateLabel("", 0, 0, $iW_crop, $iH_crop, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI_IE_Crop) GUIRegisterMsg($WM_MOVE, "WM_MOVE_IE_GUI_Crop") ;~ GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Until False GUIRegisterMsg($WM_HSCROLL, "") GUIRegisterMsg($WM_VSCROLL, "") GUIRegisterMsg($WM_MOVE, "") GUIRegisterMsg($WM_LBUTTONDOWN, "") _WinAPI_DeleteObject($hBMP_ScreenCapture) _GDIPlus_BitmapDispose($hBitmap_tmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGfx_Context) _GDIPlus_Shutdown() Exit Func WM_HSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ; Get all the horizontal scroll bar information Local $tSCROLLINFO_X = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Min = DllStructGetData($tSCROLLINFO_X, "nMin") $Max = DllStructGetData($tSCROLLINFO_X, "nMax") $Page = DllStructGetData($tSCROLLINFO_X, "nPage") ; Save the position for comparison later on $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_X, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_X, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO_X) $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_HSCROLL_IE Func WM_VSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ;~ ; Get all the horizontal scroll bar information Local $tSCROLLINFO_Y = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO_Y, "nMin") $Max = DllStructGetData($tSCROLLINFO_Y, "nMax") $Page = DllStructGetData($tSCROLLINFO_Y, "nPage") ; Save the position for comparison later on $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_Y, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_Y, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO_Y) $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_VSCROLL_IE Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI_IE_Crop, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func WM_MOVE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI_IE_Crop And $bMove_Crop Then $iPosX_Crop = _WinAPI_LoWord($lParam) $iPosY_Crop = _WinAPI_HiWord($lParam) EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_MOVE_IE_GUI_Crop Func WM_SIZE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE_IE_GUI_Crop Func DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) _GDIPlus_GraphicsDrawImageRectRect($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH, 0, 0, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) EndFunc  
      My problem: if you move the child window at left upper corner to another place and move either H or V scrollbar the child GUI will be moved properly. BUT if you have scrolled the scrollbars to the right bottom of the image and move the child GUI to that corner, too then the child GUI jumps if you click on one of the scrollbars.
      Is there something that I didn't consider?
    • ShakeelAhmad
      By ShakeelAhmad
      I've to upload different number of photos online in different assignments. There is a problem that all photos cannot be selected at once to upload. I have to choose and upload photos one by one. For this purpose I have made a script to automate whatever I have to do manually for choosing and uploading photos one by one.
      Please see my script below and check the last "MouseClick" command. This command clicks the button to choose and upload next photo. The problem I'm facing is; the last "MouseClick" works 1 step extra when all photos have been selected and uploaded. I mean if 7 photos are to be uploaded, this command opens the box from where next photo is selected and uploaded then it again opens the box and next photo is choosen and so on.... when last photo is selected and uploaded, this button once again opens the box. When all photos are uploaded, it should not click the button to select next photo. Please suggest how can I resolve this issue.
      #include <AutoItConstants.au3> Sleep(200) HotKeySet("{ESC}","Quit") ;Press ESC key to quit Send("{ALT DOWN}") Send("{TAB}") Send("{ALT UP}") Sleep(200) Local $photos = InputBox("Question", "How many photos to upload?", "#", "", _ - 1, -1, 0, 0) ; How many photos to upload Local $selector = 0 While $photos <> $selector MouseClick("Left", 281, 238, 1) ; mouse click on very first photo in the box. if $selector = 0 Then Send("{ENTER}") ; for selecting very first photo from "open" window. Sleep(800) Else sleep(200) Send("{RIGHT " & $selector & "}") ; for selecting 2nd to onward photos from "open" window. sleep(1000) Send("{ENTER}") sleep(1000) EndIf MouseClick("Left", 495, 198, 1) ; for clicking a button to choose next photo to upload $selector = $selector + 1 WEnd Beep(1500, 300) ; beep when all photos uploaded Exit Regards,
       
      Shakeel
    • Dzenan03
      By Dzenan03
      I want to make a while loop, that creates variables based on a array. For thist I created the array $iDsO with the number and the name of folders in an other folder. Every folder has a different name an I want to create variables(arrays) for each folder that show me all the files in that folder. For example: I have the Folder \Folder1. In it there are the Folders \1, \2, \3. In 1, 2 and 3 there are some files(.png). The array for Folder1 is $iDsO and now I want to crate the arrays $iDsO1, $iDsO2 and $iDsO3 with the files in them can I make something like this:
      While $iDs > 0 ;$iDs is the number of files in Folder1>> $iDsO[0] $iDs#here should come the Foldername for example '1'# = _FileListtoArray(@ProgramFilesDir&"\Folder1\"&$iDsO[$iDs]) $iDs = $iDs - 1 Wend So that in the End I have three variabels ($iDs1, $iDs2 and $iDs3)
       
      Is this posible or if not what could I do instead ( I don´t know the number of folders in Folder1 in the begining).
    • jdegraff
      By jdegraff
      I created a quick script to set/clear the topmost status of a window. It works like
          top <title> /on | /off
          
      I want the title match to be case insensitive and to work on partial strings. For example, if the window of note is titled "APLX for Windows" I want
          top apl /on
          
      to work. The AutoIt manual says that for WinTitleMatchMode
          Mode -1 to -4
              Force lower case match according to other type of match.
      so I assumed that by
          aut.Opt "WinTitleMatchMode",-1
          
      I would be doing a lower case match on existing windows. As long as I lcase(title) for the comparison it should match on "APLX for Windows" but it does not Is this a bug or am I misreading the docs?    
    • Skysnake
      By Skysnake
      From From here, bottom of the post
      I am not arguing the logic of this, merely would like to point out that if there is such a rule, it is not documented...  Are there other such rules?
      Skysnake
×