Refresh Firefox with PB [Resolved]

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Refresh Firefox with PB [Resolved]

Post by Kwai chang caine »

Hello at all :D

I search to refresh Firefox with PB
I have found this dirty method "SendKey" and that works 8)

Code: Select all

OldHwnd = GetForegroundWindow_()
Hwnd = FindWindow_(#Null, "PureBasic Forum • Post a new topic - Mozilla Firefox")
Debug Hwnd
SetForegroundWindow_(Hwnd)
keybd_event_(#VK_F5, 0, 0, 0)
keybd_event_(#VK_F5, 0, #KEYEVENTF_KEYUP, 0)
SetForegroundWindow_(OldHwnd)
But i search a better way, for not using SendKey who sometime do strange behaviour :|
So i have found in the forum something for close Firefox who works :D

Code: Select all

SendMessage_(Hwnd, #WM_SYSCOMMAND, #SC_CLOSE, 0)
After i try this who works to 8)

Code: Select all

SendMessage_(Hwnd, #WM_SYSCOMMAND, #SC_MAXIMIZE, 0)
SendMessage_(Hwnd, #WM_SYSCOMMAND, #SC_RESTORE, 0)
But all that not works :|

Code: Select all

SendMessage_(Hwnd, #WM_SYSCOMMAND, #VK_F5, 0)
SendMessage_(Hwnd, #WM_SYSCOMMAND, #SC_UPDATE_CONTENT, 0)
SendMessage_(Hwnd, #WM_SYSCOMMAND, #SC_HOTKEY, #VK_F5)
If someone have an idea for sending a refresh ...

Have a good day
Last edited by Kwai chang caine on Fri Apr 27, 2018 4:29 pm, edited 1 time in total.
ImageThe happiness is a road...
Not a destination
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: Refresh Firefox with PB

Post by firace »

Hi KCC, try this one:

Code: Select all

  Hwnd = FindWindow_(#Null, "PureBasic Forum • Post a new topic - Mozilla Firefox")
  SetForegroundWindow_(Hwnd) 
  Delay(50)
  PostMessage_(Hwnd, #WM_KEYDOWN, #VK_F5, 0)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Refresh Firefox with PB

Post by Kwai chang caine »

Yeeeeeaaahhhh !!!! Top cool :D
That works perfectly, thanks a lot MASTER FIRACE
8)

Image

That works even without the " SetForegroundWindow_(Hwnd)" :shock:

I modify your example, for do a full refresh "CTRL+F5"
That works with the keyboard, and not with PB :|
Have you an idea ?

Code: Select all

  Hwnd = FindWindow_("MozillaWindowClass", #Null)
  SetForegroundWindow_(Hwnd)
  Delay(100)
  PostMessage_(Hwnd, #WM_KEYDOWN, #VK_CONTROL, 0)
  Delay(100)
  PostMessage_(Hwnd, #WM_KEYDOWN, #VK_F5, 0)
  Delay(100)
  PostMessage_(Hwnd, #WM_KEYUP, #VK_F5, 0)
  Delay(100)
  PostMessage_(Hwnd, #WM_KEYUP, #VK_CONTROL, 0)
ImageThe happiness is a road...
Not a destination
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: Refresh Firefox with PB

Post by Bisonte »

Hi KCC.

It's not PB, but why don't you use one of Firefox's addons to refresh a page?
I e.g. use AutoReloadTab for this...
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Refresh Firefox with PB

Post by Kwai chang caine »

Hello BISONTE, happy to talk to you :D

I have thinking to adding a addon, like Mozrepl, or other :wink:
But sometime, i'm under active directory and cannot adding something :|
Furthermore, i'm not always on the same machine, or on my machine, etc...
And install an addon just for this "simple" function, i have already installing so much addon, sometime i don't remember what is it :lol:
Sure... if i needed, much remote function that's necessary, but just for a refresh ... :|

However I do not know this "AutoReloadTab" it's always interesting to learning something, thanks MASTER 8)

PS:
It's incredible, because i wanted to thank you another time, in futur days, for your precious and incredible :shock: jewel of code :
http://www.purebasic.fr/english/viewtop ... 12&t=70328
Thanks to you and him, i can mix this refresh with it, and do a new crazy idea that i had :oops: :lol:
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Refresh Firefox with PB

Post by Kwai chang caine »

I have continue to search on the WEB ..
Apparently PostMessage cannot in all case send two key in the same time :|

So, i say to me, perhaps i found another site in another language who talk about this subject.
And i have found a VB site with someone also crazy like me, and need the same thing :lol:

http://www.vbforums.com/showthread.php? ... ndMessage)

In fact the idea is so simple, that i have not thinking to it :oops:
Why choose between butter or jam ???? Eat greedily the both together :D

Image

The CTRL key, is not really dangerous for the another process, even if the CTRL is not sending to the right application, normally he never do something, when it sending alone...finally i hope :oops:

Short !!!! combined the two methods i can sending a FULL REFRESH to Firefox
Thaaaaaaaaaaat wooooooooorkssssss !!!!

Image

Code: Select all

 Hwnd = FindWindow_("MozillaWindowClass", #Null)
 Delay(50)
 keybd_event_(#VK_CONTROL,0,0,0)
 Delay(50)
 PostMessage_(Hwnd, #WM_KEYDOWN, #VK_F5, 0)
 Delay(50)
 keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0)
Thanks a lot at FIRACE for his great trick
And thanks to my wolf friend for his interest 8)
ImageThe happiness is a road...
Not a destination
User avatar
Michael Vogel
Addict
Addict
Posts: 2666
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Refresh Firefox with PB [Resolved]

Post by Michael Vogel »

Hi KCC,
I would enclose your keyboard commands between BlockInput_(#True) and BlockInput_(#False) to avoid problems when you hit your keyboard the same time your program is running.

Code: Select all

Hwnd=FindWindow_("MozillaWindowClass", #Null)
if Hwnd
 BlockInput_(#True)
 keybd_event_(#VK_CONTROL,0,0,0)
 PostMessage_(Hwnd, #WM_KEYDOWN, #VK_F5, 0)
 Delay(50)
 keybd_event_(#VK_CONTROL,0,#KEYEVENTF_KEYUP,0)
 BlockInput_(#False)
endif
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Refresh Firefox with PB [Resolved]

Post by Kwai chang caine »

Waoouuuh !!! i don't know this API :shock: or forgotten :oops:

I have read MSDN about it, and see the keyboard are locked 8)
Like this... my wife can play with it ...without any risk :lol:

Image

Thanks a lot for this tips MICHAEL 8)
ImageThe happiness is a road...
Not a destination
Post Reply