Grantson Posted January 11, 2009 Share Posted January 11, 2009 I have a script witch has a simple gui with a go button when the go button is clicked it uses _ispressed to wait for a right click then calls a function to copy the loaction of an image in firefox the 1st time through the loop it works perfectly if i press the button again and right click an image it gets asfar as the while loop and completly ignores the mouse click CODE#include <Misc.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Pic Viewer", 327, 129, 193, 125, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) $Button1 = GUICtrlCreateButton("&Go", 51, 71, 89, 25, 0) $Button2 = GUICtrlCreateButton("E&xit", 180, 71, 89, 25, 0) $dll = DllOpen("user32.dll") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 While 1 Sleep ( 250 ) If _IsPressed("02", $dll) Then copy_pic() ExitLoop EndIf WEnd DllClose($dll) Case $Button2 Exit Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func copy_pic() sleep(250) send("o") EndFunc this is probably primative as hell so if anyone can help or shed light on a more efficient method then please do Thanks Grant Link to comment Share on other sites More sharing options...
smashly Posted January 11, 2009 Share Posted January 11, 2009 (edited) I'm not sure if it's the reason for your problem, but I notice you open the dll before the first main While loop.. Then in the 2nd While loop after pressing the button your closing the dll.. From that point on the dll open never gets called again. Maybe leave the dll open untill you exit the script or open and close the dll each time the button is pressed. Edited January 11, 2009 by smashly Link to comment Share on other sites More sharing options...
fctd Posted January 11, 2009 Share Posted January 11, 2009 (edited) Try this (not tested) expandcollapse popup#include <Misc.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Pic Viewer", 327, 129, 193, 125, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) $Button1 = GUICtrlCreateButton("&Go", 51, 71, 89, 25, 0) $Button2 = GUICtrlCreateButton("E&xit", 180, 71, 89, 25, 0) ;$dll = DllOpen("user32.dll") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 $dll = DllOpen("user32.dll") While 1 Sleep ( 250 ) If _IsPressed("02", $dll) Then copy_pic() ExitLoop EndIf WEnd DllClose($dll) Case $Button2 Exit Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func copy_pic() sleep(250) send("o") EndFunc *edit* Sorry smashly, didn't saw youre reply. * Edited January 11, 2009 by fctd [list][font="Century Gothic"]If nothing is certain, everything is possible.[/font][/list][font="Century Gothic"]Experience is something you get, just after you need it.[/font] Link to comment Share on other sites More sharing options...
Grantson Posted January 11, 2009 Author Share Posted January 11, 2009 I'm not sure if it's the reason for your problem, but I notice you open the dll before the first main While loop..Then in the 2nd While loop after pressing the button your closing the dll..From that point on the dll open never gets called again.Maybe leave the dll open untill you exit the script or open and close the dll each time the button is pressed.Spot on never i thought it might be something like that but having it nested in the variable $dll i never noticed it joys of a sunday afternoon lolthanks 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